mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 14:03:23 -07:00
Fix for the High-DPI problems with the color dialog.
This commit is contained in:
parent
bf0c23f812
commit
3697675310
2 changed files with 42 additions and 16 deletions
|
@ -65,6 +65,8 @@ namespace Greenshot.Addon.LegacyEditor.Controls {
|
||||||
this.labelAlpha = new Greenshot.Addons.Controls.GreenshotLabel();
|
this.labelAlpha = new Greenshot.Addons.Controls.GreenshotLabel();
|
||||||
this.btnApply = new Greenshot.Addons.Controls.GreenshotButton();
|
this.btnApply = new Greenshot.Addons.Controls.GreenshotButton();
|
||||||
this.pipette = new Greenshot.Addon.LegacyEditor.Controls.Pipette();
|
this.pipette = new Greenshot.Addon.LegacyEditor.Controls.Pipette();
|
||||||
|
this.panelColors = new System.Windows.Forms.Panel();
|
||||||
|
this.panelRecentColors = new System.Windows.Forms.Panel();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnTransparent
|
// btnTransparent
|
||||||
|
@ -184,7 +186,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls {
|
||||||
// labelRecentColors
|
// labelRecentColors
|
||||||
//
|
//
|
||||||
this.labelRecentColors.LanguageKey = "colorpicker_recentcolors";
|
this.labelRecentColors.LanguageKey = "colorpicker_recentcolors";
|
||||||
this.labelRecentColors.Location = new System.Drawing.Point(0, 335);
|
this.labelRecentColors.Location = new System.Drawing.Point(0, 337);
|
||||||
this.labelRecentColors.Name = "labelRecentColors";
|
this.labelRecentColors.Name = "labelRecentColors";
|
||||||
this.labelRecentColors.Size = new System.Drawing.Size(411, 30);
|
this.labelRecentColors.Size = new System.Drawing.Size(411, 30);
|
||||||
this.labelRecentColors.TabIndex = 10;
|
this.labelRecentColors.TabIndex = 10;
|
||||||
|
@ -239,11 +241,27 @@ namespace Greenshot.Addon.LegacyEditor.Controls {
|
||||||
this.pipette.TabIndex = 13;
|
this.pipette.TabIndex = 13;
|
||||||
this.pipette.PipetteUsed += new System.EventHandler<Greenshot.Addon.LegacyEditor.Controls.PipetteUsedArgs>(this.PipetteUsed);
|
this.pipette.PipetteUsed += new System.EventHandler<Greenshot.Addon.LegacyEditor.Controls.PipetteUsedArgs>(this.PipetteUsed);
|
||||||
//
|
//
|
||||||
|
// panelColors
|
||||||
|
//
|
||||||
|
this.panelColors.Location = new System.Drawing.Point(5, 7);
|
||||||
|
this.panelColors.Name = "panelColors";
|
||||||
|
this.panelColors.Size = new System.Drawing.Size(406, 328);
|
||||||
|
this.panelColors.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// panelRecentColors
|
||||||
|
//
|
||||||
|
this.panelRecentColors.Location = new System.Drawing.Point(5, 366);
|
||||||
|
this.panelRecentColors.Name = "panelRecentColors";
|
||||||
|
this.panelRecentColors.Size = new System.Drawing.Size(406, 30);
|
||||||
|
this.panelRecentColors.TabIndex = 15;
|
||||||
|
//
|
||||||
// ColorDialog
|
// ColorDialog
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(584, 404);
|
this.ClientSize = new System.Drawing.Size(584, 404);
|
||||||
|
this.Controls.Add(this.panelRecentColors);
|
||||||
|
this.Controls.Add(this.panelColors);
|
||||||
this.Controls.Add(this.pipette);
|
this.Controls.Add(this.pipette);
|
||||||
this.Controls.Add(this.btnApply);
|
this.Controls.Add(this.btnApply);
|
||||||
this.Controls.Add(this.textBoxAlpha);
|
this.Controls.Add(this.textBoxAlpha);
|
||||||
|
@ -289,5 +307,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls {
|
||||||
private System.Windows.Forms.Panel colorPanel;
|
private System.Windows.Forms.Panel colorPanel;
|
||||||
private GreenshotButton btnTransparent;
|
private GreenshotButton btnTransparent;
|
||||||
private Pipette pipette;
|
private Pipette pipette;
|
||||||
}
|
private System.Windows.Forms.Panel panelColors;
|
||||||
|
private System.Windows.Forms.Panel panelRecentColors;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
||||||
private readonly IEditorConfiguration _editorConfiguration;
|
private readonly IEditorConfiguration _editorConfiguration;
|
||||||
private readonly ToolTip _toolTip = new ToolTip();
|
private readonly ToolTip _toolTip = new ToolTip();
|
||||||
private bool _updateInProgress;
|
private bool _updateInProgress;
|
||||||
private IList<Control> _recentColorButtons;
|
|
||||||
|
|
||||||
public ColorDialog(
|
public ColorDialog(
|
||||||
IEditorConfiguration editorConfiguration,
|
IEditorConfiguration editorConfiguration,
|
||||||
|
@ -60,15 +59,16 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
||||||
|
|
||||||
private void DrawButtons()
|
private void DrawButtons()
|
||||||
{
|
{
|
||||||
int pos = FormDpiHandler.ScaleWithCurrentDpi(5);
|
|
||||||
int size = FormDpiHandler.ScaleWithCurrentDpi(15);
|
int size = FormDpiHandler.ScaleWithCurrentDpi(15);
|
||||||
var buttons = CreateColorPalette(pos, pos, size, size);
|
var buttons = CreateColorPalette(size, size);
|
||||||
int lastColorY = FormDpiHandler.ScaleWithCurrentDpi(185);
|
var recentColorButtons = CreateLastUsedColorButtonRow(size, size);
|
||||||
_recentColorButtons = CreateLastUsedColorButtonRow(pos, lastColorY, size, size);
|
|
||||||
UpdateRecentColorsButtonRow();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
Controls.AddRange(buttons.ToArray());
|
panelColors.Controls.Clear();
|
||||||
Controls.AddRange(_recentColorButtons.ToArray());
|
panelColors.Controls.AddRange(buttons.ToArray());
|
||||||
|
panelRecentColors.Controls.Clear();
|
||||||
|
panelRecentColors.Controls.AddRange(recentColorButtons.ToArray());
|
||||||
|
UpdateRecentColorsButtonRow();
|
||||||
ResumeLayout();
|
ResumeLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +103,12 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
||||||
|
|
||||||
#region user interface generation
|
#region user interface generation
|
||||||
|
|
||||||
private IList<Control> CreateColorPalette(int x, int y, int w, int h)
|
private IList<Control> CreateColorPalette(int w, int h)
|
||||||
{
|
{
|
||||||
IList<Control> colorButtons = new List<Control>();
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
IList<Control> colorButtons = new List<Control>();
|
||||||
CreateColorButtonColumn(colorButtons, 255, 0, 0, x, y, w, h, 11);
|
CreateColorButtonColumn(colorButtons, 255, 0, 0, x, y, w, h, 11);
|
||||||
x += w;
|
x += w;
|
||||||
CreateColorButtonColumn(colorButtons, 255, 255 / 2, 0, x, y, w, h, 11);
|
CreateColorButtonColumn(colorButtons, 255, 255 / 2, 0, x, y, w, h, 11);
|
||||||
|
@ -170,9 +173,12 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IList<Control> CreateLastUsedColorButtonRow(int x, int y, int w, int h)
|
private IList<Control> CreateLastUsedColorButtonRow(int w, int h)
|
||||||
{
|
{
|
||||||
IList<Control> recentColorButtons = new List<Control>();
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
IList<Control> recentColorButtons = new List<Control>();
|
||||||
|
|
||||||
for (var i = 0; i < 12; i++)
|
for (var i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
|
@ -193,8 +199,8 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
||||||
{
|
{
|
||||||
for (var i = 0; i < _editorConfiguration.RecentColors.Count && i < 12; i++)
|
for (var i = 0; i < _editorConfiguration.RecentColors.Count && i < 12; i++)
|
||||||
{
|
{
|
||||||
_recentColorButtons[i].BackColor = _editorConfiguration.RecentColors[i];
|
panelRecentColors.Controls[i].BackColor = _editorConfiguration.RecentColors[i];
|
||||||
_recentColorButtons[i].Enabled = true;
|
panelRecentColors.Controls[i].Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue