Browse Source

Theme adjustments and bug fixes

Ruben 1 year ago
parent
commit
a1ee6a8d10

+ 3 - 0
src/PicView.Avalonia/PicViewTheme/Classes.axaml

@@ -11,6 +11,9 @@
         <Setter Property="TextTrimming" Value="CharacterEllipsis" />
         <Setter Property="TextWrapping" Value="Wrap" />
         <Setter Property="LineHeight" Value="18" />
+    </Style>
+
+    <Style Selector="TextBlock.txtShadow">
         <Setter Property="Effect" Value="{StaticResource TextShadow}" />
     </Style>
 

+ 1 - 0
src/PicView.Avalonia/Views/AppearanceView.axaml

@@ -47,6 +47,7 @@
 
         <WrapPanel
             HorizontalAlignment="Center"
+            Margin="0,0,0,10"
             MaxWidth="300"
             Orientation="Horizontal">
             <WrapPanel.Styles>

+ 40 - 26
src/PicView.Avalonia/Views/MainView.axaml.cs

@@ -1,11 +1,11 @@
-using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
 using System.Text;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Media;
 using Avalonia.Platform.Storage;
-using Avalonia.Styling;
 using Avalonia.Threading;
 using PicView.Avalonia.ImageHandling;
 using PicView.Avalonia.Keybindings;
@@ -120,42 +120,56 @@ public partial class MainView : UserControl
 
     private void AddOrReplaceMenuItem(int index, MainViewModel vm, bool isReplace)
     {
-        if (!Application.Current.TryGetResource("LogoAccentColor", ThemeVariant.Default, out var secondaryAccentColor))
+        if (!Application.Current.TryGetResource("SecondaryAccentColor", Application.Current.RequestedThemeVariant, out var secondaryAccentColor))
         {
             return;
         }
 
-        var secondaryAccentBrush = new SolidColorBrush((Color)(secondaryAccentColor ?? Brushes.Yellow));
-        var fileLocation = FileHistoryNavigation.GetFileLocation(index);
-        var selected = vm.ImageIterator?.CurrentIndex == vm.ImageIterator?.ImagePaths.IndexOf(fileLocation);
-        var header = Path.GetFileNameWithoutExtension(fileLocation);
-        header = header.Length > 60 ? header.Shorten(60) : header;
-        
-        var item = new MenuItem
+        try
         {
-            Header = header,
-        };
+#if DEBUG
+            Debug.Assert(secondaryAccentColor != null, nameof(secondaryAccentColor) + " != null");
+#endif
+            var secondaryAccentBrush = (SolidColorBrush)secondaryAccentColor;
+            var fileLocation = FileHistoryNavigation.GetFileLocation(index);
+            var selected = vm.ImageIterator?.CurrentIndex == vm.ImageIterator?.ImagePaths.IndexOf(fileLocation);
+            var header = Path.GetFileNameWithoutExtension(fileLocation);
+            header = header.Length > 60 ? header.Shorten(60) : header;
+        
+            var item = new MenuItem
+            {
+                Header = header,
+            };
 
-        if (selected)
-        {
-            item.Foreground = secondaryAccentBrush;
-        }
+            if (selected)
+            {
+                item.Foreground = secondaryAccentBrush;
+            }
         
-        item.Click += async delegate
-        {
-            await NavigationHelper.LoadPicFromStringAsync(fileLocation, vm).ConfigureAwait(false);
-        };
+            item.Click += async delegate
+            {
+                await NavigationHelper.LoadPicFromStringAsync(fileLocation, vm).ConfigureAwait(false);
+            };
         
-        ToolTip.SetTip(item, fileLocation);
+            ToolTip.SetTip(item, fileLocation);
 
-        if (isReplace)
-        {
-            RecentFilesCM.Items[index] = item;
+            if (isReplace)
+            {
+                RecentFilesCM.Items[index] = item;
+            }
+            else
+            {
+                RecentFilesCM.Items.Insert(index, item);
+            }
         }
-        else
+#if DEBUG
+        catch (Exception e)
         {
-            RecentFilesCM.Items.Insert(index, item);
+            Console.WriteLine(e);
         }
+#else
+        catch (Exception){}
+#endif
     }
 
     private async Task Drop(object? sender, DragEventArgs e)

+ 10 - 10
src/PicView.Avalonia/Views/SettingsView.axaml

@@ -784,7 +784,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource GeneralSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{Binding GeneralSettings, Mode=OneWay}" />
                     </StackPanel>
@@ -800,7 +800,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource AppearanceSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{Binding Appearance, Mode=OneWay}" />
                     </StackPanel>
@@ -816,7 +816,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource ImageSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{Binding ImageTxt, Mode=OneWay}" />
                     </StackPanel>
@@ -832,7 +832,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource GallerySettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding GallerySettings,
                                                    Mode=OneWay}" />
@@ -849,7 +849,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource SlideshowSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding Slideshow,
                                                    Mode=OneWay}" />
@@ -866,7 +866,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource NavigationSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding Navigation}" />
                     </StackPanel>
@@ -883,7 +883,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource ZoomSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding Zoom}" />
                     </StackPanel>
@@ -899,7 +899,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource MouseWheelSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding MouseWheel}" />
                     </StackPanel>
@@ -915,7 +915,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource LanguageSettingsIcon}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding Language}" />
                     </StackPanel>
@@ -931,7 +931,7 @@
                     <StackPanel Orientation="Horizontal">
                         <Image Classes="imageStyle" Source="{StaticResource KeyboardImage}" />
                         <TextBlock
-                            Classes="txt"
+                            Classes="txt txtShadow"
                             Foreground="{StaticResource SecondaryTextColor}"
                             Text="{CompiledBinding ApplicationShortcuts}" />
                     </StackPanel>

File diff suppressed because it is too large
+ 3 - 8
src/PicView.Avalonia/Views/StartUpMenu.axaml


+ 2 - 3
src/PicView.Avalonia/Views/StartUpMenu.axaml.cs

@@ -102,10 +102,9 @@ public partial class StartUpMenu : UserControl
         
         if (DataContext is not MainViewModel vm)
             return;
+        
         if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
-        {
             return;
-        }
         
         if (SettingsHelper.Settings.WindowProperties.AutoFit)
         {
@@ -132,7 +131,7 @@ public partial class StartUpMenu : UserControl
 
         void ShowIcon()
         {
-            if (this.TryFindResource("Icon", Application.Current.RequestedThemeVariant, out var icon))
+            if (this.TryFindResource("LogoImage", Application.Current.RequestedThemeVariant, out var icon))
                 Logo.Source = icon as DrawingImage;
             LogoViewbox.Width = logoWidth;
             Buttons.Margin = new Thickness(0, 0, 0, bottomMargin);

Some files were not shown because too many files changed in this diff