Esempio n. 1
0
        private void ClosePane()
        {
            if (_isPaneClosing)
            {
                return;
            }

            var paneClosing = PaneClosing;

            if (paneClosing != null)
            {
                var args = new SplitViewPaneClosingEventArgs();
                paneClosing(this, args);

                if (args.Cancel && IsPaneOpen)
                {
                    return;
                }
            }

            _isPaneClosing = true;

            if (IsPaneOpen)
            {
                SetCurrentValue(IsPaneOpenProperty, false);
            }

            if (!UpdateDisplayModeState())
            {
                _isPaneClosing = false;
                PaneClosed?.Invoke(this, null);
            }
        }
Esempio n. 2
0
        private void OnTogglePaneButton_Click(object sender, RoutedEventArgs e)
        {
            var closing = new NavigationViewPaneClosingEventArgs();

            if (IsPaneOpen)
            {
                PaneClosing?.Invoke(this, closing);

                if (closing.Cancel)
                {
                    this.Log().DebugIfEnabled(() => "Close pane canceled");
                    return;
                }
            }
            else
            {
                PaneOpening?.Invoke(this, null);
            }

            IsPaneOpen = !IsPaneOpen;

            if (IsPaneOpen)
            {
                PaneOpened?.Invoke(this, null);
            }
            else
            {
                PaneClosed?.Invoke(this, null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// DisplayModeStates
        /// -----------------
        /// Closed
        /// ClosedCompactLeft
        /// ClosedCompactRight
        /// OpenOverlayLeft
        /// OpenOverlayRight
        /// OpenInlineLeft
        /// OpenInlineRight
        /// OpenCompactOverlayLeft
        /// OpenCompactOverlayRight
        /// </summary>
        private void UpdateVisualStates(bool useTransitons)
        {
            string stateName = GetStateName();

            if (!IsPaneOpen)
            {
                PaneClosing?.Invoke(this, new SplitViewPaneClosingEventArgs());
            }
            else
            {
                PaneOpening?.Invoke(this, null);
            }

#if __IOS__
            PatchInvalidFinalState(stateName);
#endif
            VisualStateManager.GoToState(this, stateName, useTransitons);

            if (!IsPaneOpen)
            {
                PaneClosed?.Invoke(this, null);
            }
            else
            {
                PaneOpened?.Invoke(this, null);
            }
        }
Esempio n. 4
0
        void SplitViewIsPaneOpenChanged(DependencyProperty dp)
        {
            // this can occur if the user resizes before it loads
            if (_SecondaryButtonStackPanel == null)
            {
                return;
            }

            // secondary layout
            if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen)
            {
                _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
            }
            else
            {
                _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
            }

            // overall events
            if (ShellSplitView.IsPaneOpen)
            {
                PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
                HamburgerButtonGridWidth = (ShellSplitView.DisplayMode == SplitViewDisplayMode.CompactInline) ? PaneWidth : squareWidth;
            }
            else
            {
                PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
            }

            // this will keep the two properties in sync
            if (IsOpen != ShellSplitView.IsPaneOpen)
            {
                IsOpen = ShellSplitView.IsPaneOpen;
            }
        }
Esempio n. 5
0
 protected virtual void OnIsPaneOpenChanged(bool newValue)
 {
     if (newValue)
     {
         OnVisualStateChanged();
     }
     else
     {
         if (PaneClosing != null)
         {
             SplitViewPaneClosingEventArgs args = new SplitViewPaneClosingEventArgs();
             foreach (TypedEventHandler <SplitView, SplitViewPaneClosingEventArgs> handler in PaneClosing.GetInvocationList())
             {
                 handler(this, args);
                 if (args.Cancel)
                 {
                     IsPaneOpen = true;
                     return;
                 }
             }
         }
         OnVisualStateChanged();
         PaneClosed?.Invoke(this, null);
     }
 }
 private void RaisePaneOpenedOrClosedEvents()
 {
     // overall events
     if (IsOpen)
     {
         PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
     }
     else
     {
         PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
     }
 }
Esempio n. 7
0
        public HamburgerMenu()
        {
            InitializeComponent();
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // nothing
            }
            else
            {
                PrimaryButtons   = new ObservableItemCollection <HamburgerButtonInfo>();
                SecondaryButtons = new ObservableItemCollection <HamburgerButtonInfo>();
                KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); };
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) =>
                {
                    // secondary layout
                    if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) &&
                        ShellSplitView.IsPaneOpen)
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
                    }
                    else
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
                    }

                    // overall events
                    if ((d as SplitView).IsPaneOpen)
                    {
                        PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
                        PaneOpen?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                    else
                    {
                        PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                });
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) =>
                {
                    DisplayMode = ShellSplitView.DisplayMode;
                });
                Loaded += (s, e) =>
                {
                    var any = GetType().GetRuntimeProperties()
                              .Where(x => x.PropertyType == typeof(SolidColorBrush))
                              .Any(x => x.GetValue(this) != null);
                    if (!any)
                    {
                        // this is the default color if the user supplies none
                        AccentColor = Colors.DarkOrange;
                    }
                };
            }
        }
Esempio n. 8
0
        private void OnDisplayModeStatesCurrentStateChanged(object sender, VisualStateChangedEventArgs e)
        {
            _isDisplayModeStateChanging = false;

            if (_isPaneOpening)
            {
                _isPaneOpening = false;
                PaneOpened?.Invoke(this, null);
            }
            else if (_isPaneClosing)
            {
                _isPaneClosing = false;
                PaneClosed?.Invoke(this, null);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// DisplayModeStates
        /// -----------------
        /// Closed
        /// ClosedCompactLeft
        /// ClosedCompactRight
        /// OpenOverlayLeft
        /// OpenOverlayRight
        /// OpenInlineLeft
        /// OpenInlineRight
        /// OpenCompactOverlayLeft
        /// OpenCompactOverlayRight
        /// </summary>
        private void UpdateVisualStates(bool useTransitons)
        {
            string stateName = GetStateName();

            if (!IsPaneOpen)
            {
                PaneClosing?.Invoke(this, new SplitViewPaneClosingEventArgs());
            }

            VisualStateManager.GoToState(this, stateName, useTransitons);

            if (!IsPaneOpen)
            {
                PaneClosed?.Invoke(this, null);
            }
        }
Esempio n. 10
0
        private void ClosePane()
        {
            SplitViewPaneClosingEventArgs args = new SplitViewPaneClosingEventArgs();

            PaneClosing?.Invoke(this, args);
            if (args.Cancel)
            {
                if (DisplayMode == SplitViewDisplayMode.Overlay || DisplayMode == SplitViewDisplayMode.CompactOverlay)
                {
                    IsPaneOpen = true;
                    return;
                }
            }
            ChangeVisualState(true);
            PaneClosed?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 11
0
 /// <summary>
 /// Panel closed event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void SplitView_PaneClosed(SplitView sender, object args)
 {
     AnimateTargetToHamburger();
     PaneClosed?.Invoke(sender, args);
 }
Esempio n. 12
0
 private void OnPaneClosed(object sender, EventArgs e)
 => PaneClosed?.Invoke(sender, e);
Esempio n. 13
0
        public HamburgerMenu()
        {
            InitializeComponent();
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // nothing
            }
            else
            {
                PrimaryButtons   = new ObservableItemCollection <HamburgerButtonInfo>();
                SecondaryButtons = new ObservableItemCollection <HamburgerButtonInfo>();
                KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); };
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) =>
                {
                    DebugWrite($"Current:{(d as SplitView).IsPaneOpen}");

                    // this can occur if the user resizes before it loads
                    if (_SecondaryButtonStackPanel == null)
                    {
                        return;
                    }

                    // secondary layout
                    if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) &&
                        ShellSplitView.IsPaneOpen)
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
                    }
                    else
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
                    }

                    // overall events
                    if ((d as SplitView).IsPaneOpen)
                    {
                        PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
                        PaneOpen?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                    else
                    {
                        PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
                    }

                    // this will keep the two properties in sync
                    if (!d.GetValue(e).Equals(IsOpen))
                    {
                        IsOpen = !IsOpen;
                    }
                });
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) =>
                {
                    DebugWrite($"Current:{ShellSplitView.DisplayMode}");

                    // this will keep the two properties in sync
                    DisplayMode = ShellSplitView.DisplayMode;
                });
                Loaded += (s, e) =>
                {
                    // look to see if any brush property has been set
                    var any = GetType().GetRuntimeProperties()
                              .Where(x => x.PropertyType == typeof(SolidColorBrush))
                              .Any(x => x.GetValue(this) != null);

                    // this is the default color if the user supplies none
                    if (!any)
                    {
                        AccentColor = (Color)Resources["SystemAccentColor"];
                    }

                    // in case the developer has defined zero buttons
                    if (NavButtonCount == 0)
                    {
                        _areNavButtonsLoaded = true;
                    }
                };
            }
        }
 /// <summary>
 /// Raises the <see cref="PaneClosed"/> event.
 /// </summary>
 protected virtual void OnPaneClosed()
 {
     PaneClosed?.Invoke(this, EventArgs.Empty);
 }