Exemple #1
0
 /// <summary>
 /// 根据命令参数对象来更新用户界面
 /// </summary>
 public void UpdateUIState()
 {
     if (_CommandArgs == null)
     {
         _CommandArgs = new SearchReplaceCommandArgs();
     }
     txtSearchString.Text = _CommandArgs.SearchString;
     chkReplace.Checked   = _CommandArgs.EnableReplaceString;
     if (this.WriterControl != null)
     {
         chkReplace.Enabled = this.WriterControl.Readonly == false;
     }
     txtReplaceString.Text    = _CommandArgs.ReplaceString;
     txtReplaceString.Enabled = chkReplace.Enabled && chkReplace.Checked;
     rdoUP.Checked            = _CommandArgs.Backward == false;
     rdoDown.Checked          = _CommandArgs.Backward;
     chkIgnoreCase.Checked    = _CommandArgs.IgnoreCase;
     UpdateButtonState();
 }
Exemple #2
0
        protected void SearchReplace(object sender, WriterCommandEventArgs args)
        {
            if (args.Mode == WriterCommandEventMode.QueryState)
            {
                args.Enabled = args.EditorControl != null && args.Document != null;
            }
            else if (args.Mode == WriterCommandEventMode.Invoke)
            {
                SearchReplaceCommandArgs cmdArgs = args.Parameter as SearchReplaceCommandArgs;
                if (args.ShowUI)
                {
                    // 显示查找、替换操作对话框
                    dlgSearch dlg = ( dlgSearch )args.EditorControl.ToolWindows[typeof(dlgSearch)];
                    if (dlg == null)
                    {
                        dlg = new dlgSearch();
                        args.EditorControl.ToolWindows.Add(dlg);
                        dlg.Owner         = args.EditorControl.FindForm();
                        dlg.WriterControl = args.EditorControl;
                    }
                    if (dlg != null)
                    {
                        if (dlg.Visible == false)
                        {
                            if (cmdArgs == null)
                            {
                                cmdArgs = new SearchReplaceCommandArgs();
                            }
                            if (args.Document.Selection.Length != 0)
                            {
                                cmdArgs.SearchString = args.Document.Selection.Text;
                            }
                            dlg.CommandArgs = cmdArgs;

                            dlg.Show(args.EditorControl);
                            dlg.UpdateUIState();
                        }
                        else
                        {
                            if (cmdArgs != null)
                            {
                                dlg.CommandArgs = cmdArgs;
                                dlg.UpdateUIState();
                            }
                            else
                            {
                                if (args.Document.Selection.Length != 0)
                                {
                                    dlg.CommandArgs.SearchString = args.Document.Selection.Text;
                                    dlg.UpdateUIState();
                                }
                            }
                            dlg.Focus();
                        }
                    }
                }
                else
                {
                }
            }
        }