Exemple #1
0
 protected void SetCanEditFlags(Control c, out bool canUndo, out bool canRedo, out bool canCopy, out bool canCut, out bool canPaste)
 {
     canPaste = false;
     canCut   = false;
     canCopy  = false;
     canRedo  = false;
     canUndo  = false;
     if (c is TextBoxBase)
     {
         TextBoxBase base2 = (TextBoxBase)c;
         canUndo = base2.CanUndo;
         canCopy = base2.SelectionLength > 0;
         canCut  = (base2.SelectionLength > 0) && !base2.ReadOnly;
         bool flag = false;
         try
         {
             flag = Clipboard.ContainsData(DataFormats.Text);
         }
         catch
         {
         }
         canPaste = !base2.ReadOnly && flag;
     }
     if (c is RichTextBox)
     {
         canRedo = ((RichTextBox)c).CanRedo;
     }
     if (c is DataGridView)
     {
         canCopy = ((DataGridView)c).SelectedCells.Count > 0;
     }
     if (c is ActiproSoftware.SyntaxEditor.SyntaxEditor)
     {
         ActiproSoftware.SyntaxEditor.SyntaxEditor editor = (ActiproSoftware.SyntaxEditor.SyntaxEditor)c;
         canUndo  = editor.get_Document().get_UndoRedo().get_CanUndo();
         canRedo  = editor.get_Document().get_UndoRedo().get_CanRedo();
         canCopy  = editor.get_SelectedView().get_SelectedText().Length > 0;
         canCut   = editor.get_SelectedView().get_CanDelete();
         canPaste = editor.get_SelectedView().get_CanPaste();
     }
 }
Exemple #2
0
 protected void miEdit_Popup(object sender, EventArgs e)
 {
     if ((this.Site == null) || !this.Site.DesignMode)
     {
         bool    flag;
         bool    flag2;
         bool    flag3;
         bool    flag4;
         bool    flag5;
         bool    flag6;
         Control c = null;
         if (flag = (this.AllowForwarding && (MainForm.Instance != null)) && MainForm.Instance.ApplyEditToPlugin)
         {
             flag6 = flag5 = flag4 = flag3 = flag2 = true;
         }
         else
         {
             c = this.GetActiveControl();
             this.SetCanEditFlags(c, out flag6, out flag5, out flag4, out flag3, out flag2);
         }
         if (this.miUndo != null)
         {
             this.miUndo.Enabled = flag6;
         }
         if (this.miRedo != null)
         {
             this.miRedo.Enabled = flag5;
         }
         if (this.miCopy != null)
         {
             this.miCopy.Enabled = flag4;
         }
         if (this.miCopyPlain != null)
         {
             this.miCopyPlain.Enabled = flag4 && !flag;
         }
         if (this.miCopyMarkdown != null)
         {
             this.miCopyMarkdown.Enabled = flag4 && !flag;
         }
         if (this.miCut != null)
         {
             this.miCut.Enabled = flag3;
         }
         if (this.miPaste != null)
         {
             this.miPaste.Enabled = flag2;
         }
         this.miUndo.Text = "&Undo";
         this.miRedo.Text = "&Redo";
         if (!flag)
         {
             RichTextBox box = c as RichTextBox;
             if (box != null)
             {
                 if (this.miUndo != null)
                 {
                     this.miUndo.Text = this.miUndo.Text + " " + ((box.UndoActionName != "Unknown") ? box.UndoActionName : "");
                 }
                 if (this.miRedo != null)
                 {
                     this.miRedo.Text = this.miRedo.Text + " " + ((box.RedoActionName != "Unknown") ? box.RedoActionName : "");
                 }
             }
             ActiproSoftware.SyntaxEditor.SyntaxEditor editor = c as ActiproSoftware.SyntaxEditor.SyntaxEditor;
             if (editor != null)
             {
                 try
                 {
                     if ((this.miUndo != null) && this.miUndo.Enabled)
                     {
                         this.miUndo.Text = this.miUndo.Text + " " + editor.get_Document().get_UndoRedo().get_UndoStack().GetName(editor.get_Document().get_UndoRedo().get_UndoStack().get_Count() - 1);
                     }
                     if ((this.miRedo != null) && this.miRedo.Enabled)
                     {
                         this.miRedo.Text = this.miRedo.Text + " " + editor.get_Document().get_UndoRedo().get_RedoStack().GetName(editor.get_Document().get_UndoRedo().get_RedoStack().get_Count() - 1);
                     }
                 }
                 catch
                 {
                 }
             }
         }
     }
 }
        private void CompleteElementTag(ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor, int offset)
        {
            string     str        = null;
            TextStream textStream = syntaxEditor.get_Document().GetTextStream(offset);

            if (textStream.GoToPreviousToken() && ((textStream.get_Token().get_Key() == "StartTagEndToken") && ((offset - textStream.get_Offset()) == 1)))
            {
                bool flag = false;
                while (textStream.GoToPreviousToken())
                {
                    string str2 = textStream.get_Token().get_Key();
                    if (str2 != null)
                    {
                        if (!(str2 == "StartTagNameToken"))
                        {
                            if ((str2 == "StartTagStartToken") || (str2 == "EndTagEndToken"))
                            {
                                return;
                            }
                        }
                        else
                        {
                            str  = textStream.get_TokenText().Trim();
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                if (str != null)
                {
                    textStream.set_Offset(offset);
                    flag = false;
                    while (!textStream.get_IsAtDocumentEnd())
                    {
                        switch (textStream.get_Token().get_Key())
                        {
                        case "EndTagDefaultToken":
                            if (str == textStream.get_TokenText().Trim())
                            {
                                return;
                            }
                            flag = true;
                            break;

                        case "StartTagStartToken":
                        case "EndTagEndToken":
                            flag = true;
                            break;
                        }
                        if (flag)
                        {
                            break;
                        }
                        textStream.GoToNextToken();
                    }
                    syntaxEditor.get_SelectedView().InsertSurroundingText(0, null, "</" + str + ">");
                }
            }
        }