System.Windows.Forms.Clipboard.ContainsImage()

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.ContainsImage() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

20 Examples 7

1. Example

Project: upScreen
Source File: frmCapture.cs
View license
private void clipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsImage() && !Common.ImageFileInClipboard && !Common.ImageUrlInClipboard)
                return;

            _otherformopen = true;
            Hide();
            CaptureControl.GetFromClipboard();
        }

2. Example

Project: upScreen
Source File: frmCapture.cs
View license
private void frmCapture_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button /n ..... /n //View Source file for more details /n }

3. Example

Project: Clipboarder
Source File: MainFormPresenter.cs
View license
private void Initialize() {
            // Adds handler to view events
            view.OnExiting += OnExiting;
            view.LoadContent += LoadContent;
            view.SaveContent += SaveContent;
            view.ShowSettings += ShowSettings;
            view.InstallSHLs += InstallSHLs;
            view.URLCalled += URLCalled;
            view.textGridCheckURLAndSetStatus += textGridCheckURLAndSetStatus;
            view.EditTextContent += EditTextContent;
            view.CopySelectedTextToClipboard += CopySelectedTextToClipboard;

            // Adds first content from clipboard
            if (Clipboard.ContainsText()) {
                LastClipboardText = Clipboard.GetText();
                view.AddNewTextRow(getTextContentFromClipboard());
            } else if (Clipboard.ContainsImage()) {
                view.AddNewImageRow(getImageContentFromClipboard());
                Clipboard.GetText();
            }

            view.ProgressVisibility = false;

            // Adds handler for clipboardContentChanged Event
            clipboardMonitor = new ClipboardMonitor();
            clipboardMonitor.ClipboardChanged += ClipboardMonitor_ClipboardChanged;
        }

4. Example

Project: Clipboarder
Source File: MainFormPresenter.cs
View license
private void ClipboardMonitor_ClipboardChanged(object sender, ClipboardChangedEventArgs e) {
            if (Clipboard.ContainsText() && Clipboard.GetText() != LastClipboardText) {
                view.AddNewTextRow(getTextContentFromClipboard());
            } else if (Clipboard.ContainsImage()) {
                view.AddNewImageRow(getImageContentFromClipboard());
            }
        }

5. Example

View license
private void PasteButton_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (Clipboard.ContainsImage())
                {
                    this.unpackers.Clear();
                    this.DragAndDropLabel.Visible = false;
                    this.ControlsHelpLabel.Visible = false;
                    this.CreateUnpacker(new Bitmap(Clipboard.GetImage()), "clipboard");
                    this.StartUnpackers();
                }
                else
                {
                    MessageBox.Show("No image found in Clipboard");
                }
            }
            catch (Exception ex)
            {
                ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "[email protected]");
            }
        }

6. Example

Project: ShareX
Source File: TaskHelpers.cs
View license
public static void AnnotateImage(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            if (Clipboard.ContainsImage() && MessageBox.Show(Resources.TaskHelpers_OpenImageEditor_Your_clipboard_contains_image,
                Resources.TaskHelpers_OpenImageEditor_Image_editor___How_to_load_image_, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (Image img = ClipboardHelpers.GetImage())
                {
                    if (img != null)
                    {
                        if (taskSettings.AdvancedSettings.UseShareXForAnnotation)
                        {
                            AnnotateImageUsingShareX(img, null, taskSettings);
                        }
                        else
                        {
                            AnnotateImageUsingGreenshot(img, null);
                        }

                        return;
                    }
                }
            }

            string filePath = ImageHelpers.OpenImageFileDialog();

            if (!string.IsNullOrEmpty(filePath))
            {
                AnnotateImage(filePath, taskSettings);
            }
        }

7. Example

Project: ShareX
Source File: TaskHelpers.cs
View license
public static void OpenImageEditor(string filePath = null)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                if (Clipboard.ContainsImage() &&
                    MessageBox.Show(Resources.TaskHelpers_OpenImageEditor_Your_clipboard_contains_image,
                    Resources.TaskHelpers_OpenImageEditor_Image_editor___How_to_load_image_, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (Image img = Clipboard.GetImage())
                    {
                        if (img != null)
                        {
                            AnnotateImage(img, null);
                            return;
                        }
                    }
                }

                filePath = ImageHelpers.OpenImageFileDialog();
            }

            if (!string.IsNullOrEmpty(filePath))
            {
                AnnotateImage(filePath);
            }
        }

8. Example

View license
private static IList<object> LoadClipboardPicture()
        {
            try
            {
                Logger.Log("Load clipboard begins.");
                var result = new List<object>();
                if (Clipboard.ContainsImage())
                {
                    result.Add(Clipboard.GetImage());
                }
                if (Clipboard.ContainsFileDropList())
                {
                    result.Add(Clipboard.GetFileDropList());
                }
                if (Clipboard.ContainsText())
                {
                    result.Add(Clipboard.GetText());
                }
                Logger.Log("Load clipboard done.");
                return result;
            }
            catch (Exception e)
            {
                // sometimes Clipboard may fail
                Logger.LogException(e, "LoadClipboardPicture");
                return new List<object>();
            }
        }

9. Example

Project: Xploit
Source File: BinaryFromScreen.cs
View license
Bitmap GetBitmap()
        {
            switch (CaptureMethod)
            {
                case ECapture.Clipboard:
                    {
                        while (!Clipboard.ContainsImage())
                            Thread.Sleep(50);

                        Bitmap ret = (Bitmap)Clipboard.GetImage();
                        Clipboard.Clear();
                        return ret;
                    }
                case ECapture.ScreenShoot:
                    {
                        Rectangle bounds = Screen.GetBounds(Point.Empty);
                        Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
                        using (Graphics g = Graphics.FromImage(bitmap))
                        {
                            g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                        }
                        return bitmap;
                    }
            }
            return null;
        }

10. Example

Project: ShareX
Source File: ShapeManager.cs
View license
private void PasteFromClipboard()
        {
            if (Clipboard.ContainsImage())
            {
                Image img = ClipboardHelpers.GetImage();

                if (img != null)
                {
                    CurrentTool = ShapeType.DrawingImage;
                    ImageDrawingShape shape = (ImageDrawingShape)CreateShape(ShapeType.DrawingImage);
                    Point pos = InputManager.ClientMousePosition;
                    shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
                    shape.SetImage(img, true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text))
                {
                    CurrentTool = ShapeType.DrawingTextBackground;
                    TextDrawingShape shape = (TextDrawingShape)CreateShape(ShapeType.DrawingTextBackground);
                    Point pos = InputManager.ClientMousePosition;
                    shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
                    shape.Text = text.Trim();
                    shape.AutoSize(true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
        }

11. Example

Project: Toxy
Source File: ClipboardContentViewer.cs
View license
private void ClipboardContentViewer_Load(object sender, EventArgs e)
        {
            pbClipboa/n ..... /n //View Source file for more details /n }

12. Example

Project: upScreen
Source File: CaptureControl.cs
View license
public static void GetFromClipboard()
        {
            Image image = null;

            // Load the image from a copied image
            if (Clipboard.ContainsImage())
            {
                Log.Write(l.Info, "Clipboard mode, copied image");
                image = Clipboard.GetImage();
            }
            // Load the image from a copied image file
            else if (Clipboard.ContainsFileDropList())
            {
                Log.Write(l.Info, "Clipboard mode, file list");
                foreach (var localFile in Clipboard.GetFileDropList())
                {
                    SaveImage(localFile);
                }
                // raise CaptureComplete to start uploading
                CaptureComplete(null, EventArgs.Empty);
            }
            // Load the image from a copied image url
            else if (Common.ImageUrlInClipboard)
            {
                var url = Clipboard.GetText();
                Log.Write(l.Info, $"Clipboard mode, url: {url}");
                image = GetFromUrl(url);
            }

            // Prevent null reference exception
            if (image == null) return;

            Common.OtherFormOpen = true;

            SaveImage(image);
        }

13. Example

Project: ShareX
Source File: ClipboardContentViewer.cs
View license
private bool CheckClipboardContents()
        {
            pbClipboard.Visible = txtClipboard.Visib/n ..... /n //View Source file for more details /n }

14. Example

Project: ShareX
Source File: ClipboardContentViewer.cs
View license
private void ClipboardContentViewer_Load(object sender, EventArgs e)
        {
            pbClipboa/n ..... /n //View Source file for more details /n }

15. Example

Project: ImageGlass
Source File: frmMain.cs
View license
private void mnuMainOpenImageData_Click(object sender, EventArgs e)
        {
            //Is there/n ..... /n //View Source file for more details /n }

16. Example

Project: noterium
Source File: ClipboardHelper.cs
View license
public static Image GetImageFromClipboard()
        {
            var dataObject = Clipboard.GetDataObject();
            if (dataObject == null)
                return null;

            if (dataObject.GetDataPresent(DataFormats.Dib))
            {
                var dib = ((MemoryStream) Clipboard.GetData(DataFormats.Dib)).ToArray();
                var width = BitConverter.ToInt32(dib, 4);
                var height = BitConverter.ToInt32(dib, 8);
                var bpp = BitConverter.ToInt16(dib, 14);
                if (bpp == 32)
                {
                    var gch = GCHandle.Alloc(dib, GCHandleType.Pinned);
                    Bitmap bmp = null;
                    try
                    {
                        var ptr = new IntPtr((long) gch.AddrOfPinnedObject() + 40);
                        bmp = new Bitmap(width, height, width*4, PixelFormat.Format32bppArgb, ptr);

                        var newBmp = new Bitmap(bmp);
                        newBmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                        return newBmp;
                    }
                    finally
                    {
                        gch.Free();
                        bmp?.Dispose();
                    }
                }
            }

            return Clipboard.ContainsImage() ? Clipboard.GetImage() : null;
        }

17. Example

Project: Pscx
Source File: GetClipboardCommand.cs
View license
void GetClipboardContents()
        {
            if (_image)
            {
                if (WinF/n ..... /n //View Source file for more details /n }

18. Example

Project: KeeThief
Source File: ClipboardUtil.cs
View license
public static byte[] ComputeHash()
		{
			try // This works always or never
			{
				bool bOpened = /n ..... /n //View Source file for more details /n }

19. Example

Project: ShareX
Source File: UploadManager.cs
View license
public static void ClipboardUpload(TaskSettings taskSettings = null)
        {
            if (taskS/n ..... /n //View Source file for more details /n }

20. Example

Project: ShareX
Source File: UploadManager.cs
View license
public static void ClipboardUpload(TaskSettings taskSettings = null)
        {
            if (taskS/n ..... /n //View Source file for more details /n }