Exemple #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);
            }
        }
Exemple #2
0
        public void ShowUserControl(UserControl control)
        {
            var window = new QViewForm(control);

            window.Show();
        }