protected void DebugMode(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         if (args.EditorControl == null)
         {
             args.Enabled = false;
         }
         else
         {
             args.Enabled = true;
             args.Checked = args.EditorControl.DocumentOptions.BehaviorOptions.DebugMode;
         }
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         bool v = !args.EditorControl.DocumentOptions.BehaviorOptions.DebugMode;
         if (args.Parameter is bool)
         {
             v = (bool)args.Parameter;
         }
         else if (args.Parameter is string)
         {
             if (bool.TryParse((string)args.Parameter, out v) == false)
             {
                 v = !args.EditorControl.DocumentOptions.BehaviorOptions.DebugMode;
             }
         }
         args.EditorControl.DocumentOptions.BehaviorOptions.DebugMode = v;
         args.Document.Options.BehaviorOptions.DebugMode = v;
         args.RefreshLevel = UIStateRefreshLevel.Current;
     }
 }
 protected void AdministratorViewMode(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         if (args.EditorControl == null)
         {
             args.Enabled = false;
         }
         else
         {
             args.Enabled = true;
             args.Checked = args.EditorControl.IsAdministrator;
         }
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         bool admin = !args.EditorControl.IsAdministrator;
         if (args.Parameter is bool)
         {
             admin = (bool)args.Parameter;
         }
         args.EditorControl.IsAdministrator = admin;
         args.EditorControl.Invalidate();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
        /// <summary>
        /// 启动对象
        /// </summary>
        public void Start()
        {
            if (this.DesignMode == true)
            {
                return;
            }
            WriterCommandEventArgs args = new WriterCommandEventArgs();

            args.EditorControl = this.EditControl;
            args.Document      = this.Document;
            this.Document.FixDomState();
            foreach (object control in this._CommandTable.Keys)
            {
                string actionName = _CommandTable[control];
                if (actionName == null || actionName.Trim().Length == 0)
                {
                    continue;
                }
                actionName = actionName.Trim();
                if (_BindingEventControls.Contains(control) == false)
                {
                    BindingEvent(control);
                }
                WriterCommand cmd = this.CommandContainer.GetCommand(actionName);
                if (cmd != null)
                {
                    // 初始化命令绑定的用户界面控件
                    args.UIElement = control;
                    args.Mode      = WriterCommandEventMode.InitalizeUIElement;
                    cmd.Invoke(args);
                }
            }//foreach
            this.UpdateBindingControlStatus();
        }
예제 #4
0
 protected void SpecifyPaste(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.DocumentControler != null && args.DocumentControler.CanPaste);
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         string specifyFormat = args.Parameter as string;
         if (args.ShowUI)
         {
             using (dlgSpecifyPaste dlg = new dlgSpecifyPaste())
             {
                 dlg.Document     = args.Document;
                 dlg.DataObject   = System.Windows.Forms.Clipboard.GetDataObject();
                 dlg.ResultFormat = specifyFormat;
                 if (dlg.ShowDialog(args.EditorControl) == DialogResult.OK)
                 {
                     specifyFormat = dlg.ResultFormat;
                 }
                 else
                 {
                     return;
                 }
             }
         }
         if (string.IsNullOrEmpty(specifyFormat) == false)
         {
             args.DocumentControler.Paste(specifyFormat);
             args.RefreshLevel = UIStateRefreshLevel.All;
         }
     }
 }
예제 #5
0
        protected void PrintCurrentPage(object sender, WriterCommandEventArgs args)
        {
            if (args.Mode == WriterCommandEventMode.QueryState)
            {
                args.Enabled = (args.Document != null &&
                                args.EditorControl != null &&
                                args.Document.Options.BehaviorOptions.Printable);
            }
            else if (args.Mode == WriterCommandEventMode.Invoke)
            {
                args.Result = false;
                if (args.Document.Options.BehaviorOptions.Printable == false)
                {
                    // 文档禁止打印
                    return;
                }
                DocumentPrinter printer = new DocumentPrinter(args.Document);
                if (args.EditorControl != null)
                {
                    printer.JumpPrint   = args.EditorControl._JumpPrint;
                    printer.CurrentPage = args.EditorControl.CurrentPage;
                }
                if (args.Parameter is JumpPrintInfo)
                {
                    JumpPrintInfo info = (JumpPrintInfo)args.Parameter;
                    printer.JumpPrint = args.Document.GetJumpPrintInfo(info.Position);
                }
                printer.PrintRange = System.Drawing.Printing.PrintRange.CurrentPage;

                InnerPrint(args, printer, false);
            }
        }
 protected void DebugOutputWindow(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.EditorControl != null;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         frmDebugOutput frm = (frmDebugOutput)args.EditorControl.ToolWindows[typeof(frmDebugOutput)];
         if (frm == null)
         {
             frm       = new frmDebugOutput();
             frm.Owner = args.EditorControl.FindForm();
             args.EditorControl.ToolWindows.Add(frm);
         }
         if (frm.Visible)
         {
             frm.Activate();
         }
         else
         {
             frm.Show(args.EditorControl);
         }
     }
 }
 protected void CleanViewMode(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         if (args.Document == null)
         {
             args.Enabled = false;
         }
         else
         {
             args.Enabled = true;
             DCSoft.CSharpWriter.Security.DocumentSecurityOptions opt = args.Document.Options.SecurityOptions;
             args.Checked = opt.ShowLogicDeletedContent == false &&
                            opt.ShowPermissionMark == false &&
                            opt.ShowPermissionTip == false;
         }
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         DCSoft.CSharpWriter.Security.DocumentSecurityOptions opt = args.Document.Options.SecurityOptions;
         opt.ShowLogicDeletedContent = false;
         opt.ShowPermissionMark      = false;
         opt.ShowPermissionTip       = false;
         if (args.EditorControl != null)
         {
             opt = args.EditorControl.DocumentOptions.SecurityOptions;
             opt.ShowLogicDeletedContent = false;
             opt.ShowPermissionMark      = false;
             opt.ShowPermissionTip       = false;
         }
         args.EditorControl.RefreshDocument();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
 protected void MoveTo(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.Document != null;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         MoveTarget target = MoveTarget.None;
         if (args.Parameter is MoveTarget)
         {
             target = (MoveTarget)args.Parameter;
         }
         else if (args.Parameter is string)
         {
             try
             {
                 target = (MoveTarget)Enum.Parse(
                     typeof(MoveTarget),
                     (string)args.Parameter,
                     true);
             }
             catch
             {
             }
         }
         if (target != MoveTarget.None)
         {
             args.Document.Content.AutoClearSelection = true;
             args.Document.Content.MoveTo(target);
         }
     }
 }
 protected void BackColor(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.DocumentControler != null &&
                        args.DocumentControler.Snapshot.CanModifySelection;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         Color color = System.Drawing.Color.Transparent;
         if (args.Parameter is Color)
         {
             color = (Color)args.Parameter;
         }
         if (args.ShowUI)
         {
             using (ColorDialog dlg = new ColorDialog())
             {
                 dlg.Color = color;
                 if (dlg.ShowDialog(args.EditorControl) == DialogResult.OK)
                 {
                     color = dlg.Color;
                 }
                 else
                 {
                     return;
                 }
             }//using
         }
         args.Parameter = color;
         SetStyleProperty(sender, args, StandardCommandNames.BackColor);
     }
 }
예제 #10
0
        /// <summary>
        /// 若文档内容修改则询问用户是否保存。
        /// </summary>
        /// <param name="args">参数</param>
        /// <returns>用户确认保存</returns>
        public virtual bool QuerySave(WriterCommandEventArgs args)
        {
            if (args.ShowUI == false)
            {
                return(true);
            }
            if (args.Document.Modified)
            {
                switch (MessageBox.Show(
                            args.EditorControl,
                            string.Format(WriterStrings.PromptSaveFile_Name, args.Document.FileName),
                            WriterStrings.SystemAlert,
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxIcon.Question))
                {
                case DialogResult.Yes:
                    return(SaveDocument(false, args));

                case  DialogResult.No:
                    return(true);

                case  DialogResult.Cancel:
                    return(false);
                }
            }
            return(true);
        }
 protected void JumpPrintMode(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         if (args.EditorControl == null)
         {
             args.Enabled = false;
         }
         else
         {
             args.Enabled = args.EditorControl.ViewMode == PageViewMode.Page;
             args.Checked = args.EditorControl.EnableJumpPrint;
         }
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         bool jmp = !args.EditorControl.EnableJumpPrint;
         if (args.Parameter is bool)
         {
             jmp = (bool)args.Parameter;
         }
         if (args.EditorControl.EnableJumpPrint != jmp)
         {
             args.EditorControl.EnableJumpPrint = jmp;
             args.EditorControl.Invalidate();
         }
     }
 }
예제 #12
0
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="newFileName">使用新文件名</param>
        /// <param name="args">事件参数</param>
        /// <returns>操作是否成功</returns>
        public virtual bool SaveDocument(bool newFileName, WriterCommandEventArgs args)
        {
            string      fileName = args.Document.FileName;
            IFileSystem fs       = args.Host.FileSystems.Docuemnt;

            if (args.Parameter is string)
            {
                if (newFileName == false)
                {
                    fileName = (string)args.Parameter;
                }
            }
            else if (args.Parameter is System.IO.Stream)
            {
                System.IO.Stream stream2 = (System.IO.Stream)args.Parameter;
                args.Document.Save(stream2, FileFormat.XML);
                return(true);
            }
            else if (args.Parameter is System.IO.TextWriter)
            {
                System.IO.TextWriter writer = (System.IO.TextWriter)args.Parameter;
                args.Document.Save(writer, FileFormat.XML);
                return(true);
            }
            if (args.ShowUI)
            {
                if (fileName == null || fileName.Trim().Length == 0 || newFileName)
                {
                    fileName = fs.BrowseSave(args.Host.Services, fileName);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        return(false);
                    }
                }
            }//if

            if (fileName == null || fileName.Trim().Length == 0)
            {
                return(false);
            }

            VFileInfo  info   = fs.GetFileInfo(args.Host.Services, fileName);
            FileFormat format = WriterUtils.ParseFileFormat(info.Format);

            System.IO.Stream stream = fs.Save(args.Host.Services, fileName);
            if (stream != null)
            {
                using (stream)
                {
                    args.Document.Save(stream, format);
                }
                return(true);
            }
            else
            {
                // 未能打开文件,保存失败。
                return(false);
            }
        }
 protected void Replace(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.Document != null;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
     }
 }
        protected void FormViewMode(object sender, WriterCommandEventArgs args)
        {
            if (args.Mode == WriterCommandEventMode.QueryState)
            {
                if (args.EditorControl == null)
                {
                    args.Enabled = false;
                }
                else
                {
                    args.Enabled = true;
                    args.Checked = args.EditorControl.FormView == Controls.FormViewMode.Normal ||
                                   args.EditorControl.FormView == Controls.FormViewMode.Strict;
                }
            }
            else if (args.Mode == WriterCommandEventMode.Invoke)
            {
                FormViewMode mode = args.EditorControl.FormView;

                if (args.Parameter is FormViewMode)
                {
                    mode = (FormViewMode)args.Parameter;
                }
                else if (args.Parameter is bool)
                {
                    bool v = (bool)args.Parameter;
                    if (v)
                    {
                        mode = Controls.FormViewMode.Strict;
                    }
                    else
                    {
                        mode = Controls.FormViewMode.Disable;
                    }
                }
                else
                {
                    if (mode == Controls.FormViewMode.Disable)
                    {
                        mode = Controls.FormViewMode.Strict;
                    }
                    else
                    {
                        mode = Controls.FormViewMode.Disable;
                    }
                }
                args.EditorControl.FormView = mode;
                if (args.Document != null)
                {
                    args.Document.Content.FixCurrentIndexForStrictFormViewMode();
                }
                args.EditorControl.Invalidate();
                args.RefreshLevel = UIStateRefreshLevel.All;
            }
        }
예제 #15
0
 protected void FileSaveAs(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.Document != null;
     }
     if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Result = SaveDocument(true, args);
     }
 }
예제 #16
0
 protected void FileNew(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.Invoke)
     {
         if (QuerySave(args))
         {
             args.EditorControl.ClearContent();
             //args.EditorControl.RefreshDocument();
             args.Document.FileName = null;
         }
     }
 }
예제 #17
0
 protected void Paste(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.DocumentControler != null && args.DocumentControler.CanPaste);
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.DocumentControler.Paste();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
 protected void Font(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.DocumentControler != null &&
                        args.DocumentControler.Snapshot.CanModifySelection;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         //MessageBox.Show(Convert.ToString(args.Parameter));
         //System.Diagnostics.Debugger.Break();
         DocumentContentStyle cs   = GetCurrentStyle(args.Document);
         XFontValue           font = new XFontValue();
         if (args.Parameter == null)
         {
             font = cs.Font;
             //MessageBox.Show("1:" + font.Size);
         }
         else if (args.Parameter is XFontValue)
         {
             font = ((XFontValue)args.Parameter).Clone();
             //MessageBox.Show("2:" + font.Size);
         }
         else if (args.Parameter is System.Drawing.Font)
         {
             font = new XFontValue((System.Drawing.Font)args.Parameter);
             //MessageBox.Show("3:" + font.Size);
         }
         else
         {
             // 未知参数
             font = cs.Font;
         }
         if (args.ShowUI)
         {
             using (FontDialog dlg = new FontDialog())
             {
                 dlg.Font = font.Value;
                 if (dlg.ShowDialog(args.EditorControl) == DialogResult.OK)
                 {
                     font = new XFontValue(dlg.Font);
                 }
                 else
                 {
                     return;
                 }
             }
         }
         args.Parameter = font;
         SetStyleProperty(sender, args, StandardCommandNames.Font);
     }
 }
예제 #19
0
        protected void InsertXML(object sender, WriterCommandEventArgs args)
        {
            if (args.Mode == WriterCommandEventMode.QueryState)
            {
                args.Enabled = args.DocumentControler != null &&
                               args.Document != null &&
                               args.DocumentControler.CanInsertElementAtCurrentPosition(
                    typeof(DomElement));
            }
            else if (args.Mode == WriterCommandEventMode.Invoke)
            {
                args.Result = false;

                DomDocument document = null;
                if (args.Parameter is string)
                {
                    System.IO.StringReader reader = new System.IO.StringReader(
                        (string)args.Parameter);
                    document = DocumentLoader.LoadXmlFileWithCreateDocument(
                        reader,
                        args.Document);
                    reader.Close();
                }
                else if (args.Parameter is System.IO.Stream)
                {
                    document = DocumentLoader.LoadXmlFileWithCreateDocument(
                        (System.IO.Stream)args.Parameter,
                        args.Document);
                }
                else if (args.Parameter is System.IO.TextReader)
                {
                    document = DocumentLoader.LoadXmlFileWithCreateDocument(
                        (System.IO.TextReader)args.Parameter,
                        args.Document);
                }
                else if (args.Parameter is System.Xml.XmlReader)
                {
                    document = DocumentLoader.LoadXmlFileWithCreateDocument(
                        (System.Xml.XmlReader)args.Parameter,
                        args.Document);
                }
                if (document != null &&
                    document.Body != null &&
                    document.Body.Elements.Count > 0)
                {
                    DomElementList list = document.Body.Elements;
                    args.Document.ImportElements(list);
                    args.DocumentControler.InsertElements(list);
                    args.Result = list;
                }
            }
        }
 protected void SelectAll(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.Document != null);
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Document.Content.SelectAll();
         args.EditorControl.UpdateTextCaret();
         //args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
예제 #21
0
 protected void InsertLineBreak(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.DocumentControler != null &&
                         args.DocumentControler.CanInsertElementAtCurrentPosition(typeof(DomLineBreakElement)));
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Result       = args.DocumentControler.InsertLineBreak();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
예제 #22
0
 protected void Backspace(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         // 获得动作状态
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         // 执行动作
         args.EditorControl.DocumentControler.Backspace();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
 protected void ShiftMoveEnd(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.Document != null && args.EditorControl != null);
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Document.Content.AutoClearSelection = false;
         args.Document.Content.MoveEnd();
         args.EditorControl.UpdateTextCaret();
         //args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
 protected void MovePageUp(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = (args.Document != null && args.EditorControl != null);
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Document.Content.AutoClearSelection = true;
         args.Document.Content.MoveStep(
             -args.Document.PageSettings.ViewClientHeight);
         args.Document.EditorControl.UpdateTextCaret();
         //args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }
예제 #25
0
        private void InnerPrint(
            WriterCommandEventArgs args,
            DocumentPrinter printer,
            bool refreshDocument)
        {
            System.Windows.Forms.Cursor cur = null;
            JumpPrintInfo infoBack          = null;
            int           piBack            = -1;

            if (args.EditorControl != null)
            {
                infoBack = args.EditorControl._JumpPrint.Clone();
                if (infoBack.Enabled && infoBack.Page != null)
                {
                    piBack = args.EditorControl.Pages.IndexOf(infoBack.Page);
                }

                printer.WriterControl = args.EditorControl;
                cur = args.EditorControl.Cursor;
                args.EditorControl.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                if (refreshDocument)
                {
                    // 冻结用户界面
                    args.EditorControl.FreezeUI();
                }
            }
            try
            {
                args.Result = printer.PrintDocument(args.ShowUI);
            }
            finally
            {
                if (args.EditorControl != null)
                {
                    if (refreshDocument)
                    {
                        args.EditorControl.RefreshDocument();
                        if (piBack >= 0)
                        {
                            infoBack.Page = args.EditorControl.Pages[piBack];
                            args.EditorControl._JumpPrint = infoBack;
                        }
                        args.EditorControl.ReleaseFreezeUI();
                    }
                    args.EditorControl.Cursor = cur;
                }
            }
        }
예제 #26
0
        /// <summary>
        /// 判断指定名称的命令的状态是否处于选中状态
        /// </summary>
        /// <param name="commandName">命令名称</param>
        /// <returns>该命令是否处于选中状态</returns>
        public bool IsCommandChecked(string commandName)
        {
            WriterCommand cmd = this.CommandContainer.GetCommand(commandName);

            if (cmd != null)
            {
                WriterCommandEventArgs args = new WriterCommandEventArgs(
                    this.EditControl,
                    this.Document,
                    WriterCommandEventMode.QueryState);
                args.ShowUI = true;
                cmd.Invoke(args);
                return(args.Checked);
            }
            return(false);
        }
예제 #27
0
        /// <summary>
        /// 调用文档元素编辑器
        /// </summary>
        /// <param name="args">编辑器命令参数对象</param>
        /// <param name="element">文档元素对象</param>
        /// <param name="method">编辑使用的方法</param>
        /// <returns>操作是否成功</returns>
        internal static bool CallElementEdtior(WriterCommandEventArgs args, DomElement element, ElementEditMethod method)
        {
            ElementEditor editor = (ElementEditor)TypeDescriptor.GetEditor(element, typeof(ElementEditor));

            if (editor != null)
            {
                ElementEditEventArgs ea = new ElementEditEventArgs();
                ea.Document     = args.Document;
                ea.Host         = args.Host;
                ea.LogUndo      = (method == ElementEditMethod.Edit);
                ea.ParentWindow = args.EditorControl;
                ea.Element      = element;
                ea.Method       = method;
                return(editor.Edit(ea));
            }
            return(false);
        }
예제 #28
0
 protected void InsertString(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.DocumentControler != null &&
                        args.DocumentControler.CanInsertElementAtCurrentPosition(
             typeof(DomCharElement));
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Result = 0;
         InsertStringCommandParameter parameter = null;
         if (args.Parameter is InsertStringCommandParameter)
         {
             parameter = (InsertStringCommandParameter)args.Parameter;
         }
         else
         {
             parameter = new InsertStringCommandParameter();
             if (args.Parameter != null)
             {
                 parameter.Text = Convert.ToString(args.Parameter);
             }
         }
         if (args.ShowUI)
         {
             using (dlgInputString dlg = new dlgInputString())
             {
                 dlg.InputText = parameter.Text;
                 if (dlg.ShowDialog(args.EditorControl) == DialogResult.OK)
                 {
                     parameter.Text = dlg.InputText;
                 }
                 else
                 {
                     return;
                 }
             }
         }
         if (string.IsNullOrEmpty(parameter.Text) == false)
         {
             args.Result = args.DocumentControler.InsertString(parameter.Text);
         }
     }
 }
 protected void AboutControl(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.ShowUI;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         if (args.ShowUI)
         {
             using (DCSoft.CSharpWriter.Controls.dlgAbout dlg
                        = new DCSoft.CSharpWriter.Controls.dlgAbout())
             {
                 dlg.ShowDialog(args.EditorControl);
             }
         }
     }
 }
 protected void ParagraphFormat(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.DocumentControler != null &&
                        args.DocumentControler.Snapshot.CanModifySelection;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Result = false;
         ParagraphFormatCommandParameter parameter = args.Parameter
                                                     as ParagraphFormatCommandParameter;
         if (parameter == null)
         {
             parameter = new ParagraphFormatCommandParameter();
             parameter.Read(args.Document.CurrentParagraphStyle);
         }
         if (args.ShowUI)
         {
             using (dlgParagraphFormatcs dlg = new dlgParagraphFormatcs())
             {
                 dlg.CommandParameter = parameter;
                 if (dlg.ShowDialog(args.EditorControl) != DialogResult.OK)
                 {
                     // 用户取消操作
                     return;
                 }
             }
         }//if
         DocumentContentStyle ns = new DocumentContentStyle();
         ns.DisableDefaultValue = true;
         parameter.Save(ns);
         args.Document.BeginLogUndo();
         DomElementList list = args.Document.Selection.SetParagraphStyle(ns);
         if (list != null && list.Count > 0)
         {
             args.Result = true;
         }
         args.Document.EndLogUndo();
         args.Document.OnSelectionChanged();
         args.Document.OnDocumentContentChanged();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }