private EditorTabItem CreateNewTab(string filePath) { EditorTabItem tab = NewTab(filePath); InsertTab(tab); return(tab); }
public EditorTabItem CreateEmtyTab() { IsLoadingEmptyTab = true; EditorTabItem tab = NewTab(null); TabPanels.Add(tab); return(tab); }
private void OnFailedToFindEditorControl(object sender, FailedToFindEditorControlArg arg) { if (TabPanels.Count > 1) { EditorTabItem tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel == arg.EditorViewModel); TabPanels.Remove(tab); base.OnPropertyChanged(nameof(TabPanels)); } }
private void AdjustTabOrder(EditorTabItem tab) { if (IsSorted()) { return; } TabPanels.Remove(tab); InsertTab(tab); }
public static CodeCompletionKeyHandler Attach(EditorTabItem mainForm, TextEditorControl editor) { CodeCompletionKeyHandler h = new CodeCompletionKeyHandler(mainForm, editor); editor.ActiveTextAreaControl.TextArea.KeyEventHandler += h.TextAreaKeyEventHandler; // When the editor is disposed, close the code completion window editor.Disposed += h.CloseCodeCompletionWindow; return(h); }
public static CodeCompletionKeyHandler Attach(EditorTabItem mainForm, TextEditorControl editor) { CodeCompletionKeyHandler h = new CodeCompletionKeyHandler(mainForm, editor); editor.ActiveTextAreaControl.TextArea.KeyEventHandler += h.TextAreaKeyEventHandler; // When the editor is disposed, close the code completion window editor.Disposed += h.CloseCodeCompletionWindow; return h; }
private void InsertTab(EditorTabItem tab) { string fileName = tab.FileName; int i = 0; while (i < TabPanels.Count && Compare(fileName, TabPanels[i].FileName) > 0) { i++; } TabPanels.Insert(i, tab); }
/// <summary> /// The function used to convert from PN to KWSN /// </summary> /// <param name="topology">input PN file</param> /// public KWSNGenerationHelper(string name, EditorTabItem tabItem) : base(name, tabItem) { mPNDoc = new XmlDocument(); try { mPNDoc.Load(tabItem.FileName); mLoaded = true; } catch { DevLog.e(TAG, String.Format("Error when load PN file ({0})", name)); MessageBox.Show("Error when reading PN file!"); } }
/// <summary> /// Open a file or reload the file if it has been opened. /// </summary> /// <param name="filePath">file to be opened or reloaded</param> public void OpenFileByReloading(string filePath) { EditorTabItem tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.CurrentFilePath == filePath); if (tab != null) { tab.EditorTabContentViewModel.Load(filePath); OpeningTabEvent?.Invoke(tab); } else { FilesToLoad.Add(filePath); LoadNextFile(); } }
/// <summary> /// The function used to convert from PN to KWSN /// </summary> /// <param name="topology">input PN file</param> /// public KWSNGenerationHelper(string name, EditorTabItem tabItem) : base(name, tabItem) { mPNDoc = new XmlDocument(); try { mPNDoc.Load(tabItem.FileName); mLoaded = true; } catch { DevLog.e(TAG, String.Format("Error when load PN file ({0})", name)); MessageBox.Show("Error when reading PN file!"); } }
public PNGenerationHelper(string name, EditorTabItem tabItem) : base(name, tabItem) { try { WSNTabItem wsnTabItem = (WSNTabItem)tabItem; mCanvas = wsnTabItem.getAllCanvas(); mDocPNRes = wsnTabItem.PNRes; // Get extend information mExtendInfo = wsnTabItem.mExtendInfo; initXML(); mLoaded = true; } catch (Exception ex) { DevLog.d(TAG, "Can not read wsn document"); } }
public PNGenerationHelper(string name, EditorTabItem tabItem) : base(name, tabItem) { try { WSNTabItem wsnTabItem = (WSNTabItem)tabItem; mCanvas = wsnTabItem.getAllCanvas(); mDocPNRes = wsnTabItem.PNRes; // Get extend information mExtendInfo = wsnTabItem.mExtendInfo; initXML(); mLoaded = true; } catch (Exception ex) { DevLog.d(TAG, "Can not read wsn document"); } }
public static void Register(EditorTabItem mainForm) { // Must be implemented. Gets the project content of the active project. HostCallback.GetCurrentProjectContent = delegate { return(mainForm.myProjectContent); }; // The default implementation just logs to Log4Net. We want to display a MessageBox. // Note that we use += here - in this case, we want to keep the default Log4Net implementation. HostCallback.ShowError += delegate(string message, Exception ex) { MessageBox.Show(message + Environment.NewLine + ex.ToString()); }; HostCallback.ShowMessage += delegate(string message) { MessageBox.Show(message); }; HostCallback.ShowAssemblyLoadError += delegate(string fileName, string include, string message) { MessageBox.Show("Error loading code-completion information for " + include + " from " + fileName + ":\r\n" + message + "\r\n"); }; }
public static void Register(EditorTabItem mainForm) { // Must be implemented. Gets the project content of the active project. HostCallback.GetCurrentProjectContent = delegate { return mainForm.myProjectContent; }; // The default implementation just logs to Log4Net. We want to display a MessageBox. // Note that we use += here - in this case, we want to keep the default Log4Net implementation. HostCallback.ShowError += delegate(string message, Exception ex) { MessageBox.Show(message + Environment.NewLine + ex.ToString()); }; HostCallback.ShowMessage += delegate(string message) { MessageBox.Show(message); }; HostCallback.ShowAssemblyLoadError += delegate(string fileName, string include, string message) { MessageBox.Show("Error loading code-completion information for " + include + " from " + fileName + ":\r\n" + message + "\r\n"); }; }
private void OnDeleteEditorTab(object sender, DeleteEditorTabRequestedArg arg) { EditorTabContentViewModel editorViewModel = arg.EditorViewModel; MessageBoxResult result = GherkinSettings.SaveCurrentFileWithRequesting(editorViewModel); if (result == MessageBoxResult.Cancel) { return; } EventAggregator <EditorClosedArg> .Instance.Publish(this, new EditorClosedArg(editorViewModel.CurrentFilePath)); if (TabPanels.Count == 1) { CurrentEditor?.ChangeToEmptyFile(); NotifyCurrentFilePathChanged(); base.OnPropertyChanged(nameof(IsShowScenarioIndexEnabled)); } else { EditorTabItem editorTab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel == editorViewModel); int index = TabPanels.IndexOf(editorTab); bool isDeletingCurrentTab = (index == SelectedTabIndex); if (isDeletingCurrentTab) { // Force select a tab before removing tab. // Note: property changed notification would not be raised if index is same as SelectedTabIndex. // Therefore we select another tab at first and then select agian the indexed tab if index == SelectedTabIndex int other_index = (index + 1) % TabPanels.Count; SelectedTabIndex = other_index; } TabPanels.Remove(editorTab); if (isDeletingCurrentTab) { SelectedTabIndex = Math.Min(index, TabPanels.Count - 1); } } }
/// <summary> /// Open an editor tab. /// </summary> /// <param name="filePath"></param> /// <returns>true: new tab created</returns> public Tuple <bool, EditorTabItem> OpenEditorTab(string filePath) { bool isNewTab = false; EditorTabItem tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.CurrentFilePath == filePath); if (tab == null) { tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.IsEmptyFile()); if (tab != null) { tab.EditorTabContentViewModel.Load(filePath); AdjustTabOrder(tab); } else { isNewTab = true; tab = CreateNewTab(filePath); } } OpeningTabEvent?.Invoke(tab); m_AppSettings.LastUsedFile = filePath; return(Tuple.Create(isNewTab, tab)); }
public CodeCompletionProvider(EditorTabItem mainForm, string key) { this.mainForm = mainForm; preSelection = key; }
internal NewCodeEditorEventArgs(ref EditorTabItem tabItem) { _EditorTabItem = tabItem; }
public GenerationHelper(String name, EditorTabItem tabItem) { mFileName = name; mTabItem = tabItem; mLoaded = false; }
public static void Attach(EditorTabItem mainForm, TextEditor.TextEditorControl editor) { ToolTipProvider tp = new ToolTipProvider(mainForm, editor); editor.ActiveTextAreaControl.TextArea.ToolTipRequest += tp.OnToolTipRequest; }
private ToolTipProvider(EditorTabItem mainForm, TextEditor.TextEditorControl editor) { this.mainForm = mainForm; this.editor = editor; }
public SpecificationBase ParseSpecificationAfterCluster(bool showVerbolMsg, EditorTabItem currentPNItem) { if (currentPNItem == null || currentPNItem.Text.Trim() == "") { if (showVerbolMsg) MessageBox.Show(Resources.Please_input_a_model_first_, Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } DisableAllControls(); SpecificationBase spec = null; try { //clear the error list if (!ErrorListWindow.IsDisposed) ErrorListWindow.Clear(); string moduleName = currentPNItem.ModuleName; if (LoadModule(moduleName)) { string option = GetOption(); Stopwatch t = new Stopwatch(); t.Start(); spec = CurrentModule.ParseSpecification(currentPNItem.Text, option, currentPNItem.FileName); t.Stop(); if (spec != null) { currentPNItem.Specification = spec; if (spec.Errors.Count > 0) { string key = ""; foreach (KeyValuePair<string, ParsingException> pair in spec.Errors) { key = pair.Key; break; } ParsingException parsingException = spec.Errors[key]; spec.Errors.Remove(key); throw parsingException; } if (showVerbolMsg) { this.StatusLabel_Status.Text = Resources.Grammar_Checked; MenuButton_OutputPanel.Checked = true; Output_Window.TextBox.Text = string.Format(Resources.Specification_is_parsed_in__0_s, t.Elapsed.TotalSeconds) + "\r\n" + spec.GetSpecification() + "\r\n" + Output_Window.TextBox.Text; Output_Window.Show(DockContainer); if (spec.Warnings.Count > 0) { this.MenuButton_ErrorList.Checked = true; ErrorListWindow.AddWarnings(spec.Warnings); ShowErrorMessage(); } } //Open the translation result .csp file if (CurrentModule.ModuleName == "MDL Model") { ShowModel(spec.InputModelText, "CSP Model"); CurrentModule.ParseSpecification(spec.InputModelText, option, currentPNItem.FileName); } if (ModelExplorerWindow != null) { ModelExplorerWindow.DisplayTree(spec); if (ModelExplorerWindow.VisibleState == DockState.DockRightAutoHide) { DockContainer.ActiveAutoHideContent = ModelExplorerWindow; } } EnableAllControls(); return spec; } else { EnableAllControls(); return null; } } } catch (ParsingException ex) { EnableAllControls(); if (showVerbolMsg) { if (spec != null) { ErrorListWindow.AddWarnings(spec.Warnings); ErrorListWindow.AddErrors(spec.Errors); } CurrentEditorTabItem.HandleParsingException(ex); ErrorListWindow.InsertError(ex); MenuButton_ErrorList.Checked = true; if (ex.Line > 0) { MessageBox.Show(Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile: " + ex.DisplayFileName + (string.IsNullOrEmpty(ex.NodeName) ? "" : ", Node: " + ex.NodeName) + "\n" + ex.Message, Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile: " + ex.DisplayFileName + (string.IsNullOrEmpty(ex.NodeName) ? "" : ", Node: " + ex.NodeName) + "\n" + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace + } else { MessageBox.Show(Resources.Parsing_error__ + ex.Message, Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace + } ShowErrorMessage(); } } catch (Exception ex) { EnableAllControls(); if (showVerbolMsg) { #if (DEBUG) MessageBox.Show(Resources.Parsing_error__ + ex.Message, Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\n" + ex.StackTrace + "\r\n\r\n" + this.Output_Window.TextBox.Text; #else MessageBox.Show("Unknow Parsing Error!", Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = "Unknow Parsing Error!\r\n\r\n" + this.Output_Window.TextBox.Text; #endif } } return null; }
public SpecificationBase onParseSpecificationAfterCluster(EditorTabItem currentPNItem) { return ParseSpecificationAfterCluster(true, currentPNItem); }
private void tabItem_Activated(EditorTabItem tab) { CurrentActiveTab = tab; foreach (var item in MenuButton_Window.DropDownItems) { if (item is ToolStripMenuItem) (item as ToolStripMenuItem).Checked = false; } tab.WindowMenuItem.Checked = true; LoadModule(tab.ModuleName); if (ModelExplorerWindow != null) { if (ModelExplorerWindow.Specification != tab.Specification) ModelExplorerWindow.DisplayTree(tab.Specification); } }
private void OnOpeningTab(EditorTabItem tab) { SelectTab(tab); NotifyCurrentFilePathChanged(); }
public CodeCompletionProvider(EditorTabItem mainForm, string key) { this.mainForm = mainForm; preSelection = key; }
private void SelectTab(EditorTabItem tab) { int index = TabPanels.IndexOf(tab); this.SelectedTabIndex = Math.Max(0, index); }
public GenerationHelper(String name, EditorTabItem tabItem) { mFileName = name; mTabItem = tabItem; mLoaded = false; }
public CodeCompletionProviderDot(EditorTabItem mainForm) { this.mainForm = mainForm; }
internal NewCodeEditorEventArgs(ref EditorTabItem tabItem) { _EditorTabItem = tabItem; }
private CodeCompletionKeyHandler(EditorTabItem mainForm, TextEditorControl editor) : base(SupportedLanguage.CSharp) { this.mainForm = mainForm; this.editor = editor; }
private ToolTipProvider(EditorTabItem mainForm, TextEditor.TextEditorControl editor) { this.mainForm = mainForm; this.editor = editor; }
public CodeCompletionProviderDot(EditorTabItem mainForm) { this.mainForm = mainForm; }
public static void Attach(EditorTabItem mainForm, TextEditor.TextEditorControl editor) { ToolTipProvider tp = new ToolTipProvider(mainForm, editor); editor.ActiveTextAreaControl.TextArea.ToolTipRequest += tp.OnToolTipRequest; }
private CodeCompletionKeyHandler(EditorTabItem mainForm, TextEditorControl editor) : base(SupportedLanguage.CSharp) { this.mainForm = mainForm; this.editor = editor; }
public EditorTabItem AddDocument(string moduleName) { bool registerMouseEvent = DockContainer.Panes.Count == 0; EditorTabItem tabItem; do { if (moduleName == "PN Model") { tabItem = new PNTabItem(moduleName); break; } if (moduleName == "KWSN Model") { tabItem = new WSNTabItem(moduleName, "KWSN", this); break; } tabItem = new EditorTabItem(moduleName); } while (false); tabItem.Tag = ""; tabItem.Show(DockContainer, DockState.Document); tabItem.CodeEditor.LineViewerStyle = (MenuButton_HignlightCurrentLine.Checked) ? LineViewerStyle.FullRow : LineViewerStyle.None; tabItem.FormClosing += new FormClosingEventHandler(tabItem_FormClosing); if (NewCodeEditor != null) NewCodeEditor(this, new NewCodeEditorEventArgs(ref tabItem)); tabItem.CodeEditor.TextChanged += new EventHandler(editorControl_TextChanged); tabItem.CodeEditor.KeyUp += new KeyEventHandler(editorControl_KeyUp); tabItem.CodeEditor.ActiveTextAreaControl.TextArea.DragDrop += new DragEventHandler(CodeEditor_DragDrop); tabItem.TabActivited += new EditorTabItem.TabActivitedHandler(tabItem_Activated); tabItem.CodeEditor.ActiveTextAreaControl.Caret.CaretModeChanged += new EventHandler(CaretModeChanged); tabItem.CodeEditor.ActiveTextAreaControl.Enter += new EventHandler(Caret_Change); tabItem.CodeEditor.ActiveTextAreaControl.Caret.PositionChanged += Caret_Change; tabItem.IsDirtyChanged += new EventHandler(editorControl_TextChanged); tabItem.FindUsages += new EditorTabItem.FindUsagesHandler(tabItem_FindUsages); tabItem.GoToDeclarition += new EditorTabItem.GoToDeclaritionHandler(OpenException); MenuButton_Window.DropDownItems.Add(tabItem.WindowMenuItem); tabItem.WindowMenuItem.Click += new EventHandler(WindowMenuItem_Click); tabItem.Activate(); CurrentActiveTab = tabItem; if (registerMouseEvent) DockContainer.Panes[0].TabStripControl.MouseDown += new MouseEventHandler(FormMain_MouseDown); return tabItem; }
/// <summary> /// Creates a MethodInsightDataProvider looking at the caret position. /// </summary> public MethodInsightDataProvider(EditorTabItem form) { this.lookupOffset = -1; this.mainForm = form; }
/// <summary> /// Creates a MethodInsightDataProvider looking at the caret position. /// </summary> public MethodInsightDataProvider(EditorTabItem form) { this.lookupOffset = -1; this.mainForm = form; }