Advertisement
filmee24

ExpressionEvaluator - Scripted

Dec 19th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using ScriptMP3;
  4. using DotNetLib.Common.Util;
  5. using System.Drawing;
  6.  
  7. namespace Scripts {
  8.     public class Script
  9.     {
  10.         public Script() {
  11.             ExpressionDialog dlg = new ExpressionDialog();
  12.             if(dlg.ShowDialog() == DialogResult.OK) {
  13.                 MessageBox.Show(Scripting.Push("select->calc(`" + dlg.Expression +"`)"));
  14.             }
  15.         }
  16.        
  17.         ~Script() {
  18.            
  19.         }
  20.      
  21.     }
  22.    
  23.     #region "Expressiondialog"
  24.    
  25.         public class ExpressionDialog : Form {
  26.            
  27.             TextBox tb;
  28.            
  29.             public string Expression {
  30.                 get {
  31.                     return tb.Text;  
  32.                 }
  33.                 set {
  34.                     tb.Text = value;          
  35.                 }
  36.             }
  37.            
  38.             public ExpressionDialog() {
  39.              
  40.                 this.FormBorderStyle = FormBorderStyle.FixedDialog;
  41.                 this.Text = "Eingabe";
  42.                 this.Size = new Size(275,95);
  43.                 this.StartPosition = FormStartPosition.CenterScreen;
  44.                
  45.                 Button ok = new Button();
  46.                 ok.Text = "OK";
  47.                 ok.Location = new Point(185,35);
  48.                 ok.Click += OnOkClicked;
  49.                
  50.                 tb = new TextBox();
  51.                 tb.Location = new Point(10,10);
  52.                 tb.Size += new Size(150,0);
  53.                
  54.                 this.Controls.Add(tb);
  55.                 this.Controls.Add(ok);
  56.             }
  57.            
  58.             private void OnOkClicked(Object sender, EventArgs e) {
  59.                 this.DialogResult = DialogResult.OK;
  60.             }
  61.            
  62.         }
  63.    
  64.     #endregion
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement