상속: System.Windows.Window
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.glowWindow = ((MahApps.Metro.Controls.GlowWindow)(target));
     return;
     case 2:
     this.glow = ((MahApps.Metro.Controls.Glow)(target));
     return;
     }
     this._contentLoaded = true;
 }
예제 #2
0
        public GlowWindow(Window owner, GlowDirection direction)
        {
            Class6.yDnXvgqzyB5jw();
            base();
            GlowWindow glowWindow = this;

            this.InitializeComponent();
            this.IsGlowing          = true;
            base.AllowsTransparency = true;
            base.Closing           += new CancelEventHandler((object sender, CancelEventArgs e) => e.Cancel = !this.closing);
            base.Owner           = owner;
            this.glow.Visibility = System.Windows.Visibility.Collapsed;
            Binding binding = new Binding("GlowBrush")
            {
                Source = owner
            };

            this.glow.SetBinding(Glow.GlowBrushProperty, binding);
            binding = new Binding("NonActiveGlowBrush")
            {
                Source = owner
            };
            this.glow.SetBinding(Glow.NonActiveGlowBrushProperty, binding);
            binding = new Binding("BorderThickness")
            {
                Source = owner
            };
            this.glow.SetBinding(Control.BorderThicknessProperty, binding);
            this.glow.Direction = direction;
            switch (direction)
            {
            case GlowDirection.Left:
            {
                this.glow.Orientation         = Orientation.Vertical;
                this.glow.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                this.getLeft         = (RECT rect) => (double)rect.left - 6 + 1;
                this.getTop          = (RECT rect) => (double)(rect.top - 2);
                this.getWidth        = (RECT rect) => 6;
                this.getHeight       = (RECT rect) => (double)(rect.Height + 4);
                this.getHitTestValue = (Point p) => {
                    if ((new Rect(0, 0, base.ActualWidth, 20)).Contains(p))
                    {
                        return(HitTestValues.HTTOPLEFT);
                    }
                    if (!(new Rect(0, base.ActualHeight - 20, base.ActualWidth, 20)).Contains(p))
                    {
                        return(HitTestValues.HTLEFT);
                    }
                    return(HitTestValues.HTBOTTOMLEFT);
                };
                this.getCursor = (Point p) => {
                    if (owner.ResizeMode == System.Windows.ResizeMode.NoResize || owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
                    {
                        return(owner.Cursor);
                    }
                    if ((new Rect(0, 0, glowWindow.ActualWidth, 20)).Contains(p))
                    {
                        return(Cursors.SizeNWSE);
                    }
                    if (!(new Rect(0, glowWindow.ActualHeight - 20, glowWindow.ActualWidth, 20)).Contains(p))
                    {
                        return(Cursors.SizeWE);
                    }
                    return(Cursors.SizeNESW);
                };
                break;
            }

            case GlowDirection.Right:
            {
                this.glow.Orientation         = Orientation.Vertical;
                this.glow.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                this.getLeft         = (RECT rect) => (double)(rect.right - 1);
                this.getTop          = (RECT rect) => (double)(rect.top - 2);
                this.getWidth        = (RECT rect) => 6;
                this.getHeight       = (RECT rect) => (double)(rect.Height + 4);
                this.getHitTestValue = (Point p) => {
                    if ((new Rect(0, 0, base.ActualWidth, 20)).Contains(p))
                    {
                        return(HitTestValues.HTTOPRIGHT);
                    }
                    if (!(new Rect(0, base.ActualHeight - 20, base.ActualWidth, 20)).Contains(p))
                    {
                        return(HitTestValues.HTRIGHT);
                    }
                    return(HitTestValues.HTBOTTOMRIGHT);
                };
                this.getCursor = (Point p) => {
                    if (owner.ResizeMode == System.Windows.ResizeMode.NoResize || owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
                    {
                        return(owner.Cursor);
                    }
                    if ((new Rect(0, 0, glowWindow.ActualWidth, 20)).Contains(p))
                    {
                        return(Cursors.SizeNESW);
                    }
                    if (!(new Rect(0, glowWindow.ActualHeight - 20, glowWindow.ActualWidth, 20)).Contains(p))
                    {
                        return(Cursors.SizeWE);
                    }
                    return(Cursors.SizeNWSE);
                };
                break;
            }

            case GlowDirection.Top:
            {
                this.glow.Orientation       = Orientation.Horizontal;
                this.glow.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                this.getLeft         = (RECT rect) => (double)(rect.left - 2);
                this.getTop          = (RECT rect) => (double)rect.top - 6 + 1;
                this.getWidth        = (RECT rect) => (double)(rect.Width + 4);
                this.getHeight       = (RECT rect) => 6;
                this.getHitTestValue = (Point p) => {
                    if ((new Rect(0, 0, 14, base.ActualHeight)).Contains(p))
                    {
                        return(HitTestValues.HTTOPLEFT);
                    }
                    if (!(new Rect(base.Width - 20 + 6, 0, 14, base.ActualHeight)).Contains(p))
                    {
                        return(HitTestValues.HTTOP);
                    }
                    return(HitTestValues.HTTOPRIGHT);
                };
                this.getCursor = (Point p) => {
                    if (owner.ResizeMode == System.Windows.ResizeMode.NoResize || owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
                    {
                        return(owner.Cursor);
                    }
                    if ((new Rect(0, 0, 14, glowWindow.ActualHeight)).Contains(p))
                    {
                        return(Cursors.SizeNWSE);
                    }
                    if (!(new Rect(glowWindow.Width - 20 + 6, 0, 14, glowWindow.ActualHeight)).Contains(p))
                    {
                        return(Cursors.SizeNS);
                    }
                    return(Cursors.SizeNESW);
                };
                break;
            }

            case GlowDirection.Bottom:
            {
                this.glow.Orientation       = Orientation.Horizontal;
                this.glow.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                this.getLeft         = (RECT rect) => (double)(rect.left - 2);
                this.getTop          = (RECT rect) => (double)(rect.bottom - 1);
                this.getWidth        = (RECT rect) => (double)(rect.Width + 4);
                this.getHeight       = (RECT rect) => 6;
                this.getHitTestValue = (Point p) => {
                    if ((new Rect(0, 0, 14, base.ActualHeight)).Contains(p))
                    {
                        return(HitTestValues.HTBOTTOMLEFT);
                    }
                    if (!(new Rect(base.Width - 20 + 6, 0, 14, base.ActualHeight)).Contains(p))
                    {
                        return(HitTestValues.HTBOTTOM);
                    }
                    return(HitTestValues.HTBOTTOMRIGHT);
                };
                this.getCursor = (Point p) => {
                    if (owner.ResizeMode == System.Windows.ResizeMode.NoResize || owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
                    {
                        return(owner.Cursor);
                    }
                    if ((new Rect(0, 0, 14, glowWindow.ActualHeight)).Contains(p))
                    {
                        return(Cursors.SizeNESW);
                    }
                    if (!(new Rect(glowWindow.Width - 20 + 6, 0, 14, glowWindow.ActualHeight)).Contains(p))
                    {
                        return(Cursors.SizeNS);
                    }
                    return(Cursors.SizeNWSE);
                };
                break;
            }
            }
            owner.ContentRendered += new EventHandler((object sender, EventArgs e) => this.glow.Visibility = System.Windows.Visibility.Visible);
            owner.Activated       += new EventHandler((object sender, EventArgs e) => {
                this.Update();
                this.glow.IsGlow = true;
            });
            owner.Deactivated      += new EventHandler((object sender, EventArgs e) => this.glow.IsGlow = false);
            owner.StateChanged     += new EventHandler((object sender, EventArgs e) => this.Update());
            owner.IsVisibleChanged += new DependencyPropertyChangedEventHandler((object sender, DependencyPropertyChangedEventArgs e) => this.Update());
            owner.Closed           += new EventHandler((object sender, EventArgs e) => {
                this.closing = true;
                base.Close();
            });
        }