diff --git a/pseudocodeIde/PseudocodeIDEForm.Designer.cs b/pseudocodeIde/PseudocodeIDEForm.Designer.cs index 580c131..4654402 100644 --- a/pseudocodeIde/PseudocodeIDEForm.Designer.cs +++ b/pseudocodeIde/PseudocodeIDEForm.Designer.cs @@ -40,6 +40,7 @@ private void InitializeComponent() this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.findMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.replaceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.goToMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.wordWrapMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.runMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -52,6 +53,7 @@ private void InitializeComponent() this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.updatePseudocodeIDEMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.codeTextBox = new ScintillaNET.Scintilla(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); // @@ -85,7 +87,7 @@ private void InitializeComponent() // this.newMenuItem.Name = "newMenuItem"; this.newMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newMenuItem.Size = new System.Drawing.Size(257, 34); + this.newMenuItem.Size = new System.Drawing.Size(270, 34); this.newMenuItem.Text = "Neu"; this.newMenuItem.Click += new System.EventHandler(this.newMenuItem_Click); // @@ -93,7 +95,7 @@ private void InitializeComponent() // this.openMenuItem.Name = "openMenuItem"; this.openMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openMenuItem.Size = new System.Drawing.Size(257, 34); + this.openMenuItem.Size = new System.Drawing.Size(270, 34); this.openMenuItem.Text = "Öffnen"; this.openMenuItem.Click += new System.EventHandler(this.openMenuItem_Click); // @@ -102,7 +104,7 @@ private void InitializeComponent() this.saveMenuItem.Enabled = false; this.saveMenuItem.Name = "saveMenuItem"; this.saveMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveMenuItem.Size = new System.Drawing.Size(257, 34); + this.saveMenuItem.Size = new System.Drawing.Size(270, 34); this.saveMenuItem.Text = "Speichern"; this.saveMenuItem.Click += new System.EventHandler(this.saveMenuItem_Click); // @@ -113,7 +115,9 @@ private void InitializeComponent() this.redoToolStripMenuItem, this.toolStripSeparator1, this.findMenuItem, - this.replaceMenuItem}); + this.replaceMenuItem, + this.toolStripSeparator4, + this.goToMenuItem}); this.editMenuItem.Name = "editMenuItem"; this.editMenuItem.Size = new System.Drawing.Size(111, 29); this.editMenuItem.Text = "Bearbeiten"; @@ -157,6 +161,14 @@ private void InitializeComponent() this.replaceMenuItem.Text = "Ersetzen"; this.replaceMenuItem.Click += new System.EventHandler(this.replaceMenuItem_Click); // + // goToMenuItem + // + this.goToMenuItem.Name = "goToMenuItem"; + this.goToMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); + this.goToMenuItem.Size = new System.Drawing.Size(311, 34); + this.goToMenuItem.Text = "Gehe zu"; + this.goToMenuItem.Click += new System.EventHandler(this.goToMenuItem_Click); + // // viewMenuItem // this.viewMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -249,20 +261,26 @@ private void InitializeComponent() // codeTextBox // this.codeTextBox.AdditionalSelectionTyping = true; + this.codeTextBox.AutoCMaxHeight = 9; + this.codeTextBox.BiDirectionality = ScintillaNET.BiDirectionalDisplayType.Disabled; this.codeTextBox.CaretLineBackColor = System.Drawing.Color.WhiteSmoke; this.codeTextBox.CaretLineVisible = true; this.codeTextBox.Dock = System.Windows.Forms.DockStyle.Fill; this.codeTextBox.EolMode = ScintillaNET.Eol.Lf; this.codeTextBox.IndentationGuides = ScintillaNET.IndentView.Real; this.codeTextBox.IndentWidth = 4; + this.codeTextBox.LexerName = null; this.codeTextBox.Location = new System.Drawing.Point(0, 33); this.codeTextBox.MultiPaste = ScintillaNET.MultiPaste.Each; this.codeTextBox.MultipleSelection = true; this.codeTextBox.Name = "codeTextBox"; this.codeTextBox.ScrollWidth = 39; this.codeTextBox.Size = new System.Drawing.Size(1176, 676); + this.codeTextBox.TabIndents = true; this.codeTextBox.TabIndex = 1; + this.codeTextBox.UseRightToLeftReadingLayout = false; this.codeTextBox.UseTabs = true; + this.codeTextBox.WrapMode = ScintillaNET.WrapMode.None; this.codeTextBox.Zoom = 2; this.codeTextBox.CharAdded += new System.EventHandler(this.codeTextBox_CharAdded); this.codeTextBox.UpdateUI += new System.EventHandler(this.codeTextBox_UpdateUI); @@ -270,6 +288,11 @@ private void InitializeComponent() this.codeTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.codeTextBox_KeyDown); this.codeTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.codeTextBox_KeyPress); // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(308, 6); + // // PseudocodeIDEForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -320,6 +343,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem updatePseudocodeIDEMenuItem; private ScintillaNET.Scintilla codeTextBox; + private System.Windows.Forms.ToolStripMenuItem goToMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; } } diff --git a/pseudocodeIde/PseudocodeIDEForm.cs b/pseudocodeIde/PseudocodeIDEForm.cs index e46ebdb..82921f3 100644 --- a/pseudocodeIde/PseudocodeIDEForm.cs +++ b/pseudocodeIde/PseudocodeIDEForm.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using pseudocodeIde.findReplace; using pseudocode_ide; using Newtonsoft.Json; using System.Diagnostics; @@ -14,6 +13,7 @@ using ScintillaNET; using pseudocode_ide.interpreter.scanner; using System.Drawing; +using ScintillaNET_FindReplaceDialog; namespace pseudocodeIde { @@ -72,7 +72,7 @@ public string code /// private bool isSaved = true; - private FindReplaceForm findReplaceForm; + private FindReplace findReplace; private OutputForm outputForm; @@ -81,10 +81,11 @@ public string code public PseudocodeIDEForm() { - this.findReplaceForm = new FindReplaceForm(this); + InitializeComponent(); this.outputForm = new OutputForm(this); + this.findReplace = new FindReplace(this.codeTextBox); + this.findReplace.KeyPressed += codeTextBox_KeyDown; - InitializeComponent(); this.resetUndoRedo(); // disable right click menu @@ -163,12 +164,6 @@ private void singleEqualIsCompareOperatorMenuItem_Click(object sender, EventArgs private void PseudocodeIDE_FormClosing(object sender, FormClosingEventArgs e) { // main form won't close if child form is not disposed - if (!this.findReplaceForm.IsDisposed) - { - this.findReplaceForm.Close(); - this.Close(); - return; - } if (!this.outputForm.IsDisposed) { this.outputForm.Close(); @@ -250,6 +245,16 @@ private void codeTextBox_KeyDown(object sender, KeyEventArgs e) e.SuppressKeyPress = false; return; } + else if (e.Shift && e.KeyCode == Keys.F3) + { + this.findReplace.Window.FindPrevious(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.F3) + { + this.findReplace.Window.FindNext(); + e.SuppressKeyPress = true; + } } private void codeTextBox_KeyPress(object sender, KeyPressEventArgs e) @@ -721,70 +726,17 @@ private void redoToolStripMenuItem_Click(object sender, EventArgs e) private void findMenuItem_Click(object sender, EventArgs e) { - this.findReplaceForm.Show(FindReplaceTabs.FIND, codeTextBox.SelectedText); + this.findReplace.ShowFind(); } private void replaceMenuItem_Click(object sender, EventArgs e) { - this.findReplaceForm.Show(FindReplaceTabs.REPLACE, codeTextBox.SelectedText); - } - - /// - /// Get the start of the current selection in the code text box - /// - public int getSelectionStart() - { - return codeTextBox.SelectionStart; + this.findReplace.ShowReplace(); } - /// - /// Get the end of the current selection in the code text box - /// - public int getSelectionEnd() + private void goToMenuItem_Click(object sender, EventArgs e) { - return codeTextBox.SelectionEnd; - } - - /// - /// Get the selection length in the code text box - /// - public int getSelectionLength() - { - return codeTextBox.SelectionEnd - codeTextBox.SelectionStart; - } - - /// - /// Get the currently selected text. - /// - public string getSelection() - { - return codeTextBox.SelectedText; - } - - /// - /// Select text in the code text box. Will be invoked on the UI thread. - /// - /// start of the selection - /// length of the selection - public void selectText(int selectionStart, int selectionLength) - { - Invoke(new Action(() => - { - codeTextBox.SelectionStart = selectionStart; - codeTextBox.SelectionEnd = selectionStart + selectionLength; - })); - } - - /// - /// Replace the selected text. Will be invoked on the UI thread. - /// - /// The new text to replace - public void setSelectedText(string toReplace) - { - Invoke(new Action(() => - { - codeTextBox.ReplaceSelection(toReplace); - })); + new GoTo(codeTextBox).ShowGoToDialog(); } // --------------------------------------------- diff --git a/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs b/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs deleted file mode 100644 index 8da8e45..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs +++ /dev/null @@ -1,319 +0,0 @@ -namespace pseudocodeIde -{ - partial class FindReplaceForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.tabPageReplace = new System.Windows.Forms.TabPage(); - this.cbMatchCase2 = new System.Windows.Forms.CheckBox(); - this.btReplaceAll = new System.Windows.Forms.Button(); - this.btReplace = new System.Windows.Forms.Button(); - this.btFindNext2 = new System.Windows.Forms.Button(); - this.tbReplaceWith = new System.Windows.Forms.TextBox(); - this.tbFindWhat2 = new System.Windows.Forms.TextBox(); - this.tabPageFind = new System.Windows.Forms.TabPage(); - this.btCount = new System.Windows.Forms.Button(); - this.cbMatchCase1 = new System.Windows.Forms.CheckBox(); - this.btFindNext1 = new System.Windows.Forms.Button(); - this.tbFindWhat1 = new System.Windows.Forms.TextBox(); - this.tabControl = new System.Windows.Forms.TabControl(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.tabPageReplace.SuspendLayout(); - this.tabPageFind.SuspendLayout(); - this.tabControl.SuspendLayout(); - this.statusStrip.SuspendLayout(); - this.SuspendLayout(); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); - // - // tabPageReplace - // - this.tabPageReplace.Controls.Add(this.label2); - this.tabPageReplace.Controls.Add(this.label1); - this.tabPageReplace.Controls.Add(this.cbMatchCase2); - this.tabPageReplace.Controls.Add(this.btReplaceAll); - this.tabPageReplace.Controls.Add(this.btReplace); - this.tabPageReplace.Controls.Add(this.btFindNext2); - this.tabPageReplace.Controls.Add(this.tbReplaceWith); - this.tabPageReplace.Controls.Add(this.tbFindWhat2); - this.tabPageReplace.Location = new System.Drawing.Point(4, 29); - this.tabPageReplace.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageReplace.Name = "tabPageReplace"; - this.tabPageReplace.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageReplace.Size = new System.Drawing.Size(718, 146); - this.tabPageReplace.TabIndex = 1; - this.tabPageReplace.Text = "Ersetzen"; - this.tabPageReplace.UseVisualStyleBackColor = true; - // - // cbMatchCase2 - // - this.cbMatchCase2.AutoSize = true; - this.cbMatchCase2.Location = new System.Drawing.Point(9, 117); - this.cbMatchCase2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cbMatchCase2.Name = "cbMatchCase2"; - this.cbMatchCase2.Size = new System.Drawing.Size(264, 24); - this.cbMatchCase2.TabIndex = 3; - this.cbMatchCase2.Text = "Groß-/Kleinschreibung beachten"; - this.cbMatchCase2.UseVisualStyleBackColor = true; - // - // btReplaceAll - // - this.btReplaceAll.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btReplaceAll.Location = new System.Drawing.Point(510, 100); - this.btReplaceAll.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btReplaceAll.Name = "btReplaceAll"; - this.btReplaceAll.Size = new System.Drawing.Size(195, 35); - this.btReplaceAll.TabIndex = 6; - this.btReplaceAll.Text = "Alles ersetzen"; - this.btReplaceAll.UseVisualStyleBackColor = true; - // - // btReplace - // - this.btReplace.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btReplace.Location = new System.Drawing.Point(510, 55); - this.btReplace.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btReplace.Name = "btReplace"; - this.btReplace.Size = new System.Drawing.Size(195, 35); - this.btReplace.TabIndex = 5; - this.btReplace.Text = "Ersetzen"; - this.btReplace.UseVisualStyleBackColor = true; - // - // btFindNext2 - // - this.btFindNext2.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btFindNext2.Location = new System.Drawing.Point(510, 10); - this.btFindNext2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btFindNext2.Name = "btFindNext2"; - this.btFindNext2.Size = new System.Drawing.Size(195, 35); - this.btFindNext2.TabIndex = 4; - this.btFindNext2.Text = "Suchen"; - this.btFindNext2.UseVisualStyleBackColor = true; - // - // tbReplaceWith - // - this.tbReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbReplaceWith.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbReplaceWith.Location = new System.Drawing.Point(83, 60); - this.tbReplaceWith.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbReplaceWith.Name = "tbReplaceWith"; - this.tbReplaceWith.Size = new System.Drawing.Size(414, 26); - this.tbReplaceWith.TabIndex = 2; - // - // tbFindWhat2 - // - this.tbFindWhat2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbFindWhat2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbFindWhat2.Location = new System.Drawing.Point(83, 15); - this.tbFindWhat2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbFindWhat2.Name = "tbFindWhat2"; - this.tbFindWhat2.Size = new System.Drawing.Size(414, 26); - this.tbFindWhat2.TabIndex = 1; - // - // tabPageFind - // - this.tabPageFind.Controls.Add(this.label3); - this.tabPageFind.Controls.Add(this.btCount); - this.tabPageFind.Controls.Add(this.cbMatchCase1); - this.tabPageFind.Controls.Add(this.btFindNext1); - this.tabPageFind.Controls.Add(this.tbFindWhat1); - this.tabPageFind.Location = new System.Drawing.Point(4, 29); - this.tabPageFind.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageFind.Name = "tabPageFind"; - this.tabPageFind.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageFind.Size = new System.Drawing.Size(718, 146); - this.tabPageFind.TabIndex = 0; - this.tabPageFind.Text = "Suchen"; - this.tabPageFind.UseVisualStyleBackColor = true; - // - // btCount - // - this.btCount.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btCount.Location = new System.Drawing.Point(510, 55); - this.btCount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btCount.Name = "btCount"; - this.btCount.Size = new System.Drawing.Size(195, 35); - this.btCount.TabIndex = 4; - this.btCount.Text = "Zählen"; - this.btCount.UseVisualStyleBackColor = true; - // - // cbMatchCase1 - // - this.cbMatchCase1.AutoSize = true; - this.cbMatchCase1.Location = new System.Drawing.Point(9, 117); - this.cbMatchCase1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cbMatchCase1.Name = "cbMatchCase1"; - this.cbMatchCase1.Size = new System.Drawing.Size(264, 24); - this.cbMatchCase1.TabIndex = 2; - this.cbMatchCase1.Text = "Groß-/Kleinschreibung beachten"; - this.cbMatchCase1.UseVisualStyleBackColor = true; - // - // btFindNext1 - // - this.btFindNext1.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btFindNext1.Location = new System.Drawing.Point(510, 10); - this.btFindNext1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btFindNext1.Name = "btFindNext1"; - this.btFindNext1.Size = new System.Drawing.Size(195, 35); - this.btFindNext1.TabIndex = 3; - this.btFindNext1.Text = "Suchen"; - this.btFindNext1.UseVisualStyleBackColor = true; - // - // tbFindWhat1 - // - this.tbFindWhat1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbFindWhat1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbFindWhat1.Location = new System.Drawing.Point(83, 15); - this.tbFindWhat1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbFindWhat1.Name = "tbFindWhat1"; - this.tbFindWhat1.Size = new System.Drawing.Size(414, 26); - this.tbFindWhat1.TabIndex = 1; - // - // tabControl - // - this.tabControl.Controls.Add(this.tabPageFind); - this.tabControl.Controls.Add(this.tabPageReplace); - this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl.Location = new System.Drawing.Point(0, 0); - this.tabControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabControl.Name = "tabControl"; - this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(726, 179); - this.tabControl.TabIndex = 50; - this.tabControl.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabControl_Selecting); - // - // statusStrip - // - this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.statusLabel}); - this.statusStrip.Location = new System.Drawing.Point(0, 179); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0); - this.statusStrip.Size = new System.Drawing.Size(726, 32); - this.statusStrip.TabIndex = 0; - this.statusStrip.Text = "statusStrip1"; - // - // statusLabel - // - this.statusLabel.Name = "statusLabel"; - this.statusLabel.Size = new System.Drawing.Size(17, 25); - this.statusLabel.Text = " "; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(8, 17); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 20); - this.label1.TabIndex = 7; - this.label1.Text = "Suche:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(8, 62); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 20); - this.label2.TabIndex = 8; - this.label2.Text = "Ersetze:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(8, 17); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(59, 20); - this.label3.TabIndex = 8; - this.label3.Text = "Suche:"; - // - // FindReplaceForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(726, 211); - this.Controls.Add(this.tabControl); - this.Controls.Add(this.statusStrip); - this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MaximumSize = new System.Drawing.Size(149999990, 267); - this.MinimumSize = new System.Drawing.Size(739, 267); - this.Name = "FindReplaceForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Suchen und Ersetzen"; - this.Activated += new System.EventHandler(this.FindReplaceForm_Activated); - this.Deactivate += new System.EventHandler(this.FindReplaceForm_Deactivate); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FindReplaceForm_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FindReplaceForm_KeyDown); - this.tabPageReplace.ResumeLayout(false); - this.tabPageReplace.PerformLayout(); - this.tabPageFind.ResumeLayout(false); - this.tabPageFind.PerformLayout(); - this.tabControl.ResumeLayout(false); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.TabPage tabPageReplace; - private System.Windows.Forms.TabPage tabPageFind; - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.TabControl tabControl; - private System.Windows.Forms.ToolStripStatusLabel statusLabel; - private System.Windows.Forms.CheckBox cbMatchCase2; - private System.Windows.Forms.Button btReplaceAll; - private System.Windows.Forms.Button btReplace; - private System.Windows.Forms.Button btFindNext2; - private System.Windows.Forms.TextBox tbReplaceWith; - private System.Windows.Forms.TextBox tbFindWhat2; - private System.Windows.Forms.Button btCount; - private System.Windows.Forms.CheckBox cbMatchCase1; - private System.Windows.Forms.Button btFindNext1; - private System.Windows.Forms.TextBox tbFindWhat1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label3; - } -} \ No newline at end of file diff --git a/pseudocodeIde/findReplace/FindReplaceForm.cs b/pseudocodeIde/findReplace/FindReplaceForm.cs deleted file mode 100644 index 27ab5aa..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.cs +++ /dev/null @@ -1,328 +0,0 @@ -using pseudocodeIde.findReplace; -using System; -using System.Diagnostics; -using System.Drawing; -using System.Windows.Forms; - -namespace pseudocodeIde -{ - public partial class FindReplaceForm : Form - { - public PseudocodeIDEForm mainForm - { - get - { - return (PseudocodeIDEForm) Owner; - } - } - - /// - /// the search term to find - /// - private string findWhat = ""; - - /// - /// the term to replace the search term with - /// - private string replaceWith = ""; - - /// - /// whether the searching should be case sensitive - /// - private bool matchCase = false; - - public FindReplaceForm(PseudocodeIDEForm mainForm) - { - Owner = mainForm; - InitializeComponent(); - - // register some event listeners - - btFindNext1.Click += (ignored1, ignored2) => this.findNextAndUpdateStatus(); - btFindNext2.Click += (ignored1, ignored2) => this.findNextAndUpdateStatus(); - - btCount.Click += (ignored1, ignored2) => this.count(); - - btReplace.Click += (ignored1, ignored2) => this.replaceNextAndUpdateStatus(); - btReplaceAll.Click += (ignored1, ignored2) => this.replaceAll(); - - tbFindWhat1.TextChanged += (ignored1, ignored2) => this.findWhat = tbFindWhat1.Text; - tbFindWhat2.TextChanged += (ignored1, ignored2) => this.findWhat = tbFindWhat2.Text; - - tbReplaceWith.TextChanged += (ignored1, ignored2) => this.replaceWith = tbReplaceWith.Text; - - cbMatchCase1.CheckedChanged += (ignored1, ignored2) => this.matchCase = cbMatchCase1.Checked; - cbMatchCase2.CheckedChanged += (ignored1, ignored2) => this.matchCase = cbMatchCase2.Checked; - } - - // --------------------------------------------- - // EVENTS - // --------------------------------------------- - - private void FindReplaceForm_FormClosing(object sender, FormClosingEventArgs e) - { - if (Visible) - { - e.Cancel = true; - Hide(); - } - } - - private void FindReplaceForm_Activated(object sender, EventArgs e) - { - this.Opacity = 1; - } - - private void FindReplaceForm_Deactivate(object sender, EventArgs e) - { - this.Opacity = 0.5; - } - - private void FindReplaceForm_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - this.findNextAndUpdateStatus(); - } - } - - private void tabControl_Selecting(object sender, TabControlCancelEventArgs e) - { - this.pageSwitch((FindReplaceTabs)e.TabPageIndex); - } - - // --------------------------------------------- - // METHODS - // --------------------------------------------- - - /// - /// Show the form. - /// - /// the tab to open - /// the initial value of the findWhat textbox - public void Show(FindReplaceTabs tab, string findWhat = "") - { - tabControl.SelectedIndex = (int)tab; - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - - Show(); - Focus(); - - this.findWhat = findWhat != null && !findWhat.Equals("") ? findWhat : this.findWhat; - - this.pageSwitch(tab); - } - - /// - /// Go to a different tab - /// - /// the tab to switch to - private void pageSwitch(FindReplaceTabs tab) - { - Debug.WriteLine(tab); - switch (tab) - { - case FindReplaceTabs.REPLACE: - tbFindWhat2.Text = this.findWhat; - cbMatchCase2.Checked = this.matchCase; - tbFindWhat2.Select(); - tbFindWhat2.SelectAll(); - break; - - case FindReplaceTabs.FIND: - default: - tbFindWhat1.Text = this.findWhat; - cbMatchCase1.Checked = this.matchCase; - tbFindWhat1.Select(); - tbFindWhat1.SelectAll(); - break; - } - } - - /// - /// Find the next occurrence and update the status bar. - /// - public void findNextAndUpdateStatus() - { - switch (this.findNext()) - { - case FindReplaceResult.WRAPPED: - statusLabel.Text = $"Suchen: Ende des Dokuments erreicht. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Green; - break; - - case FindReplaceResult.NOTHING_FOUND: - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - break; - - default: - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - break; - } - } - - /// - /// Find the next occurrence. - /// - public FindReplaceResult findNext() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - FindReplaceResult result = FindReplaceResult.NONE; - - int firstOccurence = code.IndexOf(findWhat, this.mainForm.getSelectionEnd()); - - if (firstOccurence < 0) - { - if (this.mainForm.getSelectionEnd() != 0) - { - result = FindReplaceResult.WRAPPED; - - // wrap around - this.mainForm.selectText(0, 0); - firstOccurence = code.IndexOf(findWhat, this.mainForm.getSelectionEnd()); - } - - if (firstOccurence < 0) - { - result = FindReplaceResult.NOTHING_FOUND; - return result; - } - } - - this.mainForm.selectText(firstOccurence, findWhat.Length); - return result; - } - - /// - /// Count the occurrences of a search term and update the status bar. - /// - public void count() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - - statusLabel.Text = $"Zählen: {code.allIndexesOf(findWhat).Count} Vorkommen gefunden."; - statusLabel.ForeColor = Color.Blue; - } - - /// - /// Replace the current occurrence, find the next and update the status bar. - /// If there isn't a current occurence, just find the next. - /// - public void replaceNextAndUpdateStatus() - { - switch (this.replaceNext()) - { - case FindReplaceResult.WRAPPED: - statusLabel.Text = $"Suchen: Ende des Dokuments erreicht. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Green; - break; - - case FindReplaceResult.REPLACED_WRAPPED: - statusLabel.Text = $"Ersetzen: 1 Vorkommen ersetzt. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Blue; - break; - - case FindReplaceResult.NOTHING_FOUND: - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - break; - - case FindReplaceResult.NOTHING_MORE_FOUND: - statusLabel.Text = $"Ersetzen: Letztes Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - break; - - case FindReplaceResult.REPLACED: - statusLabel.Text = $"Ersetzen: 1 Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - break; - - default: - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - break; - } - } - - /// - /// Replace the current occurrence and find the next. - /// If there isn't a current occurence, just find the next. - /// - public FindReplaceResult replaceNext() - { - // if selection doesn't match search term, find next - if ((!this.matchCase && !this.mainForm.getSelection().ToLower().Equals(this.findWhat.ToLower())) - || (this.matchCase && !this.mainForm.getSelection().Equals(this.findWhat))) - { - this.mainForm.selectText(this.mainForm.getSelectionStart(), 0); - return this.findNext(); - } - - // the selected text will be the search result, so replace it - this.mainForm.setSelectedText(this.replaceWith); - this.mainForm.updateUndoStack(true); - - // find the next result - FindReplaceResult result = this.findNext(); - - switch (result) - { - case FindReplaceResult.NOTHING_FOUND: - result = FindReplaceResult.NOTHING_MORE_FOUND; - break; - case FindReplaceResult.NONE: - result = FindReplaceResult.REPLACED; - break; - case FindReplaceResult.WRAPPED: - result = FindReplaceResult.REPLACED_WRAPPED; - break; - default: - break; - } - - return result; - } - - /// - /// Replace all occurrencea and update the status bar. - /// - public void replaceAll() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - int count = code.allIndexesOf(findWhat).Count; - - // no result found - if (count == 0) - { - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - return; - } - - // go to beginning - this.mainForm.selectText(0, 0); - - // find the first occurence - this.findNext(); - - // loop through the occurences and replace them all, the count - 1 is needed to allow undo to work correctly - this.mainForm.noNewUndoPoint = true; - for (int i = 0; i < (count - 1); i++) - { - this.replaceNext(); - } - this.mainForm.noNewUndoPoint = false; - this.replaceNext(); - - statusLabel.Text = $"Ersetzen: {count} Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - } - } -} diff --git a/pseudocodeIde/findReplace/FindReplaceForm.resx b/pseudocodeIde/findReplace/FindReplaceForm.resx deleted file mode 100644 index b6a0c12..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 133, 17 - - - 288, 17 - - \ No newline at end of file diff --git a/pseudocodeIde/findReplace/FindReplaceResult.cs b/pseudocodeIde/findReplace/FindReplaceResult.cs deleted file mode 100644 index 484ab01..0000000 --- a/pseudocodeIde/findReplace/FindReplaceResult.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace pseudocodeIde.findReplace -{ - public enum FindReplaceResult - { - NOTHING_FOUND, NOTHING_MORE_FOUND, REPLACED, WRAPPED, REPLACED_WRAPPED, NONE - } -} diff --git a/pseudocodeIde/findReplace/FindReplaceTabs.cs b/pseudocodeIde/findReplace/FindReplaceTabs.cs deleted file mode 100644 index 4573055..0000000 --- a/pseudocodeIde/findReplace/FindReplaceTabs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace pseudocodeIde.findReplace -{ - public enum FindReplaceTabs - { - FIND = 0, REPLACE = 1 - } -} diff --git a/pseudocodeIde/pseudocodeIde.csproj b/pseudocodeIde/pseudocodeIde.csproj index c56c113..224b32d 100644 --- a/pseudocodeIde/pseudocodeIde.csproj +++ b/pseudocodeIde/pseudocodeIde.csproj @@ -45,6 +45,7 @@ + @@ -67,12 +68,6 @@ - - Form - - - FindReplaceForm.cs - Form @@ -85,9 +80,6 @@ OutputForm.cs - - FindReplaceForm.cs - OutputForm.cs