コード例 #1
0
        private EditorTabItem CreateNewTab(string filePath)
        {
            EditorTabItem tab = NewTab(filePath);

            InsertTab(tab);
            return(tab);
        }
コード例 #2
0
        public EditorTabItem CreateEmtyTab()
        {
            IsLoadingEmptyTab = true;
            EditorTabItem tab = NewTab(null);

            TabPanels.Add(tab);
            return(tab);
        }
コード例 #3
0
 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));
     }
 }
コード例 #4
0
        private void AdjustTabOrder(EditorTabItem tab)
        {
            if (IsSorted())
            {
                return;
            }

            TabPanels.Remove(tab);
            InsertTab(tab);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 /// <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!");
     }
 }
コード例 #9
0
        /// <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();
            }
        }
コード例 #10
0
 /// <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!");
     }
 }
コード例 #11
0
        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");
            }
        }
コード例 #12
0
ファイル: PNGenerationHelper.cs プロジェクト: nhannhan159/PAT
        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");
            }
        }
コード例 #13
0
        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");
            };
        }
コード例 #14
0
        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");
            };
        }
コード例 #15
0
        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);
                }
            }
        }
コード例 #16
0
        /// <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));
        }
コード例 #17
0
 public CodeCompletionProvider(EditorTabItem mainForm, string key)
 {
     this.mainForm = mainForm;
     preSelection = key;
 }
コード例 #18
0
 internal NewCodeEditorEventArgs(ref EditorTabItem tabItem)
 {
     _EditorTabItem = tabItem;
 }
コード例 #19
0
ファイル: GenerationHelper.cs プロジェクト: nhannhan159/PAT
 public GenerationHelper(String name, EditorTabItem tabItem)
 {
     mFileName = name;
     mTabItem = tabItem;
     mLoaded = false;
 }
コード例 #20
0
        public static void Attach(EditorTabItem mainForm, TextEditor.TextEditorControl editor)
        {
            ToolTipProvider tp = new ToolTipProvider(mainForm, editor);

            editor.ActiveTextAreaControl.TextArea.ToolTipRequest += tp.OnToolTipRequest;
        }
コード例 #21
0
 private ToolTipProvider(EditorTabItem mainForm, TextEditor.TextEditorControl editor)
 {
     this.mainForm = mainForm;
     this.editor   = editor;
 }
コード例 #22
0
ファイル: FormMain.cs プロジェクト: nhannhan159/PAT
        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;
        }
コード例 #23
0
ファイル: FormMain.cs プロジェクト: nhannhan159/PAT
 public SpecificationBase onParseSpecificationAfterCluster(EditorTabItem currentPNItem)
 {
     return ParseSpecificationAfterCluster(true, currentPNItem);
 }
コード例 #24
0
ファイル: FormMain.cs プロジェクト: nhannhan159/PAT
        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);
            }
        }
コード例 #25
0
 private void OnOpeningTab(EditorTabItem tab)
 {
     SelectTab(tab);
     NotifyCurrentFilePathChanged();
 }
コード例 #26
0
 public CodeCompletionProvider(EditorTabItem mainForm, string key)
 {
     this.mainForm = mainForm;
     preSelection  = key;
 }
コード例 #27
0
        private void SelectTab(EditorTabItem tab)
        {
            int index = TabPanels.IndexOf(tab);

            this.SelectedTabIndex = Math.Max(0, index);
        }
コード例 #28
0
ファイル: GenerationHelper.cs プロジェクト: MinhHuong/WSN-PN
 public GenerationHelper(String name, EditorTabItem tabItem)
 {
     mFileName = name;
     mTabItem  = tabItem;
     mLoaded   = false;
 }
コード例 #29
0
 public CodeCompletionProviderDot(EditorTabItem mainForm)
 {
     this.mainForm = mainForm;
 }
コード例 #30
0
 internal NewCodeEditorEventArgs(ref EditorTabItem tabItem)
 {
     _EditorTabItem = tabItem;
 }
コード例 #31
0
 private CodeCompletionKeyHandler(EditorTabItem mainForm, TextEditorControl editor)
     : base(SupportedLanguage.CSharp)
 {
     this.mainForm = mainForm;
     this.editor   = editor;
 }
コード例 #32
0
ファイル: ToolTipProvider.cs プロジェクト: nhannhan159/PAT
 private ToolTipProvider(EditorTabItem mainForm, TextEditor.TextEditorControl editor)
 {
     this.mainForm = mainForm;
     this.editor = editor;
 }
コード例 #33
0
 public CodeCompletionProviderDot(EditorTabItem mainForm)
 {
     this.mainForm = mainForm;
 }
コード例 #34
0
ファイル: ToolTipProvider.cs プロジェクト: nhannhan159/PAT
 public static void Attach(EditorTabItem mainForm, TextEditor.TextEditorControl editor)
 {
     ToolTipProvider tp = new ToolTipProvider(mainForm, editor);
     editor.ActiveTextAreaControl.TextArea.ToolTipRequest += tp.OnToolTipRequest;
 }
コード例 #35
0
 private CodeCompletionKeyHandler(EditorTabItem mainForm, TextEditorControl editor)
     : base(SupportedLanguage.CSharp)
 {
     this.mainForm = mainForm;
     this.editor = editor;
 }
コード例 #36
0
ファイル: FormMain.cs プロジェクト: nhannhan159/PAT
        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;
        }
コード例 #37
0
 /// <summary>
 /// Creates a MethodInsightDataProvider looking at the caret position.
 /// </summary>
 public MethodInsightDataProvider(EditorTabItem form)
 {
     this.lookupOffset = -1;
     this.mainForm = form;
 }
コード例 #38
0
 /// <summary>
 /// Creates a MethodInsightDataProvider looking at the caret position.
 /// </summary>
 public MethodInsightDataProvider(EditorTabItem form)
 {
     this.lookupOffset = -1;
     this.mainForm     = form;
 }