コード例 #1
0
 private void saveFormula_Click(object sender, EventArgs e)
 {
     try
     {
         this.parserError.Text = "";
         if (errorWriter != null)
         {
             errorWriter.Dispose();
         }
         errorWriter = new StringWriter();
         if (!formulaText.Text.Trim().Equals(""))
         {
             Scanner scanner = new Scanner(formulaText.Text);
             Parser parser = new Parser(scanner);
             parser.errors.errorStream = errorWriter;
             parser.Parse();
             TextReader stringReader = new StringReader(errorWriter.ToString());
             this.parserError.Text = stringReader.ReadToEnd();
             Console.Write(parser.errors.count + " errors detected");
             if (parser.errors.count > 0)
             {
                 return;
             }
             //Parse the text to Validate the java api
         }
         if (currentBaseWindow != null && selectedNode != null && currentBaseWindow.CurrentControl != null)
         {
             INodeControl eibControl = (INodeControl)currentBaseWindow.CurrentControl[0];
             if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnNode))
             {
                 eibControl.NodeValue = formulaText.Text;
             }
             if (selectedNode.Name.Trim().Equals(FormDesignerConstants.EnterNode))
             {
                 eibControl.OnNodeEnterValue = formulaText.Text;
             }
             else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.ExitNode))
             {
                 eibControl.OnNodeExitClick = formulaText.Text;
             }
         }
     }
     catch
     {
     }
 }
コード例 #2
0
        private void saveFormula_Click(object sender, EventArgs e)
        {
            try
            {
                currentBaseWindow = form.currentBaseWindow;
                this.parserError.Text = "";
                if (errorWriter != null)
                {
                    errorWriter.Dispose();
                }
                errorWriter = new StringWriter();
                if (!formulaText.Text.Trim().Equals(""))
                {
                    //Parse the text to Validate the user input formula
                    Scanner scanner = new Scanner(formulaText.Text);
                    Parser parser = new Parser(scanner);
                    parser.errors.errorStream = errorWriter;
                    parser.Parse();
                    TextReader stringReader = new StringReader(errorWriter.ToString());
                    this.parserError.Text = stringReader.ReadToEnd();
                    Console.Write(parser.errors.count + " errors detected");
                    if (parser.errors.count > 0)
                    {
                        return;
                    }
                }
                if (currentBaseWindow != null && selectedNode != null && currentBaseWindow.CurrentControl != null)
                {
                    if (selectedNode.Name.Trim().Equals(FormDesignerConstants.DefaultValue))
                    {
                        currentBaseWindow.CurrentControl[0].DefaultValue = formulaText.Text;
                    }
                    if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnClick))
                    {
                        currentBaseWindow.CurrentControl[0].OnClickValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.Exiting))
                    {
                        currentBaseWindow.CurrentControl[0].ExitingValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.Entering))
                    {
                        currentBaseWindow.CurrentControl[0].EnteringValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnDoubleClick))
                    {
                        currentBaseWindow.CurrentControl[0].OnDoubleClick = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnDrop))
                    {
                        currentBaseWindow.CurrentControl[0].OnDrop = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnFocus))
                    {
                        currentBaseWindow.CurrentControl[0].OnFocus = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnBlur))
                    {
                        currentBaseWindow.CurrentControl[0].OnBlur = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnEventCreate))
                    {
                        currentBaseWindow.CurrentControl[0].OnEventCreateValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnEventEdit))
                    {
                        currentBaseWindow.CurrentControl[0].OnEventEditValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnEventUpdate))
                    {
                        currentBaseWindow.CurrentControl[0].OnEventUpdateValue = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnChange))
                    {
                        currentBaseWindow.CurrentControl[0].OnChange = formulaText.Text;
                    }
                    else if (selectedNode.Name.Trim().Equals(FormDesignerConstants.OnOK))
                    {
                        currentBaseWindow.CurrentControl[0].OnOK = formulaText.Text;
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }