当前位置: 首页>>代码示例>>C#>>正文


C# Cursor.Draw方法代码示例

本文整理汇总了C#中System.Windows.Forms.Cursor.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.Draw方法的具体用法?C# Cursor.Draw怎么用?C# Cursor.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Cursor的用法示例。


在下文中一共展示了Cursor.Draw方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateRealHeight

 private static int CalculateRealHeight(Cursor cursor)
 {
     using (Bitmap bitmap = new Bitmap(cursor.Size.Width, cursor.Size.Height))
     {
         Rectangle targetRect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             cursor.Draw(graphics, targetRect);
         }
         BitmapData bitmapdata = bitmap.LockBits(targetRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
         try
         {
             if (bitmapdata.PixelFormat == PixelFormat.Format32bppArgb)
             {
                 int height = bitmapdata.Height;
                 do
                 {
                     int num2 = --height * bitmapdata.Stride;
                     for (int i = 0; i < bitmapdata.Width; i++)
                     {
                         if ((Marshal.ReadInt32(bitmapdata.Scan0, num2 + (i * 4)) != 0) && (height > 0))
                         {
                             return height;
                         }
                     }
                 }
                 while (height > 0);
             }
         }
         finally
         {
             bitmap.UnlockBits(bitmapdata);
         }
     }
     return cursor.Size.Height;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:36,代码来源:CursorExtension.cs

示例2: GetScreen

 private Bitmap GetScreen()
 {
     Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
     if (this.isCaptureCursor)
     {
         using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
         {
             CCWin.Win32.NativeMethods.PCURSORINFO pci;
             pci.cbSize = Marshal.SizeOf(typeof(CCWin.Win32.NativeMethods.PCURSORINFO));
             CCWin.Win32.NativeMethods.GetCursorInfo(out pci);
             if (pci.hCursor != IntPtr.Zero)
             {
                 Cursor cur = new Cursor(pci.hCursor);
                 g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                 cur.Draw(g, new Rectangle((System.Drawing.Point) (((System.Drawing.Size) Control.MousePosition) - ((System.Drawing.Size) cur.HotSpot)), cur.Size));
             }
         }
     }
     using (Graphics g = Graphics.FromImage(bmp))
     {
         g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
     }
     return bmp;
 }
开发者ID:zhushengwen,项目名称:example-zhushengwen,代码行数:24,代码来源:FrmCapture.cs

示例3: ConvertToBitmap

 public Bitmap ConvertToBitmap(Cursor c)
 {
     //it seems there is no easy way to write cursor to file
     Bitmap bmp = new Bitmap(c.Size.Width, c.Size.Height);
     using (Graphics g = Graphics.FromImage(bmp))
     {
         c.Draw(g, new Rectangle(0, 0, c.Size.Width, c.Size.Height));
     }
     return bmp;
 }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:10,代码来源:ClassEditResourceHandler.cs

示例4: function_ScreenProjecting

        private void function_ScreenProjecting()
        {
            Bitmap Bm_temp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            Graphics g_temp = Graphics.FromImage(Bm_temp);
            MemoryStream MS_temp = new MemoryStream();

            g_temp.CopyFromScreen(0, 0, 0, 0, Bm_temp.Size);

            CURSORINFO CRS;
            CRS.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
            GetCursorInfo(out CRS);
            Cursor cur = new Cursor(CRS.hCursor);
            //MessageBox.Show(this, cur.Size.ToString());
            cur.Draw(g_temp, new Rectangle(CRS.ptScreenPos.X - (Cursors.Arrow.Size.Width - cur.Size.Width), CRS.ptScreenPos.Y - (Cursors.Arrow.Size.Height - cur.Size.Height), cur.Size.Width, cur.Size.Height));

            Bm_temp.Save(MS_temp, System.Drawing.Imaging.ImageFormat.Jpeg);
            //Bm_temp.Save("111.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            

            Byte[] byte_temp = MS_temp.GetBuffer();

            //MessageBox.Show(byte_temp.Length.ToString(), "");

            try
            {
                this.SocketClient.BeginSend(byte_temp, 0, byte_temp.Length, SocketFlags.None, new AsyncCallback(CallBack_Send), this.SocketClient);
            }
            catch (Exception E)
            {
                MessageBox.Show(E.ToString());
                this.SocketConnetingProcessStatusLabel.Text = "开始发送Socket消息时,错误!";
            }

            MS_temp.Close();
            g_temp.Dispose();
            Bm_temp.Dispose();
        }
开发者ID:FAKERINHEART,项目名称:Remote_Controlling,代码行数:37,代码来源:Remote_Client.cs

示例5: GetScreen

 //获取桌面图像
 private Bitmap GetScreen()
 {
     Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
             Screen.PrimaryScreen.Bounds.Height);
     if (this.isCaptureCursor)
     {     //是否捕获鼠标
         //如果直接将捕获当的鼠标画在bmp上 光标不会反色 指针边框也很浓 也就是说
         //尽管bmp上绘制了图像 绘制鼠标的时候还是以黑色作为鼠标的背景 然后在将混合好的鼠标绘制到图像 会很别扭
         //所以 干脆直接在桌面把鼠标绘制出来再截取桌面
         using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
         {   //传入0默认就是桌面 Win32.GetDesktopWindow()也可以
             Win32.PCURSORINFO pci;
             pci.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(Win32.PCURSORINFO));
             Win32.GetCursorInfo(out pci);
             if (pci.hCursor != IntPtr.Zero)
             {
                 Cursor cur = new Cursor(pci.hCursor);
                 g.CopyFromScreen(0, 0, 0, 0, bmp.Size); //在桌面绘制鼠标前 先在桌面绘制一下当前的桌面图像
                 //如果不绘制当前桌面 那么cur.Draw的时候会是用历史桌面的快照 进行鼠标的混合 那么到时候混出现底色(测试中就是这样的)
                 cur.Draw(g, new Rectangle((Point)((Size)MousePosition - (Size)cur.HotSpot), cur.Size));
             }
         }
     }
     //做完以上操作 才开始捕获桌面图像
     using (Graphics g = Graphics.FromImage(bmp))
     {
         g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
     }
     return bmp;
 }
开发者ID:RobinGitHub,项目名称:CommonToolLibrary,代码行数:31,代码来源:FrmCapture.cs

示例6: CaptureScreenToBitmap

        private void CaptureScreenToBitmap(Bitmap bitmap)
        {
            try
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    graphics.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight),
                        CopyPixelOperation.SourceCopy);

                    CURSORINFO cursorInfo = new CURSORINFO();
                    cursorInfo.cbSize = Marshal.SizeOf(cursorInfo);

                    if (GetCursorInfo(ref cursorInfo))
                    {
                        if (cursorInfo.flags == CURSOR_SHOWING)
                        {
                            Cursor cursor = new Cursor(cursorInfo.hCursor);
                            cursor.Draw(graphics, new Rectangle(
                                cursorInfo.ptScreenPos.x - cursor.HotSpot.X,
                                cursorInfo.ptScreenPos.y - cursor.HotSpot.Y,
                                cursor.Size.Width, cursor.Size.Height));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ScreenshotNotAvailableException("Could not capture screenshot.  The application may be running as a service that has not been granted the right to interact with the desktop.", ex);
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:30,代码来源:ScreenGrabber.cs

示例7: DrawCross

		static void DrawCross(Graphics g, Point center)
		{
			System.IO.MemoryStream ms = null;
			try
			{
				ms = new System.IO.MemoryStream(Properties.Resources.Cross);
				using (Cursor cursor = new Cursor(ms))
				{
					ms = null;
					cursor.Draw(g, new Rectangle(center.X - 15, center.Y - 15, 32, 32));
				}
			}
			finally
			{
				if (ms != null)
					ms.Dispose();
			}
		}
开发者ID:kavenblog,项目名称:Comical,代码行数:18,代码来源:ImageEditingDialog.cs

示例8: drawMouse

 public void drawMouse(Point Location, Cursor MouseCursor)
 {
     this.Invalidate();
     ClearMouse(Location, MouseCursor);
     Graphics MouseGraphics = CreateGraphics();
     Rectangle MouseRectangle = new Rectangle(Location, MouseCursor.Size);
     MouseCursor.Draw(MouseGraphics, MouseRectangle);
 }
开发者ID:daemonfire300,项目名称:Eryan,代码行数:8,代码来源:Utils.cs

示例9: UpdateState

        private void UpdateState()
        {
            var imagePath = this.fileNameComboBox.Text;

            if (this.lastLoadedPath == imagePath)
            {
                return;
            }

            this.lastLoadedPath = imagePath;

            this.pictureBox1.SuspendLayout();

            try
            {
                this.okButton.Enabled = imagePath.Length == 0 || this.editor.Filter.IsSupported(imagePath);
                if (this.okButton.Enabled)
                {
                    if (ImageEditor.IsCursorFile(imagePath))
                    {
                        using (Cursor cursor = new Cursor(imagePath))
                        {
                            this.pictureBox1.Image = new Bitmap(cursor.Size.Width, cursor.Size.Height);

                            using (Graphics g = Graphics.FromImage(this.pictureBox1.Image))
                            {
                                cursor.Draw(g, new Rectangle(Point.Empty, cursor.Size));
                            }
                        }
                    }
                    else if (ImageEditor.IsIconFile(imagePath))
                    {
                        using (Icon icon = new Icon(imagePath))
                        {
                            this.pictureBox1.Image = icon.ToBitmap();
                        }
                    }
                    else if (imagePath.Length == 0)
                    {
                        this.pictureBox1.Image = null;
                    }
                    else
                    {
                        this.pictureBox1.Image = Image.FromFile(imagePath);
                    }
                }
                else
                {
                    this.pictureBox1.Image = this.pictureBox1.ErrorImage;
                }
            }
            catch (Exception ex)
            {
                if (Microsoft.VisualStudio.ErrorHandler.IsCriticalException(ex))
                {
                    throw;
                }

                this.okButton.Enabled = false;
                this.pictureBox1.Image = this.pictureBox1.ErrorImage;
            }

            this.pictureBox1.ResumeLayout();
        }
开发者ID:StevenVanDijk,项目名称:NuPattern,代码行数:64,代码来源:ImageDialog.cs

示例10: DisplayAsset

        private void DisplayAsset()
        {
            PictureBox picBox = null;

            switch (_type)
            {
                case EngineResourceFileTypes.Bitmap:
                    btnBackground.Visible = true;
                    btnMask.Visible = true;
                    axWMP.Visible = false;

                    picBox = new PictureBox();
                    picBox.SizeMode = PictureBoxSizeMode.AutoSize;
                    picBox.Image = new Bitmap(_stream);
                    picBox.MouseClick += picBox_MouseClick;

                    this.panel1.Controls.Add(picBox);
                    break;

                case EngineResourceFileTypes.Audio:
                case EngineResourceFileTypes.Video:
                    btnBackground.Visible = false;
                    btnMask.Visible = false;
                    panel1.Dock = DockStyle.Fill;

                    if (!string.IsNullOrWhiteSpace(_file))
                    {
                        axWMP.settings.autoStart = false;
                        axWMP.Visible = true;
                        axWMP.URL = _file;
                        axWMP.Dock = DockStyle.Fill;
                    }

                    break;

                case EngineResourceFileTypes.Cursor:
                    btnBackground.Visible = false;
                    btnMask.Visible = false;
                    axWMP.Visible = false;

                    picBox = new PictureBox();
                    picBox.SizeMode = PictureBoxSizeMode.AutoSize;
                    picBox.BorderStyle = BorderStyle.Fixed3D;

                    var cursor = new Cursor(_file);
                    var bmp = new Bitmap(cursor.Size.Width, cursor.Size.Height);
                    using (var graphics = Graphics.FromImage(bmp))
                        cursor.Draw(graphics, new Rectangle(new Point(), cursor.Size));

                    picBox.Image = bmp;
                    picBox.MouseClick += picBox_MouseClick;

                    this.panel1.Controls.Add(picBox);

                    break;

                case EngineResourceFileTypes.Misc:
                    btnBackground.Text = "Open File";
                    btnBackground.Visible = true;
                    btnMask.Visible = false;
                    axWMP.Visible = false;

                    break;

                default:
                    btnBackground.Visible = false;
                    btnMask.Visible = false;
                    axWMP.Visible = false;

                    break;
            }
        }
开发者ID:Isthimius,项目名称:Gondwana,代码行数:72,代码来源:AssetViewer.cs


注:本文中的System.Windows.Forms.Cursor.Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。