private void toolStripButtonExpand_Click(object sender, EventArgs e)
        {
            DetachedEditorDialog dlgEditor = new DetachedEditorDialog(_CompileErrors, (Described <ServerEvent>)comboBoxEvent.SelectedItem);

            dlgEditor.Code            = _Editor.Text;
            dlgEditor.Text            = "Editing: " + textBoxName.Text + " [" + comboBoxEvent.SelectedItem.ToString() + "]";
            dlgEditor.CurrentPosition = _Editor.CurrentPos;
            dlgEditor.AdditionalReferences.AddRange(GetReferences());
            dlgEditor.AdditionalNamespaces.AddRange(GetNamespaces());
            dlgEditor.Parameters = labelParameters.Text;
            if (dlgEditor.ShowDialog(this) == DialogResult.OK)
            {
                CurrentItem.Rule.Script = _Editor.Text = dlgEditor.Code;
                _Editor.CurrentPos      = dlgEditor.CurrentPosition;
                if (dlgEditor.CompileErrors.Count > 0)
                {
                    _CompileErrors.Clear();
                    foreach (var kvp in dlgEditor.CompileErrors)
                    {
                        _CompileErrors.Add(kvp.Key, kvp.Value);
                    }
                    _Editor.ClearAllAnnotations();
                    _Editor.DisplayErrors(_CompileErrors);
                }
            }
        }
Example #2
0
        private void toolStripButtonCheck_Click(object sender, EventArgs e)
        {
            CompilerErrorCollection errors = new CompilerErrorCollection();
            int lineCount = 0;

            _Editor.ClearAllAnnotations();
            _CompileErrors.Clear();
            if (!_Editor.Compile(_ServerEvent, _AdditionalReferences, _AdditionalNamespaces, errors, out lineCount))
            {
                foreach (CompilerError error in errors)
                {
                    int    errorLine  = (error.Line - 1) - lineCount;
                    string typeString = error.IsWarning ? "Warning" : "Error";

                    if (!_CompileErrors.ContainsKey(errorLine))
                    {
                        _CompileErrors[errorLine] = new List <string>();
                    }

                    typeString = string.Format("{0} [{1},{2}]: ", typeString, errorLine + 1, error.Column);
                    _CompileErrors[errorLine].Add(typeString + error.ErrorText);
                }

                _Editor.DisplayErrors(_CompileErrors);
            }
        }