Exemple #1
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog();

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                dialog.NewImageWidth  = image.Width;
                dialog.NewImageHeight = image.Height;
            }
            else
            {
                dialog.NewImageWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings();
            }

            dialog.Destroy();
        }
Exemple #2
0
        public bool IsTypeAvailable(TransferDataType type)
        {
            if (type == TransferDataType.Text)
            {
                return(clipboard.WaitIsTextAvailable());
            }
            if (type == TransferDataType.Image)
            {
                return(clipboard.WaitIsImageAvailable());
            }

            foreach (var at in GetAtomsForType(type))
            {
                if (clipboard.WaitIsTargetAvailable(at))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Sets the dialog to use the clipboard image's dimensions, if possible.
        /// </summary>
        /// <returns>True if an image was on the clipboard, false otherwise.</returns>
        private static bool TryUseClipboardImageSize(NewImageDialog dialog)
        {
            bool clipboardUsed = false;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed         = true;
                    dialog.NewImageWidth  = image.Width;
                    dialog.NewImageHeight = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }
        /// <summary>
        /// Gets the width and height of an image on the clipboard,
        /// if available.
        /// </summary>
        /// <param name="width">Destination for the image width.</param>
        /// <param name="height">Destination for the image height.</param>
        /// <returns>True if dimensions were available, false otherwise.</returns>
        private static bool GetClipboardImageSize(out int width, out int height)
        {
            bool clipboardUsed = false;

            width = height = 0;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed = true;
                    width         = image.Width;
                    height        = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }