private void ShowManager()
        {
            var control = new AutoNumberCategoryManager(User, AutoNumberCategory);
            var form    = new ControlHostWindow(User, control, SizeToContent.WidthAndHeight);

            form.Owner = this.FindParentWindow();
            form.Title = "Auto Number Generation Categories";
            form.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            if (form.ShowDialog().ValueOrFalse())
            {
                LoadModel();
            }
        }
Esempio n. 2
0
        protected ControlHostWindow ShowSingleton(string title, Func <Control> controlFactoryFunction, SizeToContent sizeMode = SizeToContent.Manual, bool autoSavePosition = true, Action <ControlHostWindow> initFunc = null)
        {
            ControlHostWindow frm = null;

            lock (_controlHosts) {
                if (_controlHosts.ContainsKey(title))
                {
                    frm = _controlHosts[title];
                }
                else
                {
                    var control = controlFactoryFunction();
                    if (control != null)
                    {
                        frm = PluginManager.Instance.AddNonDockableContent(this, control, title, sizeMode, autoSavePosition, initFunc);
                        _controlHosts[title] = frm;
                        frm.Closed          += new EventHandler((sender, e) => {
                            frm = null;
                            lock (_controlHosts) {
                                _controlHosts.Remove(title);
                            }
                        });

                        if (control is ILazyPopulateControl)
                        {
                            var lazyLoadee = control as ILazyPopulateControl;
                            lazyLoadee.Populate();
                        }
                    }
                }
            }

            if (frm != null)
            {
                frm.Show();
                frm.Focus();
            }

            return(frm);
        }
        public ControlHostWindow AddNonDockableContent(IBioLinkPlugin plugin, Control content, string title, SizeToContent sizeToContent, bool autoSavePosition = true, Action <ControlHostWindow> initFunc = null)
        {
            // First check to see if this content is already being shown...
            if (content is IIdentifiableContent)
            {
                var window = GetWindowForContent(content as IIdentifiableContent);
                if (window != null)
                {
                    var existing = window.Control as IIdentifiableContent;
                    window.Show();
                    if (window.WindowState == WindowState.Minimized)
                    {
                        window.WindowState = WindowState.Normal;
                    }
                    window.Focus();
                    existing.RefreshContent();
                    return(window);
                }
            }

            bool hideButtons       = !(content is DatabaseCommandControl);
            ControlHostWindow form = new ControlHostWindow(User, content, sizeToContent, hideButtons);

            form.Owner         = ParentWindow;
            form.Title         = title;
            form.Name          = "HostFor_" + content.GetType().Name;
            form.SizeToContent = sizeToContent;

            if (content is DatabaseCommandControl)
            {
                var dbcontrol = content as DatabaseCommandControl;
                dbcontrol.NotifyChangeContainerSet();
            }

            if (content is IIconHolder)
            {
                var icon = (content as IIconHolder).Icon;
                if (icon != null)
                {
                    form.Icon = icon;
                }
            }

            if (content is IPreferredSizeHolder)
            {
                var psh = content as IPreferredSizeHolder;
                form.Height = psh.PreferredHeight;
                form.Width  = psh.PreferredWidth;
            }

            if (autoSavePosition)
            {
                Config.RestoreWindowPosition(User, form);

                form.Closing += new System.ComponentModel.CancelEventHandler((source, e) => {
                    Config.SaveWindowPosition(User, form);
                });
            }

            if (initFunc != null)
            {
                initFunc(form);
            }

            form.Closed += new EventHandler((source, e) => {
                _hostWindows.Remove(form);
                form.Dispose();
            });

            _hostWindows.Add(form);
            form.Show();
            return(form);
        }