Example #1
0
 public ImageFinder(string searchString, ThumbStore model)
 {
     this.searchString = searchString;
     this.model        = model;
     this.thread       = new Thread(new ThreadStart(Run));
     this.thread.Name  = "Image Finder";
 }
Example #2
0
        public ImageExporter(ThumbStore model, string exportPath)
        {
            this.images     = new List <Image>();
            this.exportPath = exportPath;

            lock (model) {
                Gtk.TreeIter iter;
                if (model.GetIterFirst(out iter))
                {
                    do
                    {
                        this.images.Add(model.GetImage(new Gtk.TreeRowReference(model, model.GetPath(iter))));
                    } while(model.IterNext(ref iter));
                }
            }

            this.thread      = new Thread(new ThreadStart(Run));
            this.thread.Name = "Image Exporter";
        }
        ImagesResultWidget(Gtk.Builder builder, IntPtr handle) : base(builder, handle)
        {
            builder.Autoconnect(this);

            BooruApp.BooruApplication.EventCenter.WillQuit          += Abort;
            BooruApp.BooruApplication.EventCenter.FullscreenToggled += this.ToggleFullscreen;

            this.PlayImage         = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_PLAY));
            this.StopImage         = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_STOP));
            this.TagImage          = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_TAG));
            this.ShuffleImage      = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_SHUFFLE));
            this.MarkImage         = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_MARK));
            this.UnmarkImage       = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_UNMARK));
            this.DeleteImage       = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_DELETE));
            this.ViewExternalImage = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_VIEW_EXTERNAL));
            this.ExportImage       = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_EXPORT));
            this.AbortImage        = new Gtk.Image(Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_BUTTON_ABORT));

            this.ButtonSlideshow.Image    = this.PlayImage;
            this.ShowTagsButton.Image     = this.TagImage;
            this.ShuffleButton.Image      = this.ShuffleImage;
            this.MarkButton.Image         = this.MarkImage;
            this.DeleteButton.Image       = this.DeleteImage;
            this.OpenExternalButton.Image = this.ViewExternalImage;
            this.ExportButton.Image       = this.ExportImage;
            this.StopButton.Image         = this.AbortImage;

            this.Removed += (o, args) => {
                this.Abort();
            };


            // TODO: add custom tag input widget

            /*
             * var tagbox = new TagBoxWidget ();
             * ImageViewBox.PackEnd (tagbox, false, false, 0);
             * tagbox.Show ();
             */

            // add image view
            this.imageView = new ImageViewWidget();
            this.ImageViewBox.PackStart(this.imageView, true, true, 0);

            this.imageView.Controls = PlayerControlWidget.Create();
            this.ImageViewBox.PackEnd(this.imageView.Controls, false, true, 0);

            // enable mouse scrolling
            this.imageView.Events      |= Gdk.EventMask.ScrollMask;
            this.imageView.ScrollEvent += (o, args) => {
                if (args.Event.Direction == Gdk.ScrollDirection.Down)
                {
                    this.Advance(true);
                }
                else if (args.Event.Direction == Gdk.ScrollDirection.Up)
                {
                    this.Advance(false);
                }
            };

            // add overlay for tag display
            this.tagsOverlay = new TagsOverlay(this.imageView);

            // setup tag entry autocompletion
            var completion = new Gtk.EntryCompletion();

            completion.Model            = BooruApp.BooruApplication.Database.TagEntryCompletionStore;
            completion.TextColumn       = 0;
            completion.MinimumKeyLength = 3;
            this.TagsEntry.Completion   = completion;

            // set up thumb list view
            this.store = new ThumbStore();
            this.ImageThumbView.PixbufColumn  = ThumbStore.THUMB_STORE_COLUMN_THUMBNAIL;
            this.ImageThumbView.TooltipColumn = ThumbStore.THUMB_STORE_COLUMN_TOOLTIP;
            this.ImageThumbView.TextColumn    = ThumbStore.THUMB_STORE_COLUMN_INDEX;
            this.ImageThumbView.ItemWidth     = 64;

            this.ImageThumbView.Model = this.store;

            this.ImageThumbView.Model.RowInserted += on_ImageThumbView_Model_RowInserted;
            this.ImageThumbView.Model.RowChanged  += on_ImageThumbView_Model_RowChanged;

            this.ImageThumbView.Events        |= Gdk.EventMask.KeyPressMask;
            this.ImageThumbView.KeyPressEvent += on_ImageThumbView_KeyPress;

            this.StopButton.Sensitive   = true;
            this.Spinner.Active         = true;
            this.ExportButton.Sensitive = false;
            this.MarkButton.Sensitive   = false;
            this.DeleteButton.Sensitive = false;

            //var box = (Gtk.Box)this.StopButton.Parent.Parent;
            //this.tagsBox = new TagsEntryWidget ();
            //box.PackEnd (this.tagsBox, false, true, 0);
            //this.tagsBox.Show ();

            this.idle = GLib.Timeout.Add(100, () => {
                if (this.imageView.Image != this.ActiveImage)
                {
                    // get newly selected image
                    this.imageView.Image = this.ActiveImage;

                    // this.tagsBox.SetTags (image.Tags);

                    // clear tags entry to not confuse user
                    this.TagsEntry.Text = "";
                    this.UpdateButtons();
                }
                return(true);
            });
        }