Example #1
0
        public void Relocate(int x, int y, int w, int h, bool animate)
        {
            Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry(Screen, Screen.GetMonitorAtPoint(x, y));
            if (x < geometry.X)
            {
                x = geometry.X;
            }
            if (x + w > geometry.Right)
            {
                x = geometry.Right - w;
            }
            if (y < geometry.Y)
            {
                y = geometry.Y;
            }
            if (y > geometry.Bottom - h)
            {
                y = geometry.Bottom - h;
            }

            if (x != rx || y != ry || w != rw || h != rh)
            {
                Resize(w, h);
                Move(x, y);

                rx = x; ry = y; rw = w; rh = h;

                if (anim != 0)
                {
                    GLib.Source.Remove(anim);
                    anim = 0;
                }
                if (animate && w < 150 && h < 150)
                {
                    int sa = 7;
                    Move(rx - sa, ry - sa);
                    Resize(rw + sa * 2, rh + sa * 2);
                    anim = GLib.Timeout.Add(10, RunAnimation);
                }
            }
        }