Exemple #1
0
        /// <summary>
        /// Shows the content.
        /// </summary>
        /// <param name="vc">The vc.</param>
        /// <param name="region">The region.</param>
        public void ShowContent(IViewContent vc, ViewRegion region)
        {
            TabManager tm = ServiceManager.Instance.GetService<TabManager>();

            DockContent content = new DockContent();
            content.TabText = vc.Title;
            content.Text = vc.Title;
            content.ToolTipText = vc.Title;
            content.CloseButton = vc.CanClose;

            switch (region)
            {
                case ViewRegion.Bottom:
                    content.DockAreas = DockAreas.DockBottom;
                    break;
                case ViewRegion.Top:
                    content.DockAreas = DockAreas.DockTop;
                    break;
                case ViewRegion.Left:
                    content.DockAreas = DockAreas.DockLeft;
                    break;
                case ViewRegion.Right:
                    content.DockAreas = DockAreas.DockRight;
                    break;
                case ViewRegion.Document:
                    content.DockAreas = DockAreas.Document;
                    break;
                case ViewRegion.Floating:
                    content.DockAreas = DockAreas.Float;
                    break;
            }

            vc.TitleChanged += delegate(object sender, EventArgs e)
            {
                content.TabText = vc.Title;
                content.Text = vc.Title;
                content.ToolTipText = vc.Title;
            };

            vc.ViewContentClosing += delegate(object sender, EventArgs e)
            {
                if(vc.CanClose)
                    content.Close();
            };

            content.ClientSize = vc.ContentControl.Size;
            content.CloseButton = vc.CanClose;

            vc.ContentControl.Dock = DockStyle.Fill;
            content.Controls.Add(vc.ContentControl);

            if (vc is IConnectionDependentView)
            {
                tm.Register((IConnectionDependentView)vc);
            }

            if (region == ViewRegion.Dialog)
            {   
                content.StartPosition = FormStartPosition.CenterParent;
                content.ShowDialog();
            }
            else
            {
                content.Show(contentPanel);
            }
        }
Exemple #2
0
        /// <summary>
        /// Shows the content.
        /// </summary>
        /// <param name="vc">The vc.</param>
        internal void ShowContent(IViewContent vc)
        {
            DockContent content = new DockContent();
            content.TabText = vc.Title;
            content.Text = vc.Title;
            content.ToolTipText = vc.Description;
            content.CloseButton = vc.AllowUserClose;
            content.CloseButtonVisible = vc.AllowUserClose;
            content.Tag = vc;
            var icon = vc.ViewIcon;
            if (icon != null)
            {
                content.Icon = icon;
                content.ShowIcon = true;
            }

            if (vc.IsExclusiveToDocumentRegion)
            {
                content.DockAreas = DockAreas.Document;
            }
            else
            {
                content.DockAreas = (DockAreas)(vc.DefaultRegion);
            }
            vc.SetParentForm(content);
            vc.ViewContentActivating += (sender, e) =>
            {
                content.Activate();
            };
            vc.TitleChanged += (sender, e) =>
            {
                content.TabText = vc.Title;
                content.Text = vc.Title;
            };
            vc.DescriptionChanged += (sender, e) =>
            {
                content.ToolTipText = vc.Description;
            };
            if (vc.AllowUserClose && vc.IsExclusiveToDocumentRegion)
                content.TabPageContextMenuStrip = documentTabContextMenu;

            content.ClientSize = vc.ContentControl.Size;
            vc.ContentControl.Dock = DockStyle.Fill;
            content.Controls.Add(vc.ContentControl);

            if (vc.IsModalWindow && vc.DefaultRegion == ViewRegion.Floating)
            {
                content.StartPosition = FormStartPosition.CenterParent;
                content.ShowDialog();
            }
            else
            {
                content.Show(contentPanel);
            }
        }