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(); }
public object GetData(TransferDataType type) { if (type == TransferDataType.Text) { return(clipboard.WaitForText()); } if (type == TransferDataType.Text) { return(clipboard.WaitForImage()); } TransferDataStore store = new TransferDataStore(); foreach (var at in GetAtomsForType(type)) { var data = clipboard.WaitForContents(at); Util.GetSelectionData(data, store); } return(((ITransferData)store).GetValue(type)); }
public override object GetData(TransferDataType type) { if (type == TransferDataType.Text) { return(clipboard.WaitForText()); } if (type == TransferDataType.Image) { return(ApplicationContext.Toolkit.WrapImage(new GtkImage(clipboard.WaitForImage()))); } TransferDataStore store = new TransferDataStore(); foreach (var at in GetAtomsForType(type)) { var data = clipboard.WaitForContents(at); Util.GetSelectionData(ApplicationContext, data, store); } return(((ITransferData)store).GetValue(type)); }
/// <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); }