-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add percentage suggestion - batch resize #165
- Loading branch information
Showing
3 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
src/PicView.Avalonia/Converters/IndexToPercentageSizeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Globalization; | ||
using Avalonia.Data; | ||
using Avalonia.Data.Converters; | ||
|
||
namespace PicView.Avalonia.Converters; | ||
|
||
public class IndexToPercentageSizeConverter: IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (!int.TryParse(value?.ToString(), out var index) || !int.TryParse(parameter?.ToString(), out var parameterIndex)) | ||
{ | ||
return BindingOperations.DoNothing; | ||
} | ||
|
||
switch (index) | ||
{ | ||
case 1: | ||
return 30; | ||
|
||
case 2 when parameterIndex is 1: | ||
return 30; | ||
case 2: | ||
return 50; | ||
|
||
case 3 when parameterIndex is 1: | ||
return 70; | ||
case 3 when parameterIndex is 2: | ||
return 50; | ||
case 3: | ||
return 30; | ||
|
||
case 4 when parameterIndex is 1: | ||
return 70; | ||
case 4 when parameterIndex is 2: | ||
return 50; | ||
case 4 when parameterIndex is 3: | ||
return 30; | ||
case 4: | ||
return 15; | ||
|
||
case 5 when parameterIndex is 1: | ||
return 80; | ||
case 5 when parameterIndex is 2: | ||
return 70; | ||
case 5 when parameterIndex is 3: | ||
return 50; | ||
case 5when parameterIndex is 4: | ||
return 30; | ||
case 5: | ||
return 15; | ||
|
||
|
||
case 6 when parameterIndex is 1: | ||
return 80; | ||
case 6 when parameterIndex is 2: | ||
return 70; | ||
case 6 when parameterIndex is 3: | ||
return 60; | ||
case 6 when parameterIndex is 4: | ||
return 50; | ||
case 6 when parameterIndex is 5: | ||
return 40; | ||
case 6: | ||
return 30; | ||
|
||
case 7 when parameterIndex is 1: | ||
return 85; | ||
case 7 when parameterIndex is 2: | ||
return 75; | ||
case 7 when parameterIndex is 3: | ||
return 65; | ||
case 7 when parameterIndex is 4: | ||
return 50; | ||
case 7 when parameterIndex is 5: | ||
return 40; | ||
case 7 when parameterIndex is 6: | ||
return 30; | ||
case 7: | ||
return 20; | ||
default: | ||
return BindingOperations.DoNothing; | ||
} | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
return BindingOperations.DoNothing; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters