/// <summary>
        /// Adapts the WindowCommands to the theme of the first opened, topmost &amp;&amp; (top || right || left) flyout
        /// </summary>
        /// <param name="window">The MetroWindow</param>
        /// <param name="flyouts">All the flyouts! Or flyouts that fall into the category described in the summary.</param>
        /// <param name="resetBrush">An optional brush to reset the window commands brush to.</param>
        public static void HandleWindowCommandsForFlyouts(this MetroWindow window, IEnumerable <Flyout> flyouts, Brush resetBrush = null)
        {
            var allOpenFlyouts = flyouts.Where(x => x.IsOpen);

            var anyFlyoutOpen = allOpenFlyouts.Any(x => x.Position != Position.Bottom);

            if (!anyFlyoutOpen)
            {
                if (resetBrush == null)
                {
                    window.ResetAllWindowCommandsBrush();
                }
                else
                {
                    window.ChangeAllWindowCommandsBrush(resetBrush);
                }
            }

            var topFlyout = allOpenFlyouts
                            .Where(x => x.Position == Position.Top)
                            .OrderByDescending(Panel.GetZIndex)
                            .FirstOrDefault();

            if (topFlyout != null)
            {
                window.UpdateWindowCommandsForFlyout(topFlyout);
            }
            else
            {
                var leftFlyout = allOpenFlyouts
                                 .Where(x => x.Position == Position.Left)
                                 .OrderByDescending(Panel.GetZIndex)
                                 .FirstOrDefault();
                if (leftFlyout != null)
                {
                    window.UpdateWindowCommandsForFlyout(leftFlyout);
                }
                if (topFlyout == null && leftFlyout != null)
                {
                    window.ResetAllWindowCommandsBrush();
                }
                var rightFlyout = allOpenFlyouts
                                  .Where(x => x.Position == Position.Right)
                                  .OrderByDescending(Panel.GetZIndex)
                                  .FirstOrDefault();
                if (rightFlyout != null)
                {
                    window.UpdateWindowCommandsForFlyout(rightFlyout);
                }
            }
        }
Exemplo n.º 2
0
        public static void HandleWindowCommandsForFlyouts(this MetroWindow window, IEnumerable <Flyout> flyouts, Brush resetBrush = null)
        {
            IEnumerable <Flyout> flyouts1 =
                from x in flyouts
                where x.IsOpen
                select x;

            if (!flyouts1.Any <Flyout>((Flyout x) => x.Position != Position.Bottom))
            {
                if (resetBrush != null)
                {
                    window.ChangeAllWindowCommandsBrush(resetBrush, Position.Top);
                }
                else
                {
                    window.ResetAllWindowCommandsBrush();
                }
            }
            Flyout flyout = (
                from x in flyouts1
                where x.Position == Position.Top
                select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>();

            if (flyout != null)
            {
                window.UpdateWindowCommandsForFlyout(flyout);
                return;
            }
            Flyout flyout1 = (
                from x in flyouts1
                where x.Position == Position.Left
                select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>();

            if (flyout1 != null)
            {
                window.UpdateWindowCommandsForFlyout(flyout1);
            }
            Flyout flyout2 = (
                from x in flyouts1
                where x.Position == Position.Right
                select x).OrderByDescending <Flyout, int>(new Func <Flyout, int>(Panel.GetZIndex)).FirstOrDefault <Flyout>();

            if (flyout2 != null)
            {
                window.UpdateWindowCommandsForFlyout(flyout2);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adapts the WindowCommands to the theme of the first opened, topmost && && (top || right) flyout
        /// </summary>
        /// <param name="flyouts">All the flyouts! Or flyouts that fall into the category described in the summary.</param>
        /// <param name="resetBrush">An optional brush to reset the window commands brush to.</param>
        public static void HandleWindowCommandsForFlyouts(this MetroWindow window, IEnumerable <Flyout> flyouts, Brush resetBrush = null)
        {
            var flyout = flyouts
                         .Where(x => x.IsOpen && (x.Position == Position.Right || x.Position == Position.Top))
                         .OrderByDescending(Panel.GetZIndex)
                         .FirstOrDefault();

            if (flyout != null)
            {
                window.UpdateWindowCommandsForFlyout(flyout);
            }

            else if (resetBrush == null)
            {
                window.ResetAllWindowCommandsBrush();
            }

            else
            {
                window.ChangeAllWindowCommandsBrush(resetBrush);
            }
        }