Beispiel #1
0
        public FilePreview(IReloadable owner, FileData fileData)
        {
            mFileData = fileData;
            InitializeComponent();
            textBox.Text = mFileData.FlatFileData;
            mOwner       = owner;

            gotoLineDialog                = new GoTo(textBox);
            findReplaceDialog             = new FindReplace(textBox);
            findReplaceDialog.KeyPressed += findReplaceDialog_KeyPressed;

            this.configureScintilla();

            localizeFile.Visible = textBox.Lexer == ScintillaNET.Lexer.Json;
            bool hasMixins = false;

            if ((mFileData as JsonFileData) != null)
            {
                if ((mFileData as JsonFileData).Json != null)
                {
                    hasMixins = (mFileData as JsonFileData).Json.SelectToken("mixins") != null;
                }
            }

            previewMixinsButton.Visible = (textBox.Lexer == ScintillaNET.Lexer.Json) && hasMixins;
        }
Beispiel #2
0
 private void frmMain_Deactivated(object sender, EventArgs e)
 {
     if (Form.ActiveForm == null)
     {
         FindReplace.CloseDialogIfNeeded();
     }
 }
Beispiel #3
0
        public FindReplaceDialog(string defaultSearchText,
                                 string defaultReplaceText, EditorPreferences preferences,
                                 FindReplace findReplace)
        {
            _findReplace = findReplace;
            _preferences = preferences;
            InitializeComponent();
            btnOK.Enabled = false;

            foreach (string previousSearch in preferences.RecentSearches)
            {
                cmbFind.Items.Add(previousSearch);
                cmbReplace.Items.Add(previousSearch);
            }

            cmbLookIn.Items.Add(LOOK_IN_CURRENT_DOCUMENT);
            cmbLookIn.Items.Add(LOOK_IN_CURRENT_PROJECT);
            cmbLookIn.Text = _lastSelectedLookIn ?? LOOK_IN_CURRENT_DOCUMENT;

            chkCaseSensitive.Checked = _lastSelectedCaseSensitive;

            cmbFind.Text    = defaultSearchText;
            cmbReplace.Text = defaultReplaceText;
            btnCancel.Left  = btnReplace.Left;
            cmbFind.Focus();
        }
Beispiel #4
0
        public static void ShowReplaceForm(bool replace = false)
        {
            if (!initialised)
            {
                return;
            }

            if (form == null)
            {
                form         = new FindReplace(ref gridview);
                form.TopMost = true;
                form.Replace = replace;
                form.Show();
                form.FormClosed += delegate { form = null; };
            }
            else
            {
                if (form.Replace && !replace)
                {
                    form.SetScreenType(false);
                }
                else if (!form.Replace && replace)
                {
                    form.SetScreenType(true);
                }

                form.Activate();
                form.TopMost = true;
            }
        }
Beispiel #5
0
        public MainWindow()
        {
            InitializeComponent();

            App.LanguageChanged += LanguageChanged;

            CultureInfo currLang = App.Language;

            languageMenuItem.Items.Clear();
            foreach (var lang in App.Languages)
            {
                MenuItem menuLang = new MenuItem();
                menuLang.Header    = lang.NativeName.First().ToString().ToUpper() + lang.NativeName.Substring(1);
                menuLang.Tag       = lang;
                menuLang.IsChecked = lang.Equals(currLang);
                menuLang.Click    += ChangeLanguageClick;
                languageMenuItem.Items.Add(menuLang);
            }

            // TODO Why this has to be here, I have no idea.
            // All I know is that it doesn't work properly
            // if put in the xaml file.
            lineNumbersMenuItem.IsChecked = true;

            MyFindReplace = new FindReplace();
            // Tie in FindReplace event
            MyFindReplace.KeyPressed += MyFindReplace_KeyPressed;
        }
Beispiel #6
0
        private void ShowFindReplaceDialog(bool showReplace, bool showAll)
        {
            FindReplace findReplace = new FindReplace(_dialog, _agsEditor,
                                                      _lastSearchText, _lastCaseSensitive);

            findReplace.ShowFindReplaceDialog(showReplace, showAll);
        }
        public TextEditor()
        {
            InitializeComponent();

            Dock = DockStyle.Fill;

            findReplaceDialog                 = new FindReplace();
            findReplaceDialog.Scintilla       = scintilla1;
            findReplaceDialog.FindAllResults += MyFindReplace_FindAllResults;
            findReplaceDialog.KeyPressed     += MyFindReplace_KeyPressed;

            findAllResultsPanel1.Scintilla = scintilla1;
            findAllResultsPanel1.Visible   = false;
            findAllResultsPanel1.BackColor = FormThemes.BaseTheme.TextEditorBackColor;
            findAllResultsPanel1.ForeColor = FormThemes.BaseTheme.TextForeColor;
            findAllResultsPanel1.Scintilla.SetWhitespaceBackColor(true, Color.FromArgb(50, 50, 50));

            EncodingOptions.Add(Encoding.Default);
            EncodingOptions.Add(Encoding.GetEncoding("shift_jis"));

            foreach (var encoding in EncodingOptions)
            {
                var toolstrip = new ToolStripMenuItem(encoding.EncodingName, null, encodingMenuClick);
                encodingToolStripMenuItem.DropDownItems.Add(toolstrip);
            }

            ReloadEncodingMenuToggle();

            FillEditor("");
        }
Beispiel #8
0
 protected override void OnKeyPressed(Keys keyData)
 {
     if (keyData.Equals(Keys.Escape))
     {
         FindReplace.CloseDialogIfNeeded();
     }
 }
Beispiel #9
0
        internal void HandleFindMsgString(Message m)
        {
            FindReplace tempfr = (FindReplace)Marshal.PtrToStructure(m.LParam, typeof(FindReplace));

            flags       = tempfr.flags;
            findwhat    = Marshal.PtrToStringAuto(tempfr.findwhat);
            replacewith = Marshal.PtrToStringAuto(tempfr.replacewith);

            if (GetOption(FR_DIALOGTERM))
            {
                SetOption(FR_DIALOGTERM, false);
                OnDialogTerminate();
            }
            else if (GetOption(FR_FINDNEXT))
            {
                SetOption(FR_FINDNEXT, false);
                OnFindNext();
            }
            else if (GetOption(FR_REPLACE))
            {
                SetOption(FR_REPLACE, false);
                OnReplace();
            }
            else if (GetOption(FR_REPLACEALL))
            {
                SetOption(FR_REPLACEALL, false);
                OnReplaceAll();
            }
        }
Beispiel #10
0
 private void ShowFindReplaceDialog(bool showReplace, bool showAll)
 {
     FindReplace findReplace = new FindReplace(_script, _agsEditor,
         _lastSearchText, _lastCaseSensitive);
     findReplace.LastSearchTextChanged += new FindReplace.LastSearchTextChangedHandler(findReplace_LastSearchTextChanged);
     findReplace.ShowFindReplaceDialog(showReplace, showAll);
 }
Beispiel #11
0
        /// <summary>
        /// Create instance of FindReplace with reference to a ScintillaNET control.
        /// </summary>
        /// <param name="theBox"></param>
        public static void ScintillaInstance(Scintilla theBox)
        {
            _myFindReplace = new FindReplace(theBox);
            _myFindReplace.Window.StartPosition = FormStartPosition.CenterScreen;
            _myGoTo = new GoTo(theBox);

            theBox.KeyDown += KeyDown;
        }
Beispiel #12
0
 protected override void OnKeyPressed(System.Windows.Forms.Keys keyData)
 {
     if (keyData.Equals(
             System.Windows.Forms.Keys.Escape))
     {
         FindReplace.CloseDialogIfNeeded();
     }
 }
        /// <summary>
        /// Updates the find all results panel
        /// </summary>
        /// <param name="FindReplace">The FindReplace instance used to generate the find results.</param>
        /// <param name="FindAllResults"></param>
        public void UpdateFindAllResults(FindReplace FindReplace, List <ScintillaNET_FindReplaceDialog.CharacterRange> FindAllResults)
        {
            if (Scintilla == null)
            {
                return;
            }

            _findAllResults = new List <ScintillaNET_FindReplaceDialog.CharacterRange>(FindAllResults);

            FindResultsScintilla.ClearAll();

            Indicator _indicator = FindResultsScintilla.Indicators[16];

            _indicator.ForeColor = Color.Red;
            _indicator.Alpha     = 100;
            _indicator.Style     = IndicatorStyle.RoundBox;
            _indicator.Under     = true;

            FindResultsScintilla.IndicatorCurrent = _indicator.Index;

            //Write lines
            foreach (var item in _findAllResults)
            {
                int startLine = Scintilla.LineFromPosition(item.cpMin);
                int endLine   = Scintilla.LineFromPosition(item.cpMax);

                if (startLine == endLine)
                {
                    string resultsLinePrefix = string.Format("Line {0}: ", startLine + 1);

                    FindResultsScintilla.AppendText(string.Format("{0}{1}",
                                                                  resultsLinePrefix, Scintilla.Lines[startLine].Text));
                }
            }

            //Highlight
            int resultLineIndex = 0;

            foreach (var item in _findAllResults)
            {
                int startLine = Scintilla.LineFromPosition(item.cpMin);
                int endLine   = Scintilla.LineFromPosition(item.cpMax);

                if (startLine == endLine)
                {
                    string resultsLinePrefix = string.Format("Line {0}: ", startLine + 1);

                    int LinePos        = Scintilla.Lines[startLine].Position;
                    int startPosInLine = item.cpMin - LinePos;

                    int lastLineStartPos = FindResultsScintilla.Lines[resultLineIndex].Position;

                    FindResultsScintilla.IndicatorFillRange(lastLineStartPos + resultsLinePrefix.Length + startPosInLine, item.cpMax - item.cpMin);

                    resultLineIndex++;
                }
            }
        }
Beispiel #14
0
 public ScriptEditor(string filePath)
 {
     InitializeComponent();
     ScintillaFindReplace             = new FindReplace(scintillaControl);
     ScintillaFindReplace.KeyPressed += ScintillaFindReplaceOnKeyPressed;
     FilePath = filePath;
     ConfigureScintilla();
     scintillaControl.Text     = File.ReadAllText(FilePath);
     scintillaControl.KeyDown += ScintillaControlOnKeyDown;
 }
Beispiel #15
0
        public void FindTest_Find_true()
        {
            //Arrange
            FindReplace newFindReplace = new FindReplace("this car is purple", "is", "purple");
            //Act
            string expected = "thpurple car purple purple";
            string result   = newFindReplace.FindandReplace();

            //Assert
            Assert.Equal(true, result == expected);
        }
        public MainWindow()
        {
            InitializeComponent();
            // TODO Why this has to be here, I have no idea.
            // All I know is that it doesn't work properly
            // if put in the xaml file.
            lineNumbersMenuItem.IsChecked = true;

            MyFindReplace = new FindReplace();
            // Tie in FindReplace event
            MyFindReplace.KeyPressed += MyFindReplace_KeyPressed;
        }
Beispiel #17
0
        public ScintillaTextEditorCustom()
        {
            findDialog           = new FindReplace();
            bwXmlFormat          = new BackgroundWorker();
            findDialog.Scintilla = this;

            bwXmlFormat.DoWork             += BwXmlFormat_DoWork;
            bwXmlFormat.RunWorkerCompleted += BwXmlFormat_RunWorkerCompleted;
            Styles[0].Font      = "Consolas";
            Styles[0].Size      = 10;
            Styles[0].ForeColor = Color.FromArgb(0, 0, 0);
        }
  public Class WordCounterTests_SetMainWord_Void()
  {
    //Arrange
          string expected = "hello world";
          //Act
          FindReplace.SetMainArticle("hello world");
          string actual = FindReplace.GetMainArticle();
          //Assert
          Assert.AreEqual(expected, actual);


  }
Beispiel #19
0
        private void EditorKeyDown(Object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F5)
            {
                this.compile(false, true);
            }

            if (!(Keyboard.IsKeyDown(Key.LeftCtrl)))
            {
                return;
            }

            if (e.KeyCode == Keys.S)
            {
                if (Keyboard.IsKeyDown(Key.LeftShift))
                {
                    this.saveAll();
                }
                else
                {
                    this.saveFile(this.fileTabs.SelectedTab);
                }
            }
            else if (e.KeyCode == Keys.F)
            {
                FindReplace fr = new FindReplace(this.fileTabs.SelectedTab.allChildren().Where(x => x.GetType() == typeof(Scintilla)).First() as Scintilla);

                fr.FindAllResults += delegate(Object sender0, FindResultsEventArgs e0) {
                    Scintilla scin = fr.Scintilla;
                    scin.IndicatorCurrent = 8;

                    foreach (ScintillaNET_FindReplaceDialog.CharacterRange cr in e0.FindAllResults)
                    {
                        Int32 cpMin = cr.cpMin;
                        scin.IndicatorFillRange(cpMin, cr.cpMax - cpMin);
                    }
                };

                if (Keyboard.IsKeyDown(Key.LeftShift))
                {
                    fr.ShowReplace();
                }
                else
                {
                    fr.ShowFind();
                }
            }
            else if (e.KeyCode == Keys.G)
            {
                new GoTo(this.fileTabs.SelectedTab.allChildren().Where(x => x.GetType() == typeof(Scintilla)).First() as Scintilla).ShowGoToDialog();
            }
        }
Beispiel #20
0
        public Form1()
        {
            InitializeComponent();
            scintilla1.Styles[Style.Default].Size = 10;

            MyFindReplace = new FindReplace(scintilla1);
            MyFindReplace.FindAllResults += MyFindReplace_FindAllResults;
            MyFindReplace.KeyPressed     += MyFindReplace_KeyPressed;;

            incrementalSearcher1.FindReplace = MyFindReplace;

            findAllResultsPanel1.Scintilla = scintilla1;
        }
Beispiel #21
0
        public void FindAndReplace_ReplaceString_string()
        {
            //Arrange
            FindReplace newString = new FindReplace("I am walking my cat to the cathedral", "cat", "dog");
            var         output    = "I am walking my dog to the doghedral";


            //Act
            string result = newString.FindAndReplace();

            //Assert
            Assert.AreEqual(output, result);
        }
Beispiel #22
0
        public frmScriptEditor()
        {
            InitializeComponent();

            ScintillaFindReplace             = new FindReplace(scintillaControl);
            ScintillaFindReplace.KeyPressed += ScintillaFindReplaceOnKeyPressed;
            this.ShowIcon = false;

            ConfigureScintilla();
            scintillaControl.ScrollWidth         = 0;
            scintillaControl.ScrollWidthTracking = true;
            scintillaControl.KeyDown            += ScintillaControlOnKeyDown;
        }
Beispiel #23
0
 public HomeModule()
 {
     Get["/"] = _ =>
       {
     return View["index.cshtml"];
       };
       Post["/"]= _ =>
       {
     FindReplace newPhrase = new FindReplace(Request.Form["phrase"],
     Request.Form["wordToReplace"],
     Request.Form["newWord"]);
     return View["index.cshtml", newPhrase];
       };
 }
Beispiel #24
0
        void StandardScintilla_SelectionChanged(object sender, EventArgs e)
        {
            NativeInterface.IndicatorClearRange(0, Text.Length);

            if (string.IsNullOrWhiteSpace(Selection.Text))
            {
                return;
            }

            foreach (Range r in FindReplace.FindAll(Selection.Text))
            {
                r.SetIndicator(0);
            }
        }
Beispiel #25
0
 public override void OnClick()
 {
     try
     {
         FindReplace frm = new FindReplace(_context, _view.CurrentGridView.VirtualGridView);
         frm.TopMost       = true;
         frm.StartPosition = FormStartPosition.CenterParent;
         frm.Show();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Beispiel #26
0
 public frmScriptEditor(string filePath)
 {
     InitializeComponent();
     this.ShowIcon                    = false;
     this.Text                        = "Witcherscript editor - " + Path.GetFileName(filePath);
     ScintillaFindReplace             = new FindReplace(scintillaControl);
     ScintillaFindReplace.KeyPressed += ScintillaFindReplaceOnKeyPressed;
     this.ShowIcon                    = false;
     FilePath = filePath;
     ConfigureScintilla();
     scintillaControl.ScrollWidth         = 0;
     scintillaControl.ScrollWidthTracking = true;
     scintillaControl.Text     = File.ReadAllText(FilePath);
     scintillaControl.KeyDown += ScintillaControlOnKeyDown;
 }
Beispiel #27
0
        public Main()
        {
            InitializeComponent();

            this.Text += " (Community Edition)";

            tsCurrentSolution.Text = String.Empty;

            _tc.ShowToolTips          = true;
            _tc.SelectedIndexChanged += _tc_SelectedIndexChanged;
            _tc.Dock             = DockStyle.Fill;
            _tc.DrawMode         = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
            _tc.DrawItem        += new System.Windows.Forms.DrawItemEventHandler(this._tc_DrawItem);;
            _tc.MouseDown       += _tc_MouseDown;
            _tc.SizeMode         = TabSizeMode.Fixed;
            _tc.ContextMenuStrip = mnuContextTabCtl;

            _domainName        = ConfigurationManager.AppSettings["DomainName"] ?? "ET";
            _userName          = ConfigurationManager.AppSettings["UserName"] ?? Environment.UserName;
            picWaiting.Visible = false;

            lblRoot.Text = "Caching...";

            //Find dialog
            _find             = new FindReplace();
            _find.KeyPressed += find_KeyPressed;;

            CreateNewTab();

            splitContainer1.Panel2.Controls.Add(_tc);

            gridResults.RowEnter += gridResults_RowEnter;

            FillOperatorCombo(cboOperator);
            FillOperatorCombo(cboOperDLL);

            tsCurrentSolution.AutoToolTip = true;

            progressRefresh.Maximum = 100;
            progressRefresh.Minimum = 0;
            progressRefresh.Value   = 0;
            btnDown.Enabled         = false;
            btnUp.Enabled           = false;
            lblHits.Text            = String.Empty;

            lblHistoryPosition.Text = String.Empty;
            lblQueryTime.Text       = String.Empty;
        }
        public CodeEditorForm(MyPluginControl control, Webresource resource) : base(control, resource, true)
        {
            InitializeComponent();

            ManageCmdKeys();
            SetEditorStyle();

            findReplace             = new FindReplace();
            findReplace.Scintilla   = scintilla;
            findReplace.KeyPressed += MyFindReplace_KeyPressed;

            Controls.SetChildIndex(scintilla, 0);

            Text = resource.Name;
            resource.ContentReplaced += Resource_ContentReplaced;
        }
Beispiel #29
0
        private void ReplaceToolStripMenuItem1Click(Object sender, EventArgs e)
        {
            FindReplace fr = new FindReplace(this.fileTabs.SelectedTab.allChildren().Where(x => x.GetType() == typeof(Scintilla)).First() as Scintilla);

            fr.FindAllResults += delegate(Object sender0, FindResultsEventArgs e0) {
                Scintilla scin = fr.Scintilla;
                scin.IndicatorCurrent = 8;

                foreach (ScintillaNET_FindReplaceDialog.CharacterRange cr in e0.FindAllResults)
                {
                    Int32 cpMin = cr.cpMin;
                    scin.IndicatorFillRange(cpMin, cr.cpMax - cpMin);
                }
            };

            fr.ShowReplace();
        }
        public TestForm()
        {
            InitializeComponent();
            scintilla1.Styles[Style.Default].Font = "Consolas";
            scintilla1.Styles[Style.Default].Size = 10;
            scintilla2.Styles[Style.Default].Font = "Consolas";
            scintilla2.Styles[Style.Default].Size = 10;
            tabControl1.SelectedIndexChanged     += Form_TabChanged;

            MyFindReplace = new FindReplace(scintilla1);
            MyFindReplace.Window.AutoPosition = true;
            MyFindReplace.KeyPressed         += MyFindReplace_KeyPressed;

            MyGoTo = new GoTo(scintilla1);

            incrementalSearcherToolStrip.Manager = MyFindReplace;
        }
Beispiel #31
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            if (findReplaceDialog?.Window?.Visible == true)
            {
                findReplaceDialog.Window.Hide();
            }

            findReplaceDialog?.Dispose();
            findReplaceDialog = null;

            base.Dispose(disposing);
        }
Beispiel #32
0
 public void Find_Number_Of_Times_Word_Exists()
 {
     FindReplace test4 = new FindReplace("cat cat cat dog", "cat", "wolf");
       Assert.Equal(3, test4.CountWord());
 }
Beispiel #33
0
 public void Find_And_Replace_Test()
 {
     FindReplace test = new FindReplace("hello world", "world", "universe");
       Assert.Equal("hello universe", test.ReplaceWord());
 }
Beispiel #34
0
 public void Find_And_Replace_Whole_phrase()
 {
     FindReplace test2 = new FindReplace("hello world", "hello world", "universe");
       Assert.Equal("universe", test2.ReplaceWord());
 }
Beispiel #35
0
 public void Find_And_Replace_Words_Within_Words_With_Capitals()
 {
     FindReplace test3 = new FindReplace("Catdog", "cat", "wolf");
       Assert.Equal("wolfdog", test3.ReplaceWord());
 }
Beispiel #36
0
 public void Find_Number_Of_Times_Word_Exists_And_Ignore_Caps()
 {
     FindReplace test7 = new FindReplace("Cat Cat Cat dog", "cat", "wolf");
      Assert.Equal(3, test7.CountWord());
 }
Beispiel #37
0
 public void Prevent_Partial_Replacements()
 {
     FindReplace test5 = new FindReplace("catdog", "cat", "wolf");
       Assert.Equal("catdog", test5.WholeWordsOnly());
 }
Beispiel #38
0
 public void Prevent_Partial_Replacements_While_Allowing_Single()
 {
     FindReplace test6 = new FindReplace("I am walking my cat to the cathedral", "cat", "wolf");
       Assert.Equal("i am walking my wolf to the cathedral", test6.WholeWordsOnly());
 }