Skip to content

Commit 5ae159d

Browse files
authored
Move to iNKORE.UI.WPF.Modern UI Framework (#3593)
1 parent 8c98aed commit 5ae159d

File tree

77 files changed

+3961
-10198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3961
-10198
lines changed

Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,19 @@ public bool ChangeTheme(string theme = null)
449449
}
450450
return false;
451451
}
452-
catch (XamlParseException)
452+
catch (XamlParseException e)
453453
{
454-
_api.LogError(ClassName, $"Theme <{theme}> fail to parse");
454+
_api.LogException(ClassName, $"Theme <{theme}> fail to parse xaml", e);
455+
if (theme != Constant.DefaultTheme)
456+
{
457+
_api.ShowMsgBox(Localize.theme_load_failure_parse_error(theme));
458+
ChangeTheme(Constant.DefaultTheme);
459+
}
460+
return false;
461+
}
462+
catch (Exception e)
463+
{
464+
_api.LogException(ClassName, $"Theme <{theme}> fail to load", e);
455465
if (theme != Constant.DefaultTheme)
456466
{
457467
_api.ShowMsgBox(Localize.theme_load_failure_parse_error(theme));

Flow.Launcher/App.xaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22
x:Class="Flow.Launcher.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:ui="http://schemas.modernwpf.com/2019"
5+
xmlns:sys="clr-namespace:System;assembly=mscorlib"
6+
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
67
ShutdownMode="OnMainWindowClose"
78
Startup="OnStartup">
89
<Application.Resources>
910
<ResourceDictionary>
1011
<ResourceDictionary.MergedDictionaries>
1112
<ui:ThemeResources>
1213
<ui:ThemeResources.ThemeDictionaries>
13-
<ResourceDictionary x:Key="Light">
14+
<ResourceDictionary x:Key="Light" ui:ThemeDictionary.Key="Light">
1415
<ResourceDictionary.MergedDictionaries>
1516
<ResourceDictionary Source="pack://application:,,,/Resources/Light.xaml" />
1617
</ResourceDictionary.MergedDictionaries>
1718
</ResourceDictionary>
18-
<ResourceDictionary x:Key="Dark">
19+
<ResourceDictionary x:Key="Dark" ui:ThemeDictionary.Key="Dark">
1920
<ResourceDictionary.MergedDictionaries>
2021
<ResourceDictionary Source="pack://application:,,,/Resources/Dark.xaml" />
2122
</ResourceDictionary.MergedDictionaries>
2223
</ResourceDictionary>
23-
<ResourceDictionary x:Key="HighContrast">
24+
<ResourceDictionary x:Key="HighContrast" ui:ThemeDictionary.Key="HighContrast">
2425
<ResourceDictionary.MergedDictionaries>
2526
<ResourceDictionary Source="pack://application:,,,/Resources/Dark.xaml" />
2627
</ResourceDictionary.MergedDictionaries>
@@ -33,6 +34,15 @@
3334
<ResourceDictionary Source="pack://application:,,,/Themes/Win11Light.xaml" />
3435
<ResourceDictionary Source="pack://application:,,,/Languages/en.xaml" />
3536
</ResourceDictionary.MergedDictionaries>
37+
38+
<!-- Override styles in UI.Modern.WPF -->
39+
<Thickness x:Key="ListViewItemCompactSelectedBorderThemeThickness">2</Thickness>
40+
<sys:Double x:Key="CheckBoxMinWidth">0</sys:Double>
41+
<sys:Double x:Key="GridViewItemMinWidth">0</sys:Double>
42+
<sys:Double x:Key="GridViewItemMinHeight">40</sys:Double>
43+
<sys:Double x:Key="ListViewItemMinWidth">0</sys:Double>
44+
<sys:Double x:Key="ListViewItemMinHeight">36</sys:Double>
45+
<SolidColorBrush x:Key="NavigationViewSelectionIndicatorForeground" Color="#FF0063B1" />
3646
</ResourceDictionary>
3747
</Application.Resources>
3848
</Application>

Flow.Launcher/App.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using Flow.Launcher.Plugin;
2323
using Flow.Launcher.SettingPages.ViewModels;
2424
using Flow.Launcher.ViewModel;
25+
using iNKORE.UI.WPF.Modern.Common;
2526
using Microsoft.Extensions.DependencyInjection;
2627
using Microsoft.Extensions.Hosting;
2728
using Microsoft.VisualStudio.Threading;
@@ -56,6 +57,9 @@ public partial class App : IDisposable, ISingleInstanceApp
5657

5758
public App()
5859
{
60+
// Do not use bitmap cache since it can cause WPF second window freezing issue
61+
ShadowAssist.UseBitmapCache = false;
62+
5963
// Initialize settings
6064
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
6165

Flow.Launcher/Converters/BoolToIMEConversionModeConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Flow.Launcher.Converters;
77

8-
internal class BoolToIMEConversionModeConverter : IValueConverter
8+
public class BoolToIMEConversionModeConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
@@ -22,7 +22,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
2222
}
2323
}
2424

25-
internal class BoolToIMEStateConverter : IValueConverter
25+
public class BoolToIMEStateConverter : IValueConverter
2626
{
2727
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
2828
{
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Flow.Launcher.Converters;
7+
8+
public class CornerRadiusFilterConverter : DependencyObject, IValueConverter
9+
{
10+
public CornerRadiusFilterKind Filter { get; set; }
11+
12+
public double Scale { get; set; } = 1.0;
13+
14+
public static CornerRadius Convert(CornerRadius radius, CornerRadiusFilterKind filterKind)
15+
{
16+
CornerRadius result = radius;
17+
18+
switch (filterKind)
19+
{
20+
case CornerRadiusFilterKind.Top:
21+
result.BottomLeft = 0;
22+
result.BottomRight = 0;
23+
break;
24+
case CornerRadiusFilterKind.Right:
25+
result.TopLeft = 0;
26+
result.BottomLeft = 0;
27+
break;
28+
case CornerRadiusFilterKind.Bottom:
29+
result.TopLeft = 0;
30+
result.TopRight = 0;
31+
break;
32+
case CornerRadiusFilterKind.Left:
33+
result.TopRight = 0;
34+
result.BottomRight = 0;
35+
break;
36+
}
37+
38+
return result;
39+
}
40+
41+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
42+
{
43+
var cornerRadius = (CornerRadius)value;
44+
45+
var scale = Scale;
46+
if (!double.IsNaN(scale))
47+
{
48+
cornerRadius.TopLeft *= scale;
49+
cornerRadius.TopRight *= scale;
50+
cornerRadius.BottomRight *= scale;
51+
cornerRadius.BottomLeft *= scale;
52+
}
53+
54+
var filterType = Filter;
55+
if (filterType == CornerRadiusFilterKind.TopLeftValue ||
56+
filterType == CornerRadiusFilterKind.BottomRightValue)
57+
{
58+
return GetDoubleValue(cornerRadius, filterType);
59+
}
60+
61+
return Convert(cornerRadius, filterType);
62+
}
63+
64+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
69+
private static double GetDoubleValue(CornerRadius radius, CornerRadiusFilterKind filterKind)
70+
{
71+
switch (filterKind)
72+
{
73+
case CornerRadiusFilterKind.TopLeftValue:
74+
return radius.TopLeft;
75+
case CornerRadiusFilterKind.BottomRightValue:
76+
return radius.BottomRight;
77+
}
78+
return 0;
79+
}
80+
}
81+
82+
public enum CornerRadiusFilterKind
83+
{
84+
None,
85+
Top,
86+
Right,
87+
Bottom,
88+
Left,
89+
TopLeftValue,
90+
BottomRightValue
91+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Flow.Launcher.Converters;
7+
8+
public class PlacementRectangleConverter : IMultiValueConverter
9+
{
10+
public Thickness Margin { get; set; }
11+
12+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
13+
{
14+
if (values.Length == 2 &&
15+
values[0] is double width &&
16+
values[1] is double height)
17+
{
18+
var margin = Margin;
19+
var topLeft = new Point(margin.Left, margin.Top);
20+
var bottomRight = new Point(width - margin.Right, height - margin.Bottom);
21+
var rect = new Rect(topLeft, bottomRight);
22+
return rect;
23+
}
24+
25+
return Rect.Empty;
26+
}
27+
28+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
29+
{
30+
throw new NotImplementedException();
31+
}
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Flow.Launcher.Converters;
7+
8+
public class SharedSizeGroupConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
return (Visibility)value != Visibility.Collapsed ? (string)parameter : null;
13+
}
14+
15+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
}

Flow.Launcher/Converters/StringToKeyBindingConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Flow.Launcher.Converters;
77

8-
class StringToKeyBindingConverter : IValueConverter
8+
public class StringToKeyBindingConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
<PrivateAssets>all</PrivateAssets>
139139
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
140140
</PackageReference>
141+
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.10.1" />
141142
<PackageReference Include="MdXaml" Version="1.27.0" />
142143
<PackageReference Include="MdXaml.AnimatedGif" Version="1.27.0" />
143144
<PackageReference Include="MdXaml.Html" Version="1.27.0" />
@@ -146,9 +147,6 @@
146147
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
147148
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
148149
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
149-
<!-- ModernWpfUI v0.9.5 introduced WinRT changes that causes Notification platform unavailable error on some machines -->
150-
<!-- https://github.com/Flow-Launcher/Flow.Launcher/issues/1772#issuecomment-1502440801 -->
151-
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
152150
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0">
153151
<PrivateAssets>all</PrivateAssets>
154152
</PackageReference>

0 commit comments

Comments
 (0)