示例#1
0
        public static unsafe PixbufAnimation NewFromResource(string resource_path)
        {
            IntPtr          native_resource_path = GLib.Marshaller.StringToPtrGStrdup(resource_path);
            IntPtr          error  = IntPtr.Zero;
            PixbufAnimation result = new PixbufAnimation(gdk_pixbuf_animation_new_from_resource(native_resource_path, out error));

            GLib.Marshaller.Free(native_resource_path);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
示例#2
0
        public static unsafe PixbufAnimation NewFromFileUtf8(string filename)
        {
            IntPtr          native_filename = GLib.Marshaller.StringToPtrGStrdup(filename);
            IntPtr          error           = IntPtr.Zero;
            PixbufAnimation result          = new PixbufAnimation(gdk_pixbuf_animation_new_from_file_utf8(native_filename, out error));

            GLib.Marshaller.Free(native_filename);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
        Gdk.PixbufAnimation animation = Gdk.PixbufAnimation.LoadFromResource("FxPicasaWebAlbumDownloader.loading.gif");
        albumList.Sensitive               = false;
        downloadButton.Sensitive          = false;
        selectDestinationFolder.Sensitive = false;
        imageLoading.Animation            = animation;
        imageLoading.Visible              = false;
        progressBar.Visible               = false;
        selectDestinationFolder.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
        Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
        string  ver     = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);

        this.Title     += " (v" + ver + ")";
        this.FocusChain = new Widget[] { albumUser, checkAlbumsButton, albumList, downloadButton, selectDestinationFolder };
    }
    /// <summary>
    /// Sets up interface.
    /// </summary>
    protected void SetUpInterface()
    {
        // Set up TreeView
        this.tvResults.AppendColumn("Status", new CellRendererText(), "text", 0);
        this.tvResults.AppendColumn("Timestamp", new CellRendererText(), "text", 1);

        // Set Up TreeStore
        TreeStore resultListStore = new TreeStore(typeof(string), typeof(string));

        resultListStore.SetSortFunc(0, CompareURLs);
        resultListStore.SetSortColumnId(0, SortType.Ascending);

        // Bind the TreeStore to the TreeView
        this.tvResults.Model = resultListStore;

        // Create a Bold and Red TextTag
        TextTag tagBold = new TextTag("bold");

        tagBold.Weight     = Pango.Weight.Bold;
        tagBold.Foreground = "red";
        // Add the TextTag to the TextView
        this.txtURLs.Buffer.TagTable.Add(tagBold);

        // Creation of the StatusIcon
        trayIcon         = StatusIcon.NewFromStock(Stock.DialogQuestion);
        trayIcon.Visible = true;

        // Show/Hide the window (even from the Panel/Taskbar) when the TrayIcon has been clicked.
        trayIcon.Activate += delegate {
            this.Visible = !this.Visible;
        };
        // Show a pop up menu when the icon has been right clicked.
        //trayIcon.PopupMenu += OnTrayIconPopup;

        // A Tooltip for the Icon
        trayIcon.Tooltip = "Website Checker";

        // Loader icon
        Gdk.PixbufAnimation pba = Gdk.PixbufAnimation.LoadFromResource("WebsiteChecker.ajax-loader.gif");
        this.imgLoading.PixbufAnimation = pba;

        this.tvResults.Model.RowInserted += HandleTvResultsModelhandleRowInserted;
    }
 public iFolderApplication(string[] args)
     : base("ifolder", "1.0", Modules.UI, args)
 {
     Util.InitCatalog();
        Util.SetQuitiFolderDelegate(new QuitiFolderDelegate(QuitiFolder));
        tIcon = new TrayIcon("iFolder");
        bCollectionIsSynchronizing = false;
        currentIconAnimationDirection = 0;
        eBox = new EventBox();
        eBox.ButtonPressEvent +=
     new ButtonPressEventHandler(trayapp_clicked);
        RunningPixbuf =
      new Pixbuf(Util.ImagesPath("ifolder24.png"));
        StartingPixbuf =
      new Pixbuf(Util.ImagesPath("ifolder-startup.png"));
        StoppingPixbuf =
      new Pixbuf(Util.ImagesPath("ifolder-shutdown.png"));
        DownloadingPixbuf =
      new Gdk.PixbufAnimation(Util.ImagesPath("ifolder24.gif"));
        UploadingPixbuf =
      new Gdk.PixbufAnimation(Util.ImagesPath("ifolder24-upload.gif"));
        gAppIcon = new Gtk.Image(RunningPixbuf);
        eBox.Add(gAppIcon);
        tIcon.Add(eBox);
        tIcon.ShowAll();
        LoginDialog = null;
        collectionSynchronizing = null;
        synchronizationErrors = new Hashtable();
        iFolderStateChanged = new Gtk.ThreadNotify(
        new Gtk.ReadyEvent(OniFolderStateChanged));
        simiasManager = Util.CreateSimiasManager(args);
 }
示例#6
0
 public FormsImage(PixbufAnimation animation)
     : base(animation)
 {
 }
示例#7
0
 public static Gdk.PixbufAnimation StreamToPixbufAnim(Bitmap image)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
         stream.Position = 0;
         Gdk.PixbufAnimation pixbuf = new Gdk.PixbufAnimation(stream);
         return pixbuf;
     }
 }
示例#8
0
        protected void ChangeImageThread()
        {
            PixbufAnimation animation = null;
            PixbufAnimationIter animationIter = null;
            int imageWidth = 0;
            int imageHeight = 0;
            bool isResizeNeeded = false;
            bool isDisposeNeeded = false;
            bool isOldDisposeNeeded = false;
            string activeImage = "";
            string currentImage = "";

            while (!isShutdown) {

                try {

                    if (DateTime.Now > DateTime.Parse("08/01/2015")) {
                        activeImage = GetImage(DateTime.Now);
                    }

                    DateTime start;

                    if (currentImage != activeImage) {
                        Console.WriteLine("Image changed to " + activeItem);
                        currentImage = activeImage;

                        if (animationIter != null) {
                            animationIter.Dispose();
                            animationIter = null;
                        }
                        if (animation != null) {
                            animation.Unref();
                            animation.Dispose();
                            animation = null;
                            System.GC.Collect();
                        }

                        Pixbuf firstImage = null;

                        if (currentImage != null && currentImage != "") {

                            animation = new PixbufAnimation(currentImage);
                            isDisposeNeeded = false;
                            if (animation.IsStaticImage) {
                                firstImage = animation.StaticImage;
                            } else {
                                animationIter = animation.GetIter(IntPtr.Zero);
                                firstImage = animationIter.Pixbuf;
                            }

                            imageWidth = firstImage.Width;
                            imageHeight = firstImage.Height;
                            isResizeNeeded = false;
                            if (imageWidth > imageTimed.Allocation.Width) {
                                imageHeight = imageHeight * imageTimed.Allocation.Width / imageWidth;
                                imageWidth = imageTimed.Allocation.Width;
                                isResizeNeeded = true;
                            }
                            if (imageHeight > imageTimed.Allocation.Height) {
                                imageWidth = imageWidth * imageTimed.Allocation.Height / imageHeight;
                                imageHeight = imageTimed.Allocation.Height;
                                isResizeNeeded = true;
                            }

                            if (isResizeNeeded) {
                                Pixbuf resized = firstImage.ScaleSimple(imageWidth, imageHeight, InterpType.Bilinear);
                                firstImage = resized;
                                isDisposeNeeded = true;
                            }

                        }

                        Gtk.Application.Invoke(delegate {
                            try {
                                Pixbuf oldImage = imageTimed.Pixbuf;
                                imageTimed.Pixbuf = firstImage;
                                imageTimed.QueueDraw();
                                if (oldImage != null && isOldDisposeNeeded) {
                                    oldImage.Dispose();
                                }
                                isOldDisposeNeeded = isDisposeNeeded;
                            } catch (Exception ex) {
                                Console.WriteLine(ex.Source);
                                Console.WriteLine(ex.StackTrace);
                            }
                        });

                        start = DateTime.Now;
                    } else {
                        start = DateTime.Now;
                        if (animationIter != null) {
                            animationIter.Advance(IntPtr.Zero);

                            isDisposeNeeded = false;
                            Pixbuf pix = animationIter.Pixbuf;
                            if (isResizeNeeded) {
                                Pixbuf resized = pix.ScaleSimple(imageWidth, imageHeight, InterpType.Bilinear);
                                pix = resized;
                                isDisposeNeeded = true;
                            }

                            Gtk.Application.Invoke(delegate {
                                Pixbuf oldImage = imageTimed.Pixbuf;
                                imageTimed.Pixbuf = pix;
                                imageTimed.QueueDraw();
                                if (oldImage != null && isOldDisposeNeeded) {
                                    oldImage.Dispose();
                                }
                                isOldDisposeNeeded = isDisposeNeeded;
                            });
                        }
                    }

                    if (animationIter != null && animationIter.DelayTime != -1) {
                        int delay = (int)start.AddMilliseconds(animationIter.DelayTime).Subtract(DateTime.Now).TotalMilliseconds;
                        if (delay > 0) Thread.Sleep(delay);
                    } else {
                        Thread.Sleep(250);
                    }
                } catch (Exception ex) {
                    Console.WriteLine(ex.Source);
                    Console.WriteLine(ex.StackTrace);
                }
            }

            if (animationIter != null) {
                animationIter.Dispose();
                animationIter = null;
            }
            if (animation != null) {
                animation.Dispose();
                animation = null;
            }
        }