private void ShowImgFromClipBoard_Click(object sender, EventArgs e) { System.Drawing.Image returnImage = null; if (Clipboard.ContainsImage()) { returnImage = Clipboard.GetImage(); Clipboard.Clear(); pB_showImg.Image = returnImage; //pB_showImg. } }
private void loadBufferToolStripMenuItem_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { Image image = Clipboard.GetImage(); NewImage((Bitmap)image, "Изображение из буфера"); } else { MessageBox.Show("В буфере нет изображения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }; }
private void buttonPasteImage_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { this.BindingContext[this.symbolDetailDataSet, SYMBOL].EndCurrentEdit(); Image image = Clipboard.GetImage(); this.pictureBoxImage.Image = CreatePicture(image); this.EnableButtons(); } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { selectionToolButton.Checked = false; selectionToolButton.Checked = true; selection = true; temporarySelection = Clipboard.GetImage() as Bitmap; mRect = new Rectangle(1, 1, temporarySelection.Width, temporarySelection.Height); pictureBox1.Invalidate(); } }
private bool PasteImage() { if (Clipboard.ContainsImage()) { if (Clipboard.GetImage() is Bitmap bm) { InsertImage(bm); return(true); } } return(false); }
public void UploadClipboard() { if (Clipboard.ContainsImage()) { BeginWork(() => { Uploader.ImgurUpload( Clipboard.GetImage() ).Handle(); }); } }
private void cmdScreen() { Clipboard.Clear(); SendKeys.SendWait("{PRTSC}"); if (Clipboard.ContainsImage()) { Image img = Clipboard.GetImage(); savePic(img); img.Dispose(); Clipboard.Clear(); } }
private void OnPasteButtonPressed(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { Image image = Clipboard.GetImage(); previewTextBox.Paste(); valueChangedLock = true; xImageSize.Value = image.Size.Width; yImageSize.Value = image.Size.Height; valueChangedLock = false; } }
private void PasteImage() { if (Clipboard.ContainsImage()) { var image = System.Windows.Forms.Clipboard.GetImage(); string tempFile = System.IO.Path.GetTempFileName(); image.Save(tempFile, ImageFormat.Jpeg); image.Dispose(); AddAsset(tempFile); ValidatePanelHeight(); } }
public void Clipboard_SetImage_InvokeBitmap_GetReturnsExpected() { using (var bitmap = new Bitmap(10, 10)) { bitmap.SetPixel(1, 2, Color.FromArgb(0x01, 0x02, 0x03, 0x04)); Clipboard.SetImage(bitmap); Bitmap result = Assert.IsType <Bitmap>(Clipboard.GetImage()); Assert.Equal(bitmap.Size, result.Size); Assert.Equal(Color.FromArgb(0xFF, 0xD2, 0xD2, 0xD2), result.GetPixel(1, 2)); Assert.True(Clipboard.ContainsImage()); } }
/// <summary> /// Retrieves an image from the given clipboard data object, in the order PNG, DIB, Bitmap, Image object. /// </summary> /// <param name="retrievedData">The clipboard data.</param> /// <returns>The extracted image, or null if no supported image type was found.</returns> public static Bitmap GetClipboardImage(DataObject retrievedData) { Bitmap clipboardimage = null; // Order: try PNG, move on to try 32-bit ARGB DIB, then try the normal Bitmap and Image types. if (retrievedData.GetDataPresent("PNG")) { MemoryStream png_stream = retrievedData.GetData("PNG") as MemoryStream; if (png_stream != null) { using (Bitmap bm = new Bitmap(png_stream)) clipboardimage = CloneImage(bm); } } try { //does not work for any reason (crashes programm even with try/catch) //if (clipboardimage == null && retrievedData.GetDataPresent(DataFormats.Dib)) { // MemoryStream dib = retrievedData.GetData(DataFormats.Dib) as MemoryStream; // if (dib != null) // clipboardimage = ImageFromClipboardDib(dib.ToArray()); //} } catch (Exception e) { //silent catch } if (clipboardimage == null && retrievedData.GetDataPresent(DataFormats.Bitmap)) { try { clipboardimage = (Bitmap)retrievedData.GetData(DataFormats.Bitmap); } catch (Exception e) { } } if (clipboardimage == null && retrievedData.GetDataPresent(typeof(Image))) { try { clipboardimage = new Bitmap(retrievedData.GetData(typeof(Image)) as Image); } catch (Exception e) { } } if (clipboardimage != null) { return(clipboardimage); } //fallback for mspaint if (Clipboard.ContainsImage()) { return(GetBitmap(Clipboard.GetImage())); } return(null); }
internal static async Task ChangeLockScreenBackground(string path) { //if (!UserProfilePersonalizationSettings.IsSupported()) //{ // return; //} if (UILogic.ConfigureWindows.GetMainWindow.MainImage.Effect != null || Clipboard.ContainsImage()) { try { var SaveImage = ImageDecoder.GetRenderedMagickImage(); if (SaveImage == null) { return; } UILogic.Tooltip.ShowTooltipMessage(Application.Current.Resources["Applying"]); await Task.Run(() => { // Create temp directory var tempPath = Path.GetTempPath(); var randomName = Path.GetRandomFileName() + ".png"; // Write temp file to it using var filestream = new FileStream(tempPath + randomName, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.SequentialScan); SaveImage.Write(filestream); SaveImage.Dispose(); filestream.Close(); // Use it _ = Apply(tempPath + randomName); // Clean up File.Delete(tempPath + randomName); using var timer = new Timer(2000); timer.Elapsed += (s, x) => Directory.Delete(tempPath); }).ConfigureAwait(true); SaveImage.Dispose(); // Make visual studio happy } catch (Exception e) { MessageBox.Show(e.Message); } } else { await Apply(path).ConfigureAwait(false); } }
private void PasteImage_PreviewKeyDown(object sender, KeyEventArgs e) { bool isControlKey = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control; if (isControlKey && e.Key == Key.V && Clipboard.ContainsImage()) { PasteImageFromClipboard(); } else if (isControlKey && e.Key == Key.C) { Button_CopyImage(null, null); } }
public static string cmdScreen() { Clipboard.Clear(); SendKeys.SendWait("{PRTSC}"); if (Clipboard.ContainsImage()) { Image img = Clipboard.GetImage(); savePic(img); img.Dispose(); Clipboard.Clear(); } return("1"); }
private void btnGenerateGraph_Click(object sender, EventArgs e) { DrawChart(); if (Clipboard.ContainsImage()) { pbChart.SizeMode = PictureBoxSizeMode.StretchImage; pbChart.Image = Clipboard.GetImage(); } else { MessageBox.Show("Clipboard is empty"); } }
private Boolean pasteImage() { if (Clipboard.ContainsImage()) { pictureBox1.Image = Clipboard.GetImage(); return(true); } else { return(false); } }
private bool TryGetImageFromClipboard(out Image i) { if (!Clipboard.ContainsImage()) { i = null; return(false); } else { i = Clipboard.GetImage(); return(true); } }
/// <summary> /// Loads image from clipboard /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void BtnClipboard_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { tbImage.Text = "image.png"; pbPreview.Image = Clipboard.GetImage(); UseClipboard = true; } else { MessageBox.Show("Your Clipboard has no image", "No Image", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static Bitmap fromClipboardGetImage(this Control control) { return((Bitmap)control.invokeOnThread( () => { if (Clipboard.ContainsImage()) { return Clipboard.GetImage(); } "in fromClipboardGetImage, the Clipboard doesn't contain an image".debug(); return null; })); }
public BackgroundImageForm() { InitializeComponent(); if (Clipboard.ContainsImage()) { radClipboard.Checked = true; } else { radFile.Checked = true; } }
private bool CanCopyCoverImageFromClipboard() { IDataObject myDataObject = Clipboard.GetDataObject(); string[] files = (string[])myDataObject.GetData(DataFormats.FileDrop); if (files != null && files.Length == 1) { return(BookWave.Desktop.Util.ImageConverter.FileIsValid(files[0])); } return(Clipboard.ContainsImage()); }
private void PasteButton_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { ImageBox.SizeMode = PictureBoxSizeMode.StretchImage; ImageBox.Image = Clipboard.GetImage(); } else { MessageBox.Show("No image could be located. Please try pasting an image to your clipboard and then trying again.", "Image Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool pasteImage() { if (Clipboard.ContainsImage()) { Bitmap bm = Clipboard.GetImage() as Bitmap; if (bm != null) { insertImage(bm); return(true); } } return(false); }
public static bool ContainsImage() { try { return(Clipboard.ContainsImage()); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }
public void Paste() { //paste img from clipboard if (Clipboard.ContainsImage()) { //convert clipboard img to MemBitmap memBmp = Clipboard.GetImage() as MemBitmap; using (Tools.BorrowAggPainter(_lionPng, out var painter)) { painter.DrawImage(memBmp); } } }
private void btnPaste_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { var screenshot = new Bitmap(Clipboard.GetImage()); DisplayImage(screenshot); GenerateZooms(screenshot); } else { lblStatus.Text = @"Error: no image in clipboard."; } }
public byte[] GetClipboardImage() { if (!Clipboard.ContainsImage()) { return(null); } using (var ms = new MemoryStream()) { Clipboard.GetImage().Save(ms, System.Drawing.Imaging.ImageFormat.Png); return(ms.ToArray()); } }
private static void PGLShowdownSet(object sender, EventArgs e) { if (!Clipboard.ContainsImage()) { return; } var img = Clipboard.GetImage(); var rentalTeam = QRParser.DecryptQRCode(img); var sets = rentalTeam.ConvertedTeam.ToList(); ShowdownSetLoader.Import(sets); }
private void clipboard_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { var img = Clipboard.GetImage(); OnGrabScreen(new Bitmap(img), true); } else { AddEvent(LocM.GetString("event_clipboard_err")); MessageBox.Show(LocM.GetString("clipboard_err"), LocM.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static ImageItem ImageItemFromClipboard() { if (Clipboard.ContainsImage()) { ImageItem ii = ImageItemFromImage(Clipboard.GetImage()); ii.Src = Source.Clipboard; return(ii); } else { return(null); } }