//add reset button
 private void Reset_Click(object sender, EventArgs e)
 {
     textBox1.Clear();
     WeightBox.Clear();
     HeightBox.Clear();
     TextResult.Clear();
 }
Example #2
0
        //Numbers
        private void button_click(object sender, EventArgs e)
        {
            //reset if equals pressed so not adding characters to result
            ErrorLabel.Text = "";
            if ((LastAnswer) || (MemRecall1))
            {
                TextResult.Text = "0";
                LastAnswer      = false;
                MemRecall1      = false;
            }
            if ((TextResult.Text == "0") || IsOperationPerformed)
            {
                TextResult.Clear();
            }
            Button button = (Button)sender;

            IsOperationPerformed = false;
            if (button.Text == ".")
            {
                if (!TextResult.Text.Contains("."))
                {
                    TextResult.Text = TextResult.Text + button.Text;
                }
                if (TextResult.Text.Substring(0, 1) == ".")
                {
                    TextResult.Text = "0.";
                }
            }
            if (Calculation != "")
            {
                if ((Calculation.Substring(Calculation.Length - 1)) != ")")
                {
                    TextResult.Text = TextResult.Text + button.Text;
                }
            }
            else
            {
                TextResult.Text = TextResult.Text + button.Text;
            }
        }
 public bool?Execute(bool dontCopyLocals = false)
 {
     TextResult.Clear();
     if (parent == null && !dontCopyLocals)
     {
         foreach (var a in MainViewModel.GetMainViewModelStatic().CurrentGame.VarById.Where(a => a.Value.VariableBase.Name.StartsWith("_")))
         {
             var wrapper = new VariableWrapper(a.Value.VariableBase);
             if (!localVars.ContainsKey(a.Key))
             {
                 localVars.Add(a.Key, wrapper);
                 localVarsByName.Add(a.Value.VariableBase.Name, a.Value);
             }
         }
     }
     foreach (var line in ScriptBase.ScriptLines.Where(a => a.GetType() != typeof(CommentWrapper)))
     {
         ScriptLineWrapper currentLine = ScriptLineWrapper.GetScriptLineWrapper(line, this);
         if (currentLine != null)
         {
             var result = currentLine.Execute();
             //Stop executing the script once a return statement has been triggered.
             if (result != null)
             {
                 return(result);
             }
         }
         if (StopExecution)
         {
             if (this.parent != null && !this.IsRootScript)
             {
                 this.parent.StopExecution = true;
             }
             break;
         }
         //currentLine.Dispose();
     }
     return(null);
 }