Esempio n. 1
0
        public MainWindow(Type[] documentTypes, Type[] panelTypes)
        {
            DocumentManager.Init(documentTypes);

            skinService = new SkinService();
            Reflect.Invoke(skinService, "Initialize", null);
            string skinPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

            if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Dark)
            {
                skinPath = System.IO.Path.Combine(skinPath, "Resources/Dark.skn");
                skinService.OpenAndApplySkin(skinPath);
            }
            else if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Medium)
            {
                skinPath = System.IO.Path.Combine(skinPath, "Resources/Light.skn"); //Typically darker than Light
                skinService.OpenAndApplySkin(skinPath);
            }
            else if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Night)
            {
                skinPath = System.IO.Path.Combine(skinPath, "Resources/Night.skn");
                skinService.OpenAndApplySkin(skinPath);
            }
            else
            {
                // Using default native UI widget styles
            }

            inst_ = this;
            this.UseWaitCursor = false;
            InitializeComponent();
            Load += MainWindow_Load;

            FormClosing += MainWindow_FormClosing;

            dockPanel.ActiveDocumentChanged += dockPanel_ActiveDocumentChanged;
            dockPanel.SuspendLayout(true);

            string layoutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            layoutPath = System.IO.Path.Combine(layoutPath, Assembly.GetEntryAssembly().GetName().Name);
            layoutPath = System.IO.Path.Combine(layoutPath, "layout.xml");
            if (System.IO.File.Exists(layoutPath) && !CoreSettings.Value.DoNotSaveLayout)
            {
                dockPanel.LoadFromXml(layoutPath, StringToDockContent);
            }
            else // First launch
            {
                foreach (Type t in panelTypes)
                {
                    if (typeof(Controls.PanelDockContent).IsAssignableFrom(t))
                    {
                        Controls.PanelDockContent pnl = Activator.CreateInstance(t) as Controls.PanelDockContent;
                        if (pnl != null)
                        {
                            PanelUtil.Show(pnl, dockPanel);
                        }
                    }
                }
                BuildUI();
            }

            BuildMenus(documentTypes);
            BuildToolbars();

            // Insert system UI menu "Windows"
            menuStrip1.Items.Add(new Menu.PanelMenuStripItem());

            dockPanel.ResumeLayout(true, true);

            SkinService.ApplyActiveSkin(this);
        }