public Draw ( Graphics g, Rectangle targetRect ) : void | ||
g | Graphics | |
targetRect | Rectangle | |
리턴 | void |
public byte[] GetDesktop_ResizedBytes(int w, int h) { Size DesktopBitmapSize = GetDesktopBitmapSize(); Graphics Graphic = Graphics.FromHwnd(GetDesktopWindow()); Bitmap MemImage = new Bitmap(DesktopBitmapSize.Width, DesktopBitmapSize.Height, Graphic); Graphics MemGraphic = Graphics.FromImage(MemImage); IntPtr dc1 = Graphic.GetHdc(); IntPtr dc2 = MemGraphic.GetHdc(); BitBlt(dc2, 0, 0, DesktopBitmapSize.Width, DesktopBitmapSize.Height, dc1, 0, 0, SRCCOPY); Graphic.ReleaseHdc(dc1); MemGraphic.ReleaseHdc(dc2); Graphic.Dispose(); MemGraphic.Dispose(); Graphics g = System.Drawing.Graphics.FromImage(MemImage); System.Windows.Forms.Cursor cur = System.Windows.Forms.Cursors.Arrow; cur.Draw(g, new Rectangle(System.Windows.Forms.Cursor.Position.X - 10, System.Windows.Forms.Cursor.Position.Y - 10, cur.Size.Width, cur.Size.Height)); Image img = Get_Resized_Image(w, h, MemImage); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return(ms.GetBuffer()); }
/// <summary> /// 获取屏幕的bmp(带光标) /// </summary> /// <returns></returns> private static Bitmap getScreen() { #region int width = Screen.PrimaryScreen.Bounds.Width; int height = Screen.PrimaryScreen.Bounds.Height; Bitmap bmp = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(bmp)) { g.CopyFromScreen(0, 0, 0, 0, new Size(width, height)); CURSORINFO pci; pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); while (true) { bool issuccess = GetCursorInfo(out pci); if (issuccess && pci.hCursor != IntPtr.Zero) { break; } Thread.Sleep(100); } System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor); cur.Draw(g, new Rectangle(pci.ptScreenPos.x - 10, pci.ptScreenPos.y - 10, cur.Size.Width, cur.Size.Height)); } //bmp.compress() return(bmp); #endregion }
ImageSource ConvertFromWindowFormCursor(System.Windows.Forms.Cursor cursor) { int width = cursor.Size.Width; int height = cursor.Size.Height; System.Drawing.Bitmap b = new System.Drawing.Bitmap(width, height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b); cursor.Draw(g, new System.Drawing.Rectangle(0, 0, width, height)); AssociatedObject.RenderTransform = new TranslateTransform(-cursor.HotSpot.X, 0); ImageSource img = Imaging.CreateBitmapSourceFromHIcon(b.GetHicon(), new Int32Rect(0, 0, width, height), BitmapSizeOptions.FromEmptyOptions()); return(img); }
// カーソルの追加描画 public static Bitmap AddCursor(Image img) { // 描画位置 Point position = new Point(shotPoint.X - shotCursorHotspot.X - minX, shotPoint.Y - shotCursorHotspot.Y - minY); // 描画先とするImageオブジェクトを作成する Bitmap bmp = (Bitmap)img.Clone(); // ImageオブジェクトのGraphicsオブジェクトを作成する Graphics g = Graphics.FromImage(bmp); // 'Cursorsクラスの静的プロパティを取得する System.Windows.Forms.Cursor cur = shotCursor; // カーソルを描画する cur.Draw(g, new Rectangle(position, cur.Size)); return(bmp); }
public static Bitmap GetSystemCursorBitmap(System.Windows.Forms.Cursor cursor) { Bitmap bitmap = new Bitmap( cursor.Size.Width, cursor.Size.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bitmap); cursor.Draw(graphics, new Rectangle(new Point(0, 0), cursor.Size)); bitmap = Crop(bitmap); return(bitmap); }
private void capture_cursor_type() { CURSORINFO pci; pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); GetCursorInfo(out pci); System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor); Image img = new Bitmap(cur.Size.Width, cur.Size.Height); Graphics gc = Graphics.FromImage(img); cur.Draw(gc, new System.Drawing.Rectangle(0, 0, cur.Size.Width, cur.Size.Height)); img.Save(@"C:\Users\DELL\Documents\Visual Studio 2008\Projects\Happy_Fishing\target_cursor.jpg"); gc.Dispose(); img.Dispose(); }
public static byte[] Cut_Screen() { int width = Screen.PrimaryScreen.Bounds.Width; int height = Screen.PrimaryScreen.Bounds.Height; Bitmap bmp = new Bitmap(width, height); Image myimage = bmp; Graphics g = Graphics.FromImage(myimage); g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)); //获取鼠标 CURSORINFO pci; pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); GetCursorInfo(out pci); System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor); cur.Draw(g, new Rectangle(pci.ptScreenPos.x - 10, pci.ptScreenPos.y - 10, cur.Size.Width, cur.Size.Height)); Image cutImage = ChangeImageWithByte.GetThumbnail(myimage); //转换大小 byte[] imageByte = ChangeImageWithByte.ImgToByt(cutImage); return(imageByte); }
public Image GetDesktopImage() { Size DesktopBitmapSize = GetDesktopBitmapSize(); Graphics Graphic = Graphics.FromHwnd(GetDesktopWindow()); Bitmap MemImage = new Bitmap(DesktopBitmapSize.Width, DesktopBitmapSize.Height, Graphic); Graphics MemGraphic = Graphics.FromImage(MemImage); IntPtr dc1 = Graphic.GetHdc(); IntPtr dc2 = MemGraphic.GetHdc(); BitBlt(dc2, 0, 0, DesktopBitmapSize.Width, DesktopBitmapSize.Height, dc1, 0, 0, SRCCOPY); Graphic.ReleaseHdc(dc1); MemGraphic.ReleaseHdc(dc2); Graphic.Dispose(); MemGraphic.Dispose(); Graphics g = System.Drawing.Graphics.FromImage(MemImage); System.Windows.Forms.Cursor cur = System.Windows.Forms.Cursors.Arrow; cur.Draw(g, new Rectangle(System.Windows.Forms.Cursor.Position.X - 10, System.Windows.Forms.Cursor.Position.Y - 10, cur.Size.Width, cur.Size.Height)); return(MemImage); }
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; }
private Point move_2_fishing_cursor_position() { int compare_step_length_i = 25; //定义鼠标移动的横向步长,后期作成程序界面设置接入 int compare_step_length_j = 25; //定义鼠标移动的纵向步长,后期作成程序界面设置接入 int compare_step_time = 10; //定义鼠标移动的时间间隔,后期作成程序界面设置接入 Point cursor_position = new Point(88, 88); CURSORINFO pci; pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); bool whether_found_the_float = false;//初始化是否已经找到鱼漂位置的布尔值 #region 控制递归循环的次数,超过fishing_cursor_check_max次就不再继续 fishing_cursor_checks++; if (fishing_cursor_checks == fishing_cursor_check_max) { fishing_cursor_checks = 0; return(cursor_position); } #endregion else { #region [ 重要 ]核心对比代码 for (int j = 0; j *compare_step_length_j <= 150; j++) //参考目前17张图片对比测试范围是BS(71)12 ~ CO(93)19 { for (int i = 0; i *compare_step_length_i <= 650; i++) { //i的变化范围取决于i * compare_step_length有没有达到650,即从400到1050,这样就不必再针对步长重新设置 i; //j的变化范围取决于j * compare_step_length有没有达到200,即从122到322,这样就不必再针对步长重新设置 j; #region [ 已置后 ] 步进鼠标位置。有些情况下,上一次收线的鼠标位置正好是下一次鱼漂的位置,因此先判断是否满足鼠标样式,再移动鼠标,因此该段代码置后 //cursor_position.X = i * compare_step_length_i + 600;//即从横向600的位置开始计算,这样步长就有意义; //cursor_position.Y = j * compare_step_length_j + 122;//即从纵向122的位置开始计算,这样步长就有意义; //SetCursorPos(cursor_position.X, cursor_position.Y); #endregion #region [ 未使用 ] 移动鼠标后调用截取鼠标样式函数来获取当前鼠标的样式 //Thread.Sleep(500); //capture_cursor_type(); //#endregion //#region 获取鼠标样式后调用鼠标对比函数(图片路径)来判断是否为钓鱼鼠标 //Thread.Sleep(compare_step_time); //if (image_whether_match(@"C:\Users\DELL\Documents\Visual Studio 2008\Projects\Happy_Fishing\base_cursor.jpg", @"C:\Users\DELL\Documents\Visual Studio 2008\Projects\Happy_Fishing\target_cursor.jpg")) //{ // whether_found_the_float = true; // break; //} #endregion #region [ 使用 ] 获取鼠标样式后调用鼠标对比函数(图片)来判断是否为钓鱼鼠标 Thread.Sleep(compare_step_time); pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); GetCursorInfo(out pci); System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor); Image img = new Bitmap(cur.Size.Width, cur.Size.Height); Graphics gc = Graphics.FromImage(img); cur.Draw(gc, new System.Drawing.Rectangle(0, 0, cur.Size.Width, cur.Size.Height)); if (image_whether_match(base_cursor_image, (Bitmap)img)) { whether_found_the_float = true; GetCursorPos(out cursor_position);//解决第二次放线正好是上次位置时导致的不显示音量的问题 //cursor_position.X = i * compare_step_length_i + 600 + 5;//+5的目的是让鼠标横向再移动5个像素,确保在鱼漂上面 //cursor_position.Y = j * compare_step_length_j + 122 + 5;//+5的目的是让鼠标纵向再移动5个像素,确保在鱼漂上面 //SetCursorPos(cursor_position.X, cursor_position.Y); gc.Dispose(); img.Dispose(); break; } else { gc.Dispose(); //不管是否一致都释放资源 img.Dispose(); //不管是否一致都释放资源 } #endregion #region 步进鼠标位置 cursor_position.X = i * compare_step_length_i + 400; //即从横向400的位置开始计算,这样步长就有意义; cursor_position.Y = j * compare_step_length_j + 122; //即从纵向122的位置开始计算,这样步长就有意义; SetCursorPos(cursor_position.X, cursor_position.Y); #endregion } if (whether_found_the_float) { break; } } #endregion #region 使用递归的方法解决一些发现的横向移动过头的情况 Thread.Sleep(100); GetCursorInfo(out pci); System.Windows.Forms.Cursor cur_over_move = new System.Windows.Forms.Cursor(pci.hCursor); Image img_over_move = new Bitmap(cur_over_move.Size.Width, cur_over_move.Size.Height); Graphics gc_over_move = Graphics.FromImage(img_over_move); cur_over_move.Draw(gc_over_move, new System.Drawing.Rectangle(0, 0, cur_over_move.Size.Width, cur_over_move.Size.Height)); if (image_whether_match(base_cursor_image, (Bitmap)img_over_move) == false) { //cursor_position.X = cursor_position.X - 15; //cursor_position.Y = cursor_position.Y + 15; //SetCursorPos(cursor_position.X, cursor_position.Y); cursor_position = move_2_fishing_cursor_position(); } #endregion fishing_cursor_checks = 0; return(cursor_position); } }
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(); }
// 取得螢幕之位元組陣列 public byte[] GetDesktopBuffer() { // 取得螢幕的寬度與高度並建立Size物件 System.Drawing.Size desktopsize = new System.Drawing.Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); // 取得視窗的控制代碼 (Handle to a Window) IntPtr hwnd = GetDesktopWindow(); // 從視窗控制代碼建立新的Graphics物件 System.Drawing.Graphics graphics = System.Drawing.Graphics.FromHwnd(hwnd); // 封裝 GDI+ 點陣圖並建立Bitmap物件 // 參數: // width: 新Bitmap的寬度 // height: 新Bitmap的高度 // grapics: 新Bitmap解析度的Graphics物件 System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(desktopsize.Width, desktopsize.Height, graphics); // 從指定的Image建立新Graphics物件 System.Drawing.Graphics bitmapGraphics = System.Drawing.Graphics.FromImage(bitmap); // 取得來源區域之裝置內容控制代碼 (Handle to a Device Context) IntPtr hdcSrc = graphics.GetHdc(); // 取得目的區域之裝置內容控制代碼 IntPtr hdcDest = bitmapGraphics.GetHdc(); // 自來源區域之裝置內容控制代碼位元區塊轉移至目的區域之裝置內容控制代碼 BitBlt(hdcDest, 0, 0, desktopsize.Width, desktopsize.Height, hdcSrc, 0, 0, 0xCC0020); // 釋放由裝置內容控制代碼。 graphics.ReleaseHdc(hdcSrc); // 釋放由裝置內容控制代碼。 bitmapGraphics.ReleaseHdc(hdcDest); // 釋放Graphics物件所使用的所有資源 graphics.Dispose(); // 釋放Graphics物件所使用的所有資源 bitmapGraphics.Dispose(); /******************/ /* 繪製虛擬游標 */ /******************/ // 設定滑鼠游標為箭號游標 System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursors.Arrow; // 設定矩形左上角的 X 座標 int x = System.Windows.Forms.Cursor.Position.X - 10; // 設定矩形左上角的 Y 座標 int y = System.Windows.Forms.Cursor.Position.Y - 10; // 設定矩形的寬度 int width = cursor.Size.Width; // 設定矩形的高度 int height = cursor.Size.Height; // 從指定的Image建立新Graphics物件 System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap); // 建立新Rectangle物件 System.Drawing.Rectangle targetRect = new Rectangle(x, y, width, height); // 在指定的範圍內繪製虛擬游標 cursor.Draw(g, targetRect); /*****************************/ /* 儲存影像至記憶體資料流 */ /*****************************/ // 建立記憶體的資料流 System.IO.MemoryStream memStream = new System.IO.MemoryStream(); // 指定儲存之影像格式為JPEG格式 System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg; // 將影像以指定格式儲存至記憶體資料流 bitmap.Save(memStream, format); // 回傳記憶體資料流之位元組陣列 return(memStream.GetBuffer()); }
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; }
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); }
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(); } }
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); } }
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; }
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(); }
//获取桌面图像 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; }
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; } }