Ejemplo n.º 1
0
        object Resolve(Type type)
        {
            try
            {
                // Check in settings
                if (typeof(SettingsObject).IsAssignableFrom(type))
                {
                    return(SettingsManager.GetInst().GetSettingsObject(type));
                }

                // Check in the UIRegistry
                //if (typeof(System.Windows.Forms.Control).IsAssignableFrom(type))
                //{
                //    object o = UIRegistry.GetInst().GetSingle(type);
                //    if (o != null)
                //        return o;
                //}

                // Check in the DocumentManager?
                if (typeof(IDocument).IsAssignableFrom(type))
                {
                    if (firstAttempt_)
                    {
                        DocumentManager.GetInst().DocumentChanged += Required_DocumentChanged;
                    }
                    if (DocumentManager.GetInst().ActiveDocument != null && type.IsAssignableFrom(DocumentManager.GetInst().ActiveDocument.GetType()))
                    {
                        return(DocumentManager.GetInst().ActiveDocument);
                    }
                }
                failed_ = true;
                return(null);
            }
            finally
            {
                firstAttempt_ = false;
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public static void Init(params Type[] types)
 {
     inst_       = new DocumentManager();
     inst_.meta_ = new Documents.DocumentMetaCollection(types);
 }