mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 05:23:24 -07:00
Made the color picker placement logic work for all screens.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1656 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c3287906a0
commit
c1330fb88c
1 changed files with 43 additions and 37 deletions
|
@ -29,50 +29,57 @@ namespace Greenshot.Forms {
|
||||||
/// Needed some modifications to be stable.
|
/// Needed some modifications to be stable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Zoomer : Form {
|
public partial class Zoomer : Form {
|
||||||
public Color color {
|
public Color color {
|
||||||
get {
|
get {
|
||||||
return preview.BackColor;
|
return preview.BackColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Zoomer() {
|
public Zoomer() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHotSpot(int x, int y) {
|
public void setHotSpot(int x, int y) {
|
||||||
Color c = GetPixelColor(x, y);
|
Color c = GetPixelColor(x, y);
|
||||||
preview.BackColor = c;
|
preview.BackColor = c;
|
||||||
html.Text = "#" + c.Name.Substring(2).ToUpper();
|
html.Text = "#" + c.Name.Substring(2).ToUpper();
|
||||||
red.Text = "" + c.R;
|
red.Text = "" + c.R;
|
||||||
blue.Text = "" + c.B;
|
blue.Text = "" + c.B;
|
||||||
green.Text = "" + c.G;
|
green.Text = "" + c.G;
|
||||||
alpha.Text = "" + c.A;
|
alpha.Text = "" + c.A;
|
||||||
|
|
||||||
Size cs = Cursor.Current.Size;
|
Size cs = Cursor.Current.Size;
|
||||||
Point hs = Cursor.Current.HotSpot;
|
Point hs = Cursor.Current.HotSpot;
|
||||||
|
|
||||||
Point zp = new Point(x, y);
|
Point zp = new Point(x, y);
|
||||||
zp.X += cs.Width + 2 - hs.X;
|
zp.X += cs.Width + 5 - hs.X;
|
||||||
zp.Y -= hs.Y;
|
zp.Y += cs.Height + 5 - hs.Y;
|
||||||
|
|
||||||
if (zp.X < 0) {
|
foreach (Screen screen in Screen.AllScreens) {
|
||||||
zp.X = 0;
|
Rectangle screenRectangle = screen.Bounds;
|
||||||
} else if (zp.X + Width > Screen.PrimaryScreen.Bounds.Width) {
|
if (screen.Bounds.Contains(x, y)) {
|
||||||
zp.X = x - Width - 2 - hs.X;
|
if (zp.X < screenRectangle.X) {
|
||||||
}
|
zp.X = screenRectangle.X;
|
||||||
|
} else if (zp.X + Width > screenRectangle.X + screenRectangle.Width) {
|
||||||
if (zp.Y < 0) {
|
zp.X = x - Width - 5 - hs.X;
|
||||||
zp.Y = 0;
|
}
|
||||||
} else if (zp.Y + Height > Screen.PrimaryScreen.Bounds.Height) {
|
|
||||||
zp.Y = Screen.PrimaryScreen.Bounds.Height - Height;
|
if (zp.Y < screenRectangle.Y) {
|
||||||
|
zp.Y = screenRectangle.Y;
|
||||||
|
} else if (zp.Y + Height > screenRectangle.Y + screenRectangle.Height) {
|
||||||
|
zp.Y = y - Height - 5 - hs.Y;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location = zp;
|
Location = zp;
|
||||||
}
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public void setHotSpot(Point screenCoordinates) {
|
public void setHotSpot(Point screenCoordinates) {
|
||||||
setHotSpot(screenCoordinates.X, screenCoordinates.Y);
|
setHotSpot(screenCoordinates.X, screenCoordinates.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static private Color GetPixelColor(int x, int y) {
|
static private Color GetPixelColor(int x, int y) {
|
||||||
IntPtr hdc = User32.GetDC(IntPtr.Zero);
|
IntPtr hdc = User32.GetDC(IntPtr.Zero);
|
||||||
|
@ -88,6 +95,5 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue