feat(Eve-O-Preview): add aspect ratio maintenance for thumbnail size
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows8.0</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>EveOMock</RootNamespace>
|
<RootNamespace>EveOMock</RootNamespace>
|
||||||
<AssemblyName>ExeFile</AssemblyName>
|
<AssemblyName>ExeFile</AssemblyName>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DefineConstants Condition="'$(EVEOTarget)'=='Linux'">LINUX</DefineConstants>
|
<DefineConstants Condition="'$(EVEOTarget)'=='Linux'">LINUX</DefineConstants>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows8.0</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
|
@@ -41,6 +41,10 @@ namespace EveOPreview.View {
|
|||||||
this.InitFormSize();
|
this.InitFormSize();
|
||||||
|
|
||||||
this.AnimationStyleCombo.DataSource = Enum.GetValues(typeof(AnimationStyle));
|
this.AnimationStyleCombo.DataSource = Enum.GetValues(typeof(AnimationStyle));
|
||||||
|
|
||||||
|
// Add mouse wheel event handlers for aspect ratio maintenance
|
||||||
|
this.ThumbnailsWidthNumericEdit.MouseWheel += ThumbnailSizeNumeric_MouseWheel;
|
||||||
|
this.ThumbnailsHeightNumericEdit.MouseWheel += ThumbnailSizeNumeric_MouseWheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MinimizeToTray {
|
public bool MinimizeToTray {
|
||||||
@@ -437,18 +441,105 @@ namespace EveOPreview.View {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform some View work that is not properly done in the Control
|
// Check if shift is held down for aspect ratio maintenance
|
||||||
this._suppressEvents = true;
|
bool maintainAspectRatio = ModifierKeys.HasFlag(Keys.Shift);
|
||||||
Size thumbnailSize = this.ThumbnailSize;
|
|
||||||
thumbnailSize.Width = Math.Min(Math.Max(thumbnailSize.Width, this._minimumSize.Width), this._maximumSize.Width);
|
if (maintainAspectRatio && sender is NumericUpDown changedControl) {
|
||||||
thumbnailSize.Height =
|
// Calculate the aspect ratio from the current size before the change
|
||||||
Math.Min(Math.Max(thumbnailSize.Height, this._minimumSize.Height), this._maximumSize.Height);
|
double aspectRatio =
|
||||||
this.ThumbnailSize = thumbnailSize;
|
(double)this.ThumbnailsWidthNumericEdit.Value / (double)this.ThumbnailsHeightNumericEdit.Value;
|
||||||
this._suppressEvents = false;
|
|
||||||
|
// Determine which control was changed and update the other accordingly
|
||||||
|
if (changedControl == this.ThumbnailsWidthNumericEdit) {
|
||||||
|
int newWidth = (int)changedControl.Value;
|
||||||
|
int newHeight = (int)(newWidth / aspectRatio);
|
||||||
|
|
||||||
|
// Apply size constraints
|
||||||
|
newWidth = Math.Min(Math.Max(newWidth, this._minimumSize.Width), this._maximumSize.Width);
|
||||||
|
newHeight = Math.Min(Math.Max(newHeight, this._minimumSize.Height), this._maximumSize.Height);
|
||||||
|
|
||||||
|
this._suppressEvents = true;
|
||||||
|
this.ThumbnailsWidthNumericEdit.Value = newWidth;
|
||||||
|
this.ThumbnailsHeightNumericEdit.Value = newHeight;
|
||||||
|
this._suppressEvents = false;
|
||||||
|
} else if (changedControl == this.ThumbnailsHeightNumericEdit) {
|
||||||
|
int newHeight = (int)changedControl.Value;
|
||||||
|
int newWidth = (int)(newHeight * aspectRatio);
|
||||||
|
|
||||||
|
// Apply size constraints
|
||||||
|
newWidth = Math.Min(Math.Max(newWidth, this._minimumSize.Width), this._maximumSize.Width);
|
||||||
|
newHeight = Math.Min(Math.Max(newHeight, this._minimumSize.Height), this._maximumSize.Height);
|
||||||
|
|
||||||
|
this._suppressEvents = true;
|
||||||
|
this.ThumbnailsWidthNumericEdit.Value = newWidth;
|
||||||
|
this.ThumbnailsHeightNumericEdit.Value = newHeight;
|
||||||
|
this._suppressEvents = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Normal behavior without aspect ratio maintenance
|
||||||
|
this._suppressEvents = true;
|
||||||
|
Size thumbnailSize = this.ThumbnailSize;
|
||||||
|
thumbnailSize.Width =
|
||||||
|
Math.Min(Math.Max(thumbnailSize.Width, this._minimumSize.Width), this._maximumSize.Width);
|
||||||
|
thumbnailSize.Height =
|
||||||
|
Math.Min(Math.Max(thumbnailSize.Height, this._minimumSize.Height), this._maximumSize.Height);
|
||||||
|
this.ThumbnailSize = thumbnailSize;
|
||||||
|
this._suppressEvents = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.ThumbnailsSizeChanged?.Invoke();
|
this.ThumbnailsSizeChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ThumbnailSizeNumeric_MouseWheel(object sender, MouseEventArgs e) {
|
||||||
|
if (this._suppressEvents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if shift is held down for aspect ratio maintenance
|
||||||
|
bool maintainAspectRatio = ModifierKeys.HasFlag(Keys.Shift);
|
||||||
|
|
||||||
|
if (maintainAspectRatio && sender is NumericUpDown control) {
|
||||||
|
// Calculate the aspect ratio from the current size
|
||||||
|
double aspectRatio =
|
||||||
|
(double)this.ThumbnailsWidthNumericEdit.Value / (double)this.ThumbnailsHeightNumericEdit.Value;
|
||||||
|
|
||||||
|
// Determine scroll direction and increment
|
||||||
|
int increment = e.Delta > 0 ? (int)control.Increment : -(int)control.Increment;
|
||||||
|
|
||||||
|
// Determine which control was scrolled and update both accordingly
|
||||||
|
if (control == this.ThumbnailsWidthNumericEdit) {
|
||||||
|
int newWidth = (int)control.Value + increment;
|
||||||
|
int newHeight = (int)(newWidth / aspectRatio);
|
||||||
|
|
||||||
|
// Apply size constraints
|
||||||
|
newWidth = Math.Min(Math.Max(newWidth, this._minimumSize.Width), this._maximumSize.Width);
|
||||||
|
newHeight = Math.Min(Math.Max(newHeight, this._minimumSize.Height), this._maximumSize.Height);
|
||||||
|
|
||||||
|
this._suppressEvents = true;
|
||||||
|
this.ThumbnailsWidthNumericEdit.Value = newWidth;
|
||||||
|
this.ThumbnailsHeightNumericEdit.Value = newHeight;
|
||||||
|
this._suppressEvents = false;
|
||||||
|
} else if (control == this.ThumbnailsHeightNumericEdit) {
|
||||||
|
int newHeight = (int)control.Value + increment;
|
||||||
|
int newWidth = (int)(newHeight * aspectRatio);
|
||||||
|
|
||||||
|
// Apply size constraints
|
||||||
|
newWidth = Math.Min(Math.Max(newWidth, this._minimumSize.Width), this._maximumSize.Width);
|
||||||
|
newHeight = Math.Min(Math.Max(newHeight, this._minimumSize.Height), this._maximumSize.Height);
|
||||||
|
|
||||||
|
this._suppressEvents = true;
|
||||||
|
this.ThumbnailsWidthNumericEdit.Value = newWidth;
|
||||||
|
this.ThumbnailsHeightNumericEdit.Value = newHeight;
|
||||||
|
this._suppressEvents = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent the default scroll behavior
|
||||||
|
((HandledMouseEventArgs)e).Handled = true;
|
||||||
|
|
||||||
|
this.ThumbnailsSizeChanged?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ActiveClientHighlightColorButton_Click(object sender, EventArgs e) {
|
private void ActiveClientHighlightColorButton_Click(object sender, EventArgs e) {
|
||||||
using (ColorDialog dialog = new ColorDialog()) {
|
using (ColorDialog dialog = new ColorDialog()) {
|
||||||
dialog.Color = this.ActiveClientHighlightColor;
|
dialog.Color = this.ActiveClientHighlightColor;
|
||||||
|
Reference in New Issue
Block a user