Esempio n. 1
0
        void XCodeTextBox_KeyDownHandler(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers != ModifierKeys.Control)
            {
                return;
            }

            if (e.Key == Key.F)
            {
                FindReplaceDialog.Show(XCodeTextBox, FindReplaceDialog.SearchType.Find);
                e.Handled = true;
            }

            if (e.Key == Key.H)
            {
                FindReplaceDialog.Show(XCodeTextBox, FindReplaceDialog.SearchType.Replace);
                e.Handled = true;
            }
            if (e.Key == Key.OemPlus)
            {
                XCodeTextBox.FontSize++;
                e.Handled = true;
            }

            if (e.Key == Key.OemMinus)
            {
                if (XCodeTextBox.FontSize > MIN_FONT_SIZE)
                {
                    XCodeTextBox.FontSize--;
                }
                e.Handled = true;
            }
        }
Esempio n. 2
0
        private async void Find(TextEditor obj)
        {
            var dialog = new FindReplaceDialog(obj);

            dialog.ConfigureFor(FindReplaceDialog.DialogType.Find);
            await _app.ShowDialog("Find & Replace", dialog, DialogButtons.None, false);
        }
Esempio n. 3
0
        public override void Run()
        {
            var wb      = Workbench.Instance;
            var exp     = wb.ActiveSiteExplorer;
            var omgr    = ServiceRegistry.GetService <OpenResourceManager>();
            var connMgr = ServiceRegistry.GetService <ServerConnectionManager>();
            var conn    = connMgr.GetConnection(exp.ConnectionName);

            if (exp.SelectedItems.Length > 0)
            {
                int             replaced = 0;
                var             diag     = new FindReplaceDialog();
                Action <string> DoRun    = (string resourceId) =>
                {
                    //To maintain resource integrity, we don't modify any open resources. So we
                    //ask if they want to close down first. If they say no, omit this resource from
                    //the find/replace
                    if (omgr.IsOpen(resourceId, conn))
                    {
                        omgr.CloseEditors(conn, resourceId, false);
                        //Still open. Must've said no
                        if (omgr.IsOpen(resourceId, conn))
                        {
                            LoggingService.Info(string.Format(Strings.SkippingResource, resourceId));
                            return;
                        }
                    }

                    //Re-open in XML editor for user review
                    var ed = (XmlEditor)omgr.Open(resourceId, conn, true, wb.ActiveSiteExplorer);

                    //Do the find/replace. Dirty state would be triggered if any replacements were made
                    //It is then up to the user to review the change and decide whether to save or not
                    ed.FindAndReplace(diag.FindToken, diag.ReplaceToken);

                    replaced++;
                };
                if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (var item in exp.SelectedItems)
                    {
                        if (item.IsFolder)
                        {
                            var resources = conn.ResourceService.GetRepositoryResources(item.ResourceId);
                            foreach (IRepositoryItem resource in resources.Items)
                            {
                                if (resource.ResourceType != "Folder")
                                {
                                    DoRun(resource.ResourceId);
                                }
                            }
                        }
                        else
                        {
                            DoRun(item.ResourceId);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FindReplaceDialog.ShowForFind(loliScriptEditor);
     }
     catch { }
 }
Esempio n. 5
0
 private void findToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.findReplaceDialog == null)
     {
         this.findReplaceDialog              = new FindReplaceDialog();
         this.findReplaceDialog.FormClosing += new FormClosingEventHandler(this.findReplaceDialog_FormClosing);
     }
     this.InitFindReplace();
 }
Esempio n. 6
0
        internal void DoFind()
        {
            FindReplaceDialog diag = new FindReplaceDialog();

            diag.EnableReplace = false;
            diag.FindNext     += new EventHandler(diag_FindNext);
            diag.Closed       += new EventHandler(diagFind_Closed);
            diag.Show();
        }
Esempio n. 7
0
        void diag_ReplaceAll(object sender, EventArgs e)
        {
            FindReplaceDialog diag = sender as FindReplaceDialog;

            if (diag != null)
            {
                Content.Document.Text = Content.Document.Text.Replace(diag.SearchText, diag.ReplaceText);
            }
        }
Esempio n. 8
0
        private static void ExecuteFindReplace(BoneViewModel target)
        {
            var  dialog = new FindReplaceDialog("Find and Replace in Hierarchy...");
            bool result = dialog.ShowDialog() ?? false;

            if (result)
            {
                FindReplaceRecursive(target, dialog.Find, dialog.Replace);
            }
        }
Esempio n. 9
0
 private void CreateDialog(bool showReplace, bool showAll)
 {
     if (_dialog == null || _dialog.IsDisposed)
     {
         _dialog = new FindReplaceDialog(_lastSearchText,
                                         _lastReplaceText, this);
         _dialog.ShowingReplaceDialog = showReplace;
         _dialog.ShowingAllDialog     = showAll;
     }
 }
Esempio n. 10
0
    void FindDialogOnFindNext(object obj, EventArgs ea)
    {
        FindReplaceDialog dlg = (FindReplaceDialog)obj;

        strFind    = dlg.FindText;
        bMatchCase = dlg.MatchCase;
        bFindDown  = dlg.FindDown;

        FindNext();
    }
Esempio n. 11
0
        internal void DoReplace()
        {
            FindReplaceDialog diag = new FindReplaceDialog();

            diag.EnableReplace = true;
            diag.FindNext     += new EventHandler(diag_FindNext);
            diag.Replace      += new EventHandler(diag_Replace);
            diag.ReplaceAll   += new EventHandler(diag_ReplaceAll);
            diag.Closed       += new EventHandler(diag_Closed);
            diag.Show();
        }
Esempio n. 12
0
 private void CreateDialog(bool showReplace, bool showAll)
 {
     if (_dialog == null || _dialog.IsDisposed)
     {
         _dialog = new FindReplaceDialog(_lastSearchText,
             _lastReplaceText, _agsEditor.Preferences, this);
         _dialog.ShowingReplaceDialog = showReplace;
         _dialog.ShowingAllDialog = showAll;
         _dialog.CaseSensitive = _lastCaseSensitive;
     }            
 }
Esempio n. 13
0
        void diagFind_Closed(object sender, EventArgs e)
        {
            FindReplaceDialog diag = sender as FindReplaceDialog;

            if (diag != null)
            {
                diag.FindNext -= new EventHandler(diag_FindNext);

                diag.Closed -= new EventHandler(diag_Closed);
            }
        }
Esempio n. 14
0
    void ReplaceDialogOnReplace(object obj, EventArgs ea)
    {
        FindReplaceDialog dlg = (FindReplaceDialog)obj;

        strFind    = dlg.FindText;
        strReplace = dlg.ReplaceText;
        bMatchCase = dlg.MatchCase;

        if (string.Compare(strFind, txtbox.SelectedText, !bMatchCase) == 0)
        {
            txtbox.SelectedText = strReplace;
        }
        FindNext();
    }
        private void browserDesign_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            modifiedDocument = true;

            if (e.KeyData == (Keys.Control | Keys.F))
            {
                modeTabs.SelectedTab = tabEditor;
                FindReplaceDialog dlgFind = new FindReplaceDialog();
                dlgFind.Scintilla = editor;
                dlgFind.ShowDialog();
                dlgFind.Activate();
                dlgFind.Focus();
                return;
            }
        }
        /// <summary>
        /// 実行
        /// </summary>
        /// <param name="parameter"></param>
        protected override void Invoke(object parameter)
        {
            // イベント引数とContextを取得する
            var args   = parameter as InteractionRequestedEventArgs;
            var ctx    = args.Context as Confirmation;
            var entity = ctx.Content as FindReplaceDialogRequestEntity;

            if (entity != null)
            {
                switch (entity.RequestKind)
                {
                case FindReplaceDialogRequestEntity.DialogRequest.OpenFind:
                    FindReplaceDialog.ShowFindReplaceDialog(
                        this.AssociatedObject,
                        this.AssociatedObject._CenterTextEditor,
                        this.AssociatedObject._NodeView,
                        true);
                    break;

                case FindReplaceDialogRequestEntity.DialogRequest.OpenReplace:
                    FindReplaceDialog.ShowFindReplaceDialog(
                        this.AssociatedObject,
                        this.AssociatedObject._CenterTextEditor,
                        this.AssociatedObject._NodeView,
                        false);
                    break;

                case FindReplaceDialogRequestEntity.DialogRequest.FindNext:
                    FindReplaceDialog.Find(this.AssociatedObject, false);
                    break;

                case FindReplaceDialogRequestEntity.DialogRequest.FindPrev:
                    FindReplaceDialog.Find(this.AssociatedObject, true);
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 17
0
        void diag_Replace(object sender, EventArgs e)
        {
            FindReplaceDialog diag = sender as FindReplaceDialog;

            if (diag != null)
            {
                //first--is the currently selected text already matched?
                if (Content.SelectedText == diag.SearchText)
                {
                    Content.SelectedText = diag.ReplaceText;
                    diag_FindNext(sender, e);
                }
                else
                {
                    diag_FindNext(sender, e);
                    if (Content.SelectedText == diag.SearchText)
                    {
                        Content.SelectedText = diag.ReplaceText;
                    }
                }
            }
        }
Esempio n. 18
0
    void ReplaceDialogOnReplaceAll(object obj, EventArgs ea)
    {
        FindReplaceDialog dlg = (FindReplaceDialog)obj;

        string str = txtbox.Text;

        strFind    = dlg.FindText;
        strReplace = dlg.ReplaceText;
        bMatchCase = dlg.MatchCase;

        if (bMatchCase)
        {
            str = str.Replace(strFind, strReplace);
        }
        else
        {
            for (int i = 0; i < str.Length - strFind.Length;)
            {
                if (String.Compare(str, i, strFind, 0,
                                   strFind.Length, true) == 0)
                {
                    str = str.Remove(i, strFind.Length);
                    str = str.Insert(i, strReplace);
                    i  += strReplace.Length;
                }
                else
                {
                    i += 1;
                }
            }
        }
        if (str != txtbox.Text)
        {
            txtbox.Text            = str;
            txtbox.SelectionStart  = 0;
            txtbox.SelectionLength = 0;
            txtbox.Modified        = true;
        }
    }
Esempio n. 19
0
        void diag_FindNext(object sender, EventArgs e)
        {
            FindReplaceDialog diag = sender as FindReplaceDialog;

            if (diag != null)
            {
                int i = Content.Document.Text.IndexOf(diag.SearchText, Content.CaretOffset);
                if (i < 0)
                {
                    i = Content.Document.Text.IndexOf(diag.SearchText);
                }
                if (i >= 0)
                {
                    Content.CaretOffset = i;
                    Content.Select(Content.CaretOffset, diag.SearchText.Length);
                }
                else
                {
                    MessageBox.Show(diag.SearchText + " not found.", "Find", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Esempio n. 20
0
 private void findReplaceDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     this.findReplaceDialog = null;
 }
Esempio n. 21
0
 private static void ExecuteFindReplace(BoneViewModel target)
 {
     var dialog = new FindReplaceDialog("Find and Replace in Hierarchy...");
     bool result = dialog.ShowDialog() ?? false;
     if (result)
     {
         FindReplaceRecursive(target, dialog.Find, dialog.Replace);
     }
 }
Esempio n. 22
0
 private void CreateDialog(bool showReplace, bool showAll)
 {
     if (_dialog == null || _dialog.IsDisposed)
     {
         _dialog = new FindReplaceDialog(_lastSearchText,
             _lastReplaceText, _agsEditor.Preferences, this);
         _dialog.ShowingReplaceDialog = showReplace;
         _dialog.ShowingAllDialog = showAll;
         _dialog.CaseSensitive = _lastCaseSensitive;
     }            
 }