Optionally show a border around the thumbnail of the currently active EVE client

This commit is contained in:
Anton Kasyanov
2016-08-17 19:10:11 +03:00
parent ae071a9a1c
commit 88140d257e
12 changed files with 131 additions and 66 deletions

View File

@@ -50,10 +50,9 @@
// OverlayLabel
//
this.OverlayLabel.AutoSize = true;
this.OverlayLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.OverlayLabel.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.OverlayLabel.ForeColor = System.Drawing.Color.DarkGray;
this.OverlayLabel.Location = new System.Drawing.Point(0, 0);
this.OverlayLabel.Location = new System.Drawing.Point(8, 8);
this.OverlayLabel.Name = "OverlayLabel";
this.OverlayLabel.Size = new System.Drawing.Size(25, 13);
this.OverlayLabel.TabIndex = 1;

View File

@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace EveOPreview.UI
@@ -7,6 +8,8 @@ namespace EveOPreview.UI
{
#region Private fields
private readonly Action<object, MouseEventArgs> _areaClickAction;
private bool _highlightEnabled;
private Color _highlightColor;
#endregion
public ThumbnailOverlay(Form owner, Action<object, MouseEventArgs> areaClickAction)
@@ -14,6 +17,9 @@ namespace EveOPreview.UI
this.Owner = owner;
this._areaClickAction = areaClickAction;
this._highlightEnabled = false;
this._highlightColor = Color.Red;
InitializeComponent();
}
@@ -27,6 +33,24 @@ namespace EveOPreview.UI
this.OverlayLabel.Text = label;
}
public void EnableOverlayLabel(bool enable)
{
this.OverlayLabel.Visible = enable;
}
public void EnableHighlight(bool enabled, Color color)
{
if (!enabled && !this._highlightEnabled)
{
// Nothing to do here
return;
}
this._highlightEnabled = enabled;
this._highlightColor = color;
this.Refresh();
}
protected override CreateParams CreateParams
{
get
@@ -36,5 +60,19 @@ namespace EveOPreview.UI
return Params;
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this._highlightEnabled)
{
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
this._highlightColor, 4, ButtonBorderStyle.Solid,
this._highlightColor, 4, ButtonBorderStyle.Solid,
this._highlightColor, 4, ButtonBorderStyle.Solid,
this._highlightColor, 4, ButtonBorderStyle.Solid);
}
}
}
}

View File

@@ -34,8 +34,8 @@ namespace EveOPreview.UI
this.Text = "Preview";
this.TopMost = true;
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MouseDown_Handler);
this.MouseLeave += new System.EventHandler(this.MouseLeave_Handler);
this.MouseEnter += new System.EventHandler(this.MouseEnter_Handler);
this.MouseLeave += new System.EventHandler(this.MouseLeave_Handler);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MouseMove_Handler);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MouseUp_Handler);
this.Move += new System.EventHandler(this.Move_Handler);

View File

@@ -113,7 +113,11 @@ namespace EveOPreview.UI
{
base.Show();
// Thumbnail will be registered during the Refresh cycle
this._isPositionChanged = true;
this._isSizeChanged = true;
this._isOverlayVisible = false;
// Thumbnail will be properly registered during the Manager's Refresh cycle
this.Refresh();
this.IsActive = true;
@@ -152,6 +156,12 @@ namespace EveOPreview.UI
public void SetOpacity(double opacity)
{
this.Opacity = opacity;
// Overlay opacity settings
// Of the thumbnail's opacity is almost full then set the overlay's one to
// full. Otherwise set it to half of the thumnail opacity
// Opacity value is stored even if the overlay is not displayed atm
this._overlay.Opacity = this.Opacity > 0.9 ? 1.0 : 1.0 - (1.0 - this.Opacity) / 2;
}
public void SetFrames(bool enable)
@@ -187,6 +197,11 @@ namespace EveOPreview.UI
this._isTopMost = enableTopmost;
}
public void SetHighlight(bool enabled, Color color)
{
this._overlay.EnableHighlight(enabled, color);
}
public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor)
{
int oldWidth = this._baseZoomSize.Width;
@@ -312,40 +327,34 @@ namespace EveOPreview.UI
this.UnregisterThumbnail(obsoleteThumbnailHanlde);
}
if (!this.IsOverlayEnabled)
{
if (this._isOverlayVisible)
{
this._overlay.Hide();
this._isOverlayVisible = false;
}
return;
}
this._overlay.EnableOverlayLabel(this.IsOverlayEnabled);
if (!this._isOverlayVisible)
{
// One-time action to show the Overlay before it is set up
// Otherwise its position won't be set
this._overlay.Show();
this._isOverlayVisible = true;
}
else if (!(sizeChanged || locationChanged))
else
{
// No need to adjust in the overlay location if it is already visible and properly set
return;
if (!(sizeChanged || locationChanged))
{
// No need to adjust in the overlay location if it is already visible and properly set
return;
}
}
Size overlaySize = this.ClientSize;
overlaySize.Width -= 2 * 5;
overlaySize.Height -= 2 * 5;
Point overlayLocation = this.Location;
overlayLocation.X += 5 + (this.Size.Width - this.ClientSize.Width) / 2;
overlayLocation.Y += 5 + (this.Size.Height - this.ClientSize.Height) - (this.Size.Width - this.ClientSize.Width) / 2;
overlayLocation.X += (this.Size.Width - this.ClientSize.Width) / 2;
overlayLocation.Y += (this.Size.Height - this.ClientSize.Height) - (this.Size.Width - this.ClientSize.Width) / 2;
this._isPositionChanged = false;
this._overlay.Size = overlaySize;
this._overlay.Location = overlayLocation;
this._overlay.Invalidate();
}
#region GUI events
@@ -427,26 +436,7 @@ namespace EveOPreview.UI
}
#endregion
// This pair of methods saves/restores certain window propeties
// Methods are used to remove the 'Zoom' effect (if any) when the
// custom resize/move mode is activated
// Methods are kept on this level because moving to the presenter
// the code that responds to the mouse events like movement
// seems like a huge overkill
private void SaveWindowSizeAndLocation()
{
this._baseZoomSize = this.Size;
this._baseZoomLocation = this.Location;
this._baseZoomMaximumSize = this.MaximumSize;
}
private void RestoreWindowSizeAndLocation()
{
this.Size = this._baseZoomSize;
this.MaximumSize = this._baseZoomMaximumSize;
this.Location = this._baseZoomLocation;
}
#region Thumbnail management
private void RegisterThumbnail()
{
this._thumbnailHandle = WindowManagerNativeMethods.DwmRegisterThumbnail(this.Handle, this.Id);
@@ -473,6 +463,28 @@ namespace EveOPreview.UI
{
}
}
#endregion
#region Custom Mouse mode
// This pair of methods saves/restores certain window propeties
// Methods are used to remove the 'Zoom' effect (if any) when the
// custom resize/move mode is activated
// Methods are kept on this level because moving to the presenter
// the code that responds to the mouse events like movement
// seems like a huge overkill
private void SaveWindowSizeAndLocation()
{
this._baseZoomSize = this.Size;
this._baseZoomLocation = this.Location;
this._baseZoomMaximumSize = this.MaximumSize;
}
private void RestoreWindowSizeAndLocation()
{
this.Size = this._baseZoomSize;
this.MaximumSize = this._baseZoomMaximumSize;
this.Location = this._baseZoomLocation;
}
private void EnterCustomMouseMode()
{
@@ -507,5 +519,6 @@ namespace EveOPreview.UI
{
this._isCustomMouseModeActive = false;
}
#endregion
}
}

View File

@@ -12,13 +12,13 @@ namespace EveOPreview.UI
{
bool MinimizeToTray { get; set; }
double ThumbnailsOpacity { get; set; }
double ThumbnailOpacity { get; set; }
bool EnableClientLayoutTracking { get; set; }
bool HideActiveClientThumbnail { get; set; }
bool ShowThumbnailsAlwaysOnTop { get; set; }
bool HideThumbnailsOnLostFocus { get; set; }
bool EnablePerClientThumbnailsLayouts { get; set; }
bool EnablePerClientThumbnailLayouts { get; set; }
Size ThumbnailSize { get; set; }
@@ -29,6 +29,9 @@ namespace EveOPreview.UI
bool ShowThumbnailOverlays { get; set; }
bool ShowThumbnailFrames { get; set; }
bool EnableActiveClientHighlight { get; set; }
Color ActiveClientHighlightColor { get; set; }
void SetForumUrl(string url);
void SetThumbnailSizeLimitations(Size minimumSize, Size maximumSize);

View File

@@ -21,6 +21,7 @@ namespace EveOPreview.UI
void SetOpacity(double opacity);
void SetFrames(bool enable);
void SetTopMost(bool enableTopmost);
void SetHighlight(bool enabled, Color color);
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
void ZoomOut();