コード例 #1
0
        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.
            }
        }
コード例 #2
0
 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);
     };
 }
コード例 #3
0
ファイル: SymbolDetailForm.cs プロジェクト: nakijun/adasg
        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();
            }
        }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
ファイル: ImageForm.cs プロジェクト: queueRAM/Texture64
 private bool PasteImage()
 {
     if (Clipboard.ContainsImage())
     {
         if (Clipboard.GetImage() is Bitmap bm)
         {
             InsertImage(bm);
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
ファイル: FrmSettings.cs プロジェクト: TheKronks/Kapture
 public void UploadClipboard()
 {
     if (Clipboard.ContainsImage())
     {
         BeginWork(() =>
         {
             Uploader.ImgurUpload(
                 Clipboard.GetImage()
                 ).Handle();
         });
     }
 }
コード例 #7
0
 private void cmdScreen()
 {
     Clipboard.Clear();
     SendKeys.SendWait("{PRTSC}");
     if (Clipboard.ContainsImage())
     {
         Image img = Clipboard.GetImage();
         savePic(img);
         img.Dispose();
         Clipboard.Clear();
     }
 }
コード例 #8
0
 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;
     }
 }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
 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());
     }
 }
コード例 #11
0
        /// <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);
        }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: cmds.cs プロジェクト: opensanyue/cs
 public static string cmdScreen()
 {
     Clipboard.Clear();
     SendKeys.SendWait("{PRTSC}");
     if (Clipboard.ContainsImage())
     {
         Image img = Clipboard.GetImage();
         savePic(img);
         img.Dispose();
         Clipboard.Clear();
     }
     return("1");
 }
コード例 #15
0
 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");
     }
 }
コード例 #16
0
ファイル: frmMyOwnApp.cs プロジェクト: Fvega1/VirtualUI-Demos
        private Boolean pasteImage()
        {
            if (Clipboard.ContainsImage())
            {
                pictureBox1.Image = Clipboard.GetImage();

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #17
0
 private bool TryGetImageFromClipboard(out Image i)
 {
     if (!Clipboard.ContainsImage())
     {
         i = null;
         return(false);
     }
     else
     {
         i = Clipboard.GetImage();
         return(true);
     }
 }
コード例 #18
0
ファイル: frmUpload.cs プロジェクト: AyrA/ImgurTitleEditor
 /// <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);
     }
 }
コード例 #19
0
 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;
     }));
 }
コード例 #20
0
        public BackgroundImageForm()
        {
            InitializeComponent();

            if (Clipboard.ContainsImage())
            {
                radClipboard.Checked = true;
            }
            else
            {
                radFile.Checked = true;
            }
        }
コード例 #21
0
        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());
        }
コード例 #22
0
 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);
     }
 }
コード例 #23
0
 private bool pasteImage()
 {
     if (Clipboard.ContainsImage())
     {
         Bitmap bm = Clipboard.GetImage() as Bitmap;
         if (bm != null)
         {
             insertImage(bm);
             return(true);
         }
     }
     return(false);
 }
コード例 #24
0
ファイル: ClipboardHelpers.cs プロジェクト: McoreD/ShareX
        public static bool ContainsImage()
        {
            try
            {
                return(Clipboard.ContainsImage());
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e);
            }

            return(false);
        }
コード例 #25
0
 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);
         }
     }
 }
コード例 #26
0
ファイル: frmMain.cs プロジェクト: dHeinemann/What-The-Hex
 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.";
     }
 }
コード例 #27
0
ファイル: MainForm.cs プロジェクト: main--/windows-gaming
        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());
            }
        }
コード例 #28
0
        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);
        }
コード例 #29
0
 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);
     }
 }
コード例 #30
0
 public static ImageItem ImageItemFromClipboard()
 {
     if (Clipboard.ContainsImage())
     {
         ImageItem ii = ImageItemFromImage(Clipboard.GetImage());
         ii.Src = Source.Clipboard;
         return(ii);
     }
     else
     {
         return(null);
     }
 }