Esempio n. 1
0
        void HandleMiniScreenButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            if (args.Event.Button == 3)
            {
                MiniScreenSettings();
            }
            else
            {
                //Console.WriteLine("Press");
                Llista_Punts.Clear();
                int    px, py;                                                  // Posició de la minipantalla
                int    miniscreen_size_x, miniscreen_size_y;                    // dimensions de la minipantalla
                double pos_mouse_x, pos_mouse_y;                                // posició del ratolí en el clic
                double pos_mouse_x_global, pos_mouse_y_global;                  // posició del ratolí en el clic referent al global de pa pantalla

                // Agafem les dimensions de la minipantalla
                MiniScreen.GetSizeRequest(out miniscreen_size_x, out miniscreen_size_y);

                // Agafem la posició del ratolí en el moment del clic
                pos_mouse_x = args.Event.X;
                pos_mouse_y = args.Event.Y;

                // Agafem la posició de la finestra
                //Gdk.Window root=Gdk.Global.ActiveWindow;
                //root.GetPosition(out px, out py);
                //LliureXMiniScreen.MainClass.win.GetPosition(out px, out py);
                LliureXMiniScreen.Core.getCore().win.GetPosition(out px, out py);

                // Posició global del ratolí en el clic (recalculada)
                pos_mouse_x_global = pos_mouse_x * ScreenWidth / this.MiniScreenWidth;
                pos_mouse_y_global = pos_mouse_y * ScreenHeight / this.MiniScreenHeight;

                // Mostrem la informació
                Console.WriteLine("Screen From: (" + px + "," + py + ") to (" + (px + miniscreen_size_x) + "," + (py + miniscreen_size_y) + ")");
                Console.WriteLine("Pointer at: (" + pos_mouse_x + "," + pos_mouse_y + ")");
                Console.WriteLine("Pointer at: (" + pos_mouse_x_global + "," + pos_mouse_y_global + ")");

                // Controlem si el clic és dins de la seua finestra de miniscreen

                if (pos_mouse_x_global > px && pos_mouse_x_global < px + miniscreen_size_x &&
                    pos_mouse_y_global > py && pos_mouse_y_global < py + miniscreen_size_y)
                {
                    Console.WriteLine("ESTA DINS!!!");
                    Init();
                }
                else
                {
                    if (args.Event.Button == 1)                  // Si el botó era l'1...
                    {
                        BtnPressed = true;                       // Indiquem que el botó està polsat
                        Llista_Punts.Add(new Gdk.Point((int)pos_mouse_x, (int)pos_mouse_y));
                    }
                }
            }
        }
Esempio n. 2
0
        private bool DrawPreview()
        {
            Console.WriteLine(OldRefreshRate + "--------" + RefreshRate);

            if (OldRefreshRate == RefreshRate)
            {
                if (!moving_mouse)
                {
                    Console.WriteLine("Drawing with ref rate..." + RefreshRate);

                    int width  = 0;
                    int height = 0;

                    if (!BtnPressed)
                    {
                        try{
                            root = Gdk.Global.DefaultRootWindow;

                            // get its width and height
                            root.GetSize(out width, out height);
                            // create a new pixbuf from the root window
                            //try{
                            //LliureXMiniScreen.Core.getCore().win.Hide();
                            screenshot = Gdk.Pixbuf.FromDrawable(root, root.Colormap, 0, 0, 0, 0, width, height);

                            int miniscreen_size_x, miniscreen_size_y;                                   // dimensions de la minipantalla
                            int px, py, win_px, win_py;
                            if (LliureXMiniScreen.Core.getCore().win != null)
                            {
                                LliureXMiniScreen.Core.getCore().win.GetPosition(out win_px, out win_py);
                                MiniScreen.GetSizeRequest(out miniscreen_size_x, out miniscreen_size_y);
                                px = MiniScreenPosition * (width - miniscreen_size_x);
                                py = height - miniscreen_size_y;

                                Console.WriteLine("Dibuixe en: (" + px + "," + py + ") una finestra de " + miniscreen_size_x + "x" + miniscreen_size_y);
                                if (px != win_px || py != win_py)
                                {
                                    LliureXMiniScreen.Core.getCore().win.Move(px, py);
                                }

                                // Amaguem la minipantallla

                                // PATCH
                                //Gdk.Pixbuf HiddenMiniScreen=new Pixbuf("/usr/share/icons/LliureX-Accessibility/llx-miniscreen-hide.png", miniscreen_size_x, miniscreen_size_y);
                                HiddenMiniScreen = new Pixbuf(InitScreenshot, px, py, MiniScreenWidth, MiniScreenHeight);

                                // END PATCH

                                Console.WriteLine("->" + HiddenMiniScreen.Width + " " + HiddenMiniScreen.Height);
                                HiddenMiniScreen = HiddenMiniScreen.ScaleSimple(miniscreen_size_x, miniscreen_size_y, InterpType.Bilinear);
                                HiddenMiniScreen.CopyArea(0, 0, miniscreen_size_x, miniscreen_size_y,
                                                          screenshot, px, py);
                            }

                            //LliureXMiniScreen.Core.getCore().win.Activate();
                            //	LliureXMiniScreen.Core.getCore().win.Show();

                            /*} catch (Exception exc){
                             *      Console.WriteLine("Excepció...: "+exc);
                             * }*/

                            //Gdk.Pixbuf screenshot = Gdk.Pixbuf.FromDrawable(root, root.Colormap, 0,0, 0,0, width, height);
                            //
                            // Cal inserir una imatge al screenshot per poder ocultar la minifinestra a la captura!!!
                            //
                            screenshot = screenshot.ScaleSimple(this.MiniScreenWidth, this.MiniScreenHeight, InterpType.Bilinear);
                        }catch (Exception exc) {
                            Console.WriteLine("Excepció...: " + exc);
                        }
                    }

                    // Creem la imatge per emmagatzemar el pixbuf

                    Gtk.Image MyImage = new Gtk.Image();
                    MyImage.Pixbuf = screenshot;

                    // Agafem les dimensions de la finestra
                    Gdk.GC gc = ((Gtk.DrawingArea)MiniScreen).Style.TextGC(Gtk.StateType.Normal);

                    MiniScreen.GdkWindow.DrawPixbuf(gc, MyImage.Pixbuf, 0, 0, 0, 0, this.MiniScreenWidth, this.MiniScreenHeight, Gdk.RgbDither.Max, 0, 0);

                    Cairo.Context context = Gdk.CairoHelper.Create(MiniScreen.GdkWindow);

                    if (BtnPressed)
                    {
                        double r = double.Parse((PathColor.Red).ToString()) / 65535;
                        double g = double.Parse((PathColor.Green).ToString()) / 65535;
                        double b = double.Parse((PathColor.Blue).ToString()) / 65535;

                        context.Color = new Cairo.Color(r, g, b);

                        try{
                            if (Llista_Punts.Count > 1)
                            {
                                context.LineWidth = 3;
                                context.MoveTo(Llista_Punts[0].X, Llista_Punts[0].Y);
                                foreach (Gdk.Point p in Llista_Punts)
                                {
                                    context.LineTo(p.X, p.Y);
                                    context.MoveTo(p.X, p.Y);
                                }
                            }
                            context.Stroke();
                            context.FillPreserve();
                        }

                        catch (Exception ex) {
                            Console.WriteLine("Exception: " + ex.Message);
                        }
                    }

                    ((IDisposable)context.Target).Dispose();
                    ((IDisposable)context).Dispose();


                    return(true);
                }
            }
            else
            {
                //if(RefreshRate!=OldRefreshRate){
                Console.WriteLine("Change refresg rate!!!");
                OldRefreshRate = RefreshRate;
                return(false);
                //}
            }
            return(false);
        }
Esempio n. 3
0
        void HandleEventbox1ButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
        {
            moving_mouse = true;           // Indiquem que s'està movent el ratolí (per tant no redibuixarem)
            //Console.WriteLine("RELEASEEE!!!");

            int    px, py;                                 // Posició de la minipantalla
            int    miniscreen_size_x, miniscreen_size_y;   // dimensions de la minipantalla
            double pos_mouse_x, pos_mouse_y;               // posició del ratolí en el clic
            double pos_mouse_x_global, pos_mouse_y_global; // posició del ratolí en el clic referent al global de pa pantalla

            /*line_x0=0; // Amaguem la línia
             * line_y0=0;
             * line_xf=0;
             * line_yf=0;*/

            // Agafem les dimensions de la minipantalla
            MiniScreen.GetSizeRequest(out miniscreen_size_x, out miniscreen_size_y);

            // Agafem la posició del ratolí en el moment del release
            pos_mouse_x = args.Event.X;
            pos_mouse_y = args.Event.Y;

            // Afegim a la llista la última posició
            Llista_Punts.Add(new Gdk.Point((int)pos_mouse_x, (int)pos_mouse_y));

            // Agafem la posició de la finestra
            //Gdk.Window root=Gdk.Global.ActiveWindow;
            //root.GetPosition(out px, out py);
            //LliureXMiniScreen.MainClass.win.GetPosition(out px, out py);
            LliureXMiniScreen.Core.getCore().win.GetPosition(out px, out py);



            // Posició global del ratolí en el clic (recalculada)
            pos_mouse_x_global = pos_mouse_x * ScreenWidth / this.MiniScreenWidth;
            pos_mouse_y_global = pos_mouse_y * ScreenHeight / this.MiniScreenHeight;

            // Mostrem la informació
            Console.WriteLine("RELEASE: Screen From: (" + px + "," + py + ") to (" + (px + miniscreen_size_x) + "," + (py + miniscreen_size_y) + ")");
            Console.WriteLine("RELEASE: Pointer at: (" + pos_mouse_x + "," + pos_mouse_y + ")");
            Console.WriteLine("RELEASE: Pointer at: (" + pos_mouse_x_global + "," + pos_mouse_y_global + ")");

            if (args.Event.Button == 1)           // Si el botó era l'1...
            // Movem el ratolí en funció de la llista...

            {
                Console.WriteLine("N PUNTS: " + Llista_Punts.Count);
                if (Llista_Punts.Count > 3)
                {
                    //Console.WriteLine("N PUNT 1: "+Llista_Punts[0].X+","+Llista_Punts[0].Y);
                    //Console.WriteLine("N PUNT 2: "+Llista_Punts[1].X+","+Llista_Punts[1].Y);
                    //Console.WriteLine("N PUNT 3: "+Llista_Punts[2].X+","+Llista_Punts[2].Y);


                    Process p = new Process();
                    p.StartInfo.FileName = "xdotool";

                    // Alliberem el ratolí
                    //	p.StartInfo.Arguments = " mouseup 1  ";
                    //	p.Start();
                    //	p.WaitForExit();



                    // DESACTIVEM ELS RATOLINS // PATCH 2012
                    foreach (String [] device in Input_Devices_List)
                    {
                        ExecuteCommandSync("xinput", "set-prop " + device[0] + " " + device[1] + " 0");
                    }



                    Console.WriteLine("Posicionant en: " + Llista_Punts[0].X * ScreenWidth / this.MiniScreenWidth + " " + Llista_Punts[0].Y * ScreenHeight / this.MiniScreenHeight);
                    p.StartInfo.Arguments = " mousemove  " + Llista_Punts[0].X * ScreenWidth / this.MiniScreenWidth + " " + Llista_Punts[0].Y * ScreenHeight / this.MiniScreenHeight;
                    p.Start();
                    p.WaitForExit();



                    // Click inicial:
                    p.StartInfo.Arguments = " mousedown 1 ";
                    p.Start();
                    p.WaitForExit();

                    foreach (Gdk.Point pt in Llista_Punts)
                    {
                        Console.WriteLine("Movint to: " + pt.X * ScreenWidth / this.MiniScreenWidth + " " + pt.Y * ScreenHeight / this.MiniScreenHeight);
                        p.StartInfo.Arguments = " mousemove  " + pt.X * ScreenWidth / this.MiniScreenWidth + " " + pt.Y * ScreenHeight / this.MiniScreenHeight;
                        p.Start();
                        p.WaitForExit();
                    }
                    p.StartInfo.Arguments = " mouseup 1  ";
                    p.Start();
                    p.WaitForExit();


                    // Reposicionament del ratolí en la minipantalla
                    double finalx, finaly;
                    finalx = px + pos_mouse_x;
                    finaly = py + pos_mouse_y;

                    Console.WriteLine("px: " + px + " pos_mouse_x: " + pos_mouse_x);
                    Console.WriteLine("px: " + py + " pos_mouse_x: " + pos_mouse_y);


                    p.StartInfo.Arguments = "mousemove " + finalx + " " + finaly;


                    p.Start();
                    p.WaitForExit();
                    p.Close();

                    Llista_Punts.Clear();


                    // REACTIVEM EL RATOLI // PATCH 2012
                    foreach (String [] device in Input_Devices_List)
                    {
                        ExecuteCommandSync("xinput", "set-prop " + device[0] + " " + device[1] + " 1");
                    }
                }
                else
                {
                    // Si només hi ha un clic...
                    if (Llista_Punts.Count > 0)
                    {
                        Console.WriteLine("Click*****************************");

                        Process p = new Process();
                        p.StartInfo.FileName = "xdotool";

                        // Alliberem el ratolí
                        //p.StartInfo.Arguments = " mouseup 1  ";
                        //p.Start();
                        //p.WaitForExit();

                        Console.WriteLine("Movint INIT to: " + Llista_Punts[0].X * ScreenWidth / this.MiniScreenWidth + " " + Llista_Punts[0].Y * ScreenHeight / this.MiniScreenHeight);
                        p.StartInfo.Arguments = " mousemove  " + Llista_Punts[0].X * ScreenWidth / this.MiniScreenWidth + " " + Llista_Punts[0].Y * ScreenHeight / this.MiniScreenHeight;
                        p.Start();
                        p.WaitForExit();

                        // Click:
                        p.StartInfo.Arguments = " click 1 ";
                        p.Start();
                        p.WaitForExit();

                        // Reposicionament del ratolí en la minipantalla
                        double finalx, finaly;
                        finalx = px + pos_mouse_x;
                        finaly = py + pos_mouse_y;

                        p.StartInfo.Arguments = "mousemove " + finalx + " " + finaly;

                        p.Start();
                        p.WaitForExit();
                        p.Close();
                        Llista_Punts.Clear();
                    }
                }

                // Restaurem el botó
            }
            BtnPressed   = false;         // Alliberem el botó es faça on es faça
            moving_mouse = false;         // Hem acabat de mouse el ratoló, podem redibuixar
        }