/// <summary>
        /// this function modifies a window shape
        /// </summary>
        /// <param name="bmp">
        /// the bitmap that has the shape of the window. <see cref="System.Drawing.Bitmap"/>
        /// </param>
        /// <param name="window">
        /// the window to apply the shape change <see cref="Gtk.Window"/>
        /// </param>
        /// <returns>
        /// true if it succeded, either return false <see cref="System.Boolean"/>
        /// </returns>
        public static bool ModifyWindowShape(System.Drawing.Bitmap bmp, Gtk.Window window)
        {
            bool ret = false;

            try
            {
                //save bitmap to stream
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                //verry important: put stream on position 0
                stream.Position = 0;
                //get the pixmap mask
                Gdk.Pixbuf buf = new Gdk.Pixbuf(stream, bmp.Width, bmp.Height);
                Gdk.Pixmap map1, map2;
                buf.RenderPixmapAndMask(out map1, out map2, 255);
                //shape combine window
                window.ShapeCombineMask(map2, 0, 0);
                //dispose
                buf.Dispose();
                map1.Dispose();
                map2.Dispose();
                bmp.Dispose();
                //if evrything is ok return true;
                ret = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
            }
            return(ret);
        }
        private void Refresh(bool Draw)
        {
            Graphics offScreenGraphics;
            Bitmap   offscreenBitmap;

            offscreenBitmap   = new Bitmap(BackgroundBitmap.Width, BackgroundBitmap.Height);
            offScreenGraphics = Graphics.FromImage(offscreenBitmap);

            if (BackgroundBitmap != null)
            {
                offScreenGraphics.DrawImage(BackgroundBitmap, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
            }

            DrawCloseButton(ref offScreenGraphics);
            DrawText(ref offScreenGraphics);


            if (Gdk.Display.Default.SupportsShapes)
            {
                background = modFunctions.ImageToPixbuf(offscreenBitmap).AddAlpha(true, transparencyKey.R, transparencyKey.G, transparencyKey.B);
                Gdk.Pixmap pixmap = null;
                Gdk.Pixmap mask   = null;
                this.WidthRequest  = background.Width;
                this.HeightRequest = background.Height;
                background.RenderPixmapAndMask(out pixmap, out mask, 2);
                this.ShapeCombineMask(mask, 0, 0);
            }
            else
            {
                if (this.GdkWindow == null)
                {
                    background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                }
                else if (this.GdkWindow.FrameExtents.Location.X <= 0 | this.GdkWindow.FrameExtents.Location.Y <= 0)
                {
                    background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                }
                else
                {
                    if (ScreenTransBitmap == null)
                    {
                        ScreenTransBitmap = modFunctions.GetScreenRect(new Rectangle(this.GdkWindow.FrameExtents.Location.X, this.GdkWindow.FrameExtents.Location.Y, offscreenBitmap.Size.Width, offscreenBitmap.Size.Height));
                    }
                    if (ScreenTransBitmap == null)
                    {
                        background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                    }
                    else
                    {
                        background = modFunctions.ImageToPixbuf(modFunctions.ReplaceColors(offscreenBitmap, transparencyKey, ScreenTransBitmap));
                    }
                }
                this.WidthRequest  = background.Width;
                this.HeightRequest = background.Height;
            }
            if (Draw & titleText != null)
            {
                GdkWindow.DrawPixbuf(Style.BackgroundGC(State), background, 0, 0, 0, 0, background.Width, background.Height, Gdk.RgbDither.None, 0, 0);
            }
        }
 /// <summary>
 /// this function modifies a window shape
 /// </summary>
 /// <param name="bmp">
 /// the bitmap that has the shape of the window. <see cref="System.Drawing.Bitmap"/>
 /// </param>
 /// <param name="window">
 /// the window to apply the shape change <see cref="Gtk.Window"/>
 /// </param>
 /// <returns>
 /// true if it succeded, either return false <see cref="System.Boolean"/>
 /// </returns>
 public static bool ModifyWindowShape( System.Drawing.Bitmap bmp, Gtk.Window window )
 {
     bool ret = false;
     try
     {
         //save bitmap to stream
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         bmp.Save( stream, System.Drawing.Imaging.ImageFormat.Png );
         //verry important: put stream on position 0
         stream.Position     = 0;
         //get the pixmap mask
         Gdk.Pixbuf buf      = new Gdk.Pixbuf( stream, bmp.Width, bmp.Height );
         Gdk.Pixmap map1, map2;
         buf.RenderPixmapAndMask( out map1, out map2, 255 );
         //shape combine window
         window.ShapeCombineMask( map2, 0, 0 );
         //dispose
         buf.Dispose();
         map1.Dispose();
         map2.Dispose();
         bmp.Dispose();
         //if evrything is ok return true;
         ret = true;
     }
     catch(Exception ex)
     {
         Console.WriteLine( ex.Message + "\r\n" + ex.StackTrace );
     }
     return ret;
 }
Beispiel #4
0
        public static void setBackgroundImage(Gtk.Window win, Gdk.Pixbuf image)
        {
            Gdk.Pixmap pixmap, pixmap_mask;
            image.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255);
            var style = win.Style;

            style.SetBgPixmap(StateType.Normal, pixmap);
            win.Style = style;
        }
        public SparkleAbout()
            : base("")
        {
            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                HideAll ();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = _("About SparkleShare");
            AppPaintable   = true;

            string image_path = new string [] {SparkleUI.AssetsPath,
                 "pixmaps", "about.png"}.Combine ();

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            Controller = new SparkleAboutController ();

            Controller.NewVersionEvent += delegate (string new_version) {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#f57900'>{0}</span>",
                        String.Format (_("A newer version ({0}) is available!"), new_version));

                    this.updates.ShowAll ();
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#4e9a06'>{0}</span>",
                        _("You are running the latest version."));

                    this.updates.ShowAll ();
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#4e9a06'>{0}</span>",
                        _("Checking for updates..."));

                    this.updates.ShowAll ();
                });
            };

            this.CreateAbout ();
        }
Beispiel #6
0
        public SparkleAbout() : base("")
        {
            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                HideAll();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size(600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = _("About SparkleShare");
            AppPaintable   = true;

            string image_path = new string [] { SparkleUI.AssetsPath,
                                                "pixmaps", "about.png" }.Combine();

            Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            Controller = new SparkleAboutController();

            Controller.NewVersionEvent += delegate(string new_version) {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#f57900'>{0}</span>",
                                                        String.Format(_("A newer version ({0}) is available!"), new_version));

                    this.updates.ShowAll();
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        _("You are running the latest version."));

                    this.updates.ShowAll();
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        _("Checking for updates..."));

                    this.updates.ShowAll();
                });
            };

            this.CreateAbout();
        }
Beispiel #7
0
        public PryanetAbout()
            : base("")
        {
            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-pryanetshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About PryanetShare";
            AppPaintable   = true;

            string image_path = new string [] { PryanetUI.AssetsPath, "pixmaps", "about.png" }.Combine ();

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            CreateAbout ();

            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) {

                    Controller.WindowClosed ();
                }
            };

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                    HideAll ();
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                    ShowAll ();
                    Present ();
                });
            };

            Controller.UpdateLabelEvent += delegate (string text) {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>", text);
                    this.updates.ShowAll ();
                });
            };
        }
Beispiel #8
0
        public SparkleAbout() : base("")
        {
            DefaultSize    = new Gdk.Size(600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About SparkleShare";
            AppPaintable   = true;

            string image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "about.png" }.Combine();

            Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            CreateAbout();


            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };

            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.UpdateLabelEvent += delegate(string text) {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>", text);
                    this.updates.ShowAll();
                });
            };
        }
Beispiel #9
0
        public About() : base(string.Empty)
        {
            this.DeleteEvent += delegate(object o, DeleteEventArgs args) {
                this.Controller.WindowClosed();
                args.RetVal = true;
            };

            this.DefaultSize    = new Gdk.Size(600, 260);
            this.Resizable      = false;
            this.BorderWidth    = 0;
            this.IconName       = "dataspacesyc-folder";
            this.WindowPosition = WindowPosition.Center;
            this.Title          = string.Format(Properties_Resources.About, Properties_Resources.ApplicationName);
            this.AppPaintable   = true;

            string image_path = UIHelpers.GetImagePath("about.png");

            this.Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            this.CreateAbout();

            this.Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    this.HideAll();
                });
            };

            this.Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    this.ShowAll();
                    this.Present();
                });
            };
        }
Beispiel #10
0
        public About() : base(string.Empty) {
            this.DeleteEvent += delegate(object o, DeleteEventArgs args) {
                this.Controller.WindowClosed();
                args.RetVal = true;
            };

            this.DefaultSize    = new Gdk.Size(600, 260);
            this.Resizable      = false;
            this.BorderWidth    = 0;
            this.IconName       = "dataspacesyc-folder";
            this.WindowPosition = WindowPosition.Center;
            this.Title          = string.Format(Properties_Resources.About, Properties_Resources.ApplicationName);
            this.AppPaintable   = true;

            string image_path = UIHelpers.GetImagePath("about.png");

            this.Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            this.CreateAbout();

            this.Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    this.HideAll();
                });
            };

            this.Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    this.ShowAll();
                    this.Present();
                });
            };
        }
Beispiel #11
0
        public About () : base ("")
        {
            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-cmissync";
            WindowPosition = WindowPosition.Center;
            Title          = Properties_Resources.About;
            AppPaintable   = true;

            string image_path = System.IO.Path.Combine(GUI.AssetsPath, "pixmaps", "about.png");

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            CreateAbout ();

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                        HideAll ();
                        });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                        ShowAll ();
                        Present ();
                        });
            };

            Controller.NewVersionEvent += delegate (string new_version) {
                Application.Invoke (delegate {
                        this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                            string.Format (Properties_Resources.NewVersionAvailable, new_version));

                        this.updates.ShowAll ();
                        });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke (delegate {
                        this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                            Properties_Resources.RunningLatestVersion);

                        this.updates.ShowAll ();
                        });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke (delegate {
                        // this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                        //    "Checking for updates...");

                        this.updates.ShowAll ();
                        });
            };
        }
Beispiel #12
0
        public About() : base("")
        {
            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size(600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "dataspacesyc-folder";
            WindowPosition = WindowPosition.Center;
            Title          = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName);
            AppPaintable   = true;

            string image_path = System.IO.Path.Combine(UI.AssetsPath, "pixmaps", "about.png");

            Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            CreateAbout();

            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.NewVersionEvent += delegate(string new_version) {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        string.Format(Properties_Resources.NewVersionAvailable, new_version));

                    this.updates.ShowAll();
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        Properties_Resources.RunningLatestVersion);

                    this.updates.ShowAll();
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke(delegate {
                    // this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                    //    "Checking for updates...");

                    this.updates.ShowAll();
                });
            };
        }