Example #1
0
 protected virtual void AddTabButton(Button button, IDockableControl tab)
 {
     ButtonsPanel.Children.Add(button);
     button.HorizontalContentAlignment = DockSide == PanelDockSide.Right
                                          ? HorizontalAlignment.Right
                                          : HorizontalAlignment.Left;
     _tabButtons.Add(new TabButton(tab, button));
 }
Example #2
0
 public virtual void AddTab(IDockableControl tab)
 {
     _tabs.Add(tab);
     var btn = new Button { Content = tab.ContainerPanel.Caption };
     AddTabButton(btn, tab);
     tab.ContainerPanel.DockStatusChanged += OnContainerPanelOnDockStatusChanged;
     ResolveTabs();
 }
 public override void init(IDockableControl parent, Size size, object back)
 {
     base.init(parent, size, back);
     this.btnViewCastle.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnViewCastle.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnViewCastle.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnViewCastle.setSizeToImage();
     this.btnViewCastle.Position = new Point(base.btnForward.Position.X, (base.btnUtility.Position.Y - this.btnViewCastle.Height) - 2);
     this.btnViewCastle.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnViewCastle.TextYOffset = -2;
     this.btnViewCastle.Text.Color = ARGBColors.Black;
     this.btnViewCastle.Enabled = true;
     this.btnViewCastle.Visible = false;
     this.btnViewCastle.Text.Text = SK.Text("Reports_View_Castle", "View Castle");
     this.btnViewCastle.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.viewCastleClick), "Reports_View_Castle");
     base.btnUtility.Text.Text = SK.Text("Reports_Show_On_Map", "Show On Map");
     this.lblResult.Color = ARGBColors.Black;
     this.lblResult.Font = FontManager.GetFont("Arial", 14f, FontStyle.Regular);
     this.lblResult.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblResult.Position = new Point(20, base.lblSecondaryText.Rectangle.Bottom);
     this.lblResult.Size = new Size(base.Width - 40, 0x1a);
     base.lblDate.Y = this.lblResult.Rectangle.Bottom;
     this.lblScouts.Text = SK.Text("GENERIC_Scouts", "Scouts");
     this.lblScouts.Color = ARGBColors.Black;
     this.lblScouts.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblScouts.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblScouts.Position = new Point(base.borderOffset, base.lblDate.Rectangle.Bottom + 5);
     this.lblScouts.Size = new Size(base.Width - (base.borderOffset * 2), 0x1a);
     this.lblScouts.Visible = false;
     this.lblWolves.Color = ARGBColors.Black;
     this.lblWolves.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblWolves.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblWolves.Position = new Point(base.borderOffset, this.lblScouts.Y + 30);
     this.lblWolves.Size = new Size(base.Width - (base.borderOffset * 2), 0x1a);
     this.lblWolves.Visible = false;
     this.lblHonour.Color = ARGBColors.Black;
     this.lblHonour.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblHonour.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblHonour.Position = new Point(base.borderOffset, base.btnDelete.Y);
     this.lblHonour.Size = new Size(base.Width - (base.borderOffset * 2), 0x1a);
     this.lblHonour.Visible = false;
     if (base.imgBackground.Image != null)
     {
         base.imgBackground.addControl(this.lblScouts);
         base.imgBackground.addControl(this.lblResult);
         base.imgBackground.addControl(this.btnViewCastle);
         base.imgBackground.addControl(this.lblHonour);
         base.imgBackground.addControl(this.lblWolves);
     }
     else
     {
         base.addControl(this.lblScouts);
         base.addControl(this.lblResult);
         base.addControl(this.btnViewCastle);
         base.addControl(this.lblHonour);
         base.addControl(this.lblWolves);
     }
 }
 public override void init(IDockableControl parent, Size size, object back)
 {
     base.init(parent, size, back);
     this.valuesPanel = new ReportBattleValuesPanel(this, new Size((base.btnClose.X - base.btnForward.Rectangle.Right) - 4, 200));
     this.valuesPanel.Position = new Point(base.btnForward.Rectangle.Right + 2, base.Height - this.valuesPanel.Height);
     string header = SK.Text("GENERIC_Reinforcements", "Reinforcements");
     this.valuesPanel.init(header, false, true);
     if (base.imgBackground.Image != null)
     {
         base.imgBackground.addControl(this.valuesPanel);
     }
     else
     {
         base.addControl(this.valuesPanel);
     }
 }
Example #5
0
 public TabButton(IDockableControl dockableControl, Button button)
 {
     DockableControl = dockableControl;
     Button = button;
 }
Example #6
0
        protected virtual void ResolveTabs()
        {
            if (_tabs.Count < 1)
                return;
            _resolvingTabs = true;

            for (var i = _tabs.Count-1; i >= 0; i--)
            {
                if (_tabs[i].Visibility != Visibility.Visible)
                    continue;
                if (FilledPanel != null)
                    _tabs[i].Visibility = Visibility.Collapsed;
                if (_tabs[i].ContainerPanel.DockStatus == PanelDockStatus.Fill)
                    FilledPanel = _tabs[i];
                else if (_tabs[i].ContainerPanel.DockStatus == PanelDockStatus.Top)
                {
                    if (TopPanel == null)
                        TopPanel = _tabs[i];
                    else if (BottomPanel == null)
                    {
                        _tabs[i].ContainerPanel.DockStatus = PanelDockStatus.Bottom;
                        BottomPanel = _tabs[i];
                    }
                    else
                        _tabs[i].Visibility = Visibility.Collapsed;
                }
                else if (_tabs[i].ContainerPanel.DockStatus == PanelDockStatus.Bottom)
                {
                    if (BottomPanel == null)
                        BottomPanel = _tabs[i];
                    else if (TopPanel == null)
                    {
                        _tabs[i].ContainerPanel.DockStatus = PanelDockStatus.Top;
                        TopPanel = _tabs[i];
                    }
                    else
                    {
                        _tabs[i].ContainerPanel.Visibility = Visibility.Collapsed;
                    }

                }
            }
            _resolvingTabs = false;
        }
 public override void init(IDockableControl parent, Size size, object back)
 {
     base.init(parent, size, back);
     this.btnViewBattle.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnViewBattle.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnViewBattle.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnViewBattle.setSizeToImage();
     this.btnViewBattle.Position = new Point((base.Width / 2) - (this.btnViewBattle.Width / 2), base.btnClose.Y);
     this.btnViewBattle.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnViewBattle.TextYOffset = -2;
     this.btnViewBattle.Text.Color = ARGBColors.Black;
     this.btnViewBattle.Enabled = true;
     this.btnViewBattle.Visible = true;
     this.btnViewBattle.Text.Text = SK.Text("Reports_View_Battle", "View Battle");
     this.btnViewBattle.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.viewBattleClick), "Reports_View_Battle");
     this.btnViewResult.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnViewResult.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnViewResult.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnViewResult.setSizeToImage();
     this.btnViewResult.Position = new Point((base.Width / 2) - (this.btnViewResult.Width / 2), base.btnDelete.Y);
     this.btnViewResult.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnViewResult.TextYOffset = -2;
     this.btnViewResult.Text.Color = ARGBColors.Black;
     this.btnViewResult.Enabled = true;
     this.btnViewResult.Visible = true;
     this.btnViewResult.Text.Text = SK.Text("Reports_View_Reports", "View Result");
     this.btnViewResult.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.viewResultClick), "Reports_View_Result");
     this.btnShowResources.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnShowResources.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnShowResources.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnShowResources.setSizeToImage();
     this.btnShowResources.Position = new Point((base.Width / 2) - (this.btnViewResult.Width / 2), base.btnDelete.Y);
     this.btnShowResources.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnShowResources.TextYOffset = -2;
     this.btnShowResources.Text.Color = ARGBColors.Black;
     this.btnShowResources.Enabled = true;
     this.btnShowResources.Visible = false;
     this.btnShowResources.Text.Text = SK.Text("Reports_Show_Resources", "Show Resources");
     this.btnShowResources.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.showResourcesClick), "Reports_Show_Resources");
     base.btnUtility.Text.Text = SK.Text("Reports_Show_On_Map", "Show On Map");
     base.btnUtility.Visible = true;
     this.lblResult.Text = "";
     this.lblResult.Color = ARGBColors.Black;
     this.lblResult.Font = FontManager.GetFont("Arial", 14f, FontStyle.Regular);
     this.lblResult.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblResult.Position = new Point(0, base.lblSecondaryText.Rectangle.Bottom);
     this.lblResult.Size = new Size(base.Width, 0x1a);
     base.lblDate.Y = this.lblResult.Rectangle.Bottom;
     string header = SK.Text("GENERIC_Attackers", "Attackers");
     this.attackerValuesPanel = new ReportBattleValuesPanel(this, new Size((base.btnClose.X - base.btnForward.Rectangle.Right) - 4, 180));
     this.attackerValuesPanel.Position = new Point(base.btnForward.X, base.lblDate.Rectangle.Bottom);
     this.attackerValuesPanel.init(header, true, true);
     header = SK.Text("GENERIC_Defenders", "Defenders");
     this.defenderValuesPanel = new ReportBattleValuesPanel(this, new Size((base.btnClose.X - base.btnForward.Rectangle.Right) - 4, 180));
     this.defenderValuesPanel.Position = new Point((base.btnClose.Rectangle.Right - 2) - this.defenderValuesPanel.Width, base.lblDate.Rectangle.Bottom);
     this.defenderValuesPanel.init(header, true, false);
     this.lblSpoils.Text = "";
     this.lblSpoils.Color = ARGBColors.Black;
     this.lblSpoils.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblSpoils.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblSpoils.Position = new Point(0, this.attackerValuesPanel.Rectangle.Bottom);
     this.lblSpoils.Size = new Size(base.Width, 0x1a);
     this.lblTargetVillageInfo.Text = "";
     this.lblTargetVillageInfo.Color = ARGBColors.Black;
     this.lblTargetVillageInfo.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblTargetVillageInfo.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblTargetVillageInfo.Position = new Point(0, this.lblSpoils.Rectangle.Bottom);
     this.lblTargetVillageInfo.Size = new Size(base.Width, 0x1a);
     this.lblHonour.Text = "";
     this.lblHonour.Color = ARGBColors.Black;
     this.lblHonour.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblHonour.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblHonour.Position = new Point(0, this.lblTargetVillageInfo.Rectangle.Bottom);
     this.lblHonour.Size = new Size(base.Width, 0x1a);
     this.lblFlagCaptured.Text = "";
     this.lblFlagCaptured.Color = ARGBColors.Black;
     this.lblFlagCaptured.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblFlagCaptured.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblFlagCaptured.Position = new Point(0, this.lblHonour.Rectangle.Bottom);
     this.lblFlagCaptured.Size = new Size(base.Width, 0x1a);
     this.resourcesPanel.Size = this.attackerValuesPanel.Size;
     this.resourcesPanel.Width *= 2;
     this.resourcesPanel.Position = this.attackerValuesPanel.Position;
     this.resourcesPanel.X = (base.Width / 2) - (this.resourcesPanel.Width / 2);
     this.resourcesPanel.init();
     this.resourcesPanel.Visible = false;
     if (base.imgBackground.Image != null)
     {
         base.imgBackground.addControl(this.attackerValuesPanel);
         base.imgBackground.addControl(this.defenderValuesPanel);
         base.imgBackground.addControl(this.btnViewBattle);
         base.imgBackground.addControl(this.btnViewResult);
         base.imgBackground.addControl(this.btnShowResources);
         base.imgBackground.addControl(this.lblResult);
         base.imgBackground.addControl(this.lblSpoils);
         base.imgBackground.addControl(this.lblTargetVillageInfo);
         base.imgBackground.addControl(this.lblHonour);
         base.imgBackground.addControl(this.lblFlagCaptured);
         base.imgBackground.addControl(this.resourcesPanel);
     }
     else
     {
         base.addControl(this.attackerValuesPanel);
         base.addControl(this.defenderValuesPanel);
         base.addControl(this.btnViewBattle);
         base.addControl(this.btnViewResult);
         base.addControl(this.btnShowResources);
         base.addControl(this.lblResult);
         base.addControl(this.lblSpoils);
         base.addControl(this.lblTargetVillageInfo);
         base.addControl(this.lblHonour);
         base.addControl(this.lblFlagCaptured);
         base.addControl(this.resourcesPanel);
     }
 }
 public virtual void init(IDockableControl parent, Size size, object back)
 {
     this.imgBackground.Image = (Image) back;
     this.imgBackground.Alpha = 0.1f;
     this.m_parent = parent;
     base.Size = size;
     this.borderOffset = 20;
     this.btnClose.Text.Text = SK.Text("GENERIC_Close", "Close");
     this.btnForward.Text.Text = SK.Text("GENERIC_Forward", "Forward");
     this.btnDelete.Text.Text = SK.Text("GENERIC_Delete", "Delete");
     this.lblMainText.Color = ARGBColors.Black;
     this.lblMainText.Position = new Point(this.borderOffset, 3 + this.borderOffset);
     this.lblMainText.Size = new Size(base.Width - (this.borderOffset * 2), 0x39);
     this.lblMainText.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.BOTTOM_CENTER;
     this.lblMainText.Font = FontManager.GetFont("Arial", 18f, FontStyle.Regular);
     this.lblSubTitle.Color = ARGBColors.Black;
     this.lblSubTitle.Position = new Point(20, this.lblMainText.Rectangle.Bottom);
     this.lblSubTitle.Size = new Size(base.Width - 40, 0x1a);
     this.lblSubTitle.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblSubTitle.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblSecondaryText.Color = ARGBColors.Black;
     this.lblSecondaryText.Position = new Point(20, this.lblSubTitle.Rectangle.Bottom);
     this.lblSecondaryText.Size = new Size(base.Width - 40, 60);
     this.lblSecondaryText.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblSecondaryText.Font = FontManager.GetFont("Arial", 16f, FontStyle.Regular);
     this.lblDate.Color = ARGBColors.Black;
     this.lblDate.Position = new Point(0, this.lblSecondaryText.Rectangle.Bottom);
     this.lblDate.Size = new Size(base.Width, 30);
     this.lblDate.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblDate.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.btnClose.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnClose.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnClose.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnClose.setSizeToImage();
     this.btnClose.Position = new Point(((base.Width - this.btnClose.Width) - 5) - this.borderOffset, ((base.Bottom - this.btnClose.Height) - 8) - this.borderOffset);
     this.btnClose.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnClose.TextYOffset = -2;
     this.btnClose.Text.Color = ARGBColors.Black;
     this.btnClose.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.closeClick), "Report_Close");
     this.btnClose.Enabled = true;
     this.btnDelete.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnDelete.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnDelete.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnDelete.setSizeToImage();
     this.btnDelete.Position = new Point(this.btnClose.Position.X, (this.btnClose.Position.Y - this.btnDelete.Height) - 3);
     this.btnDelete.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnDelete.TextYOffset = -2;
     this.btnDelete.Text.Color = ARGBColors.Black;
     this.btnDelete.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.deleteClick), "Report_Delete");
     this.btnDelete.Enabled = true;
     this.btnForward.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnForward.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnForward.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnForward.setSizeToImage();
     this.btnForward.Position = new Point(5 + this.borderOffset, ((base.Bottom - this.btnForward.Height) - 8) - this.borderOffset);
     this.btnForward.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnForward.TextYOffset = -2;
     this.btnForward.Text.Color = ARGBColors.Black;
     this.btnForward.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.forwardClick), "Report_Forward");
     this.btnForward.Enabled = true;
     this.btnUtility.ImageNorm = (Image) GFXLibrary.button_132_normal;
     this.btnUtility.ImageOver = (Image) GFXLibrary.button_132_over;
     this.btnUtility.ImageClick = (Image) GFXLibrary.button_132_in;
     this.btnUtility.setSizeToImage();
     this.btnUtility.Position = new Point(this.btnForward.Position.X, (this.btnForward.Position.Y - this.btnUtility.Height) - 2);
     this.btnUtility.Text.Font = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
     this.btnUtility.TextYOffset = -2;
     this.btnUtility.Text.Color = ARGBColors.Black;
     this.btnUtility.Enabled = true;
     this.btnUtility.Visible = false;
     this.lblFurther.Text = "";
     this.lblFurther.Color = ARGBColors.Black;
     this.lblFurther.Font = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
     this.lblFurther.Visible = false;
     this.lblFurther.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
     this.lblFurther.Position = new Point(this.btnForward.Rectangle.Right + 5, this.btnDelete.Y);
     this.lblFurther.Size = new Size((this.btnDelete.X - this.btnForward.Rectangle.Right) - 10, base.Height - this.lblFurther.Y);
     this.imgFurther.Tile = false;
     this.imgFurther.Visible = false;
     this.initBorder(GFXLibrary.panel_border_top_left, GFXLibrary.panel_border_top, GFXLibrary.panel_border_left);
     if (this.imgBackground.Image != null)
     {
         this.imgBackground.Tile = true;
         this.imgBackground.Position = new Point(0, 0);
         this.imgBackground.Size = base.Size;
         base.addControl(this.imgBackground);
         this.imgBackground.addControl(this.btnClose);
         this.imgBackground.addControl(this.btnForward);
         this.imgBackground.addControl(this.btnUtility);
         this.imgBackground.addControl(this.btnDelete);
         this.imgBackground.addControl(this.lblMainText);
         this.imgBackground.addControl(this.lblSubTitle);
         this.imgBackground.addControl(this.lblSecondaryText);
         this.imgBackground.addControl(this.lblDate);
         this.imgBackground.addControl(this.borderPanel);
     }
     else
     {
         base.addControl(this.btnClose);
         base.addControl(this.btnForward);
         base.addControl(this.btnUtility);
         base.addControl(this.btnDelete);
         base.addControl(this.lblMainText);
         base.addControl(this.lblSubTitle);
         base.addControl(this.lblSecondaryText);
         base.addControl(this.lblDate);
         base.addControl(this.borderPanel);
     }
 }
 public void init(IDockableControl parent, Size size)
 {
     this.init(parent, size, null);
 }
        protected override Size MeasureOverride(Size availableSize)
        {
            SetupSplitters();
            ChildDefinitiveLenght.Clear();

            if (Children.Count == 0)
            {
                return(base.MeasureOverride(availableSize));
            }

            //if (!IsDocked)
            //    return new Size();

            System.Diagnostics.Debug.Assert(_splitterList.Count == Children.Count / 2, "One and only one splitter must be present between two consecutive childs!");
            bool foundChildWithInfResizeProperty = false;

            foreach (UIElement child in Children)
            {
                if (child is ResizingPanelSplitter)
                {
                    continue;
                }

                if (Orientation == Orientation.Horizontal &&
                    double.IsInfinity(GetResizeWidth(child)))
                {
                    if (child is DocumentPane ||
                        (child is ResizingPanel && DockingManager.IsPanelContainingDocumentPane(child as ResizingPanel)))
                    {
                        if (foundChildWithInfResizeProperty)
                        {
                            Debug.WriteLine("A child with resize width set to infinty has been corrected to 200");
                            SetResizeWidth(child, 200);
                        }

                        foundChildWithInfResizeProperty = true;
                    }
                    else
                    {
                        SetResizeWidth(child, 200);
                    }
                }
                else if (Orientation == Orientation.Vertical &&
                         double.IsInfinity(GetResizeHeight(child)))
                {
                    if (child is DocumentPane ||
                        (child is ResizingPanel && DockingManager.IsPanelContainingDocumentPane(child as ResizingPanel)))
                    {
                        if (foundChildWithInfResizeProperty)
                        {
                            Debug.WriteLine("A child with resize height set to infinty has been corrected to 200");
                            SetResizeHeight(child, 200);
                        }

                        foundChildWithInfResizeProperty = true;
                    }
                    else
                    {
                        SetResizeHeight(child, 200);
                    }
                }
            }

            if (!foundChildWithInfResizeProperty)
            {
                foreach (UIElement child in Children)
                {
                    if (child is ResizingPanelSplitter)
                    {
                        continue;
                    }

                    if (Orientation == Orientation.Horizontal)
                    {
                        if (child is DocumentPane ||
                            (child is ResizingPanel && DockingManager.IsPanelContainingDocumentPane(child as ResizingPanel)))
                        {
                            SetResizeWidth(child, double.PositiveInfinity);
                            foundChildWithInfResizeProperty = true;
                            break;
                        }
                    }
                    else if (Orientation == Orientation.Vertical &&
                             double.IsInfinity(GetResizeHeight(child)))
                    {
                        if (child is DocumentPane ||
                            (child is ResizingPanel && DockingManager.IsPanelContainingDocumentPane(child as ResizingPanel)))
                        {
                            SetResizeHeight(child, double.PositiveInfinity);
                            foundChildWithInfResizeProperty = true;
                            break;
                        }
                    }
                }
            }

            if (!foundChildWithInfResizeProperty)
            {
                if (Children.Count == 1)
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(Children[0], double.PositiveInfinity);
                    }
                    else
                    {
                        SetResizeHeight(Children[0], double.PositiveInfinity);
                    }
                }
                else if (Children.Count > 2)
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(Children[2], double.PositiveInfinity);
                    }
                    else
                    {
                        SetResizeHeight(Children[2], double.PositiveInfinity);
                    }
                }
            }



            #region Horizontal orientation
            if (Orientation == Orientation.Horizontal)
            {
                double totSplittersWidth    = 0;
                double totWidth             = 0;
                int    childWithPosInfWidth = 0;

                List <UIElement>      childsOrderedByWidth = new List <UIElement>();
                ResizingPanelSplitter currentSplitter      = null;
                bool prevChildIsVisible = false;

                for (int i = 0; i < Children.Count; i++)
                {
                    UIElement        child         = Children[i];
                    IDockableControl dockableChild = child as IDockableControl;
                    if (dockableChild != null && !dockableChild.IsDocked)
                    {
                        prevChildIsVisible = false;
                        child.Measure(new Size());
                    }
                    else if (child is ResizingPanelSplitter)
                    {
                        if (currentSplitter != null)
                        {
                            child.Measure(new Size());
                        }
                        else if (prevChildIsVisible)
                        {
                            currentSplitter = child as ResizingPanelSplitter;
                        }

                        //if (//(i < Children.Count - 2 && PrevChildIsVisible(i)) ||
                        //    NextChildIsVisible(i) && PrevChildIsVisible(i)
                        //    )
                        //{
                        //    child.Measure(new Size(double.PositiveInfinity, availableSize.Height));
                        //    totSplittersWidth += child.DesiredSize.Width;
                        //}
                        //else
                        //{
                        //    child.Measure(new Size());
                        //}
                    }
                    else
                    {
                        if (currentSplitter != null)
                        {
                            currentSplitter.Measure(new Size(double.PositiveInfinity, availableSize.Height));
                            totSplittersWidth += currentSplitter.DesiredSize.Width;
                            currentSplitter    = null;
                        }

                        prevChildIsVisible = true;
                        double resWidth = (double)child.GetValue(ResizeWidthProperty);

                        if (double.IsPositiveInfinity(resWidth))
                        {
                            childWithPosInfWidth++;
                        }
                        else
                        {
                            totWidth += resWidth;
                            childsOrderedByWidth.Add(child);
                        }
                    }
                }

                if (currentSplitter != null)
                {
                    currentSplitter.Measure(new Size());
                    currentSplitter = null;
                }


                double widthForPosInfChilds = 0;
                double availWidth           = availableSize.Width - totSplittersWidth;
                double shWidth = double.PositiveInfinity;

                if (totWidth > availWidth)
                {
                    childsOrderedByWidth.Sort(delegate(UIElement e1, UIElement e2)
                    {
                        double resWidth1 = (double)e1.GetValue(ResizeWidthProperty);
                        double resWidth2 = (double)e2.GetValue(ResizeWidthProperty);

                        return(resWidth1.CompareTo(resWidth2));
                    });


                    int    count    = childsOrderedByWidth.Count;
                    int    i        = 0;
                    double resWidth = 0;

                    while ((double)childsOrderedByWidth[i].GetValue(ResizeWidthProperty) * (count - i) + resWidth < availWidth)
                    {
                        i++;

                        if (i >= count)
                        {
                            break;
                        }

                        resWidth += (double)childsOrderedByWidth[i - 1].GetValue(ResizeWidthProperty);
                    }

                    shWidth = (availWidth - resWidth) / (count - i);
                    if (shWidth < 0)
                    {
                        shWidth = 0;
                    }
                }
                else
                {
                    if (childWithPosInfWidth > 0)
                    {
                        widthForPosInfChilds = (availWidth - totWidth) / childWithPosInfWidth;
                    }
                    else
                    {
                        widthForPosInfChilds = (availWidth - totWidth) / childsOrderedByWidth.Count;

                        foreach (UIElement child in childsOrderedByWidth)
                        {
                            double resWidth = (double)child.GetValue(ResizeWidthProperty);
                            //double resHeight = (double)child.GetValue(ResizeHeightProperty);

                            child.SetValue(ResizeWidthProperty, resWidth + widthForPosInfChilds);
                        }
                    }
                }



                for (int i = 0; i < Children.Count; i++)
                {
                    UIElement        child         = Children[i];
                    IDockableControl dockableChild = child as IDockableControl;
                    if (dockableChild != null && !dockableChild.IsDocked)
                    {
                        child.Measure(new Size());
                    }
                    else if (!(child is ResizingPanelSplitter))
                    {
                        double resWidth = (double)child.GetValue(ResizeWidthProperty);

                        if (double.IsPositiveInfinity(resWidth))
                        {
                            ChildDefinitiveLenght[child] = widthForPosInfChilds;
                        }
                        else if (shWidth < resWidth)
                        {
                            ChildDefinitiveLenght[child] = shWidth;
                        }
                        else
                        {
                            ChildDefinitiveLenght[child] = resWidth;
                        }

                        child.Measure(new Size(ChildDefinitiveLenght[child], availableSize.Height));
                    }
                }
            }
            #endregion
            #region Vertical orientation
            else //if (Orientation == Orientation.Horizontal)
            {
                double totSplittersHeight    = 0;
                double totHeight             = 0;
                int    childWithPosInfHeight = 0;

                List <UIElement>      childsOrderedByHeight = new List <UIElement>();
                ResizingPanelSplitter currentSplitter       = null;
                bool prevChildIsVisible = false;

                for (int i = 0; i < Children.Count; i++)
                {
                    UIElement        child         = Children[i];
                    IDockableControl dockableChild = child as IDockableControl;

                    if (dockableChild != null && !dockableChild.IsDocked)
                    {
                        prevChildIsVisible = true;
                        child.Measure(new Size());
                    }
                    else if (child is ResizingPanelSplitter)
                    {
                        if (currentSplitter != null)
                        {
                            child.Measure(new Size());
                        }
                        else if (prevChildIsVisible)
                        {
                            currentSplitter = child as ResizingPanelSplitter;
                        }

                        //if ((i < Children.Count - 2 &&
                        //    PrevChildIsVisible(i)) ||
                        //    NextChildIsVisible(i) && PrevChildIsVisible(i)
                        //    )
                        //{
                        //    child.Measure(new Size(availableSize.Width, double.PositiveInfinity));
                        //    totSplittersHeight += child.DesiredSize.Height;
                        //}
                        //else
                        //{
                        //    child.Measure(new Size());
                        //}
                    }
                    else
                    {
                        if (currentSplitter != null)
                        {
                            currentSplitter.Measure(new Size(double.PositiveInfinity, availableSize.Height));
                            totSplittersHeight += currentSplitter.DesiredSize.Height;
                            currentSplitter     = null;
                        }

                        prevChildIsVisible = true;

                        double resHeight = (double)child.GetValue(ResizeHeightProperty);

                        if (double.IsPositiveInfinity(resHeight))
                        {
                            childWithPosInfHeight++;
                        }
                        else
                        {
                            totHeight += resHeight;
                            childsOrderedByHeight.Add(child);
                        }
                    }
                }

                if (currentSplitter != null)
                {
                    currentSplitter.Measure(new Size());
                    currentSplitter = null;
                }

                Debug.Assert(childWithPosInfHeight <= 1);

                double heightForPosInfChilds = 0;
                double availHeight           = availableSize.Height - totSplittersHeight;
                double shHeight = double.PositiveInfinity;

                if (totHeight > availHeight)
                {
                    childsOrderedByHeight.Sort(delegate(UIElement e1, UIElement e2)
                    {
                        double resHeight1 = (double)e1.GetValue(ResizeHeightProperty);
                        double resHeight2 = (double)e2.GetValue(ResizeHeightProperty);

                        return(resHeight1.CompareTo(resHeight2));
                    });

                    int    count     = childsOrderedByHeight.Count;
                    int    i         = 0;
                    double resHeight = 0;

                    while ((double)childsOrderedByHeight[i].GetValue(ResizeHeightProperty) * (count - i) + resHeight < availHeight)
                    {
                        i++;

                        if (i >= count)
                        {
                            break;
                        }

                        resHeight += (double)childsOrderedByHeight[i - 1].GetValue(ResizeHeightProperty);
                    }

                    shHeight = (availHeight - resHeight) / (count - i);
                    if (shHeight < 0)
                    {
                        shHeight = 0;
                    }
                }
                else
                {
                    if (childWithPosInfHeight > 0)
                    {
                        heightForPosInfChilds = (availHeight - totHeight) / childWithPosInfHeight;
                    }
                    else
                    {
                        heightForPosInfChilds = (availHeight - totHeight) / childsOrderedByHeight.Count;

                        foreach (UIElement child in childsOrderedByHeight)
                        {
                            //double resWidth = (double)child.GetValue(ResizeWidthProperty);
                            double resHeight = (double)child.GetValue(ResizeHeightProperty);


                            child.SetValue(ResizeHeightProperty, resHeight + heightForPosInfChilds);
                        }
                    }
                }

                for (int i = 0; i < Children.Count; i++)
                {
                    UIElement        child         = Children[i];
                    IDockableControl dockableChild = child as IDockableControl;
                    if (dockableChild != null && !dockableChild.IsDocked)
                    {
                        child.Measure(new Size());
                    }
                    else if (!(child is ResizingPanelSplitter))
                    {
                        double resHeight = (double)child.GetValue(ResizeHeightProperty);

                        if (double.IsPositiveInfinity(resHeight))
                        {
                            ChildDefinitiveLenght[child] = heightForPosInfChilds;
                        }
                        else if (shHeight < resHeight)
                        {
                            ChildDefinitiveLenght[child] = shHeight;
                        }
                        else
                        {
                            ChildDefinitiveLenght[child] = resHeight;
                        }

                        child.Measure(new Size(availableSize.Width, ChildDefinitiveLenght[child]));
                    }
                }
            }
            #endregion

            //Debug.Assert(ChildDefinitiveLenght.Count > 0);

            return(base.MeasureOverride(availableSize));
        }
Example #11
0
        void UpdatePoints(IDockableControl controlBeingAdded)
        {
            Control controlCopy = (Control)controlBeingAdded;

            //Depending on how the control fills the screen,
            //update the location of the dock points
            switch (controlBeingAdded.FillStyle)
            {
            case FillStyles.FullWidth:
            {
                //Change the locatoin of the dock points that are affected by the control
                if (MyPanel.IsDockedAtTop(controlBeingAdded.DockType))
                {
                    dockPointLocations[DockTypes.TopLeft]  = AddHeightToDockPoint(DockTypes.TopLeft, controlCopy.Height);
                    dockPointLocations[DockTypes.Left]     = AddHeightToDockPoint(DockTypes.Left, controlCopy.Height);
                    dockPointLocations[DockTypes.Top]      = AddHeightToDockPoint(DockTypes.Top, controlCopy.Height);
                    dockPointLocations[DockTypes.None]     = AddHeightToDockPoint(DockTypes.None, controlCopy.Height);
                    dockPointLocations[DockTypes.TopRight] = AddHeightToDockPoint(DockTypes.TopRight, controlCopy.Height);
                    dockPointLocations[DockTypes.Right]    = AddHeightToDockPoint(DockTypes.Right, controlCopy.Height);
                    dockPointLocations[DockTypes.Top2]     = AddHeightToDockPoint(DockTypes.Top2, controlCopy.Height);
                }
                else
                {
                    dockPointLocations[DockTypes.BottomLeft]  = AddHeightToDockPoint(DockTypes.BottomLeft, -controlCopy.Height);
                    dockPointLocations[DockTypes.Bottom]      = AddHeightToDockPoint(DockTypes.Bottom, -controlCopy.Height);
                    dockPointLocations[DockTypes.BottomRight] = AddHeightToDockPoint(DockTypes.BottomRight, -controlCopy.Height);
                    dockPointLocations[DockTypes.Bottom2]     = AddHeightToDockPoint(DockTypes.Bottom2, -controlCopy.Height);
                }
                break;
            }

            case FillStyles.FullHeight:
            {
                if (MyPanel.IsDockedAtLeft(controlBeingAdded.DockType))
                {
                    dockPointLocations[DockTypes.TopLeft]    = AddWidthToDockPoint(DockTypes.TopLeft, controlCopy.Width);
                    dockPointLocations[DockTypes.Left]       = AddWidthToDockPoint(DockTypes.Left, controlCopy.Width);
                    dockPointLocations[DockTypes.BottomLeft] = AddWidthToDockPoint(DockTypes.BottomLeft, controlCopy.Width);
                    dockPointLocations[DockTypes.Top]        = AddWidthToDockPoint(DockTypes.Top, controlCopy.Width);
                    dockPointLocations[DockTypes.None]       = AddWidthToDockPoint(DockTypes.None, controlCopy.Width);
                    dockPointLocations[DockTypes.Bottom]     = AddWidthToDockPoint(DockTypes.Bottom, controlCopy.Width);
                }
                else
                {
                    dockPointLocations[DockTypes.TopRight]    = AddWidthToDockPoint(DockTypes.TopRight, -controlCopy.Width);
                    dockPointLocations[DockTypes.Right]       = AddWidthToDockPoint(DockTypes.Right, -controlCopy.Width);
                    dockPointLocations[DockTypes.BottomRight] = AddWidthToDockPoint(DockTypes.BottomRight, -controlCopy.Width);
                    dockPointLocations[DockTypes.Top2]        = AddWidthToDockPoint(DockTypes.Top2, -controlCopy.Width);
                    dockPointLocations[DockTypes.Bottom2]     = AddWidthToDockPoint(DockTypes.Bottom2, -controlCopy.Width);
                }
                break;
            }

            case FillStyles.None:
            {
                //If the panel being added will affect the dock point:
                if ((controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.TopLeft]) || (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Left]) || (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.None]))
                {
                    dockPointLocations[DockTypes.TopLeft] = AddHeightToDockPoint(DockTypes.TopLeft, controlCopy.Height);
                    dockPointLocations[DockTypes.Left]    = AddHeightToDockPoint(DockTypes.Left, controlCopy.Height);
                    dockPointLocations[DockTypes.None]    = AddHeightToDockPoint(DockTypes.None, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.BottomLeft])
                {
                    dockPointLocations[DockTypes.BottomLeft] = AddHeightToDockPoint(DockTypes.BottomLeft, -controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Top])
                {
                    dockPointLocations[DockTypes.Top] = AddWidthToDockPoint(DockTypes.Top, controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Bottom])
                {
                    dockPointLocations[DockTypes.Bottom] = AddWidthToDockPoint(DockTypes.Bottom, controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.TopRight])
                {
                    dockPointLocations[DockTypes.TopRight] = AddHeightToDockPoint(DockTypes.TopRight, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Right])
                {
                    dockPointLocations[DockTypes.Right] = AddHeightToDockPoint(DockTypes.Right, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.BottomRight])
                {
                    dockPointLocations[DockTypes.BottomRight] = AddHeightToDockPoint(DockTypes.BottomRight, -controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Top2])
                {
                    dockPointLocations[DockTypes.Top2] = AddWidthToDockPoint(DockTypes.Top2, -controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Bottom2])
                {
                    dockPointLocations[DockTypes.Bottom2] = AddWidthToDockPoint(DockTypes.Bottom2, -controlCopy.Width);
                }
                break;
            }
            }
        }
Example #12
0
        /// <summary>
        /// Lays out the controls dynamically
        /// Adds the controls to their respective lists for FillStyle
        /// Adds the controls in order so that their maximum size is observed
        /// Then adds all other controls using the layout lines to size the panels
        /// </summary>
        void RepeatLayout()
        {
            List <IDockableControl> FullScreens = new List <IDockableControl>();
            List <IDockableControl> FullWidths  = new List <IDockableControl>();
            List <IDockableControl> FullHeights = new List <IDockableControl>();
            List <IDockableControl> Others      = new List <IDockableControl>();
            IDockableControl        toolbar     = null;

            myLayoutLines.ClearLinesInContainer(this.ClientRectangle);
            SetInitialLocationsForDockPoints();

            //Remove all controls and assign them to relevant lists
            foreach (IDockableControl d in dockableControlsInPanel)
            {
                this.Controls.Remove((Control)d);
                if (d.Type == typeof(MyToolbar))
                {
                    toolbar = d;
                }
                if (d.FillStyle == FillStyles.FullScreen)
                {
                    FullScreens.Add(d);
                }
                if (d.FillStyle == FillStyles.FullWidth)
                {
                    FullWidths.Add(d);
                }
                if (d.FillStyle == FillStyles.FullHeight)
                {
                    FullHeights.Add(d);
                }
                if (d.FillStyle == FillStyles.None)
                {
                    Others.Add(d);
                }
            }

            //Work through the lists adding controls again

            //If any control is fullscreen, only it and the toolbar should be added
            if (FullScreens.Count != 0)
            {
                AddControl(toolbar, false);
                foreach (IDockableControl d in FullScreens)
                {
                    AddControl(d, false);
                }
            }
            else
            {
                foreach (IDockableControl d in FullWidths)
                {
                    AddControl(d, false);
                }
                foreach (IDockableControl d in FullHeights)
                {
                    AddControl(d, false);
                }
                foreach (IDockableControl d in Others)
                {
                    AddControl(d, false);
                }
            }
        }