Пример #1
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            PluginManager.Register(null, new DefaultStyleProvider(), "Sphere Studio");
            PluginManager.Register(null, new IdeSettingsPage(), "Sphere Studio IDE");

            Form = new IdeWindow();

            // check for and open files dragged onto the app.
            foreach (var fileName in args)
            {
                if (File.Exists(fileName))
                {
                    Form.OpenFile(fileName);
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                Form.SetDefaultActive(args[args.Length - 1]);
            }

            Application.Run(Form);
        }
Пример #2
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(IdeWindow 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++);

            _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*
            }
        }