private void AddColor(IColor c) { CrossThreading.UIInvoke(() => { foreach (ListViewItem item in recordView.Items) { if (item.SubItems[1].Text == c.ToString()) { return; } } Copy(c); ListViewItem itm = PaletteManager.Add(selectedPaletteName, c, GetItemIconIndex(c)); recordView.Items.Add(itm); recordView.EnsureVisible(recordView.Items.Count - 1); }); }
private void Processing() { // Prevent Zoom Tolerance float Zoom = setting.Zoom; // ViewSize Size vSize = new Size(100, 100); // View Half Size Size vhSize = new Size(vSize.Width / 2, vSize.Height / 2); // Capture Size Size scSize = new Size(SelectOdd(vSize.Width / Zoom), SelectOdd(vSize.Height / Zoom)); // ZoomBuffer Size Size zbSize = new Size((int)(scSize.Width * Zoom), (int)(scSize.Height * Zoom)); // Remain Size Size rmSize = zbSize - vSize; // Capture Area Point mPt = Mouse.Position; if (IsActivated && IntersectWith(this.Bounds, mPt)) { if (mInWorkArea) { return; } else { mInWorkArea = true; } mPt = this.Location; } else { mInWorkArea = false; } Rectangle area = new Rectangle(mPt.X - scSize.Width / 2, mPt.Y - scSize.Height / 2, scSize.Width, scSize.Height); // Capture Bitmap buffer = ScreenCapture.Capture(area); // Picked Color Color pColor = buffer.GetPixel(area.Width / 2, area.Height / 2); // ViewBox Processing Bitmap view = new Bitmap(vSize.Width, vSize.Height); using (Graphics g = Graphics.FromImage(view)) { Point dPos = new Point(-rmSize.Width / 2, -rmSize.Height / 2); g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(buffer, new Rectangle(dPos, zbSize)); // Grid Processing if (setting.ShowGrid && Zoom >= 2f) { using (SolidBrush sb = new SolidBrush(Color.FromArgb(100, Color.White))) { using (Pen p = new Pen(sb)) { int z = (int)Zoom; for (int x = dPos.X; x <= vSize.Width; x += z) { if (x >= 0) { g.DrawLine(p, new PointF(x, 0), new PointF(x, vSize.Height)); } } for (int y = dPos.Y; y <= vSize.Height; y += z) { if (y >= 0) { g.DrawLine(p, new PointF(0, y), new PointF(vSize.Width, y)); } } } } } // CrossLine Processing for (int x = 0; x < vSize.Width; x++) { Color px = view.GetPixel(x, vhSize.Height); view.SetPixel(x, vhSize.Height, ColorUtils.Invert(px)); } for (int y = 0; y < vSize.Height; y++) { Color px = view.GetPixel(vhSize.Width, y); view.SetPixel(vhSize.Width, y, ColorUtils.Invert(px)); } } buffer.Dispose(); SetPickedColor(pColor); CrossThreading.UIInvoke(() => { ldcPlate.BaseColor = pColor; viewBox.Image?.Dispose(); viewBox.Image = view; }); }