/// <summary>
        /// Measure a multiline string
        /// </summary>
        public static Size MeasureString(Graphics gr, Font font, string text, int width)
        {
            if (text == null) return new Size(1, 1);

            Rect bounds = new Rect() { Left = 0, Right = width, Bottom = 1, Top = 0 };
            IntPtr hDc = gr.GetHdc();
            try
            {
                int flags = DTCALCRECT | DTWORDBREAK;
                IntPtr controlFont = font.ToHfont();
                IntPtr originalObject = SelectObject(hDc, controlFont);
                try
                {
                    DrawText(hDc, text, text.Length, ref bounds, flags);
                }
                finally
                {
                    SelectObject(hDc, originalObject); // Release resources
                }
            }
            finally
            {
                gr.ReleaseHdc(hDc);
            }

            return new Size(bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
        }
        public static Rectangle GetHearthstoneRect(bool dpiScaling)
        {
            // Returns the co-ordinates of Hearthstone's client area in screen co-ordinates
            var hsHandle = GetHearthstoneWindow();
            var rect = new Rect();
            var ptUL = new Point();
            var ptLR = new Point();

            GetClientRect(hsHandle, ref rect);

            ptUL.X = rect.left;
            ptUL.Y = rect.top;

            ptLR.X = rect.right;
            ptLR.Y = rect.bottom;

            ClientToScreen(hsHandle, ref ptUL);
            ClientToScreen(hsHandle, ref ptLR);

            if(dpiScaling)
            {
                ptUL.X = (int)(ptUL.X / Helper.DpiScalingX);
                ptUL.Y = (int)(ptUL.Y / Helper.DpiScalingY);
                ptLR.X = (int)(ptLR.X / Helper.DpiScalingX);
                ptLR.Y = (int)(ptLR.Y / Helper.DpiScalingY);
            }

            return new Rectangle(ptUL.X, ptUL.Y, ptLR.X - ptUL.X, ptLR.Y - ptUL.Y);
        }
        public static string ocr(Bitmap CropedPrescription, int x, int y, int width, int height)
        {
            string text;

            // var PrescriptionImage = CropedPrescription;
            using (var engine = new TesseractEngine(@"C:\Program Files\Tesseract-OCR\tessdata\", "kor", EngineMode.Default))
            {
                engine.SetVariable("tessedit_char_whitelist", "0123456789-."); // 숫자와 . - 만 인식하도록 설정

                var roi = new Rect(x, y, width, height); // region of interest 좌표를 생성하고
                //     using (var img = Pix.LoadFromFile(PrescriptionImage))
                //      {
                using (var page = engine.Process(CropedPrescription, roi, PageSegMode.SingleLine))
                {
                    text = page.GetText();
                    System.IO.File.WriteAllText(@"C:\Program Files\PLOCR\textrecognition.html", text);  // 인식한 글자를 html 형식으로 저장한다.

                //    text = TextProcess.RemoveWhiteSpace(text);

                    //      Console.WriteLine("인식한 문자: \n{0}\n", text);
                    //   Console.Read();
                }
                //         }
            }

            return text;
        }
Exemple #4
0
 public virtual Bitmap GetVisibleImage()
 {
     var compatibleDeviceContext = IntPtr.Zero;
     var deviceContext = IntPtr.Zero;
     IntPtr bitmap = IntPtr.Zero;
     Image img;
     try
     {
         deviceContext = GetWindowDC(windowHandle);
         var rect = new Rect();
         GetWindowRect(windowHandle, ref rect);
         int width = rect.right - rect.left;
         int height = rect.bottom - rect.top;
         compatibleDeviceContext = CreateCompatibleDC(deviceContext);
         bitmap = CreateCompatibleBitmap(deviceContext, width, height);
         IntPtr @object = SelectObject(compatibleDeviceContext, bitmap);
         BitBlt(compatibleDeviceContext, 0, 0, width, height, deviceContext, 0, 0, srccopy);
         SelectObject(compatibleDeviceContext, @object);
     }
     finally
     {
         DeleteDC(compatibleDeviceContext);
         ReleaseDC(windowHandle, deviceContext);
         img = Image.FromHbitmap(bitmap);
         DeleteObject(bitmap);
     }
     using (img) return new Bitmap(img);
 }
Exemple #5
0
        public Bitmap Capture(enmScreenCaptureMode screenCaptureMode = enmScreenCaptureMode.Window)
        {
            Rectangle bounds;

            if (screenCaptureMode == enmScreenCaptureMode.Screen)
            {
            bounds = Screen.GetBounds(Point.Empty);
            CursorPosition = Cursor.Position;
            }
            else
            {
            var foregroundWindowsHandle = GetForegroundWindow();
            var rect = new Rect();
            GetWindowRect(foregroundWindowsHandle, ref rect);
            bounds = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
            CursorPosition = new Point(Cursor.Position.X - rect.Left, Cursor.Position.Y - rect.Top);
            }

            var result = new Bitmap(bounds.Width, bounds.Height);

            using (var g = Graphics.FromImage(result))
            {
            g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
            }

            return result;
        }
Exemple #6
0
 public Notice(Point p, int duration, string txt)
     : base(Game.game, txt)
 {
     pos = p;
     life = duration;
     text = txt;
     float splits = txt.Length / 20f;
     if (splits > 1)
     {
         int upper = (int)Math.Ceiling(splits - 1); //if the number is an integer, take away one, otherwise if there's a decimal portion have it remain
         for (int i = 1; i <= upper; i++)
         {
             int position = i * 20;
             text = text.Insert(position, "\n");
             numberOfLines++;
         }
     }
     texture = new Text(new Size(1024, 768), p);
     texture.textFont = new Font("Myriad Pro", 14);
     texture.Line = text;
     texture.Shadow = false;
     bg = new Rect(new Rectangle(pos, new Size(270 , numberOfLines * 22)));
     bg.Colour = Color.Gray;
     bg.Alpha = .9f;
 }
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_SIZING && m.HWnd.Equals(this.Handle))
            {
                Rect r = new Rect();
                r = (Rect)Marshal.PtrToStructure(m.LParam, r.GetType());

                double width = r.Right - r.Left;
                double height = r.Bottom - r.Top;

                if (height / width > aspect_ratio((int)width))
                    width = height / aspect_ratio((int)width);
                else
                    height = width * aspect_ratio((int)width);

                if (m.WParam.ToInt32() == WMSZ_TOP || m.WParam.ToInt32() == WMSZ_TOPLEFT || m.WParam.ToInt32() == WMSZ_TOPRIGHT)
                    r.Top = r.Bottom - (int)height;
                else
                    r.Bottom = r.Top + (int)height;

                if (m.WParam.ToInt32() == WMSZ_LEFT || m.WParam.ToInt32() == WMSZ_TOPLEFT || m.WParam.ToInt32() == WMSZ_BOTTOMLEFT)
                    r.Left = r.Right - (int)width;
                else
                    r.Right = r.Left + (int)width;

                Marshal.StructureToPtr(r, m.LParam, true);
            }

            base.WndProc(ref m);
        }
Exemple #8
0
        //first downloadasync didn't work until window was moved for no reason, then threading context issues... ;_;
        /// <summary>
        /// temporarily disabled until avatars are sorted
        /// </summary>
        public void downloadAvatar()
        {
            if (Account.currentAccount != null)
            {
                //if (!string.IsNullOrWhiteSpace(Account.currentAccount.AvatarUrl))
                //{
                avatar = null;
                done = false;
                Thread t = new Thread(new ThreadStart(downloadThread));
                t.IsBackground = true;
                t.Start();
                //   }
            }
            #region obsolete

            /* wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
                wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
                wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);

                Console.WriteLine("starting d/l");
              //  HttpWebRequest req = HttpWebRequest.Create("");

                wc.DownloadFileAsync(new Uri("http://rep.ulse.net/uploads/profile/photo-323.gif"), Path.GetTempPath() + "pulsetempavi.jpg");

                Console.WriteLine("started async," + wc.IsBusy);
                //        Console.WriteLine("done downloading avatar");
                //          Image i = Image.FromFile(Path.GetTempPath() + "pulsetempavi.jpg");
                //            avatar = new Rect(new Rectangle(Utils.getMX(800), 10, i.Width, i.Height), Path.GetTempPath() + "pulsetempavi.jpg");
              */
            #endregion
        }
Exemple #9
0
 public HitObject(Game game, int offset, Point location)
 {
     this.location = location;
     this.approach = offset - (1200 - (approach * 100));
     texture = new Rect(new Rectangle(location.X - 100, location.Y - 100, 200, 200), Skin.skindict["circle"]);
     approachTexture = new Rect(new Rectangle(location.X - 200, location.Y - 200, 400, 400), Skin.skindict["app"]);
 }
 protected Rect GetOKBounds( )
 {
     IntPtr hwndOK = GetDlgItem ( dia.Handle, 0x0001 );
     Rect retVal = new Rect ( );
     GetWindowRect ( hwndOK, retVal );
     return retVal;
 }
Exemple #11
0
		/// <summary>
		/// Extracts a rectangular portion of the original image.
		/// </summary>
		/// <param name="bm">The original Bitmap.</param>
		/// <param name="rect">The rectangular portion to extract.</param>
		/// <returns>A new Bitmap containing the selected area.</returns>
		public static Bitmap SubImage(this Bitmap bm, Rect rect)
		{
			return SubImage(bm,
				MathF.RoundToInt(rect.X),
				MathF.RoundToInt(rect.Y),
				MathF.RoundToInt(rect.W),
				MathF.RoundToInt(rect.H));
		}
 protected Rect GetRememberBounds( )
 {
     IntPtr hwndSysCred = GetDlgItem ( dia.Handle, 0x03EA );
     IntPtr hwndRemember = GetDlgItem ( hwndSysCred, 0x03EF );
     Rect retVal = new Rect ( );
     GetWindowRect ( hwndRemember, retVal );
     return retVal;
 }
 private void AdjustSize()
 {
     var rect = new Rect();
     if (GetClientRect(_parentHandle, ref rect) != 0)
     {
         Size = new Size(rect.Right - rect.Left, rect.Bottom - rect.Top);
     }
 }
Exemple #14
0
		internal static CocoaContext GetCGContextForNSView (IntPtr handle) {
			IntPtr graphicsContext = objc_msgSend (objc_getClass ("NSGraphicsContext"), sel_registerName ("currentContext"));
			IntPtr ctx = objc_msgSend (graphicsContext, sel_registerName ("graphicsPort"));
			Rect bounds = new Rect ();

			objc_msgSend_stret (ref bounds, handle, sel_registerName ("bounds"));

			return new CocoaContext (ctx, (int) bounds.size.width, (int) bounds.size.height);
		}
Exemple #15
0
        public static bool MoveMouseToWoWCoords(float x, float y, float z)
        {
            var pseudoVec = new Vector3D(x, y, z); //not really a vector. its the location we want to click
            IntPtr hwnd = ProcessManager.WowProcess.WindowHandle; //windowhandle for getting size
            var camera = new CameraInfo();
            //Read information
            uint pAddr2 =
                ProcessManager.WowProcess.ReadUInt((ProcessManager.WowProcess.ReadUInt(
                    ProcessManager.GlobalOffsets.CameraPointer)) +
                        ProcessManager.GlobalOffsets.CameraOffset);
            var bCamera = new byte[68];
            bCamera = ProcessManager.WowProcess.ReadBytes(pAddr2, 68);

            //Convert bytes to usable data
            camera.Pos = new Vector3D(BitConverter.ToSingle(bCamera, 8),
                                    BitConverter.ToSingle(bCamera, 12),
                                        BitConverter.ToSingle(bCamera, 16));
            camera.ViewMat = new Matrix(BitConverter.ToSingle(bCamera, 20),
                BitConverter.ToSingle(bCamera, 24), BitConverter.ToSingle(bCamera, 28),
                BitConverter.ToSingle(bCamera, 32), BitConverter.ToSingle(bCamera, 36),
                BitConverter.ToSingle(bCamera, 40), BitConverter.ToSingle(bCamera, 44),
                BitConverter.ToSingle(bCamera, 48), BitConverter.ToSingle(bCamera, 52));
            camera.Foc = BitConverter.ToSingle(bCamera, 64);
            //Get windoesize
            var rc = new Rect();
            GetClientRect(hwnd, ref rc);

            //Vector camera -> object
            Vector3D Diff = pseudoVec - camera.Pos;

            if ((Diff*camera.ViewMat.getFirstColumn) < 0)
            {
                return false;
            }

            Vector3D View = Diff * camera.ViewMat.inverse();
            var Cam = new Vector3D(-View.Y, -View.Z, View.X);

            float fScreenX = (rc.right - rc.left)/2.0f;
            float fScreenY = (rc.bottom - rc.top)/2.0f;
            //Aspect ratio
            float fTmpX = fScreenX/(float) Math.Tan(((camera.Foc*44.0f)/2.0f)*Deg2Rad);
            float fTmpY = fScreenY/(float) Math.Tan(((camera.Foc*35.0f)/2.0f)*Deg2Rad);

            var pctMouse = new Point();
            pctMouse.X = (int) (fScreenX + Cam.X*fTmpX/Cam.Z);
            pctMouse.Y = (int) (fScreenY + Cam.Y*fTmpY/Cam.Z);

            if (pctMouse.X < 0 || pctMouse.Y < 0 || pctMouse.X > rc.right || pctMouse.Y > rc.bottom)
            {
                return false;
            }

            ProcessManager.CommandManager.MoveMouse(pctMouse.X, pctMouse.Y);
            return true;
        }
 /// <summary>
 /// Measure a multiline string for a Control
 /// </summary>
 /// <param name="gr">Graphics</param>
 /// <param name="text">String to messure</param>
 /// <param name="rect">Original rect. The Width will be taken as fixed</param>
 /// <param name="textboxControl">True if you want to measure the string for a textbox control</param>
 /// <returns>A Size object with the measure of the string according with the params</returns>
 public static Size MeasureString(Graphics gr, string text, Rectangle rect, bool textboxControl)
 {
     Rect bounds = new Rect(rect);
     IntPtr hdc = gr.GetHdc();
     int flags = DT_CALCRECT | DT_WORDBREAK;
     if (textboxControl) flags |= DT_EDITCONTROL;
     DrawText(hdc, text, text.Length, ref bounds, flags);
     gr.ReleaseHdc(hdc);
     return new Size(bounds.Right - bounds.Left, bounds.Bottom - bounds.Top + (textboxControl ? 6 : 0));
 }
Exemple #17
0
 public Button(Game game, Rectangle bounds, string text, clicked c, bool stretch, bool custom, Color col)
     : this(game, bounds, text, c)
 {
     if (stretchable = stretch) //rofl n1 matt
     {
         end1 = new Rect(new Rectangle(bounds.X, bounds.Y, 65, bounds.Height), Skin.skindict["buttonLeft"]);
         end2 = new Rect(new Rectangle(bounds.X + bounds.Width - 63, bounds.Y, 66, bounds.Height), Skin.skindict["buttonRight"]);
         texture = new Rect(new Rectangle(bounds.X + 65, bounds.Y, bounds.Width - 128, bounds.Height), Skin.skindict["buttonMid"]);
         TextTexture.Location = new Point((bounds.X + bounds.Width / 2) - ((int)Pulse.Text.getStringSize(text, textTexture.textFont).Width / 2), bounds.Y + (bounds.Height / 2) - 20);
     }
     customcol = custom;
     this.custom = col;
 }
Exemple #18
0
        /// <summary> Capture a specific window and return it as a bitmap </summary>
        /// <param name="handle">hWnd (handle) of the window to capture</param>
        public static Bitmap Capture(IntPtr handle)
        {
            System.Drawing.Rectangle bounds;
                var rect = new Rect();
                GetWindowRect(handle, ref rect);
                bounds = new System.Drawing.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
                CursorPosition = new System.Drawing.Point(Cursor.Position.X - rect.Left, Cursor.Position.Y - rect.Top);

                var result = new Bitmap(bounds.Width, bounds.Height);
                using (var g = Graphics.FromImage(result))
                     g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), System.Drawing.Point.Empty, bounds.Size);

                return result;
        }
        private static Bitmap CaptureWindow(IntPtr handle)
        {
            var rect = new Rect();
            GetWindowRect(handle, ref rect);
            var bounds = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
            var result = new Bitmap(bounds.Width, bounds.Height);

            using (var graphics = Graphics.FromImage(result))
            {
                graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
            }

            return result;
        }
Exemple #20
0
 public Frame(Point location, bool middleEdit, bool editor)
     : this(location, 8)
 {
     this.editor = editor;
     if (editor)
     {
         bottomFrame = null;
         keyReleased.Clear();
         left = null;
     }
     if (middleEdit)
     {
         hitBar = new Rect(new Rectangle(location.X, location.Y + (((int)hitHeight - 4) / 2), (int)width, 8), Skin.skindict["hitBar"]);
     }
 }
 public static void CaptureActiveWindow(string location, ImageFormat imageFormat)
 {
     var foregroundWindowHandle = GetForegroundWindow();
     var rect = new Rect();
     GetWindowRect(foregroundWindowHandle, ref rect);
     var bounds = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
     using (var bitmap = new Bitmap(bounds.Width, bounds.Height))
     {
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
         }
         bitmap.Save(location, imageFormat);
     }
 }
        public static Bitmap GetWindowImage(IntPtr windowHandle)
        {
            var boundsRect = new Rect();

            GetWindowRect(windowHandle, ref boundsRect);
            var bounds = new Rectangle(boundsRect.Left, boundsRect.Top, boundsRect.Right - boundsRect.Left, boundsRect.Bottom - boundsRect.Top);

            var bitmap = new Bitmap(bounds.Width, bounds.Height);

            using (var g = Graphics.FromImage(bitmap))
            {
                g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), System.Drawing.Point.Empty, bounds.Size);
            }

            return bitmap;
        }
Exemple #23
0
		internal static CocoaContext GetCGContextForNSView (IntPtr handle) {
			IntPtr graphicsContext = objc_msgSend (objc_getClass ("NSGraphicsContext"), sel_registerName ("currentContext"));
			IntPtr ctx = objc_msgSend (graphicsContext, sel_registerName ("graphicsPort"));
			Rect bounds = new Rect ();

			objc_msgSend_stret (ref bounds, handle, sel_registerName ("bounds"));

			var isFlipped = bool_objc_msgSend (handle, sel_registerName ("isFlipped"));
			if (isFlipped) {
				CGContextSaveGState (ctx);
				CGContextTranslateCTM (ctx, bounds.origin.x, bounds.size.height);
				CGContextScaleCTM (ctx,1.0f,-1.0f);
			}

			return new CocoaContext (ctx, (int) bounds.size.width, (int) bounds.size.height);
		}
        /// <summary>
        /// creates and returns the screenshot of the currently active window
        /// </summary>
        /// <returns></returns>
        private static Screenshot CaptureWindow()
        {
            try
            {
                var ptrHandle = GetForegroundWindow(); // currently active window
                var rect = new Rect();

                //var test = Screen.AllScreens; // => http://stackoverflow.com/questions/3827367/how-can-i-take-a-picture-from-screen (get rect for screen)

                // screen resolution stuff (device-independent units -> Pixels)
                double dpiX;
                double dpiY;
                using (var g = Graphics.FromHwnd(IntPtr.Zero)) // use using to dispose afterwards
                {
                    dpiX = (g.DpiX / 96.0); //TODO: directly here to 300 dpi?
                    dpiY = (g.DpiY / 96.0);
                }

                rect.Right = Convert.ToInt32(rect.Right / dpiX);
                rect.Left = Convert.ToInt32(rect.Left / dpiX);
                rect.Bottom = Convert.ToInt32(rect.Bottom / dpiY);
                rect.Top = Convert.ToInt32(rect.Top / dpiY);

                // get bounds, etc.
                GetWindowRect(ptrHandle, ref rect);
                var width = Math.Abs(rect.Right - rect.Left);
                var height = Math.Abs(rect.Bottom - rect.Top);
                var bounds = new Rectangle(rect.Left, rect.Top, width, height);
                var result = new Bitmap(bounds.Width, bounds.Height);

                // get screenshot
                using (var graphics = Graphics.FromImage(result)) // use using to dispose afterwards
                {
                    graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                    graphics.Dispose();
                }

                var sc = new Screenshot(result);
                return sc;
            }
            catch (Exception e)
            {
                Logger.WriteToLogFile(e);
            }

            return null;
        }
Exemple #25
0
        /// <summary>
        /// Measure a multiline string
        /// </summary>
        public static Size MeasureString(Graphics gr, Font font, string text, int width)
        {
            try{
                Rect bounds = new Rect() { Left = 0, Right = width, Bottom = 1, Top = 0 };
                IntPtr hDc = gr.GetHdc();
                int flags = DTCALCRECT | DTWORDBREAK;
                IntPtr controlFont = font.ToHfont();
                IntPtr originalObject = SelectObject(hDc, controlFont);
                DrawText(hDc, text, text.Length, ref bounds, flags);
                SelectObject(hDc, originalObject); // Release resources
                gr.ReleaseHdc(hDc);

                return new Size(bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
            }catch(Exception){
                return Size.Empty;
            }
        }
        /// <summary>
        /// Processes the specific image.
        /// </summary>
        /// <remarks>
        /// You can only have one result iterator open at any one time.
        /// </remarks>
        /// <param name="image">The image to process.</param>
        /// <param name="region">The image region to process.</param>
        /// <returns>A result iterator</returns>
        public Page Process(Pix image, Rect region, PageSegMode? pageSegMode = null)
        {
            if (image == null) throw new ArgumentNullException("image");
            if (region.X1 < 0 || region.Y1 < 0 || region.X2 > image.Width || region.Y2 > image.Height)
                throw new ArgumentException("The image region to be processed must be within the image bounds.", "region");
            if (processCount > 0) throw new InvalidOperationException("Only one image can be processed at once. Please make sure you dispose of the page once your finished with it.");

            processCount++;

            Interop.TessApi.BaseAPISetPageSegMode(handle, pageSegMode.HasValue ? pageSegMode.Value : DefaultPageSegMode);
            Interop.TessApi.BaseApiSetImage(handle, image.Handle);
            Interop.TessApi.BaseApiSetRectangle(handle, region.X1, region.Y1, region.Width, region.Height);

            var page = new Page(this);
            page.Disposed += OnIteratorDisposed;
            return page;
        }
        public static void CreateBox(Rect rectangle)
        {
            Form f = new Form();
            f.Name = BoxName;
            f.BackColor = Color.AliceBlue;
            f.FormBorderStyle = FormBorderStyle.None;
            f.TopMost = true;
            f.Opacity = 0.3;

            Application.EnableVisualStyles();
            Task.Run(() =>
            {
                Application.Run(f);
            });

            MoveBox(rectangle);
        }
Exemple #28
0
 public Dragbar(Game game, Point pos, int length, bool vert, dragged d)
     : base(game, new Rectangle(pos.X, pos.Y, 13, length))
 {
     OnLoad(null);
     vertical = vert;
     if (!vertical)
     {
         bounds = new Rectangle(Bounds.Location, new Size(length, 13));
         texture = new Rect(new Rectangle(bounds.X, bounds.Y + 8, bounds.Width, bounds.Height), Skin.skindict["hbar"]);
     }
     else
     {
         texture = new Rect(new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height), Skin.skindict["bar"]);
     }
     del = d;
     this.Length = length;
 }
Exemple #29
0
        static void Main(string[] args)
        {
            var proc = Process.GetProcessesByName("notepad")[0];

            InvokeHelper.SetForegroundWindow(proc.MainWindowHandle);

            var rect = new Rect();
            InvokeHelper.GetWindowRect(proc.MainWindowHandle, ref rect);

            int width = rect.right - rect.left;
            int height = rect.bottom - rect.top;

            var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(bmp);
            graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

            bmp.Save("c:\\test.png", ImageFormat.Png);
        }
        public void DrawDotRectangle(Rect theRect, System.Drawing.Color lineColor)
        {
            if (lineColor == System.Drawing.Color.Transparent)
            {
                return;
            }

            IntPtr hPen = API.CreatePen(API.PenStyle.PS_DOT, 1, System.Drawing.ColorTranslator.ToWin32(lineColor));
            IntPtr hOldPen = API.SelectObject(hDC, hPen);

            IntPtr hBrush = API.GetStockObject(5); // NULL_BRUSH
            IntPtr hOldBrush = API.SelectObject(hDC, hBrush);

            API.Rectangle(hDC, theRect.Location.X, theRect.Location.Y, theRect.Right, theRect.Bottom);

            API.SelectObject(hDC, hOldBrush);
            API.SelectObject(hDC, hOldPen);
            API.DeleteObject(hPen);
        }