Esempio n. 1
0
 public static void UpdateStickyWindows()
 {
     foreach (var stickyWindow in Active)
     {
         stickyWindow.StickyWindows.Clear();
     }
     foreach (var stickyWindow in Active)
     {
         if (!stickyWindow.IsSticky || !stickyWindow.Adapter.IsVisible)
         {
             continue;
         }
         var from = stickyWindow.Adapter.Bounds;
         foreach (var snappingWindow in Active)
         {
             if (object.ReferenceEquals(stickyWindow, snappingWindow))
             {
                 continue;
             }
             if (snappingWindow.IsSticky)
             {
                 //Don't stick sticky windows together or they can't be separated!
                 continue;
             }
             var to        = snappingWindow.Adapter.Bounds;
             var direction = SnappingHelper.IsSnapped(from, to, 0);
             if (direction == SnapDirection.None)
             {
                 continue;
             }
             stickyWindow.StickyWindows[snappingWindow] = direction;
             snappingWindow.StickyWindows[stickyWindow] = SnappingHelper.IsSnapped(to, from);
         }
     }
 }
Esempio n. 2
0
        protected virtual SnapDirection SnapToWindows(Point mousePosition, ref Rectangle bounds, bool resize)
        {
            var direction = SnapDirection.None;

            foreach (var snappingWindow in Active)
            {
                if (object.ReferenceEquals(snappingWindow, this))
                {
                    continue;
                }
                if (!snappingWindow.Adapter.IsVisible)
                {
                    continue;
                }
                var to = snappingWindow.Adapter.Bounds;
                if (this.StickyWindows.ContainsKey(snappingWindow))
                {
                    if (resize)
                    {
                        if (this.IsStuck(snappingWindow, this.StickyWindows[snappingWindow]))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!this.IsSticky && SnappingHelper.IsSnapped(bounds, to) == SnapDirection.None)
                        {
                            this.StickyWindows.Remove(snappingWindow);
                            snappingWindow.StickyWindows.Remove(this);
                            Logger.Write(this, LogLevel.Debug, "Unstick.");
                        }
                        continue;
                    }
                }
                direction |= SnappingHelper.Snap(ref bounds, to, resize);
            }
            return(direction);
        }