Exemplo n.º 1
0
        public Dockable(string text)
        {
            //BorderStyle = BorderStyle.None;
            //Text = text;
            //BackgroundImage = SystemIcons.Error.ToBitmap();
            //BackgroundImageLayout = ImageLayout.Stretch;
            DockControl = new DockControl(this, text)
            {
                TabText = text,
                TabIcon = System.Drawing.SystemIcons.Exclamation.ToBitmapSource()
            };

            var label = Children.Add2(new Label {
                Content = "LABEL"
            });

            DockControl.PaneChanged += (s, a) =>
            {
                var pane = DockControl.DockPane;
                if (pane == null)
                {
                    label.Content = "No Pane";
                }
                else
                {
                    label.Content = pane.LocationDesc();
                }
            };

            //Children.Add(new TextBox { Width = 140, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top });
            //Children.Add(new TextBox { Width = 140, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top });
            //Children.Add(new TextBox { Width = 140, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top });
        }
Exemplo n.º 2
0
        /// <summary>Create a new dock container</summary>
        public DockContainer()
        {
            InitializeComponent();

            Options              = new OptionsData();
            m_all_content        = new HashSet <DockControl>();
            ActiveContentManager = new ActiveContentManager(this);

            // The auto hide tab strips dock around the edge of the main dock container
            // but remain hidden unless there are auto hide panels with content.
            // The rest of the docking area is within 'centre' which contains the
            // root branch (filling the canvas) and four AutoHidePanels.

            // Add a Canvas for the centre area and add the root branch (filling the canvas)
            var centre = new Canvas {
                Name = "DockContainerCentre"
            };

            // Create the auto hide panels
            AutoHidePanels = new AutoHidePanelCollection(this, centre);

            // Create a collection for floating windows
            FloatingWindows = new FloatingWindowCollection(this);

            // Add the centre content
            Children.Add2(centre);
            Root = centre.Children.Add2(new Branch(this, DockSizeData.Quarters));
            Root.SetBinding(Branch.WidthProperty, new Binding(nameof(Canvas.ActualWidth))
            {
                Source = centre
            });
            Root.SetBinding(Branch.HeightProperty, new Binding(nameof(Canvas.ActualHeight))
            {
                Source = centre
            });

            // Ensure the default centre pane exists
            Root.PruneBranches();
            ActivePane = (DockPane?)Root.Descendants[EDockSite.Centre].Item ?? throw new ArgumentNullException("Expected a DockPane");

            // Create Commands
            CmdLoadLayout  = Command.Create(this, CmdLoadLayoutInternal);
            CmdSaveLayout  = Command.Create(this, CmdSaveLayoutInternal);
            CmdResetLayout = Command.Create(this, CmdResetLayoutInternal);
        }
Exemplo n.º 3
0
        // Notes:
        //  - An auto hide panel is a panel that pops out from the edges of the dock container.
        //  - It is basically a root branch with a single centre dock pane. The tab strip from the
        //    dock pane is used for the auto-hide tab strip displayed around the edges of the control.
        // Other behaviours:
        //  - Click pin on the pane only pins the active content
        //  - Clicking a tab makes that dockable the active content
        //  - 'Root' only uses the centre dock site

        public AutoHidePanel(DockContainer dc, EDockSite ds)
        {
            InitializeComponent();
            Visibility = Visibility.Collapsed;
            Canvas.SetZIndex(this, 1);

            DockContainer = dc;
            DockSite      = ds;
            PoppedOut     = false;

            var splitter_size = 5.0;
            var splitter      = new GridSplitter
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Background          = SystemColors.ControlBrush,
                BorderBrush         = new SolidColorBrush(Color.FromRgb(0xc0, 0xc0, 0xc0)),
                BorderThickness     = DockSite.IsVertical() ? new Thickness(1, 0, 1, 0) : new Thickness(0, 1, 0, 1),
            };

            // Create a grid to contain the root branch and the splitter
            switch (DockSite)
            {
            default: throw new Exception($"Auto hide panels cannot be docked to {ds}");

            case EDockSite.Left:
            case EDockSite.Right:
            {
                // Vertical auto hide panel
                ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(DockSite == EDockSite.Left ? 1 : 2, GridUnitType.Star), MinWidth = 10
                    });
                ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(0, GridUnitType.Auto)
                    });
                ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(DockSite == EDockSite.Right ? 1 : 2, GridUnitType.Star), MinWidth = 10
                    });

                // Add the root branch to the appropriate column
                Root = Children.Add2(new Branch(dc, DockSizeData.Quarters));
                Grid.SetColumn(Root, DockSite == EDockSite.Left ? 0 : 2);

                // Add the splitter to the centre column
                splitter.Width = splitter_size;
                Children.Add2(splitter);
                Grid.SetColumn(splitter, 1);
                break;
            }

            case EDockSite.Top:
            case EDockSite.Bottom:
            {
                // Horizontal auto hide panel
                RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(DockSite == EDockSite.Top ? 1 : 2, GridUnitType.Star), MinHeight = 10
                    });
                RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(0, GridUnitType.Auto)
                    });
                RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(DockSite == EDockSite.Bottom ? 1 : 2, GridUnitType.Star), MinHeight = 10
                    });

                // Add the root branch to the appropriate row
                Root = Children.Add2(new Branch(dc, DockSizeData.Quarters));
                Grid.SetRow(Root, DockSite == EDockSite.Top ? 0 : 2);

                // Add the splitter to the centre row
                splitter.Height = splitter_size;
                Children.Add2(splitter);
                Grid.SetRow(splitter, 1);
                break;
            }
            }

            // Remove the tab strip from the dock pane child so we can use
            // it as the auto hide tab strip for this auto hide panel
            TabStrip = DockPane.TabStrip;
            TabStrip.Detach();
            TabStrip.AHPanel = this;
        }