/*public override string Text * { * get * { * return base.Text; * } * set * { * base.Text = value; * * if(tabPage != null) * tabPage.Text = this.Text; * } * }*/ public EditorWindow(MainForm mainForm) { //this.Text = "Untitled"; //this.WindowState = FormWindowState.Maximized; //this.ShowIcon = false; //this.ShowInTaskbar = false; //this.DockAreas = DockAreas.Document | DockAreas.Float; var cfg = Globals.LoadConfiguration(); EditorConfigurationSection section = cfg.GetEditorConfiguration(); textEditorControl = new TextEditorControl(); textEditorControl.Name = "textEditorControl"; textEditorControl.Dock = DockStyle.Fill; string fontFamily = section?.FontName?.Value ?? String.Empty; int fontSize = (int)(section?.FontSize?.Value ?? 12); textEditorControl.Font = new Font(new FontFamily(fontFamily), fontSize, FontStyle.Regular); textEditorControl.ShowEOLMarkers = section?.ShowEOLMarkers?.Value ?? false; textEditorControl.ShowHRuler = section?.ShowHRuler?.Value ?? false; textEditorControl.ShowInvalidLines = section?.ShowInvalidLines?.Value ?? false; textEditorControl.ShowLineNumbers = section?.ShowLineNumbers?.Value ?? false; textEditorControl.ShowMatchingBracket = section?.ShowMatchingBrackets?.Value ?? false; textEditorControl.ShowSpaces = section?.ShowSpaces?.Value ?? false; textEditorControl.ShowTabs = section?.ShowTabs?.Value ?? false; textEditorControl.ShowVRuler = section?.ShowVRuler?.Value ?? false; textEditorControl.EnableFolding = section?.EnableFolding?.Value ?? false; textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.SelectionChanged += new EventHandler(SelectionManager_SelectionChanged); textEditorControl.ActiveTextAreaControl.TextArea.KeyPress += new KeyPressEventHandler(TextArea_KeyPress); textEditorControl.TextChanged += new EventHandler(textEditorControl_TextChanged); textEditorControl.Show(); this.Controls.Add(textEditorControl); completionKeyHandler = CodeCompletionKeyHandler.Attach(mainForm, textEditorControl); }
public void SaveFile(string file) { var cfg = Globals.LoadConfiguration(); EditorConfigurationSection section = cfg.GetEditorConfiguration(); if (section?.TrailingWhitespace?.Value ?? false) { TrimTrailingWhitespace(); } openFile = file; saved = true; this.Text = this.Text.Replace("*", ""); this.Text = Path.GetFileName(file); textEditorControl.SaveFile(file); ILanguageStrategy lang = LanguageManager.GetLanguageStrategyForFile(file); if (lang != null) { textEditorControl.Document.FoldingManager.FoldingStrategy = lang.FoldingStrategy; textEditorControl.Document.HighlightingStrategy = lang.HighlightingStrategy; completionKeyHandler.CompletionDataProvider = lang.CompletionData; } }
public EditorTabPage() { cfg = Globals.LoadConfiguration(); EditorConfigurationSection section = cfg.GetEditorConfiguration(); string fontName = section.FontName.Value; float fontSize = section.FontSize.Value; textEditorControl = new TextEditorControl(); textEditorControl.Name = "textEditorControl"; textEditorControl.Dock = DockStyle.Fill; textEditorControl.TextChanged += new EventHandler(Handle_EditorTextChanged); textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.SelectionChanged += new EventHandler(SelectionManager_SelectionChanged); textEditorControl.AllowCaretBeyondEOL = section?.AllowCaretBeyondEOL?.Value ?? false; textEditorControl.ConvertTabsToSpaces = section?.ConvertTabsToSpaces?.Value ?? false; textEditorControl.EnableFolding = section?.EnableFolding?.Value ?? false; textEditorControl.ShowEOLMarkers = section?.ShowEOLMarkers?.Value ?? false; textEditorControl.ShowHRuler = section?.ShowHRuler?.Value ?? false; textEditorControl.ShowInvalidLines = section?.ShowInvalidLines?.Value ?? false; textEditorControl.ShowLineNumbers = section?.ShowLineNumbers?.Value ?? false; textEditorControl.ShowMatchingBracket = section?.ShowMatchingBrackets?.Value ?? false; textEditorControl.ShowSpaces = section?.ShowSpaces?.Value ?? false; textEditorControl.ShowTabs = section?.ShowTabs?.Value ?? false; textEditorControl.ShowVRuler = section?.ShowVRuler?.Value ?? false; if (!string.IsNullOrWhiteSpace(fontName) && fontSize > 0) { try { textEditorControl.Font = new Font(new FontFamily(fontName), fontSize, FontStyle.Regular); } catch (Exception ex) { textEditorControl.Font = new Font(FontFamily.GenericMonospace, 9.75f, FontStyle.Regular); string err = ex.Message; } } if (section?.HighlightCurrentLine?.Value ?? false) { textEditorControl.LineViewerStyle = LineViewerStyle.FullRow; } if (string.Compare(section?.IndentStyle?.Value, "Smart") == 0) { textEditorControl.IndentStyle = IndentStyle.Smart; } if (string.Compare(section?.IndentStyle?.Value, "Auto") == 0) { textEditorControl.IndentStyle = IndentStyle.Auto; } if (string.Compare(section?.IndentStyle?.Value, "None") == 0) { textEditorControl.IndentStyle = IndentStyle.None; } if (section.AutoInsertBrackets.Value) { textEditorControl.ActiveTextAreaControl.TextEditorProperties.AutoInsertCurlyBracket = true; } textEditorControl.Show(); this.Controls.Add(textEditorControl); }
protected override void OnClosing(CancelEventArgs e) { EditorConfigurationSection section = cfg.GetEditorConfiguration(); section.MainWindowX.Value = this.Location.X; section.MainWindowY.Value = this.Location.Y; section.MainWindowWidth.Value = this.Size.Width; section.MainWindowHeight.Value = this.Size.Height; cfg.SaveAll(); unsavedDocumentsDialog.ClearDocuments(); foreach (TabPage tb in tabControl1.TabPages) { if (tb is EditorTabPage) { EditorTabPage etb = tb as EditorTabPage; if (!etb.Saved) { unsavedDocumentsDialog.AddDocument(etb.GetFileFullPathAndName()); } } } if (unsavedDocumentsDialog.SelectedDocumentsCount > 0) { DialogResult dr = unsavedDocumentsDialog.ShowDialog(); if (dr == DialogResult.Yes) { IEnumerable <string> documents = unsavedDocumentsDialog.SelectedDocuments; foreach (string document in documents) { string file = Path.GetFileName(document); EditorTabPage etb = GetTabByTitle(file); if (etb != null) { tabControl1.SelectedTab = etb; saveToolStripMenuItem_Click(null, null); } } } else if (dr == DialogResult.Cancel) { e.Cancel = true; } } base.OnClosing(e); }
public static EditorConfigurationSection GetEditorConfiguration(this Configuration cfg) { EditorConfigurationSection section = cfg.GetSection("EditorConfiguration") as EditorConfigurationSection; if (section == null) { section = new EditorConfigurationSection(); cfg.Sections.Add("EditorConfiguration", section); } //section.SectionInformation.ForceSave = true; return(section); }
public void ReloadSettings() { EditorConfigurationSection section = cfg.GetEditorConfiguration(); string fontName = section.FontName.Value; float fontSize = section.FontSize.Value; textEditorControl.AllowCaretBeyondEOL = section.AllowCaretBeyondEOL.Value; textEditorControl.ConvertTabsToSpaces = section.ConvertTabsToSpaces.Value; textEditorControl.EnableFolding = section.EnableFolding.Value; textEditorControl.ShowEOLMarkers = section.ShowEOLMarkers.Value; textEditorControl.ShowHRuler = section.ShowHRuler.Value; textEditorControl.ShowInvalidLines = section.ShowInvalidLines.Value; textEditorControl.ShowLineNumbers = section.ShowLineNumbers.Value; textEditorControl.ShowMatchingBracket = section.ShowMatchingBrackets.Value; textEditorControl.ShowSpaces = section.ShowSpaces.Value; textEditorControl.ShowTabs = section.ShowTabs.Value; textEditorControl.ShowVRuler = section.ShowVRuler.Value; if (fontName != string.Empty && fontSize > 0) { try { textEditorControl.Font = new Font(new FontFamily(fontName), fontSize, FontStyle.Regular); } catch (Exception ex) { textEditorControl.Font = new Font(FontFamily.GenericMonospace, 9.75f, FontStyle.Regular); string err = ex.Message; } } if (section.HighlightCurrentLine.Value) { textEditorControl.LineViewerStyle = LineViewerStyle.FullRow; } if (section.IndentStyle.Value == "Smart") { textEditorControl.IndentStyle = IndentStyle.Smart; } if (section.IndentStyle.Value == "Auto") { textEditorControl.IndentStyle = IndentStyle.Auto; } if (section.IndentStyle.Value == "None") { textEditorControl.IndentStyle = IndentStyle.None; } if (section.AutoInsertBrackets.Value) { textEditorControl.ActiveTextAreaControl.TextEditorProperties.AutoInsertCurlyBracket = true; } textEditorControl.OptionsChanged(); }