Пример #1
0
        /// <summary>
        /// Gets or creates a new document window
        /// </summary>
        /// <param name="type">Can be either a QDockWindow or a UserControl </param>
        /// <param name="key">Key should be the serialized settingslist </param>
        /// <returns></returns>
        public Form GetOrCreateDocument(Type type, string key)
        {
            DocumentsDictionary docs = _documents[type];

            if (docs.ContainsKey(key))
            {
                return(docs[key]);
            }
            else //create new
            {
                SettingsList settings = SettingsList.Deserialize(key);
                var          obj      = _container.Resolve(type);
                var          qWindow  = obj as QDockingWindow;
                if (qWindow != null)
                {
                    qWindow.FormClosed += (s, o) => docs.Remove(key);
                    docs.Add(key, qWindow);
                    qWindow.Settings = settings;
                    return(qWindow);
                }

                var control = obj as UserControl;
                if (control != null)
                {
                    qWindow             = new QViewForm(control);
                    qWindow.FormClosed += (s, o) => docs.Remove(key);
                    docs.Add(key, qWindow);
                    qWindow.Settings = settings;
                    return(qWindow);
                }
                return(null);
            }
        }
Пример #2
0
        public void CloseDocument(Type doctype, string key)
        {
            DocumentsDictionary docs = _documents[doctype];
            QDockingWindow      doc  = null;

            if (docs.TryGetValue(key, out doc))
            {
                doc.Close();
            }
        }