diff --git a/Greenshot/Controls/Dropper.cs b/Greenshot/Controls/Pipette.cs similarity index 88% rename from Greenshot/Controls/Dropper.cs rename to Greenshot/Controls/Pipette.cs index 4159ddedc..19f723dd3 100644 --- a/Greenshot/Controls/Dropper.cs +++ b/Greenshot/Controls/Pipette.cs @@ -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. /// - 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 DropperUsed; + public event EventHandler 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; } } diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index dd26e7d84..531ba84dc 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -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: diff --git a/Greenshot/Forms/ColorDialog.Designer.cs b/Greenshot/Forms/ColorDialog.Designer.cs index e233f983d..ad522f120 100644 --- a/Greenshot/Forms/ColorDialog.Designer.cs +++ b/Greenshot/Forms/ColorDialog.Designer.cs @@ -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(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(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; diff --git a/Greenshot/Forms/ColorDialog.cs b/Greenshot/Forms/ColorDialog.cs index 4c47e1531..b9ca0ebf9 100644 --- a/Greenshot/Forms/ColorDialog.cs +++ b/Greenshot/Forms/ColorDialog.cs @@ -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; } } diff --git a/Greenshot/Forms/ColorDialog.resx b/Greenshot/Forms/ColorDialog.resx index b6b28bd6d..da9eec254 100644 --- a/Greenshot/Forms/ColorDialog.resx +++ b/Greenshot/Forms/ColorDialog.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi diff --git a/Greenshot/Forms/Zoomer.Designer.cs b/Greenshot/Forms/Zoomer.Designer.cs index bac5a3c1c..3bc8c6ec2 100644 --- a/Greenshot/Forms/Zoomer.Designer.cs +++ b/Greenshot/Forms/Zoomer.Designer.cs @@ -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); @@ -151,9 +130,32 @@ namespace Greenshot.Forms this.label5.Size = new System.Drawing.Size(40, 13); 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 diff --git a/Greenshot/Forms/Zoomer.cs b/Greenshot/Forms/Zoomer.cs index c91bcad78..4c4d5152b 100644 --- a/Greenshot/Forms/Zoomer.cs +++ b/Greenshot/Forms/Zoomer.cs @@ -42,39 +42,38 @@ namespace Greenshot.Forms { public void setHotSpot(int x, int y) { Color c = GetPixelColor(x, y); preview.BackColor = c; - html.Text = "#" + c.Name.Substring(2).ToUpper(); + html.Text = "#" + c.Name.Substring(2).ToUpper(); red.Text = "" + c.R; blue.Text = "" + c.B; 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) { diff --git a/Greenshot/Greenshot.csproj b/Greenshot/Greenshot.csproj index cf11900f3..d13cdbd11 100644 --- a/Greenshot/Greenshot.csproj +++ b/Greenshot/Greenshot.csproj @@ -67,7 +67,7 @@ - +