public void SetUnmodified() { if (m_Modified) { m_Modified = false; if (Text.EndsWith("*")) { Text = Text.Substring(0, Text.Length - 1); } if (string.IsNullOrEmpty(TabText)) { TabText = Text; } if (TabText.EndsWith("*")) { TabText = TabText.Substring(0, TabText.Length - 1); } if (FloatPane != null) { FloatPane.Text = TabText; FloatPane.FloatWindow.Text = TabText; } if (Core != null) { Core.MainForm.UpdateUndoSettings(); } } }
private void DocumentForm_FormClosing(object sender, FormClosingEventArgs e) { if (Scintilla.Modified) { // Prompt if not saved string message = String.Format( CultureInfo.CurrentCulture, "The data in the {0} file has changed.{1}{2}Do you want to save the changes?", TabText.TrimEnd(' ', '*'), Environment.NewLine, Environment.NewLine); DialogResult dr = MessageBox.Show(this, message, Program.Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (dr == DialogResult.Cancel) { // Stop closing e.Cancel = true; return; } else if (dr == DialogResult.Yes) { // Try to save before closing e.Cancel = !Save(); return; } } // Close as normal }
void DocumentFormLoad(object sender, EventArgs e) { ToolTipText = _filePath ?? TabText; SetLanguage(); scintilla.NativeInterface.SendMessageDirect(2516, true); SetMarginAuto(); scintilla.LineWrapping.Mode = Settings.Current.lineWrapping ? ScintillaNET.LineWrappingMode.Word : ScintillaNET.LineWrappingMode.None; scintilla.Whitespace.Mode = Settings.Current.showWhiteSpaces ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible; scintilla.EndOfLine.IsVisible = Settings.Current.showEndOfLineChars; if (Settings.Current.lfPath == null || !File.Exists(Settings.Current.lfPath)) { return; } if (TabText.TrimEnd(' ', '*').EndsWith(".dat")) { try { if (ParseFiles(Path.GetDirectoryName(Settings.Current.lfPath))) { ParseFrames(); } } catch (Exception ex) { mainForm.formEventLog.Error(ex, "Parsing Error"); } } }
protected void SetDirty() { if (!TabText.EndsWith("*")) { TabText = TabText + "*"; } RaiseIsDirtyChanged(); }
private void OnUnSavedChanges(object sender, bool unsavedChanges) { if (TabText == null) { return; } TabText = unsavedChanges ? TabText.TrimEnd('*') + '*' : TabText.TrimEnd('*'); }
public bool SaveAs() { string tabText = TabText.TrimEnd(' ', '*'); if (!string.IsNullOrEmpty(_filePath)) { saveFileDialog.FileName = Path.GetFileName(_filePath); saveFileDialog.InitialDirectory = Path.GetDirectoryName(_filePath); } else { saveFileDialog.FileName = tabText; } switch (Path.GetExtension(tabText)) { case ".dat": saveFileDialog.FilterIndex = 2; break; case ".txt": saveFileDialog.FilterIndex = 3; break; case ".as": saveFileDialog.FilterIndex = 4; break; case ".xml": saveFileDialog.FilterIndex = 5; break; case ".html": case ".htm": saveFileDialog.FilterIndex = 6; break; case ".cs": saveFileDialog.FilterIndex = 7; break; default: saveFileDialog.FilterIndex = 1; break; } if (saveFileDialog.ShowDialog() == DialogResult.OK) { ToolTipText = _filePath = saveFileDialog.FileName; TabText = Path.GetFileName(_filePath); SetLanguage(); return(Save(_filePath)); } return(false); }
private void OnDocumentChanged() { if (_textChanged && !TabText.EndsWith("*")) { m_fileName += "*"; TabText += "*"; Text += "*"; EventHandler <EventArgs> handler = DocumentChanged; if (handler != null) { // raises the event. handler(this, new EventArgs()); } } }
private void AddOrRemoveAsteric() { if (Scintilla.Modified) { if (!TabText.EndsWith(" *")) { TabText += " *"; } } else { if (TabText.EndsWith(" *")) { TabText = TabText.Substring(0, TabText.Length - 2); } } }
public void SetModified() { if (InvokeRequired) { Invoke(new C64Studio.MainForm.ParameterLessCallback(SetModified)); return; } if (!m_Modified) { m_Modified = true; if (!Text.EndsWith("*")) { Text += "*"; } if (string.IsNullOrEmpty(TabText)) { if (DocumentFilename != null) { TabText = System.IO.Path.GetFileName(DocumentFilename); } else { TabText = Text; } } if (!TabText.EndsWith("*")) { TabText += "*"; } if (FloatPane != null) { FloatPane.Text = TabText; FloatPane.FloatWindow.Text = TabText; } if (Core != null) { Core.MainForm.UpdateUndoSettings(); } DocumentInfo.HasBeenSuccessfullyBuilt = false; FileParsed = false; } }
protected void OnDirtyChanged(object sender, EventArgs e) { if (IsDirty) { if (TabText.IndexOf("*") < 0) { TabText = TabText + "*"; } } else { TabText = _solution.SolutionName; } if (DirtyChanged != null) { DirtyChanged(sender, e); } }
public static Control CreateChildControl(TabInstance parentTabInstance, object obj, string label = null, ITabSelector tabControl = null) { object value = obj.GetInnerValue(); if (value == null || value is bool) { return(null); } if (label == null) { // use object? or inner value? label = obj.Formatted(); if (label.IsNullOrEmpty()) { label = "(" + obj.GetType().Name + ")"; } } TabBookmark tabBookmark = null; // Also assigned to child TabView's, tabView.tabInstance.tabBookmark = tabBookmark; if (parentTabInstance.TabBookmark != null && parentTabInstance.TabBookmark.ChildBookmarks != null) { if (parentTabInstance.TabBookmark.ChildBookmarks.TryGetValue(label, out tabBookmark)) { // FindMatches only if (tabBookmark.TabModel != null) { value = tabBookmark.TabModel; } } } string labelOverride = null; if (value is Exception) { } else if (parentTabInstance is ITabCreator parentTabCreator) { value = parentTabCreator.CreateControl(value, out labelOverride); } else if (tabControl is ITabCreator tabCreator) { value = tabCreator.CreateControl(value, out labelOverride); } if (value == null) { return(null); } if (labelOverride != null) { label = labelOverride; } Type type = value.GetType(); if (value is string || value is decimal || type.IsPrimitive) { value = new TabText(value.ToString()); // create an ITab } /*else if (value is Uri uri) * { * var tabWebBrowser = new TabWebBrowser(uri); * value = tabWebBrowser; * }*/ if (value is ILoadAsync loadAsync) { var childTabInstance = new TabInstanceLoadAsync(loadAsync) { Project = parentTabInstance.Project, TabBookmark = tabBookmark, }; childTabInstance.Model.Name = label; value = new TabView(childTabInstance); } if (value is ITabCreatorAsync creatorAsync) { //value = new TabCreatorAsync(creatorAsync); // todo: move elsewhere, we shouldn't be blocking during creation value = Task.Run(() => creatorAsync.CreateAsync(new Call())).GetAwaiter().GetResult(); } if (value is ITab iTab) { // Custom controls implement ITab TabInstance childTabInstance = parentTabInstance.CreateChildTab(iTab); if (childTabInstance == null) { return(null); } childTabInstance.TabBookmark ??= tabBookmark; //childTabInstance.Reintialize(); // todo: fix, called in TabView childTabInstance.Model.Name = label; var tabView = new TabView(childTabInstance); tabView.Load(); return(tabView); } else if (value is TabView tabView) { tabView.Instance.ParentTabInstance = parentTabInstance; tabView.Instance.TabBookmark = tabBookmark ?? tabView.Instance.TabBookmark; tabView.Label = label; tabView.Load(); return(tabView); } else if (value is Control control) { return(control); } /*else if (value is FilePath filePath) * { * var tabAvalonEdit = new TabAvalonEdit(name); * tabAvalonEdit.Load(filePath.path); * return tabAvalonEdit; * }*/ else { if (value is Enum && parentTabInstance.Model.Object.GetType().IsEnum) { return(null); } TabModel childTabModel; if (value is TabModel tabModel) { childTabModel = tabModel; childTabModel.Name = label; } else { childTabModel = TabModel.Create(label, value); if (childTabModel == null) { return(null); } } childTabModel.Editing = parentTabInstance.Model.Editing; TabInstance childTabInstance = parentTabInstance.CreateChild(childTabModel); childTabInstance.Label = label; var tabModelView = new TabView(childTabInstance); tabModelView.Load(); return(tabModelView); } }
protected override string GetPersistString() { string retval = string.Empty; try { retval = GetType().ToString() + "," + m_fileName.Replace("*", "") + "," + TabText.Replace("*", ""); } catch { } return(retval); }
public Instance(TabText tab) { Tab = tab; }
public void SetLanguage(string language) { language = language.ToLowerInvariant(); { this.Scintilla.Snippets.List.Clear(); this.Scintilla.AutoComplete.List.Clear(); this.Scintilla.ConfigurationManager.Language = "default"; documentType = DocumentType.Default; switch (language) { case "dat": Scintilla.Indentation.UseTabs = false; if (Scintilla.Text.Contains("<stage>")) { Scintilla.Indentation.TabWidth = 8; this.Scintilla.ConfigurationManager.Language = "stage_dat"; documentType = DocumentType.StageData; } else if (Scintilla.Text.Contains("zboundary:")) { Scintilla.Indentation.TabWidth = 2; this.Scintilla.ConfigurationManager.Language = "bg_dat"; documentType = DocumentType.BgData; } else { Scintilla.Indentation.TabWidth = 3; this.Scintilla.ConfigurationManager.Language = "object_dat"; documentType = DocumentType.ObjectData; } Scintilla.EndOfLine.Mode = EndOfLineMode.LF; this.Icon = Properties.Resources.DocumentDAT; auto = true; smart = true; break; case "default": goto default; case "txt": if (TabText.TrimEnd(' ', '*') != "data.txt") { goto default; } Scintilla.Indentation.UseTabs = false; Scintilla.Indentation.TabWidth = 4; Scintilla.EndOfLine.Mode = EndOfLineMode.Crlf; this.Icon = Properties.Resources.DocumentDAT; auto = true; smart = true; this.Scintilla.ConfigurationManager.Language = "data_txt"; documentType = DocumentType.DataTxt; break; case "as": Scintilla.Indentation.UseTabs = true; Scintilla.Indentation.TabWidth = 4; Scintilla.EndOfLine.Mode = EndOfLineMode.Crlf; this.Icon = Properties.Resources.DocumentAS; auto = false; smart = true; this.Scintilla.ConfigurationManager.Language = language; documentType = DocumentType.AngelScript; break; case "cs": Scintilla.Indentation.UseTabs = true; Scintilla.Indentation.TabWidth = 4; Scintilla.EndOfLine.Mode = EndOfLineMode.Crlf; this.Icon = Properties.Resources.DocumentCS; auto = false; smart = true; this.Scintilla.ConfigurationManager.Language = language; documentType = DocumentType.CSharp; break; case "html": case "xml": Scintilla.Indentation.UseTabs = false; Scintilla.Indentation.TabWidth = 2; Scintilla.EndOfLine.Mode = EndOfLineMode.Crlf; this.Icon = Properties.Resources.DocumentXML; auto = false; smart = true; this.Scintilla.ConfigurationManager.Language = language; documentType = DocumentType.XML; break; default: Scintilla.Indentation.UseTabs = true; Scintilla.Indentation.TabWidth = 4; Scintilla.EndOfLine.Mode = EndOfLineMode.Crlf; this.Icon = Properties.Resources.Document; documentType = DocumentType.Default; auto = false; smart = false; break; } Scintilla.AutoComplete.List.Sort(); } }
public void SetLanguage() { SetLanguageByExtension(Path.GetExtension(TabText.TrimEnd('*', ' '))); }