public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

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

            LeftWindowCommandsPresenter  = GetTemplateChild(PART_LeftWindowCommands) as ContentPresenter;
            RightWindowCommandsPresenter = GetTemplateChild(PART_RightWindowCommands) as ContentPresenter;
            WindowButtonCommands         = GetTemplateChild(PART_WindowButtonCommands) as WindowButtonCommands;

            overlayBox                    = GetTemplateChild(PART_OverlayBox) as Grid;
            metroDialogContainer          = GetTemplateChild(PART_MetroDialogContainer) as Grid;
            flyoutModal                   = (Rectangle)GetTemplateChild(PART_FlyoutModal);
            flyoutModal.PreviewMouseDown += FlyoutsPreviewMouseDown;
            this.PreviewMouseDown        += FlyoutsPreviewMouseDown;

            icon               = GetTemplateChild(PART_Icon) as UIElement;
            titleBar           = GetTemplateChild(PART_TitleBar) as UIElement;
            titleBarBackground = GetTemplateChild(PART_WindowTitleBackground) as UIElement;

            this.SetVisibiltyForAllTitleElements(this.TitlebarHeight > 0);
        }
Example #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (TextBlockStyle != null && !this.Resources.Contains(typeof(TextBlock)))
            {
                this.Resources.Add(typeof(TextBlock), TextBlockStyle);
            }

            if (WindowCommands == null)
            {
                WindowCommands = new WindowCommands();
            }
            WindowCommandsPresenter = GetTemplateChild("PART_WindowCommands") as ContentPresenter;
            WindowButtonCommands    = GetTemplateChild(PART_WindowButtonCommands) as WindowButtonCommands;

            overlayBox             = GetTemplateChild(PART_OverlayBox) as Grid;
            messageDialogContainer = GetTemplateChild(PART_MessageDialogContainer) as Grid;
            flyoutModal            = GetTemplateChild(PART_FlyoutModal) as Rectangle;

            titleBar = GetTemplateChild(PART_TitleBar) as UIElement;

            if (titleBar != null && titleBar.Visibility == System.Windows.Visibility.Visible)
            {
                titleBar.MouseDown += TitleBarMouseDown;
                titleBar.MouseUp   += TitleBarMouseUp;
                titleBar.MouseMove += TitleBarMouseMove;
            }
            else
            {
                MouseDown += TitleBarMouseDown;
                MouseUp   += TitleBarMouseUp;
                MouseMove += TitleBarMouseMove;
            }
        }
Example #3
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (WindowCommands == null)
            {
                WindowCommands = new WindowCommands();
            }

            WindowCommandsPresenter = GetTemplateChild("PART_WindowCommands") as ContentPresenter;
            WindowButtonCommands    = GetTemplateChild(PART_WindowButtonCommands) as WindowButtonCommands;

            overlayBox                    = GetTemplateChild(PART_OverlayBox) as Grid;
            metroDialogContainer          = GetTemplateChild(PART_MetroDialogContainer) as Grid;
            flyoutModal                   = GetTemplateChild(PART_FlyoutModal) as Rectangle;
            flyoutModal.PreviewMouseDown += FlyoutsPreviewMouseDown;
            this.PreviewMouseDown        += FlyoutsPreviewMouseDown;

            titleBar = GetTemplateChild(PART_TitleBar) as UIElement;

            if (titleBar != null && titleBar.Visibility == Visibility.Visible)
            {
                titleBar.MouseDown += TitleBarMouseDown;
                titleBar.MouseUp   += TitleBarMouseUp;
                titleBar.MouseMove += TitleBarMouseMove;
            }
            else
            {
                MouseDown += TitleBarMouseDown;
                MouseUp   += TitleBarMouseUp;
                MouseMove += TitleBarMouseMove;
            }
        }
Example #4
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

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

            LeftWindowCommandsPresenter  = GetTemplateChild(PART_LeftWindowCommands) as ContentPresenter;
            RightWindowCommandsPresenter = GetTemplateChild(PART_RightWindowCommands) as ContentPresenter;
            WindowButtonCommands         = GetTemplateChild(PART_WindowButtonCommands) as WindowButtonCommands;

            overlayBox                    = GetTemplateChild(PART_OverlayBox) as Grid;
            metroDialogContainer          = GetTemplateChild(PART_MetroDialogContainer) as Grid;
            flyoutModal                   = GetTemplateChild(PART_FlyoutModal) as Rectangle;
            flyoutModal.PreviewMouseDown += FlyoutsPreviewMouseDown;
            this.PreviewMouseDown        += FlyoutsPreviewMouseDown;

            icon               = GetTemplateChild(PART_Icon) as UIElement;
            titleBar           = GetTemplateChild(PART_TitleBar) as UIElement;
            titleBarBackground = GetTemplateChild(PART_WindowTitleBackground) as UIElement;

            this.ToggleVisibiltyForAllTitleElements(this.TitlebarHeight > 0);

            if (icon != null && icon.Visibility == Visibility.Visible)
            {
                icon.MouseDown += IconMouseDown;
                icon.MouseUp   += IconMouseUp;
            }

            // handle mouse events if title template use HorizontalAlignment != Center
            if (titleBarBackground != null && titleBarBackground.Visibility == Visibility.Visible)
            {
                titleBarBackground.MouseDown += TitleBarMouseDown;
                titleBarBackground.MouseUp   += TitleBarMouseUp;
                titleBarBackground.MouseMove += TitleBarMouseMove;
            }

            if (titleBar != null && titleBar.Visibility == Visibility.Visible)
            {
                titleBar.MouseDown += TitleBarMouseDown;
                titleBar.MouseUp   += TitleBarMouseUp;
                titleBar.MouseMove += TitleBarMouseMove;

                if (titleBar.GetType() == typeof(Grid))
                {
                    SizeChanged += this.MetroWindow_SizeChanged;
                }
            }
            else
            {
                MouseDown += TitleBarMouseDown;
                MouseUp   += TitleBarMouseUp;
                MouseMove += TitleBarMouseMove;
            }
        }