Ejemplo n.º 1
0
        private void OnThemeChanged(WindowCommands o, AvaloniaPropertyChangedEventArgs e)
        {
            // only apply theme if value is changed
            if (e.NewValue == e.OldValue)
            {
                return;
            }

            if ((WindowCommandTheme)e.NewValue == WindowCommandTheme.Light)
            {
                //if (o.LightTemplate != null)
                //{
                //    o.SetValue(TemplateProperty, o.LightTemplate);
                //}

                if (o.LightClasses != null)
                {
                    if (o.DarkClasses != null)
                    {
                        foreach (var item in o.DarkClasses)
                        {
                            o.Classes.Remove(item);
                        }
                    }

                    foreach (var item in o.LightClasses)
                    {
                        o.Classes.Remove(item);
                    }

                    o.Classes.AddRange(o.LightClasses);

                    //o.SetValue(TemplateProperty, o.LightTemplate);
                }
            }
            else if ((WindowCommandTheme)e.NewValue == WindowCommandTheme.Dark)
            {
                //if (o.DarkTemplate != null)
                //{
                //    o.SetValue(TemplateProperty, o.DarkTemplate);
                //}
                if (o.DarkClasses != null)
                {
                    if (o.LightClasses != null)
                    {
                        foreach (var item in o.LightClasses)
                        {
                            o.Classes.Remove(item);
                        }
                    }

                    foreach (var item in o.DarkClasses)
                    {
                        o.Classes.Remove(item);
                    }

                    o.Classes.AddRange(o.DarkClasses);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnClassesChanged(WindowCommands o, AvaloniaPropertyChangedEventArgs e)
        {
            Classes classes = e.NewValue as Classes;

            if (classes != null)
            {
                if (LightClasses != null)
                {
                    foreach (var item in LightClasses)
                    {
                        base.Classes.Remove(item);
                    }
                }

                if (DarkClasses != null)
                {
                    foreach (var item in DarkClasses)
                    {
                        base.Classes.Remove(item);
                    }
                }

                foreach (var item in classes)
                {
                    base.Classes.Add(item);
                }
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            LeftWindowCommandsPresenter   = e.NameScope.Find <ContentPresenter>(PART_LeftWindowCommands);
            RightWindowCommandsPresenter  = e.NameScope.Find <ContentPresenter>(PART_RightWindowCommands);
            WindowButtonCommandsPresenter = e.NameScope.Find <ContentPresenter>(PART_WindowButtonCommands);

            if (LeftWindowCommands == null)
            {
                LeftWindowCommands = new WindowCommands();
            }
            if (RightWindowCommands == null)
            {
                RightWindowCommands = new WindowCommands();
            }
            if (WindowButtonCommands == null)
            {
                WindowButtonCommands = new WindowButtonCommands();
            }

            LeftWindowCommands.ParentWindow   = this;
            RightWindowCommands.ParentWindow  = this;
            WindowButtonCommands.ParentWindow = this;
            overlayBox = e.NameScope.Find <Grid>(PART_OverlayBox);
            metroActiveDialogContainer   = e.NameScope.Find <Grid>(PART_MetroActiveDialogContainer);
            metroInactiveDialogContainer = e.NameScope.Find <Grid>(PART_MetroInactiveDialogsContainer);
            flyoutModal = e.NameScope.Find <Rectangle>(PART_FlyoutModal);
            flyoutModal.PointerPressed += FlyoutsPreviewMouseDown;
            //flyoutModal.MouseDown += FlyoutsPreviewMouseDown;
            this.PointerPressed += FlyoutsPreviewMouseDown;

            _icon                     = e.NameScope.Find <ContentControl>(PART_Icon);
            _titleBar                 = e.NameScope.Find <ContentControl>(PART_TitleBar);
            _titleBarBackground       = e.NameScope.Find <Rectangle>(PART_WindowTitleBackground);
            _windowTitleThumb         = e.NameScope.Find <Thumb>(PART_WindowTitleThumb);
            _flyoutModalDragMoveThumb = e.NameScope.Find <Thumb>(PART_FlyoutModalDragMoveThumb);
            SetVisibiltyForAllTitleElements();

            var metroContentControl = e.NameScope.Find <MetroContentControl>(PART_Content);

            if (metroContentControl != null)
            {
                if (Design.IsDesignMode == false)
                {
                    metroContentControl.TransitionCompleted += (sender, args) => this.RaiseEvent(new RoutedEventArgs(WindowTransitionCompletedEvent));
                }
            }

            _topHorizontalGrip    = e.NameScope.Find <Grid>(PART_TopHorizontalGrip);
            _bottomHorizontalGrip = e.NameScope.Find <Grid>(PART_BottomHorizontalGrip);
            _leftVerticalGrip     = e.NameScope.Find <Grid>(PART_LeftVerticalGrip);
            _rightVerticalGrip    = e.NameScope.Find <Grid>(PART_RightVerticalGrip);

            _topLeftGrip     = e.NameScope.Find <Grid>(PART_TopLeftGrip);
            _bottomLeftGrip  = e.NameScope.Find <Grid>(PART_BottomLeftGrip);
            _topRightGrip    = e.NameScope.Find <Grid>(PART_TopRightGrip);
            _bottomRightGrip = e.NameScope.Find <Grid>(PART_BottomRightGrip);
        }
Ejemplo n.º 4
0
 private void OnShowSeparatorsChanged(WindowCommands o, AvaloniaPropertyChangedEventArgs e)
 {
     if (e.NewValue == e.OldValue)
     {
         return;
     }
     ResetSeparators();
 }
Ejemplo n.º 5
0
        private void OnParentWindowChanged(WindowCommands o, AvaloniaPropertyChangedEventArgs e)
        {
            MetroWindow metroWindow = e.NewValue as MetroWindow;

            if (metroWindow != null)
            {
                ShowTitleBar = metroWindow.ShowTitleBar;
            }
        }