Inheritance: System.Windows.Forms.UserControl
Example #1
0
        /// <summary>
        /// Creates a new Sphere Studio document tab.
        /// </summary>
        /// <param name="ide">The IDE form that the tab will be created in.</param>
        /// <param name="view">The IDocumentView the tab is hosting.</param>
        /// <param name="fileName">The fully-qualified filename of the document, or null if untitled.</param>
        /// <param name="restoreView">'true' to restore the last saved view state. Has no effect on untitled tabs.</param>
        public DocumentTab(MainWindow ide, DocumentView view, string fileName = null, bool restoreView = false)
        {
            FileName = fileName;
            View = view;

            View.Dock = DockStyle.Fill;
            
            _tabText = fileName != null ? Path.GetFileName(fileName)
                : string.Format("Untitled{0}", _unsavedID++);
            _ide = ide;
            _content = new DockContent();
            _content.FormClosing += on_FormClosing;
            _content.FormClosed += on_FormClosed;
            _content.Tag = this;
            _content.Icon = View.Icon;
            _content.TabText = _tabText;
            _content.ToolTipText = FileName;
            _content.Controls.Add(View);
            _content.Show(ide.MainDock, DockState.Document);
            View.DirtyChanged += on_DirtyChanged;

            UpdateTabText();

            if (View is ScriptView)
            {
                ScriptView scriptView = View as ScriptView;
                scriptView.Breakpoints = Core.Project.GetBreakpoints(FileName);
                scriptView.BreakpointChanged += on_BreakpointSet;
            }

            if (restoreView && FileName != null)
            {
                string setting = string.Format("viewState:{0:X8}", FileName.GetHashCode());
                try { View.ViewState = Core.Project.User.GetString(setting, ""); }
                catch (Exception) { } // *munch*
            }
        }
Example #2
0
 internal DocumentTab AddDocument(DocumentView view, string filepath = null, bool restoreView = false)
 {
     DocumentTab tab = new DocumentTab(this, view, filepath, restoreView);
     tab.Closed += (sender, e) => _tabs.Remove(tab);
     tab.Activate();
     _tabs.Add(tab);
     return tab;
 }