Exemplo n.º 1
0
        private void ShapeWindow()
        {
            Layout();
            Gdk.Pixmap bitmap = new Gdk.Pixmap(GdkWindow,
                                               Allocation.Width,
                                               Allocation.Height, 1);

            Context g = CairoUtils.CreateContext(bitmap);

            DrawShape(g, Allocation.Width, Allocation.Height);
            ((IDisposable)g).Dispose();

            if (use_shape_ext)
            {
                ShapeCombineMask(bitmap, 0, 0);
            }
            else
            {
                Context rgba = CairoUtils.CreateContext(GdkWindow);
                DrawShape(rgba, Allocation.Width, Allocation.Height);
                ((IDisposable)rgba).Dispose();
                try {
                    CompositeUtils.InputShapeCombineMask(this, bitmap, 0, 0);
                } catch (EntryPointNotFoundException) {
                    System.Console.WriteLine("Warning: gtk+ version doesn't support input shapping");
                }
            }
            bitmap.Dispose();
        }
Exemplo n.º 2
0
        void ShapeWindow()
        {
            if (composited)
            {
                return;
            }

            var bitmap = new Gdk.Pixmap(GdkWindow, Allocation.Width, Allocation.Height, 1);

            Context cr = Gdk.CairoHelper.Create(bitmap);

            ShapeCombineMask(bitmap, 0, 0);
            ShapeSurface(cr, new Color(1, 1, 1));
            ShapeCombineMask(bitmap, 0, 0);
            ((IDisposable)cr).Dispose();
            bitmap.Dispose();
        }
Exemplo n.º 3
0
        private void ShapeWindow()
        {
            if (composited)
            {
                return;
            }

            Gdk.Pixmap bitmap = new Gdk.Pixmap(GdkWindow,
                                               Allocation.Width,
                                               Allocation.Height, 1);

#if CAIRO_1_2_5
            Context cr = Gdk.CairoHelper.Create(bitmap);
#else
            Context cr = CairoUtils.CreateContext(bitmap);
#endif
            ShapeCombineMask(bitmap, 0, 0);
            ShapeSurface(cr, new Color(1, 1, 1));
            ShapeCombineMask(bitmap, 0, 0);
            ((IDisposable)cr).Dispose();
            bitmap.Dispose();
        }
Exemplo n.º 4
0
        private void HideCursor()
        {
            if (GdkWindow == null)
            {
                return;
            }

            Gdk.Pixmap pixmap = Gdk.Pixmap.CreateBitmapFromData(GdkWindow, "0x0", 1, 1);
            if (pixmap == null)
            {
                return;
            }

            UpdateHiddenCursorPosition();
            cursor_is_hidden = true;

            Gdk.Color  color  = new Gdk.Color(0, 0, 0);
            Gdk.Cursor cursor = new Gdk.Cursor(pixmap, pixmap, color, color, 0, 0);

            GdkWindow.Cursor = cursor;

            pixmap.Dispose();
            cursor.Dispose();
        }
Exemplo n.º 5
0
        private void ShapeWindow()
        {
            if (composited)
                return;

            Gdk.Pixmap bitmap = new Gdk.Pixmap (GdkWindow,
                                Allocation.Width,
                                Allocation.Height, 1);

            Context cr = Gdk.CairoHelper.Create (bitmap);
            ShapeCombineMask (bitmap, 0, 0);
            ShapeSurface (cr, new Color (1, 1, 1));
            ShapeCombineMask (bitmap, 0, 0);
            ((IDisposable)cr).Dispose ();
            bitmap.Dispose ();
        }
Exemplo n.º 6
0
        protected void UpdatePreview()
        {
            thumb_image.Clear();
            FileIsGood = false;

            int size = 200, margins = 30;

            if (System.IO.File.Exists(mFilename))              // Selected item is a file
            {
                origsize_label.Markup = "";

                GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate {
                    Gdk.Pixmap pm = null;
                    Gdk.GC gc     = null;
                    Gdk.Pixbuf pb = null;
                    try
                    {
                        pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1);
                        gc = new Gdk.GC(thumb_image.GdkWindow);
                        pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));

                        RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename);

                        string idtext = "";
                        try
                        {
                            idtext += "Shot has been taken\n" +
                                      "   on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n";

                            idtext += "   with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n";
                            idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n";
                            if (rdl.Shutter > 1)
                            {
                                idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n";
                            }
                            else
                            {
                                idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n";
                            }

                            idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" +
                                      "Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n";

                            if (rdl.Artist != "")
                            {
                                idtext += "Artist: <b>" + rdl.Artist + "</b>\n";
                            }
                            if (rdl.Description != "")
                            {
                                idtext += "Description: <b>" + rdl.Description + "</b>\n";
                            }

                            Console.WriteLine(rdl.Flip);

                            // Creating the thumbnail pixbuf
                            pb = new Gdk.Pixbuf(rdl.ThumbnailData);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Can't load the thumbnail: " + ex.Message);
                            idtext += "\n<i>Can't load the thumbnail.</i>";
                        }
                        identification_label.Markup = idtext;

                        if (pb != null)
                        {
                            // Scaling the thumbnail
                            Gdk.Pixbuf pbold = pb;
                            int imgw         = pb.Width, imgh = pb.Height;
                            if (pb.Width > pb.Height)
                            {
                                pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
                            }
                            else
                            {
                                pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);
                            }

                            pbold.Dispose();

                            // Rotating the thumbnail
                            if (rdl.Flip != RawDescriptionLoader.FlipValues.None)
                            {
                                pbold = pb;

                                if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown)
                                {
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown);
                                }
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise)
                                {
                                    int t = imgw;
                                    imgw  = imgh;
                                    imgh  = t;
                                    pb    = pb.RotateSimple(Gdk.PixbufRotation.Clockwise);
                                }
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise)
                                {
                                    int t = imgw;
                                    imgw  = imgh;
                                    imgh  = t;
                                    pb    = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise);
                                }

                                pbold.Dispose();
                            }

                            origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>";
                            pm.DrawPixbuf(gc, pb, 0, 0,
                                          (size + margins) / 2 - pb.Width / 2,
                                          (size + margins) / 2 - pb.Height / 2,
                                          pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0);
                            thumb_image.SetFromPixmap(pm, null);
                            pb.Dispose();
                        }
                        FileIsGood = true;
                    }
                    catch (Exception
#if DEBUG
                           ex
#endif
                           )
                    {
#if DEBUG
                        Console.WriteLine("Exception occured during the thumbnail loading process: " + ex.Message);
#endif
                        identification_label.Wrap   = true;
                        identification_label.Markup = "<i>Cannot decode the selected file. " +
                                                      "Maybe it's corrupted or the user hasn't enough access rights to open it.</i>";
                        FileIsGood = false;
                    }
                    finally
                    {
                        if (gc != null)
                        {
                            gc.Dispose();
                        }
                        if (pm != null)
                        {
                            pm.Dispose();
                        }
                    }
                    return(false);
                }));
            }
        }
Exemplo n.º 7
0
		private void ShapeWindow ()
		{
			Layout ();
			Gdk.Pixmap bitmap = new Gdk.Pixmap (GdkWindow, 
							    Allocation.Width, 
							    Allocation.Height, 1);
			
			Context g = CairoUtils.CreateContext (bitmap);
			DrawShape (g, Allocation.Width, Allocation.Height);
			((IDisposable)g).Dispose ();

			if (use_shape_ext)
				ShapeCombineMask (bitmap, 0, 0);
			else {
				Context rgba = CairoUtils.CreateContext (GdkWindow);
				DrawShape (rgba, Allocation.Width, Allocation.Height);
				((IDisposable)rgba).Dispose ();
				try {
					CompositeUtils.InputShapeCombineMask (this, bitmap, 0,0);
				} catch (EntryPointNotFoundException) {
					System.Console.WriteLine ("Warning: gtk+ version doesn't support input shapping");
				}
			}
			bitmap.Dispose ();
		}
Exemplo n.º 8
0
        protected void UpdatePreview()
        {
            thumb_image.Clear();
            FileIsGood = false;

            int size = 200, margins = 30;

            if (System.IO.File.Exists(mFilename))  // Selected item is a file
            {
                origsize_label.Markup = "";

                GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate {

                    Gdk.Pixmap pm = null;
                    Gdk.GC gc = null;
                    Gdk.Pixbuf pb = null;
                    try
                    {
                        pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1);
                        gc = new Gdk.GC(thumb_image.GdkWindow);
                        pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));

                        RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename);

                        string idtext = "";
                        try
                        {
                            idtext += "Shot has been taken\n" +
                                      "   on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n";

                            idtext += "   with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n";
                            idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n";
                            if (rdl.Shutter > 1)
                                idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n";
                            else
                                idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n";

                            idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" +
                                      "Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n";

                            if (rdl.Artist != "") idtext += "Artist: <b>" + rdl.Artist + "</b>\n";
                            if (rdl.Description != "") idtext += "Description: <b>" + rdl.Description + "</b>\n";

                            Console.WriteLine(rdl.Flip);

                            // Creating the thumbnail pixbuf
                            pb = new Gdk.Pixbuf(rdl.ThumbnailData);

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Can't load the thumbnail: " + ex.Message);
                            idtext += "\n<i>Can't load the thumbnail.</i>";
                        }
                        identification_label.Markup = idtext;

                        if (pb != null)
                        {
                            // Scaling the thumbnail
                            Gdk.Pixbuf pbold = pb;
                            int imgw = pb.Width, imgh = pb.Height;
                            if (pb.Width > pb.Height)
                                pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
                            else
                                pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);

                            pbold.Dispose();

                            // Rotating the thumbnail
                            if (rdl.Flip != RawDescriptionLoader.FlipValues.None)
                            {
                                pbold = pb;

                                if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown)
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown);
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise)
                                {
                                    int t = imgw;
                                    imgw = imgh;
                                    imgh = t;
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Clockwise);
                                }
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise)
                                {
                                    int t = imgw;
                                    imgw = imgh;
                                    imgh = t;
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise);
                                }

                                pbold.Dispose();
                            }

                            origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>";
                            pm.DrawPixbuf(gc, pb, 0, 0,
                                          (size + margins) / 2 - pb.Width / 2,
                                          (size + margins) / 2 - pb.Height / 2,
                                          pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0);
                            thumb_image.SetFromPixmap(pm, null);
                            pb.Dispose();
                        }
                        FileIsGood = true;
                    }
                    catch (Exception
            #if DEBUG
                        ex
            #endif
                        )
                    {
            #if DEBUG
                        Console.WriteLine("Exception occured during the thumbnail loading process: " + ex.Message);
            #endif
                        identification_label.Wrap = true;
                        identification_label.Markup = "<i>Cannot decode the selected file. "+
                                                      "Maybe it's corrupted or the user hasn't enough access rights to open it.</i>";
                        FileIsGood = false;
                    }
                    finally
                    {
                        if (gc != null) gc.Dispose();
                        if (pm != null) pm.Dispose();
                    }
                    return false;
                }));
            }
        }