Esempio n. 1
0
 protected virtual void SetDisplayMode(NavigationViewDisplayModes mode)
 {
     this.Collapse();
     this.displayMode = mode;
     mode             = this.GetEffectiveDisplayMode((float)this.Size.Width);
     this.EnsureDisplayMode(mode);
 }
Esempio n. 2
0
        public virtual void Collapse()
        {
            if (this.IsCollapsed)
            {
                return;
            }
            CancelEventArgs e = new CancelEventArgs();

            this.OnCollapsing(e);
            if (e.Cancel)
            {
                return;
            }
            this.IsCollapsed = true;
            foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
            {
                lightVisualElement.DrawText = false;
            }
            NavigationViewDisplayModes effectiveDisplayMode = this.GetEffectiveDisplayMode((float)this.Size.Width);

            if (effectiveDisplayMode == NavigationViewDisplayModes.Expanded)
            {
                if (this.AllowAnimation)
                {
                    Size size1 = new Size(TelerikDpiHelper.ScaleInt(this.ExpandedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    Size size2 = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    AnimatedPropertySetting animatedPropertySetting = new AnimatedPropertySetting(RadElement.MinSizeProperty, (object)size1, (object)size2, this.AnimationFrames, this.AnimationInterval);
                    animatedPropertySetting.AnimationFinished += (AnimationFinishedEventHandler)((param0, param1) => this.OnCollapsed(EventArgs.Empty));
                    animatedPropertySetting.ApplyValue((RadObject)this.ItemContainer);
                }
                else
                {
                    this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    this.OnCollapsed(EventArgs.Empty);
                }
            }
            else
            {
                this.programmaticallyClosingPopup = true;
                this.Popup.ClosePopup(RadPopupCloseReason.Mouse);
                this.HamburgerButton.StretchHorizontally = false;
                this.programmaticallyClosingPopup        = false;
                if (effectiveDisplayMode == NavigationViewDisplayModes.Compact)
                {
                    this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    this.ItemContainer.MaxSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    if (!this.Children.Contains((RadElement)this.ItemContainer))
                    {
                        int num = (int)this.Popup.RootElement.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.Local);
                        this.Children.Insert(0, (RadElement)this.ItemContainer);
                    }
                }
                if (!this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    int num = (int)this.HamburgerButton.ResetValue(RadElement.AlignmentProperty, ValueResetFlags.Local);
                    this.Children.Add((RadElement)this.HamburgerButton);
                }
                this.OnCollapsed(EventArgs.Empty);
            }
        }
Esempio n. 3
0
        protected virtual void EnsureDisplayMode(NavigationViewDisplayModes mode)
        {
            switch (mode)
            {
            case NavigationViewDisplayModes.Minimal:
                this.ItemContainer.MaxSize = Size.Empty;
                this.HamburgerButton.StretchHorizontally = false;
                if (!this.PopupStack.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.PopupStack.Children.Add((RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;

            case NavigationViewDisplayModes.Compact:
                foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
                {
                    lightVisualElement.DrawText = false;
                }
                this.HamburgerButton.StretchHorizontally = false;
                this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                this.ItemContainer.MaxSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                if (!this.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.Children.Insert(0, (RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;

            case NavigationViewDisplayModes.Expanded:
                foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
                {
                    lightVisualElement.DrawText = !this.IsCollapsed;
                }
                this.ItemContainer.MaxSize = Size.Empty;
                this.HamburgerButton.StretchHorizontally = true;
                if (!this.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.Children.Insert(0, (RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.ItemContainer))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;
            }
        }
Esempio n. 4
0
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            NavigationViewDisplayModes effectiveDisplayMode = this.GetEffectiveDisplayMode(availableSize.Width);

            if (this.displayModeCache != effectiveDisplayMode)
            {
                this.EnsureDisplayMode(effectiveDisplayMode);
                this.displayModeCache = effectiveDisplayMode;
            }
            SizeF sizeF = base.MeasureOverride(availableSize);

            if (this.GetEffectiveDisplayMode(availableSize.Width) == NavigationViewDisplayModes.Expanded)
            {
                if (this.IsCollapsed)
                {
                    this.HamburgerButton.Measure(new SizeF((float)this.CollapsedPaneWidth, (float)this.HeaderHeight));
                }
                else
                {
                    this.HamburgerButton.Measure(new SizeF(this.ItemContainer.DesiredSize.Width, (float)this.HeaderHeight));
                }
            }
            return(sizeF);
        }
Esempio n. 5
0
        protected override RectangleF ArrangeItems(RectangleF itemsRect)
        {
            RectangleF rectangleF = itemsRect;
            NavigationViewDisplayModes effectiveDisplayMode = this.GetEffectiveDisplayMode((float)this.Size.Width);

            if (this.ItemContainer.Visibility != ElementVisibility.Collapsed)
            {
                SizeF      desiredSize = this.ItemContainer.DesiredSize;
                Padding    margin      = this.ItemContainer.Margin;
                RectangleF finalRect   = new RectangleF(itemsRect.X + (float)margin.Left, itemsRect.Y + (float)margin.Top + this.HamburgerButton.DesiredSize.Height, desiredSize.Width, desiredSize.Height - (float)margin.Vertical);
                if (this.RightToLeft)
                {
                    switch (effectiveDisplayMode)
                    {
                    case NavigationViewDisplayModes.Compact:
                        if (!this.IsCollapsed)
                        {
                            break;
                        }
                        goto case NavigationViewDisplayModes.Expanded;

                    case NavigationViewDisplayModes.Expanded:
                        finalRect.X = itemsRect.Right - (float)margin.Horizontal - desiredSize.Width;
                        break;
                    }
                }
                this.ItemContainer.Arrange(finalRect);
                switch (effectiveDisplayMode - 1)
                {
                case NavigationViewDisplayModes.Auto:
                    rectangleF = new RectangleF(this.RightToLeft ? itemsRect.X : itemsRect.X + (float)margin.Horizontal, itemsRect.Y, itemsRect.Width, itemsRect.Height);
                    break;

                case NavigationViewDisplayModes.Minimal:
                    rectangleF = new RectangleF(this.RightToLeft ? itemsRect.X : (float)this.CollapsedPaneWidth + itemsRect.X + (float)margin.Horizontal, itemsRect.Y, itemsRect.Width - (float)this.CollapsedPaneWidth, itemsRect.Height);
                    break;

                case NavigationViewDisplayModes.Compact:
                    rectangleF = new RectangleF(this.RightToLeft ? itemsRect.X : finalRect.Right + (float)margin.Right, itemsRect.Y, itemsRect.Width - finalRect.Width - (float)margin.Horizontal, itemsRect.Height);
                    break;
                }
            }
            if (this.HeaderElement.Visibility != ElementVisibility.Collapsed)
            {
                RectangleF finalRect = new RectangleF(rectangleF.Location, new SizeF(rectangleF.Width, (float)this.HeaderHeight));
                if (effectiveDisplayMode == NavigationViewDisplayModes.Minimal)
                {
                    if (this.RightToLeft)
                    {
                        finalRect.Width -= this.HamburgerButton.DesiredSize.Width;
                    }
                    else
                    {
                        finalRect.X += (float)(this.CollapsedPaneWidth + this.ItemContainer.Margin.Horizontal);
                    }
                }
                this.HeaderElement.Arrange(finalRect);
                rectangleF.Y      += (float)this.HeaderHeight;
                rectangleF.Height -= (float)this.HeaderHeight;
            }
            return(rectangleF);
        }