mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Fixed update issue with Dropper/Zoomer, now called Pipette and I will rename the zoomer.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1657 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c1330fb88c
commit
1116ff8a25
8 changed files with 70 additions and 72 deletions
|
@ -32,29 +32,29 @@ namespace Greenshot.Controls {
|
|||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||
/// Needed some modifications to be stable.
|
||||
/// </summary>
|
||||
public class Dropper : Label, IMessageFilter, IDisposable {
|
||||
public class Pipette : Label, IMessageFilter, IDisposable {
|
||||
private Zoomer zoomer;
|
||||
private bool dragging;
|
||||
private Cursor _cursor;
|
||||
private Bitmap _image;
|
||||
private const int VK_ESC = 27;
|
||||
|
||||
public event EventHandler<DropperUsedArgs> DropperUsed;
|
||||
public event EventHandler<PipetteUsedArgs> PipetteUsed;
|
||||
|
||||
public Dropper() {
|
||||
public Pipette() {
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
dragging = false;
|
||||
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("dropper.Image");
|
||||
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
|
||||
Image = _image;
|
||||
_cursor = CreateCursor((Bitmap)_image, 0, 15);
|
||||
zoomer = new Zoomer();
|
||||
zoomer.Visible = false;
|
||||
Application.AddMessageFilter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Dropper() {
|
||||
~Pipette() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace Greenshot.Controls {
|
|||
if (e.Button == MouseButtons.Left) {
|
||||
//Release Capture should consume MouseUp when canceled with the escape key
|
||||
User32.ReleaseCapture();
|
||||
DropperUsed(this, new DropperUsedArgs(zoomer.color));
|
||||
PipetteUsed(this, new PipetteUsedArgs(zoomer.color));
|
||||
}
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ namespace Greenshot.Controls {
|
|||
zoomer.Visible = true;
|
||||
} else {
|
||||
dragging = false;
|
||||
|
||||
Image = _image;
|
||||
Cursor = Cursors.Arrow;
|
||||
zoomer.Visible = false;
|
||||
}
|
||||
Update();
|
||||
base.OnMouseCaptureChanged(e);
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,10 @@ namespace Greenshot.Controls {
|
|||
#endregion
|
||||
}
|
||||
|
||||
public class DropperUsedArgs : EventArgs {
|
||||
public class PipetteUsedArgs : EventArgs {
|
||||
public Color color;
|
||||
|
||||
public DropperUsedArgs(Color c) {
|
||||
public PipetteUsedArgs(Color c) {
|
||||
color = c;
|
||||
}
|
||||
}
|
|
@ -557,12 +557,12 @@ namespace Greenshot.Drawing {
|
|||
switch (effect) {
|
||||
case Effects.Shadow:
|
||||
offset = new Point(6, 6);
|
||||
newImage = ImageHelper.CreateShadow((Bitmap)Image, 1f, 7, offset, PixelFormat.Format24bppRgb); //Image.PixelFormat);
|
||||
newImage = ImageHelper.CreateShadow((Bitmap)Image, 1f, 7, offset, PixelFormat.Format32bppRgb); //Image.PixelFormat);
|
||||
break;
|
||||
case Effects.TornEdge:
|
||||
offset = new Point(5, 5);
|
||||
using (Bitmap tmpImage = ImageHelper.CreateTornEdge((Bitmap)Image)) {
|
||||
newImage = ImageHelper.CreateShadow(tmpImage, 1f, 6, offset, PixelFormat.Format24bppRgb); //Image.PixelFormat);
|
||||
newImage = ImageHelper.CreateShadow(tmpImage, 1f, 6, offset, PixelFormat.Format32bppRgb); //Image.PixelFormat);
|
||||
}
|
||||
break;
|
||||
case Effects.Border:
|
||||
|
|
25
Greenshot/Forms/ColorDialog.Designer.cs
generated
25
Greenshot/Forms/ColorDialog.Designer.cs
generated
|
@ -47,6 +47,7 @@ namespace Greenshot {
|
|||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
|
||||
this.SuspendLayout();
|
||||
this.btnTransparent = new System.Windows.Forms.Button();
|
||||
this.colorPanel = new System.Windows.Forms.Panel();
|
||||
this.labelHtmlColor = new System.Windows.Forms.Label();
|
||||
|
@ -61,8 +62,7 @@ namespace Greenshot {
|
|||
this.textBoxAlpha = new System.Windows.Forms.TextBox();
|
||||
this.labelAlpha = new System.Windows.Forms.Label();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.dropper = new Greenshot.Controls.Dropper();
|
||||
this.SuspendLayout();
|
||||
this.pipette = new Greenshot.Controls.Pipette();
|
||||
//
|
||||
// btnTransparent
|
||||
//
|
||||
|
@ -208,23 +208,22 @@ namespace Greenshot {
|
|||
this.btnApply.UseVisualStyleBackColor = false;
|
||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||
//
|
||||
// dropper
|
||||
// pipette
|
||||
//
|
||||
this.dropper.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.dropper.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||
this.dropper.Image = ((System.Drawing.Image)(resources.GetObject("dropper.Image")));
|
||||
this.dropper.Location = new System.Drawing.Point(255, 30);
|
||||
this.dropper.Name = "dropper";
|
||||
this.dropper.Size = new System.Drawing.Size(33, 23);
|
||||
this.dropper.TabIndex = 13;
|
||||
this.dropper.DropperUsed += new System.EventHandler<Greenshot.Controls.DropperUsedArgs>(this.dropperUsed);
|
||||
this.pipette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pipette.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||
this.pipette.Location = new System.Drawing.Point(255, 30);
|
||||
this.pipette.Name = "pipette";
|
||||
this.pipette.Size = new System.Drawing.Size(33, 23);
|
||||
this.pipette.TabIndex = 13;
|
||||
this.pipette.PipetteUsed += new System.EventHandler<Greenshot.Controls.PipetteUsedArgs>(this.pipetteUsed);
|
||||
//
|
||||
// ColorDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(292, 218);
|
||||
this.Controls.Add(this.dropper);
|
||||
this.Controls.Add(this.pipette);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.textBoxAlpha);
|
||||
this.Controls.Add(this.labelAlpha);
|
||||
|
@ -265,7 +264,7 @@ namespace Greenshot {
|
|||
private System.Windows.Forms.TextBox textBoxBlue;
|
||||
private System.Windows.Forms.Panel colorPanel;
|
||||
private System.Windows.Forms.Button btnTransparent;
|
||||
private Greenshot.Controls.Dropper dropper;
|
||||
private Greenshot.Controls.Pipette pipette;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ namespace Greenshot {
|
|||
|
||||
#endregion
|
||||
|
||||
private void dropperUsed(object sender, Greenshot.Controls.DropperUsedArgs e) {
|
||||
private void pipetteUsed(object sender, Greenshot.Controls.PipetteUsedArgs e) {
|
||||
this.Color = e.color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="dropper.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<data name="pipette.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
|
||||
|
|
50
Greenshot/Forms/Zoomer.Designer.cs
generated
50
Greenshot/Forms/Zoomer.Designer.cs
generated
|
@ -43,27 +43,6 @@ namespace Greenshot.Forms
|
|||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.Info;
|
||||
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panel1.Controls.Add(this.alpha);
|
||||
this.panel1.Controls.Add(this.label5);
|
||||
this.panel1.Controls.Add(this.blue);
|
||||
this.panel1.Controls.Add(this.label6);
|
||||
this.panel1.Controls.Add(this.green);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.red);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.html);
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.preview);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(100, 100);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// html
|
||||
//
|
||||
this.html.Location = new System.Drawing.Point(40, 18);
|
||||
|
@ -152,8 +131,31 @@ namespace Greenshot.Forms
|
|||
this.label5.TabIndex = 9;
|
||||
this.label5.Text = "Alpha: ";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.Info;
|
||||
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panel1.Controls.Add(this.alpha);
|
||||
this.panel1.Controls.Add(this.label5);
|
||||
this.panel1.Controls.Add(this.blue);
|
||||
this.panel1.Controls.Add(this.label6);
|
||||
this.panel1.Controls.Add(this.green);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.red);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.html);
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.preview);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(100, 100);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// Zoomer
|
||||
//
|
||||
this.Visible = false;
|
||||
this.Location = new System.Drawing.Point(-10000,-10000);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(100, 100);
|
||||
|
@ -164,10 +166,8 @@ namespace Greenshot.Forms
|
|||
this.ShowInTaskbar = false;
|
||||
this.Text = "Zoomer";
|
||||
this.TopMost = true;
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
this.panel1.ResumeLayout(true);
|
||||
this.ResumeLayout(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -48,33 +48,32 @@ namespace Greenshot.Forms {
|
|||
green.Text = "" + c.G;
|
||||
alpha.Text = "" + c.A;
|
||||
|
||||
Size cs = Cursor.Current.Size;
|
||||
Point hs = Cursor.Current.HotSpot;
|
||||
Size cursorSize = Cursor.Current.Size;
|
||||
Point hotspot = Cursor.Current.HotSpot;
|
||||
|
||||
Point zp = new Point(x, y);
|
||||
zp.X += cs.Width + 5 - hs.X;
|
||||
zp.Y += cs.Height + 5 - hs.Y;
|
||||
Point zoomerLocation = new Point(x, y);
|
||||
zoomerLocation.X += cursorSize.Width + 5 - hotspot.X;
|
||||
zoomerLocation.Y += cursorSize.Height + 5 - hotspot.Y;
|
||||
|
||||
foreach (Screen screen in Screen.AllScreens) {
|
||||
Rectangle screenRectangle = screen.Bounds;
|
||||
if (screen.Bounds.Contains(x, y)) {
|
||||
if (zp.X < screenRectangle.X) {
|
||||
zp.X = screenRectangle.X;
|
||||
} else if (zp.X + Width > screenRectangle.X + screenRectangle.Width) {
|
||||
zp.X = x - Width - 5 - hs.X;
|
||||
if (zoomerLocation.X < screenRectangle.X) {
|
||||
zoomerLocation.X = screenRectangle.X;
|
||||
} else if (zoomerLocation.X + Width > screenRectangle.X + screenRectangle.Width) {
|
||||
zoomerLocation.X = x - Width - 5 - hotspot.X;
|
||||
}
|
||||
|
||||
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;
|
||||
if (zoomerLocation.Y < screenRectangle.Y) {
|
||||
zoomerLocation.Y = screenRectangle.Y;
|
||||
} else if (zoomerLocation.Y + Height > screenRectangle.Y + screenRectangle.Height) {
|
||||
zoomerLocation.Y = y - Height - 5 - hotspot.Y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Location = zp;
|
||||
Invalidate();
|
||||
Location = zoomerLocation;
|
||||
Update();
|
||||
}
|
||||
|
||||
public void setHotSpot(Point screenCoordinates) {
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<Compile Include="Controls\ToolStripNumericUpDown.cs" />
|
||||
<Compile Include="Controls\ToolStripEx.cs" />
|
||||
<Compile Include="Controls\MenuStripEx.cs" />
|
||||
<Compile Include="Controls\Dropper.cs" />
|
||||
<Compile Include="Controls\Pipette.cs" />
|
||||
<Compile Include="Destinations\ClipboardDestination.cs" />
|
||||
<Compile Include="Destinations\EditorDestination.cs" />
|
||||
<Compile Include="Destinations\EmailDestination.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue