1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Delete { public partial class FormMain : Form { public FormMain() { InitializeComponent(); } [DllImport("user32.dll")] private static extern IntPtr GetDC(IntPtr hwnd); [DllImport("gdi32.dll")] private static extern int GetPixel(IntPtr hdc, Point p);
private void lete_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("http://lete114.github.io/"); } private void LeteTools_Load(object sender, EventArgs e) { this.tm.Enabled = true; this.tm.Interval = 1; }
private void tm_Tick(object sender, EventArgs e) { Timer tim = new Timer(); tim.Interval = 1; tim.Tick += delegate { Point p = new Point(MousePosition.X, MousePosition.Y); IntPtr hdc = GetDC(new IntPtr(0)); int c = GetPixel(hdc, p); int r = (c & 0xFF); int g = (c & 0xFF00) / 256; int b = (c & 0xFF0000) / 65536; lblR255.Text = r.ToString(); lblG255.Text = g.ToString(); lblB255.Text = b.ToString();
FormMain lt = new FormMain(); lblVHEX.Text = lt.convertRGBToHex(r, g, b);
lblVX.Text = Control.MousePosition.X.ToString(); lblVY.Text = Control.MousePosition.Y.ToString();
}; tim.Start();
}
public String convertRGBToHex(int r, int g, int b) { String rFString, rSString, gFString, gSString, bFString, bSString, result; int red, green, blue; int rred, rgreen, rblue; red = r / 16; rred = r % 16; if (red == 10) rFString = "A"; else if (red == 11) rFString = "B"; else if (red == 12) rFString = "C"; else if (red == 13) rFString = "D"; else if (red == 14) rFString = "E"; else if (red == 15) rFString = "F"; else rFString = red.ToString();
if (rred == 10) rSString = "A"; else if (rred == 11) rSString = "B"; else if (rred == 12) rSString = "C"; else if (rred == 13) rSString = "D"; else if (rred == 14) rSString = "E"; else if (rred == 15) rSString = "F"; else rSString = rred.ToString();
rFString = rFString + rSString;
green = g / 16; rgreen = g % 16;
if (green == 10) gFString = "A"; else if (green == 11) gFString = "B"; else if (green == 12) gFString = "C"; else if (green == 13) gFString = "D"; else if (green == 14) gFString = "E"; else if (green == 15) gFString = "F"; else gFString = green.ToString();
if (rgreen == 10) gSString = "A"; else if (rgreen == 11) gSString = "B"; else if (rgreen == 12) gSString = "C"; else if (rgreen == 13) gSString = "D"; else if (rgreen == 14) gSString = "E"; else if (rgreen == 15) gSString = "F"; else gSString = rgreen.ToString();
gFString = gFString + gSString;
blue = b / 16; rblue = b % 16;
if (blue == 10) bFString = "A"; else if (blue == 11) bFString = "B"; else if (blue == 12) bFString = "C"; else if (blue == 13) bFString = "D"; else if (blue == 14) bFString = "E"; else if (blue == 15) bFString = "F"; else bFString = blue.ToString();
if (rblue == 10) bSString = "A"; else if (rblue == 11) bSString = "B"; else if (rblue == 12) bSString = "C"; else if (rblue == 13) bSString = "D"; else if (rblue == 14) bSString = "E"; else if (rblue == 15) bSString = "F"; else bSString = rblue.ToString(); bFString = bFString + bSString; result = "#" + rFString + gFString + bFString; return result;
}
private void Zhu_Click(object sender, EventArgs e) { Delete m = new Delete(); m.Show(); } } }
|