Esempio n. 1
0
        public void RefreshButtons()
        {
            if (!IsUpdateLocked())
            {
                ClearButtons();
                Parent.SuspendUpdate();
                string[] PathArray = Path.Split('\\');
                var BreadCrumbPath = new List<string>();

                Padding RealEdges = BreadcrumbButton.GetEdges(Parent.Maximized);
                Point ControlEdges = Location;

                int AddressBarWidth = Parent.Width - (RealEdges.Left + RealEdges.Right);
                int LastWidth = 0;
                for (int i = PathArray.Length - 1; i >= 0; i += -1)
                {
                    int TextWidth = TitleRenderer.TextWidth(PathArray[i], BreadcrumbButton.Font) +
                                    BreadcrumbButton.StretchPadding.Left + BreadcrumbButton.StretchPadding.Right;
                    if ((LastWidth + TextWidth) < AddressBarWidth)
                    {
                        BreadCrumbPath.Insert(0, PathArray[i]);
                    }
                    LastWidth += TextWidth;
                }
                Padding LastLocation = BreadcrumbButton.CalculateEdgesRelativeToTopLeftCorner(Parent.Width, Parent.Maximized, RightWidth);
                BreadCrumbPath.Insert(0, ExplorerSkinIDs.RightArrowButton);
                //Path.Split("\"c)
                foreach (string PathName in BreadCrumbPath)
                {
                    if (PathName.Length > 0)
                    {
                        var NewButton = new LayeredButtonWithSkinElement(Parent);
                        NewButton.SkinElement = BreadcrumbButton;
                        NewButton.RightWidth = RightArrowWidth;

                        if (PathName.Contains("::"))
                        {
                            NewButton.Text = ExtendedFileInfo.GetDisplayName(Path);
                        }
                        else
                        {
                            NewButton.Text = PathName;
                        }
                        if (PathName == ExplorerSkinIDs.RightArrowButton)
                        {
                            NewButton.SizeType = SizingType.SizeToRightWidth;
                            NewButton.TextVisible = false;
                            NewButton.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        }
                        else
                        {
                            NewButton.SizeType = SizingType.SizeToText;
                            NewButton.Tag = Path.Substring(0, Path.IndexOf(PathName) + PathName.Length);
                            if (!PathName.Contains("::"))
                            {
                                NewButton.Tag += System.IO.Path.DirectorySeparatorChar;
                            }
                        }
                        NewButton.X = LastLocation.Left;
                        NewButton.Y = BreadcrumbButton.CalculateEdgesRelativeToTopLeftCorner(0, Parent.Maximized).Top;

                        NewButton.Click += BreadcrumbButton_OnClick;
                        NewButton.MouseEnter += BreadcrumbButtonOnMouseEnter;

                        _buttons.Add(NewButton);
                        if (BreadcrumbButton.ElementAlign == VerticalAlignment.left)
                        {
                            LastLocation.Left += NewButton.Size.Width;
                        }
                        else
                        {
                            NewButton.X -= NewButton.Size.Width;
                            LastLocation.Left = NewButton.X;
                        }
                    }
                }

                Parent.ResumeUpdate();
            }
        }
Esempio n. 2
0
        public void RefreshButtons()
        {
            if (!IsUpdateLocked())
            {
                ClearButtons();
                Parent.SuspendUpdate();
                string[] PathArray      = Path.Split('\\');
                var      BreadCrumbPath = new List <string>();

                Padding RealEdges    = BreadcrumbButton.GetEdges(Parent.Maximized);
                Point   ControlEdges = Location;

                int AddressBarWidth = Parent.Width - (RealEdges.Left + RealEdges.Right);
                int LastWidth       = 0;
                for (int i = PathArray.Length - 1; i >= 0; i += -1)
                {
                    int TextWidth = TitleRenderer.TextWidth(PathArray[i], BreadcrumbButton.Font) +
                                    BreadcrumbButton.StretchPadding.Left + BreadcrumbButton.StretchPadding.Right;
                    if ((LastWidth + TextWidth) < AddressBarWidth)
                    {
                        BreadCrumbPath.Insert(0, PathArray[i]);
                    }
                    LastWidth += TextWidth;
                }
                Padding LastLocation = BreadcrumbButton.CalculateEdgesRelativeToTopLeftCorner(Parent.Width, Parent.Maximized, RightWidth);
                BreadCrumbPath.Insert(0, ExplorerSkinIDs.RightArrowButton);
                //Path.Split("\"c)
                foreach (string PathName in BreadCrumbPath)
                {
                    if (PathName.Length > 0)
                    {
                        var NewButton = new LayeredButtonWithSkinElement(Parent);
                        NewButton.SkinElement = BreadcrumbButton;
                        NewButton.RightWidth  = RightArrowWidth;

                        if (PathName.Contains("::"))
                        {
                            NewButton.Text = ExtendedFileInfo.GetDisplayName(Path);
                        }
                        else
                        {
                            NewButton.Text = PathName;
                        }
                        if (PathName == ExplorerSkinIDs.RightArrowButton)
                        {
                            NewButton.SizeType    = SizingType.SizeToRightWidth;
                            NewButton.TextVisible = false;
                            NewButton.Tag         = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        }
                        else
                        {
                            NewButton.SizeType = SizingType.SizeToText;
                            NewButton.Tag      = Path.Substring(0, Path.IndexOf(PathName) + PathName.Length);
                            if (!PathName.Contains("::"))
                            {
                                NewButton.Tag += System.IO.Path.DirectorySeparatorChar;
                            }
                        }
                        NewButton.X = LastLocation.Left;
                        NewButton.Y = BreadcrumbButton.CalculateEdgesRelativeToTopLeftCorner(0, Parent.Maximized).Top;

                        NewButton.Click      += BreadcrumbButton_OnClick;
                        NewButton.MouseEnter += BreadcrumbButtonOnMouseEnter;

                        _buttons.Add(NewButton);
                        if (BreadcrumbButton.ElementAlign == VerticalAlignment.left)
                        {
                            LastLocation.Left += NewButton.Size.Width;
                        }
                        else
                        {
                            NewButton.X      -= NewButton.Size.Width;
                            LastLocation.Left = NewButton.X;
                        }
                    }
                }

                Parent.ResumeUpdate();
            }
        }