Beispiel #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);
            }
        }
Beispiel #2
0
        public IDockContent GetContentFromPersistString(string persistString)
        {
            string[] items = persistString.Split('$');
            if (items.Length != 2)
            {
                return(null);
            }

            string typeName = items[0];

            Type type = null;

            if (!_typenames.TryGetValue(typeName, out type))
            {
                try
                {
                    type = Type.GetType(typeName);
                }
                catch { }
            }
            if (type == null)
            {
                return(null);
            }
            string       doc_key  = items[1];
            SettingsList settings = SettingsList.Deserialize(doc_key);

            if (_documents.ContainsKey(type))
            {
                return(GetOrCreateDocument(type, doc_key) as QDockingWindow);
            }
            else
            {
                var window = _windows[type] as QDockingWindow;
                window.Settings = settings;

                return(window);
            }
        }