public static void MoveBy(Gtk.Window window, int x, int y)
        {
            int winX, winY;

            window.GetPosition(out winX, out winY);
            window.Move(winX + x, winY + y);
        }
        public static void Shake(Gtk.Window window, int times)
        {
            int winX, winY;

            Gtk.Application.Invoke(delegate {
                window.GetPosition(out winX, out winY);

                for (int i=10; i > 0; i--) {
                    for (int j=times; j > 0; j--) {
                        MoveBy(window, 0, i);
                        TimeUtils.Sleep(5);

                        MoveBy(window, i, 0);
                        TimeUtils.Sleep(5);

                        MoveBy(window, 0, -i);
                        TimeUtils.Sleep(5);

                        MoveBy(window, -i, 0);
                        TimeUtils.Sleep(5);
                    }
                }

                window.Move(winX, winY);
            });
        }
示例#3
0
        public static void CenterChildToParent(Gtk.Window parent,Gtk.Window child)
        {
            if (parent==null || child == null)
                return;

            int parentX = 0;
            int parentY = 0;
            int parentW = 0;
            int parentH = 0;

            parent.GetPosition(out parentX,out parentY);
            parent.GetSize(out parentW,out parentH);

            int w = 0;
            int h = 0;
            child.GetSize(out w,out h);

            var x = parentX + Convert.ToInt32( (parentW-w) / 2);
            var y = parentY + Convert.ToInt32( (parentH-h) / 2);

            if (x<=0) x =0;
            if (y<=0) y =0;

            child.Move(x,y);
            child.KeepAbove = true;
        }
        public static void FadeOut(Gtk.Window window, uint millisecondsTimeout)
        {
            int screenHeight = window.Screen.Height + 10;
            int winX, winY;

            do {
                window.GetPosition(out winX, out winY);
                window.Move(winX, winY + 1);
                //System.Threading.Thread.Sleep(millisecondsTimeout);
                TimeUtils.Sleep(millisecondsTimeout);
            } while (winY <= screenHeight);
        }
        public static void FadeIn(Gtk.Window window, uint millisecondsTimeout)
        {
            int screenHeight = window.Screen.Height;
            int winWidth, winHeight;
            int winX, winY;

            // Hide Window At Bottom of The Screen
            window.GetPosition(out winX, out winY);
            //int firstWinY = winY;
            window.GetSize(out winWidth, out winHeight);
            window.Move(winX, screenHeight);

            // Rise Window
            do {
                window.GetPosition(out winX, out winY);
                window.Move(winX, winY - 1);
                //System.Threading.Thread.Sleep(millisecondsTimeout);
                TimeUtils.Sleep(millisecondsTimeout);
            //} while (winY >= firstWinY);
            } while (winY > (screenHeight - winHeight));
        }
 /// <summary>Centers a window relative to its parent.</summary>
 static void CenterWindow(Gtk.Window child, Gtk.Window parent)
 {
     child.Child.Show ();
     int w, h, winw, winh, x, y, winx, winy;
     if (child.Visible)
         child.GetSize (out w, out h);
     else {
         w = child.DefaultSize.Width;
         h = child.DefaultSize.Height;
     }
     parent.GetSize (out winw, out winh);
     parent.GetPosition (out winx, out winy);
     x = Math.Max (0, (winw - w) /2) + winx;
     y = Math.Max (0, (winh - h) /2) + winy;
     child.Move (x, y);
 }
示例#7
0
 /// <summary>Centers a window relative to its parent.</summary>
 static void CenterWindow(Gtk.Window child, Gtk.Window parent)
 {
     child.Child.Show ();
     int w, h, winw, winh, x, y, winx, winy;
     child.GetSize (out w, out h);
     parent.GetSize (out winw, out winh);
     parent.GetPosition (out winx, out winy);
     x = Math.Max (0, (winw - w) /2) + winx;
     y = Math.Max (0, (winh - h) /2) + winy;
     child.Move (x, y);
 }