Ejemplo n.º 1
0
        public EditorTabItem AddDocument(string moduleName)
        {
            EditorTabItem tabItem = new EditorTabItem(moduleName);

            tabItem.Tag = "";

            tabItem.Show(DockContainer, DockState.Document);

            tabItem.CodeEditor.LineViewerStyle = LineViewerStyle.None;

            tabItem.FormClosing += new FormClosingEventHandler(tabItem_FormClosing);

            tabItem.CodeEditor.TextChanged += new EventHandler(editorControl_TextChanged);
            tabItem.TabActivited           += new EditorTabItem.TabActivitedHandler(tabItem_Activated);
            tabItem.IsDirtyChanged         += new EventHandler(editorControl_TextChanged);

            tabItem.Activate();

            CurrentActiveTab = tabItem;

            return(tabItem);
        }
Ejemplo n.º 2
0
        public EditorTabItem OpenFile(string filename, bool ShowMessageBox)
        {
            int N = DockContainer.Documents.Length;

            for (int i = 0; i < N; i++)
            {
                EditorTabItem item = DockContainer.Documents[i] as EditorTabItem;
                if (item != null)
                {
                    if (item.FileName == filename)
                    {
                        item.Activate();
                        CurrentActiveTab = item;
                        SetAllFileNameLabel(filename);
                        return(item);
                    }
                }
            }

            if (File.Exists(filename))
            {
                try
                {
                    SyntaxMode ModuleSyntax = null;

                    foreach (string extension in Language.Extensions)
                    {
                        if (filename.ToLower().EndsWith(extension))
                        {
                            ModuleSyntax = Language;
                            break;
                        }
                    }



                    if (ModuleSyntax == null)
                    {
                        if (ShowMessageBox)
                        {
                            MessageBox.Show(Resources.Error_happened_in_opening_ + filename + ".\r\n" + Resources.File_format_is_not_supported_by_PAT_, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        return(null);
                    }

                    try
                    {
                        OpenFilter = "";

                        if (ModuleSyntax.Name == Language.Name)
                        {
                            OpenFilter = Language.Name + " (*" + Language.ExtensionString + ")|*" +
                                         Language.ExtensionString + "|" + OpenFilter;
                        }
                        else
                        {
                            OpenFilter += Language.Name + " (*" + Language.ExtensionString + ")|*" +
                                          Language.ExtensionString + "|";
                        }

                        OpenFilter += "All File (*.*)|*.*";
                    }
                    catch (Exception)
                    {
                    }


                    EditorTabItem tabItem = this.AddDocument(ModuleSyntax.Name);
                    tabItem.Open(filename);


                    SetAllFileNameLabel(filename);

                    if (tabItem.TabText.EndsWith("*"))
                    {
                        tabItem.TabText = tabItem.TabText.TrimEnd('*');
                    }

                    this.StatusLabel_Status.Text = "Ready";

                    return(tabItem);
                }
                catch (Exception ex)
                {
                    if (ShowMessageBox)
                    {
                        MessageBox.Show(Resources.Open_Error_ + ex.Message + "\r\n" + Resources.Please_make_sure_that_the_format_is_correct_, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                if (ShowMessageBox)
                {
                    MessageBox.Show(Resources.Open_Error__the_selected_file_is_not_found_, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(null);
        }