Inheritance: System.Windows.Documents.Adorner
Esempio n. 1
0
        // called when window is loaded; extends Aero glass effect
        protected void OnLoaded(object sender, RoutedEventArgs e)
        {
            // set caption height
            _captionControl.Height = CaptionHeight;

            if (_contentExtend)
            {
                _contentWindowBorder.Margin = new Thickness(0);
            }
            else
            {
                _contentWindowBorder.Margin = new Thickness(0, CaptionHeight, 0, 0);
            }

            // bug? I don't know why, but when aero is disabled and _captionControl.Height is set,
            // the windowDockPanel doesn't react on the _captionControl size change.
            // Only after window is resized the dockpanel reacts on the change.
            this.Height = this.Height + 1;
            this.Height = this.Height - 1;

            // try to enable aero
            _aeroEnabled = Graphics.InicializeAero(this, CaptionHeight);

            // aero is enabled => caption background color managed by aero; otherwise set system color
            if (_aeroEnabled)
            {
                _captionControl.Background = Brushes.Transparent;
            }

            // if aero is not enabled => create default border around the window, disable default resizing, add custom resizing
            else
            {
                _captionControl.Background = SystemColors.ActiveCaptionBrush;

                // disconnect current content
                object content = base.Content;
                base.Content = null;

                // window border
                _windowBorderBorder = new Border();
                _windowBorderBorder.BorderThickness = new Thickness(5);
                _windowBorderBorder.Child           = (UIElement)content;
                _windowBorderBorder.BorderBrush     = SystemColors.ActiveCaptionBrush;

                // white strip arround the window
                Border borderWhite = new Border();

                borderWhite.BorderThickness = new Thickness(1);
                borderWhite.Child           = _windowBorderBorder;
                borderWhite.BorderBrush     = Brushes.White;

                // black strip arround the window
                Border borderBlack = new Border();
                borderBlack.BorderThickness = new Thickness(1);
                borderBlack.Child           = borderWhite;
                borderBlack.BorderBrush     = Brushes.Black;

                // put the content back
                base.Content = borderBlack;

                // switch off resizing => it hides the ugly gray border => resizing must be implemented again though
                this.ResizeMode = ResizeMode.NoResize;

                // create window resizing
                _resizingAdorner = new WindowResizingAdorner((UIElement)base.Content, this);
                AdornerLayer.GetAdornerLayer((UIElement)this.Content).Add(_resizingAdorner);
            }

            // set system properties
            TextBlock.SetForeground(_captionControl, SystemColors.ActiveCaptionTextBrush);
            TextBlock.SetFontFamily(_captionControl, SystemFonts.CaptionFontFamily);
            TextBlock.SetFontSize(_captionControl, SystemFonts.CaptionFontSize);
            TextBlock.SetFontStyle(_captionControl, SystemFonts.CaptionFontStyle);
            TextBlock.SetFontWeight(_captionControl, SystemFonts.CaptionFontWeight);

            this.StateChanged += new EventHandler(StandardWindow_StateChanged);

            // buttons on active window and not active window differ => manage
            this.Activated   += new EventHandler(OnStandardWindowActivated);
            this.Deactivated += new EventHandler(OnStandardWindowDeactivated);

            // refresh state
            OnStateChanged(new EventArgs());
        }
Esempio n. 2
0
        // called when window is loaded; extends Aero glass effect
        protected void OnLoaded(object sender, RoutedEventArgs e)
        {
            // set caption height
            _captionControl.Height = CaptionHeight;

            if (_contentExtend)
                _contentWindowBorder.Margin = new Thickness(0);
            else
                _contentWindowBorder.Margin = new Thickness(0, CaptionHeight, 0, 0);

            // bug? I don't know why, but when aero is disabled and _captionControl.Height is set,
            // the windowDockPanel doesn't react on the _captionControl size change.
            // Only after window is resized the dockpanel reacts on the change.
            this.Height = this.Height + 1;
            this.Height = this.Height - 1;

            // try to enable aero
            _aeroEnabled = Graphics.InicializeAero(this, CaptionHeight);

            // aero is enabled => caption background color managed by aero; otherwise set system color
            if (_aeroEnabled)
                _captionControl.Background = Brushes.Transparent;

            // if aero is not enabled => create default border around the window, disable default resizing, add custom resizing
            else
            {
                _captionControl.Background = SystemColors.ActiveCaptionBrush;

                // disconnect current content
                object content = base.Content;
                base.Content = null;

                // window border
                _windowBorderBorder = new Border();
                _windowBorderBorder.BorderThickness = new Thickness(5);
                _windowBorderBorder.Child = (UIElement)content;
                _windowBorderBorder.BorderBrush = SystemColors.ActiveCaptionBrush;

                // white strip arround the window
                Border borderWhite = new Border();

                borderWhite.BorderThickness = new Thickness(1);
                borderWhite.Child = _windowBorderBorder;
                borderWhite.BorderBrush = Brushes.White;

                // black strip arround the window
                Border borderBlack = new Border();
                borderBlack.BorderThickness = new Thickness(1);
                borderBlack.Child = borderWhite;
                borderBlack.BorderBrush = Brushes.Black;

                // put the content back
                base.Content = borderBlack;

                // switch off resizing => it hides the ugly gray border => resizing must be implemented again though
                this.ResizeMode = ResizeMode.NoResize;

                // create window resizing
                _resizingAdorner = new WindowResizingAdorner((UIElement)base.Content, this);
                AdornerLayer.GetAdornerLayer((UIElement)this.Content).Add(_resizingAdorner);
            }

            // set system properties
            TextBlock.SetForeground(_captionControl, SystemColors.ActiveCaptionTextBrush);
            TextBlock.SetFontFamily(_captionControl, SystemFonts.CaptionFontFamily);
            TextBlock.SetFontSize(_captionControl, SystemFonts.CaptionFontSize);
            TextBlock.SetFontStyle(_captionControl, SystemFonts.CaptionFontStyle);
            TextBlock.SetFontWeight(_captionControl, SystemFonts.CaptionFontWeight);

            this.StateChanged += new EventHandler(StandardWindow_StateChanged);

            // buttons on active window and not active window differ => manage
            this.Activated += new EventHandler(OnStandardWindowActivated);
            this.Deactivated += new EventHandler(OnStandardWindowDeactivated);

            // refresh state
            OnStateChanged(new EventArgs());
        }