private void CreateEditor(string domainName) { if (Database.ProjectEditors.Any(pe => pe.Project == Project && pe.Editor == domainName)) { MessageBox.Show("The editor is already on the project. Try again", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EditorTextBox.Focus(); CreateButton.Enabled = false; return; } var editor = new ProjectEditor { Project = Project, Editor = domainName, }; Database.ProjectEditors.InsertOnSubmit(editor); if (!SubmitChanges()) { Database.ProjectEditors.DeleteOnSubmit(editor); EditorTextBox.Focus(); CreateButton.Enabled = false; return; } OnDatabaseChanged(); Close(); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.richTextBoxCtrl = new PacktPub.VSPackageSample.EditorTextBox(); this.SuspendLayout(); // // richTextBoxCtrl // this.richTextBoxCtrl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBoxCtrl.Location = new System.Drawing.Point(0, 0); this.richTextBoxCtrl.Name = "richTextBoxCtrl"; this.richTextBoxCtrl.Size = new System.Drawing.Size(150, 150); this.richTextBoxCtrl.TabIndex = 0; this.richTextBoxCtrl.MouseEnter += new System.EventHandler(this.richTextBoxCtrl_MouseEnter); this.richTextBoxCtrl.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.richTextBoxCtrl_KeyPress); this.richTextBoxCtrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.richTextBoxCtrl_KeyDown); // // MyEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.richTextBoxCtrl); this.Name = "MyEditor"; this.ResumeLayout(false); }
private void NewToolStripMenuItem_Click(object sender, EventArgs e) { if (textChanged) { DialogResult result; result = MessageBox.Show( "Czy chcesz zapisać zmiany", "Edytor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { SaveToolStripMenuItem_Click(sender, e); textChanged = false; EditorTextBox.Clear(); } if (result == DialogResult.No) { EditorTextBox.Clear(); textChanged = false; } } else { EditorTextBox.Clear(); } }
/// <summary>Save file method</summary> /// <param name="strFileName">string - file name</param> private void SaveDocument(string strFileName) { this.Text = "Simple Text Editor" + strFileName; EditorTextBox.Select(0, 0); FileStream fileStream = null; try { fileStream = new FileStream(strFileName, FileMode.Create, FileAccess.Write); Byte[] dataByte; dataByte = new Byte[EditorTextBox.Text.Length]; dataByte.Initialize(); dataByte = m_Encoder.GetBytes(EditorTextBox.Text.ToString()); fileStream.Write(dataByte, 0, dataByte.Length); } catch (Exception ex) { MessageBox.Show(this, "Error :" + ex, "Simple Text Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } finally { if (fileStream != null) { fileStream.Close(); } } this.Text = "Simple Text Editor" + strFileName; return; }
/// <summary>Copy menu implementation</summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void mnuCopy_Click(object sender, EventArgs e) { if (EditorTextBox.SelectedText != "") { EditorTextBox.Copy(); } }
private void UIWindow_Initialized(object sender, EventArgs e) { if (Properties.Settings.Default.LastEdit == "") { EditorTextBox.AppendText("MOV 1 R1\nMOV 1 R2\n:LOOP\nMOV R1 R3\nADD R2 R3\nPRT R3\nMOV R2 R1\nMOV R3 R2\nLES R3 255\n+JMP LOOP\n-JMP END\n:END"); } else { EditorTextBox.AppendText(Properties.Settings.Default.LastEdit); } PixelGridUI.GridSize = Properties.Settings.Default.GridSize; EditorTextBox.ShowLineNumbers = true; using (Stream s = new MemoryStream(Properties.Resources.SyntaxRules)) { using (XmlTextReader reader = new XmlTextReader(s)) { EditorTextBox.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance); LineHighlighter = new LineHighlightRenderer(); EditorTextBox.TextArea.TextView.BackgroundRenderers.Add(LineHighlighter); } } Iterator.DoWork += IteratorWait; Iterator.RunWorkerCompleted += IteratorDone; GetInput.DoWork += GetInputWait; GetInput.RunWorkerCompleted += GetInputDone; RunFull.DoWork += RunFullWait; RunFull.RunWorkerCompleted += RunFullDone; RunFullUpdate.DoWork += RunFullUpdateWait; RunFullUpdate.RunWorkerCompleted += RunFullUpdateDone; PixelGrid.DoWork += PixelGridWait; }
/// <summary> /// Initializes a new Text Editor window and registers it to the specified parent element. /// You can leave the parent null and use the parent element's register method if you prefer. /// </summary> public TextEditor(HudParentBase parent = null) : base(parent) { textBox = new EditorTextBox(body) { ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV, DimAlignment = DimAlignments.Width }; toolBar = new EditorToolBar(header) { DimAlignment = DimAlignments.Width, ParentAlignment = ParentAlignments.Bottom, Format = textBox.text.Format, BulderMode = textBox.text.BuilderMode, }; toolBar.FormatChanged += ChangeFormat; toolBar.BuildModeChanged += ChangeBuilderMode; // Window styling: BodyColor = new Color(41, 54, 62, 150); BorderColor = new Color(58, 68, 77); header.Format = new GlyphFormat(GlyphFormat.Blueish.Color, TextAlignment.Center, 1.08f); header.Height = 30f; HeaderText = "Example Text Editor"; Size = new Vector2(500f, 300f); }
private void CreateAssistant(string domainName) { if (Database.ProjectInvestigatorAssistants.Any(a => a.ProjectInvestigator1 == Investigator && a.Assistant == domainName)) { MessageBox.Show("The assistant is already helping the investigator. Try again", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EditorTextBox.Focus(); CreateButton.Enabled = false; return; } var assistant = new ProjectInvestigatorAssistant { ProjectInvestigator1 = Investigator, Assistant = domainName, }; Database.ProjectInvestigatorAssistants.InsertOnSubmit(assistant); if (!SubmitChanges()) { Database.ProjectInvestigatorAssistants.DeleteOnSubmit(assistant); EditorTextBox.Focus(); CreateButton.Enabled = false; return; } OnDatabaseChanged(); Close(); }
public void Setup() { // We'll just reset all keys to their default (non-pressed) state in case // a test forgot to do so... _keyboard.Reset(); _textBox = new EditorTextBox(); }
public void Setup() { _control = new EditableTextBlock { Style = StyleHelper.Load <EditableTextBlock>() }; _control.ApplyTemplate(); var type = typeof(EditableTextBlock); _textBox = (EditorTextBox)type.GetField("_textBox", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_control); _presenter = (MarkdownPresenter)type.GetField("_presenter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_control); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.elementHost1 = new System.Windows.Forms.Integration.ElementHost(); this.objectBuilderControl1 = new CogaenEditorControls.GUI_Elements.ObjectBuilderControl(); this.richTextBoxCtrl = new CogaenEditExtension.EditorTextBox(); this.SuspendLayout(); // // elementHost1 // this.elementHost1.AllowDrop = true; this.elementHost1.Dock = System.Windows.Forms.DockStyle.Fill; this.elementHost1.Location = new System.Drawing.Point(0, 0); this.elementHost1.Name = "elementHost1"; this.elementHost1.Size = new System.Drawing.Size(500, 500); this.elementHost1.TabIndex = 0; this.elementHost1.Text = "elementHost1"; this.elementHost1.Child = this.objectBuilderControl1; //// //// richTextBoxCtrl //// //this.richTextBoxCtrl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) // | System.Windows.Forms.AnchorStyles.Left) // | System.Windows.Forms.AnchorStyles.Right))); //this.richTextBoxCtrl.FilterMouseClickMessages = false; //this.richTextBoxCtrl.Location = new System.Drawing.Point(0, 0); //this.richTextBoxCtrl.Name = "richTextBoxCtrl"; //this.richTextBoxCtrl.Size = new System.Drawing.Size(150, 150); //this.richTextBoxCtrl.TabIndex = 0; //this.richTextBoxCtrl.Text = ""; //this.richTextBoxCtrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.richTextBoxCtrl_KeyDown); //this.richTextBoxCtrl.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.richTextBoxCtrl_KeyPress); //this.richTextBoxCtrl.MouseEnter += new System.EventHandler(this.richTextBoxCtrl_MouseEnter); // // MyEditor // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange; this.Controls.Add(this.elementHost1); this.Name = "MyEditor"; this.Size = new System.Drawing.Size(500, 500); this.ResumeLayout(false); }
public void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult saveAsResult = SaveFileDialog1.ShowDialog(); if (saveAsResult == DialogResult.OK && SaveFileDialog1.FilterIndex == 2) { EditorTextBox.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.RichText); FileName1 = SaveFileDialog1.FileName; textChanged = false; EditorTextBox.ClearUndo(); } else if (saveAsResult == DialogResult.OK && SaveFileDialog1.FilterIndex == 1) { EditorTextBox.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText); FileName1 = SaveFileDialog1.FileName; textChanged = false; EditorTextBox.ClearUndo(); } }
// ReSharper restore UnusedAutoPropertyAccessor.Local private void FindButton_Click(object sender, EventArgs e) { #if NO_ACTIVE_DIRECTORY MessageBox.Show("Active Directory Search Disabled.", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information); #else var context = new PrincipalContext(ContextType.Domain, "nps", "OU=AKR,DC=nps,DC=doi,DC=net"); string search = EditorTextBox.Text + "*"; var principal = new UserPrincipal(context) { Surname = search, Enabled = true }; var searcher = new PrincipalSearcher { QueryFilter = principal }; var query = from Principal p in searcher.FindAll() orderby p.DisplayName select new EditorListItem { DisplayName = p.Name + " (" + p.Description + ") - NPS\\" + p.SamAccountName, DomainName = "NPS\\" + p.SamAccountName, }; ResultsListBox.DisplayMember = "DisplayName"; var data = query.ToList(); ResultsListBox.DataSource = data; EnableControls(); //If the Datasource is empty, then SelectedIndexChanged is not called. if (data.Count > 0) { ResultsListBox.Focus(); } else { MessageBox.Show("Nobody found with that name.", "Try again", MessageBoxButtons.OK, MessageBoxIcon.Information); EditorTextBox.Focus(); } #endif }
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { if (FileName1 == " ") { DialogResult saveResult = SaveFileDialog1.ShowDialog(); if (saveResult == DialogResult.OK && SaveFileDialog1.FilterIndex == 2) { EditorTextBox.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.RichText); textChanged = false; FileName1 = SaveFileDialog1.FileName; EditorTextBox.ClearUndo(); } else if (saveResult == DialogResult.OK && SaveFileDialog1.FilterIndex == 1) { EditorTextBox.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText); textChanged = false; FileName1 = SaveFileDialog1.FileName; EditorTextBox.ClearUndo(); } } else { if (FileName1 == "*.rtf") { EditorTextBox.SaveFile(FileName1, RichTextBoxStreamType.RichText); textChanged = false; EditorTextBox.ClearUndo(); } if (FileName1 == "*.txt") { EditorTextBox.SaveFile(FileName1, RichTextBoxStreamType.PlainText); textChanged = false; EditorTextBox.ClearUndo(); } } }
private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { EditorTextBox.Copy(); }
/// <summary>Paste menu implementation</summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void mnuPaste_Click(object sender, EventArgs e) { EditorTextBox.Paste(); }
/// <summary>Select all menu implementation</summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void mnuSelectAll_Click(object sender, EventArgs e) { EditorTextBox.SelectAll(); }
/// <summary>Open menu implementation</summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void mnuOpen_Click(object sender, EventArgs e) { string strFileName = ""; string strTemp = ""; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { //If the document is not saved then prompt the user to save if (m_IsContentModified && ( m_Features.CheckStatus(LicenseFeatures.Save.ToString()) || m_Features.CheckStatus(LicenseFeatures.SaveAs.ToString()))) { switch (MessageBox.Show(this, "The document is not saved. Do you wish to save now ?", "Simple Text Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation)) { case DialogResult.Yes: if (!SaveFile()) { return; } EditorTextBox.Text = ""; this.Text = "Simple Text Editor"; break; case DialogResult.No: EditorTextBox.Text = ""; this.Text = "Simple Text Editor"; break; case DialogResult.Cancel: return; } } strFileName = openFileDialog.FileName; m_DocumentName = strFileName; } else { return; } //Read the file FileStream fileStream = null; string strFileContents = ""; try { strTemp = ""; int iRetval = 1; fileStream = new FileStream(strFileName, FileMode.Open, FileAccess.Read); Byte[] dataByte = new Byte[1024]; dataByte.Initialize(); for (; iRetval != 0;) { dataByte.Initialize(); strTemp = ""; iRetval = fileStream.Read(dataByte, 0, 1024); strTemp = m_Encoder.GetString(dataByte, 0, 1024); strFileContents += strTemp; } } catch (FileNotFoundException) { MessageBox.Show(this, "File not found or permission denied", "Simple Text Editor", MessageBoxButtons.OK); return; } catch (Exception ex) { MessageBox.Show(this, "Error : " + ex.ToString(), "Simple Text Editor", MessageBoxButtons.OK); return; } finally { if (fileStream != null) { fileStream.Close(); } } strTemp = strFileName.ToLower(); EditorTextBox.Text = strFileContents; this.Text = "Simple Text Editor" + strFileName; EditorTextBox.Select(0, 0); m_IsContentModified = false; }
private void OpenToolStripMenuItem_Click(object sender, EventArgs e) { if (textChanged) { DialogResult result; result = MessageBox.Show( "Czy chcesz zapisać zmiany", "Edytor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { SaveToolStripMenuItem_Click(sender, e); DialogResult openFileResult = OpenFileDialog1.ShowDialog(); if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 2) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.RichText); FileName1 = OpenFileDialog1.FileName; textChanged = false; EditorTextBox.ClearUndo(); } else if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 1) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText); textChanged = false; FileName1 = OpenFileDialog1.FileName; EditorTextBox.ClearUndo(); } } if (result == DialogResult.No) { DialogResult openFileResult = OpenFileDialog1.ShowDialog(); if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 2) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.RichText); textChanged = false; FileName1 = OpenFileDialog1.FileName; EditorTextBox.ClearUndo(); } else if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 1) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText); textChanged = false; FileName1 = OpenFileDialog1.FileName; EditorTextBox.ClearUndo(); } } } else { DialogResult openFileResult = OpenFileDialog1.ShowDialog(); if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 2) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.RichText); FileName1 = OpenFileDialog1.FileName; textChanged = false; EditorTextBox.ClearUndo(); } else if (openFileResult == DialogResult.OK && OpenFileDialog1.FilterIndex == 1) { EditorTextBox.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText); FileName1 = OpenFileDialog1.FileName; textChanged = false; EditorTextBox.ClearUndo(); } } }
private void SelectAllToolStripMenuItem_Click(object sender, EventArgs e) { EditorTextBox.SelectAll(); }
private void toolUnderline_Click(object sender, EventArgs e) { if (EditorTextBox.SelectionFont != null) { if (EditorTextBox.SelectionFont.Underline) { EditorTextBox.SelectionFont = new Font(EditorTextBox.SelectionFont, EditorTextBox.SelectionFont.Style & ~FontStyle.Underline); toolUnderline.Checked = false; } else { EditorTextBox.SelectionFont = new Font(EditorTextBox.SelectionFont, EditorTextBox.SelectionFont.Style | FontStyle.Underline); toolUnderline.Checked = true; } } else { int selectionStart = EditorTextBox.SelectionStart; int selectionLength = EditorTextBox.SelectionLength; int selectionEnd = selectionStart + EditorTextBox.SelectionLength; int j = 0; while (true) { int i = 0; int sectionSelectionStart = selectionStart + j; if (sectionSelectionStart < selectionEnd) { while (true) { EditorTextBox.Select(sectionSelectionStart, i); if (EditorTextBox.SelectionFont != null) { if (selectionEnd > sectionSelectionStart + i) { i++; } else { EditorTextBox.SelectionFont = new Font(EditorTextBox.SelectionFont, EditorTextBox.SelectionFont.Style | FontStyle.Underline); j += i; break; } } if (EditorTextBox.SelectionFont == null) { i--; EditorTextBox.Select(sectionSelectionStart, i); EditorTextBox.SelectionFont = new Font(EditorTextBox.SelectionFont, EditorTextBox.SelectionFont.Style | FontStyle.Underline); j += i; EditorTextBox.Select(selectionStart, selectionLength); break; } } } else { EditorTextBox.Select(selectionStart, selectionLength); break; } } } }
private void UndoToolStripMenuItem_Click(object sender, EventArgs e) { EditorTextBox.Undo(); }
private void PasteToolStripMenuItem_Click(object sender, EventArgs e) { EditorTextBox.Paste(); }