Layer overlay tooltip is now semi-transparent

This commit is contained in:
Tiago Conceição
2020-09-12 17:35:10 +01:00
parent dcc7d06149
commit 75aa7829f8
6 changed files with 111 additions and 45 deletions
+1
View File
@@ -8,6 +8,7 @@
* (Change) Layer status bar: Pixel picker text to button - Click to center in point
* (Change) Layer status bar: Resolution text to button - Click to zoom to fit
* (Change) Customized cursor for Pixel Edit mode (#51)
* (Change) Layer overlay tooltip is now semi-transparent
* (Fix) Misc. text cleanup (#52)
## 12/09/2020 - v0.8.1.0
+87
View File
@@ -0,0 +1,87 @@
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
// https://stackoverflow.com/questions/34335157/show-a-label-with-semi-transparent-backcolor-above-other-controls
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace UVtools.GUI.Controls
{
public class TransparentLabel : Label
{
public TransparentLabel()
{
transparentBackColor = Color.Blue;
opacity = 50;
BackColor = Color.Transparent;
DoubleBuffered = true;
}
protected override void OnPaint(PaintEventArgs e)
{
if (Parent == null) return;
using (var bmp = new Bitmap(Parent.Width, Parent.Height))
{
Parent.Controls.Cast<Control>()
.Where(c => Parent.Controls.GetChildIndex(c) > Parent.Controls.GetChildIndex(this))
.Where(c => c.Bounds.IntersectsWith(Bounds))
.OrderByDescending(c => Parent.Controls.GetChildIndex(c))
.ToList()
.ForEach(c => c.DrawToBitmap(bmp, c.Bounds));
e.Graphics.DrawImage(bmp, -Left, -Top);
using (var b = new SolidBrush(Color.FromArgb(Opacity, TransparentBackColor)))
{
e.Graphics.FillRectangle(b, ClientRectangle);
}
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
var rectangle = ClientRectangle;
rectangle.X += Padding.Left;
//rectangle.Y += Padding.Top;
//rectangle.Width -= Padding.Left - Padding.Right;
//rectangle.Height -= Padding.Top - Padding.Bottom;
TextRenderer.DrawText(e.Graphics, Text, Font, rectangle, ForeColor, Color.Transparent, TextFormatFlags.VerticalCenter);
}
}
private int opacity;
public int Opacity
{
get => opacity;
set
{
if (value >= 0 && value <= 255)
opacity = value;
Invalidate();
}
}
private Color transparentBackColor;
public Color TransparentBackColor
{
get => transparentBackColor;
set
{
transparentBackColor = value;
Invalidate();
}
}
[Browsable(false)]
public override Color BackColor
{
get => Color.Transparent;
set => base.BackColor = Color.Transparent;
}
}
}
+19 -15
View File
@@ -61,7 +61,6 @@ namespace UVtools.GUI
this.statusBar = new System.Windows.Forms.StatusStrip();
this.mainTable = new System.Windows.Forms.TableLayoutPanel();
this.scCenter = new System.Windows.Forms.SplitContainer();
this.lbLayerImageOverlay = new System.Windows.Forms.Label();
this.pbLayer = new Cyotek.Windows.Forms.ImageBox();
this.tsLayer = new System.Windows.Forms.ToolStrip();
this.btnLayerImageExport = new System.Windows.Forms.ToolStripSplitButton();
@@ -259,6 +258,7 @@ namespace UVtools.GUI
this.toolTipInformation = new System.Windows.Forms.ToolTip(this.components);
this.layerScrollTimer = new System.Windows.Forms.Timer(this.components);
this.mouseHoldTimer = new System.Windows.Forms.Timer(this.components);
this.lbLayerImageOverlay = new UVtools.GUI.Controls.TransparentLabel();
this.tbLayer = new UVtools.GUI.Controls.TrackBarEx();
this.menu.SuspendLayout();
this.mainTable.SuspendLayout();
@@ -608,19 +608,6 @@ namespace UVtools.GUI
this.scCenter.SplitterDistance = 730;
this.scCenter.TabIndex = 4;
//
// lbLayerImageOverlay
//
this.lbLayerImageOverlay.AutoSize = true;
this.lbLayerImageOverlay.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.lbLayerImageOverlay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbLayerImageOverlay.Location = new System.Drawing.Point(13, 37);
this.lbLayerImageOverlay.Name = "lbLayerImageOverlay";
this.lbLayerImageOverlay.Padding = new System.Windows.Forms.Padding(5);
this.lbLayerImageOverlay.Size = new System.Drawing.Size(70, 30);
this.lbLayerImageOverlay.TabIndex = 8;
this.lbLayerImageOverlay.Text = "Overlay";
this.lbLayerImageOverlay.Visible = false;
//
// pbLayer
//
this.pbLayer.AllowDoubleClick = true;
@@ -2856,6 +2843,23 @@ namespace UVtools.GUI
this.mouseHoldTimer.Interval = 1000;
this.mouseHoldTimer.Tick += new System.EventHandler(this.EventTimerTick);
//
// lbLayerImageOverlay
//
this.lbLayerImageOverlay.AutoSize = true;
this.lbLayerImageOverlay.BackColor = System.Drawing.Color.Transparent;
this.lbLayerImageOverlay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbLayerImageOverlay.CausesValidation = false;
this.lbLayerImageOverlay.Location = new System.Drawing.Point(13, 37);
this.lbLayerImageOverlay.Name = "lbLayerImageOverlay";
this.lbLayerImageOverlay.Opacity = 210;
this.lbLayerImageOverlay.Padding = new System.Windows.Forms.Padding(10);
this.lbLayerImageOverlay.Size = new System.Drawing.Size(80, 40);
this.lbLayerImageOverlay.TabIndex = 8;
this.lbLayerImageOverlay.Text = "Overlay";
this.lbLayerImageOverlay.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lbLayerImageOverlay.TransparentBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.lbLayerImageOverlay.Visible = false;
//
// tbLayer
//
this.tbLayer.Dock = System.Windows.Forms.DockStyle.Right;
@@ -3204,7 +3208,7 @@ namespace UVtools.GUI
private System.Windows.Forms.ToolStripSplitButton btnLayerImageActions;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator26;
private System.Windows.Forms.ToolStripButton btnLogVerbose;
private System.Windows.Forms.Label lbLayerImageOverlay;
private TransparentLabel lbLayerImageOverlay;
public Cyotek.Windows.Forms.ImageBox pbLayer;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator27;
private System.Windows.Forms.ToolStripButton btnLayerROI;
-29
View File
@@ -735,35 +735,6 @@ namespace UVtools.GUI
ShowRunOperation(baseOperation.GetType());
return;
}
if (!ReferenceEquals(menuItem.Tag, null))
{
if (menuItem.Tag.GetType() == typeof(FileFormat.PrintParameterModifier))
{
FileFormat.PrintParameterModifier modifier = (FileFormat.PrintParameterModifier) menuItem.Tag;
using (FrmInputBox inputBox = new FrmInputBox(modifier,
decimal.Parse(SlicerFile.GetValueFromPrintParameterModifier(modifier).ToString())))
{
if (inputBox.ShowDialog() != DialogResult.OK) return;
var value = inputBox.NewValue;
if (!SlicerFile.SetValueFromPrintParameterModifier(modifier, value))
{
MessageBox.Show(
$"Unable to set '{modifier.Name}'. Value was not found, it may not yet be implemented.",
"Operation error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
RefreshInfo();
menuFileSave.Enabled =
menuFileSaveAs.Enabled = true;
}
return;
}
}
// About
if (ReferenceEquals(menuItem, menuHelpAbout))
+1 -1
View File
@@ -174,7 +174,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk
FAAAAk1TRnQBSQFMAgEBBgEAAaABCwGgAQsBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
FAAAAk1TRnQBSQFMAgEBBgEAAfgBCwH4AQsBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUDMAAQEDJAE2AysBQqwAAyIBMQNWAbkDXQHi
AwAB/wMAAf8BKgEtASgB/gNTAawDTQGVAwABARgAAwkBDAMzAVIDUAGdA1cB6AMAAf4DKwH8Ay8BSqQA
AyEBMANZAewBKwEuASkB+gNRAfcDUgH0A1MB8QNIAfYDQQH5AwAB/wNPAZsDAAEBCAADFQEdAz8BbgNV
+3
View File
@@ -281,6 +281,9 @@
<Compile Include="Controls\TrackBarEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\TransparentLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Extensions\BitmapExtension.cs" />
<Compile Include="Extensions\ControlExtensions.cs" />
<Compile Include="Extensions\CursorExtensions.cs" />