コード例 #1
0
        private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            if (makeGlowVisibleTimer == null)
            {
                makeGlowVisibleTimer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromMilliseconds(glowTimerDelay)
                };
                makeGlowVisibleTimer.Tick += makeGlowVisibleTimer_Tick;
            }

            // No glow effect if UseNoneWindowStyle is true or GlowBrush not set.
            var metroWindow = this.AssociatedObject as MetroWindow;

            if (metroWindow != null && (metroWindow.UseNoneWindowStyle || metroWindow.GlowBrush == null))
            {
                return;
            }

            this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
            this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
            this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
            this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

            this.Show();
            this.Update();

            var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled;

            this.SetOpacityTo(0.25);
        }
コード例 #2
0
        protected override void OnAttached()
        {
            base.OnAttached();

            this.AssociatedObject.SourceInitialized += (o, args) => {
                handle = new WindowInteropHelper(this.AssociatedObject).Handle;
                var hwndSource = HwndSource.FromHwnd(handle);
                if (hwndSource != null)
                {
                    hwndSource.AddHook(AssociatedObjectWindowProc);
                }
            };
            this.AssociatedObject.Loaded += (sender, e) => {
                this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
                this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
                this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
                this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

                left.Show();
                left.Update();

                right.Show();
                right.Update();

                top.Show();
                top.Update();

                bottom.Show();
                bottom.Update();
            };
        }
コード例 #3
0
        private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            MetroWindow metroWindow = this.AssociatedObject as MetroWindow;

            if (metroWindow != null && (metroWindow.UseNoneWindowStyle /* || metroWindow.GlowBrush == null*/))
            {
                return;
            }
            this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
            this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
            this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
            this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);
            this.Show();
            this.Update();
            if (metroWindow == null || !metroWindow.WindowTransitionsEnabled)
            {
                this.SetOpacityTo(1.0);
            }
            else
            {
                this.StartOpacityStoryboard();
                this.AssociatedObject.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged);
                this.AssociatedObject.Closing          += (CancelEventHandler)((o, args) =>
                {
                    if (args.Cancel)
                    {
                        return;
                    }
                    this.AssociatedObject.IsVisibleChanged -= new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged);
                });
            }
        }
コード例 #4
0
        protected override void OnAttached()
        {
            base.OnAttached();

            this.AssociatedObject.Loaded += (sender, e) =>
            {
                left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
                right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
                top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
                bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

                Show();

                left.Update();
                right.Update();
                top.Update();
                bottom.Update();
            };

            this.AssociatedObject.Closed += (sender, args) =>
            {
                left.Close();
                right.Close();
                top.Close();
                bottom.Close();
            };
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            GlowWindow w = new GlowWindow();

            w.Show();
        }
コード例 #6
0
        protected override void OnAttached()
        {
            base.OnAttached();

            this.left   = new GlowWindow(this, new GlowWindowProcessorLeft());
            this.right  = new GlowWindow(this, new GlowWindowProcessorRight());
            this.top    = new GlowWindow(this, new GlowWindowProcessorTop());
            this.bottom = new GlowWindow(this, new GlowWindowProcessorBottom());
        }
コード例 #7
0
        private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            // No glow effect if UseNoneWindowStyle is true or GlowBrush not set.
            var metroWindow = this.AssociatedObject as MetroWindow;

            if (metroWindow != null && (metroWindow.UseNoneWindowStyle || metroWindow.GlowBrush == null))
            {
                return;
            }

            this.AssociatedObject.StateChanged -= AssociatedObjectStateChanged;
            this.AssociatedObject.StateChanged += AssociatedObjectStateChanged;

            if (makeGlowVisibleTimer == null)
            {
                makeGlowVisibleTimer = new DispatcherTimer {
                    Interval = GlowTimerDelay
                };
                makeGlowVisibleTimer.Tick += makeGlowVisibleTimer_Tick;
            }

            this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
            this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
            this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
            this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

            this.Show();
            this.Update();

            var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled;

            if (!windowTransitionsEnabled)
            {
                // no storyboard so set opacity to 1
                this.SetOpacityTo(1);
            }
            else
            {
                // start the opacity storyboard 0->1
                this.StartOpacityStoryboard();
                // hide the glows if window get invisible state
                this.AssociatedObject.IsVisibleChanged += this.AssociatedObjectIsVisibleChanged;
                // closing always handled
                this.AssociatedObject.Closing += (o, args) =>
                {
                    if (!args.Cancel)
                    {
                        this.AssociatedObject.IsVisibleChanged -= this.AssociatedObjectIsVisibleChanged;
                    }
                };
            }
        }
コード例 #8
0
        private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            // No glow effect if GlowBrush not set.
            if (this.IsGlowDisabled)
            {
                return;
            }

            this.AssociatedObject.StateChanged -= this.AssociatedObjectStateChanged;
            this.AssociatedObject.StateChanged += this.AssociatedObjectStateChanged;

            if (this.makeGlowVisibleTimer == null)
            {
                this.makeGlowVisibleTimer = new DispatcherTimer {
                    Interval = GlowTimerDelay
                };
                this.makeGlowVisibleTimer.Tick += this.GlowVisibleTimerOnTick;
            }

            this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
            this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
            this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
            this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

            this.Show();
            this.Update();

            if (!this.IsWindowTransitionsEnabled)
            {
                // no storyboard so set opacity to 1
                this.AssociatedObject.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => this.SetOpacityTo(1)));
            }
            else
            {
                // start the opacity storyboard 0->1
                this.StartOpacityStoryboard();
                // hide the glows if window get invisible state
                this.AssociatedObject.IsVisibleChanged += this.AssociatedObjectIsVisibleChanged;
                // closing always handled
                this.AssociatedObject.Closing += (o, args) =>
                {
                    if (!args.Cancel)
                    {
                        this.AssociatedObject.IsVisibleChanged -= this.AssociatedObjectIsVisibleChanged;
                    }
                };
            }
        }
コード例 #9
0
        protected override void OnAttached()
        {
            base.OnAttached();

            var metroWindow = this.AssociatedObject as MetroWindow;

            if (metroWindow != null && metroWindow.UseNoneWindowStyle)
            {
                return;
            }

            this.AssociatedObject.Loaded += (sender, e) =>
            {
                left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
                right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
                top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
                bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

                Show();

                left.Update();
                right.Update();
                top.Update();
                bottom.Update();
            };

            this.AssociatedObject.Closed += (sender, args) =>
            {
                if (left != null)
                {
                    left.Close();
                }
                if (right != null)
                {
                    right.Close();
                }
                if (top != null)
                {
                    top.Close();
                }
                if (bottom != null)
                {
                    bottom.Close();
                }
            };
        }
コード例 #10
0
        protected override void OnAttached()
        {
            base.OnAttached();

            // now glow effect if UseNoneWindowStyle is true or GlowBrush not set
            var metroWindow = this.AssociatedObject as MetroWindow;

            if (metroWindow != null && (metroWindow.UseNoneWindowStyle || metroWindow.GlowBrush == null))
            {
                return;
            }

            this.AssociatedObject.Loaded += (sender, e) =>
            {
                this.left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
                this.right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
                this.top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
                this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

                this.Show();
                this.Update();

                var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled;
                if (!windowTransitionsEnabled)
                {
                    // no storyboard so set opacity to 1
                    this.SetOpacityTo(1);
                }
                else
                {
                    // start the opacity storyboard 0->1
                    this.StartOpacityStoryboard();
                    // hide the glows if window get invisible state
                    this.AssociatedObject.IsVisibleChanged += this.AssociatedObject_IsVisibleChanged;
                    // closing always handled
                    this.AssociatedObject.Closing += (o, args) =>
                    {
                        if (!args.Cancel)
                        {
                            this.AssociatedObject.IsVisibleChanged -= this.AssociatedObject_IsVisibleChanged;
                        }
                    };
                }
            };
        }
コード例 #11
0
        protected override void OnAttached()
        {
            base.OnAttached();

            this.AssociatedObject.Loaded += (sender, e) =>
            {
                left   = new GlowWindow(this.AssociatedObject, GlowDirection.Left);
                right  = new GlowWindow(this.AssociatedObject, GlowDirection.Right);
                top    = new GlowWindow(this.AssociatedObject, GlowDirection.Top);
                bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom);

                ShowAll();
                UpdateAll();
            };

            this.AssociatedObject.Activated += (sender, e) =>
            {
                ShowAll();
            };
            this.AssociatedObject.Deactivated += (sender, e) =>
            {
                HideAll();
            };
        }
コード例 #12
0
 private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs e)
 {
     if (this.IsGlowDisabled)
     {
         return;
     }
     base.AssociatedObject.StateChanged -= new EventHandler(this.AssociatedObjectStateChanged);
     base.AssociatedObject.StateChanged += new EventHandler(this.AssociatedObjectStateChanged);
     if (this.makeGlowVisibleTimer == null)
     {
         this.makeGlowVisibleTimer = new DispatcherTimer()
         {
             Interval = GlowWindowBehavior.GlowTimerDelay
         };
         this.makeGlowVisibleTimer.Tick += new EventHandler(this.makeGlowVisibleTimer_Tick);
     }
     this.left   = new GlowWindow(base.AssociatedObject, GlowDirection.Left);
     this.right  = new GlowWindow(base.AssociatedObject, GlowDirection.Right);
     this.top    = new GlowWindow(base.AssociatedObject, GlowDirection.Top);
     this.bottom = new GlowWindow(base.AssociatedObject, GlowDirection.Bottom);
     this.Show();
     this.Update();
     if (!this.IsWindowTransitionsEnabled)
     {
         base.AssociatedObject.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => this.SetOpacityTo(1)));
         return;
     }
     this.StartOpacityStoryboard();
     base.AssociatedObject.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged);
     base.AssociatedObject.Closing          += new CancelEventHandler((object argument0, CancelEventArgs argument1) => {
         if (!argument1.Cancel)
         {
             base.AssociatedObject.IsVisibleChanged -= new DependencyPropertyChangedEventHandler(this.AssociatedObjectIsVisibleChanged);
         }
     });
 }
コード例 #13
0
 public ChangeScope(GlowWindow window)
 {
     _window = window;
     _window.DeferGlowChangesCount++;
 }
コード例 #14
0
ファイル: GlowEdge.cs プロジェクト: varKeytrap/Otto.Theme
 internal GlowEdge(GlowWindow owner, Dock orientation)
 {
     _targetWindow     = owner ?? throw new ArgumentNullException(nameof(owner));
     _orientation      = orientation;
     CreatedGlowEdges += 1L;
 }
コード例 #15
0
ファイル: GlowEdge.cs プロジェクト: User-Cool/WPFDesign
 internal GlowEdge(GlowWindow targetWindow, Dock orientation)
 {
     _targetWindow       = targetWindow ?? throw new ArgumentNullException(nameof(targetWindow));
     _orientation        = orientation;
     _targetWindowHandle = new WindowInteropHelper(_targetWindow).Handle;
 }