Skip to content

Commit 9972e89

Browse files
Upgrade to avalonia 11.3 - Part 2 (#90)
1 parent 3806dc3 commit 9972e89

20 files changed

Lines changed: 389 additions & 157 deletions

src/ByteSync.Client/App.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<Application.Styles>
2424
<FluentTheme />
2525
<StyleInclude Source="avares://ByteSync/Assets/Icons/BoxIcons.axaml"/>
26-
<StyleInclude Source="avares://ByteSync/Assets/Themes/LinearProgress.axaml"/>
26+
<StyleInclude Source="avares://ByteSync/Assets/Themes/ActivityIndicator.axaml"/>
2727
<StyleInclude Source="avares://ByteSync/Assets/Themes/GeneralStyles.axaml"/>
2828
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
2929
</Application.Styles>

src/ByteSync.Client/Assets/Themes/LinearProgress.axaml renamed to src/ByteSync.Client/Assets/Themes/ActivityIndicator.axaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:local="clr-namespace:ByteSync.Views.Misc">
44

5-
<Style Selector="local|LinearProgress">
5+
<Style Selector="local|ActivityIndicator">
66
<Setter Property="Background" Value="Transparent" />
77
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColor}" />
88
<Setter Property="IsHitTestVisible" Value="False" />
@@ -23,28 +23,28 @@
2323
Padding="{TemplateBinding Padding}">
2424

2525
<Grid ColumnDefinitions="2*, *, 2*, *, 2*, *, 2*">
26-
<Border Grid.Column="0" x:Name="R1" Classes="cR1"
26+
<Border Grid.Column="0" x:Name="R1" Classes="Shape1"
2727
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RectangleHeight}"
2828
CornerRadius="2"
2929
Background="Transparent"
3030
BorderBrush="{DynamicResource TextControlBorderBrush}"
3131
BorderThickness="1"/>
3232

33-
<Border Grid.Column="2" x:Name="R2" Classes="cR2"
33+
<Border Grid.Column="2" x:Name="R2" Classes="Shape2"
3434
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RectangleHeight}"
3535
CornerRadius="2"
3636
Background="Transparent"
3737
BorderBrush="{DynamicResource TextControlBorderBrush}"
3838
BorderThickness="1"/>
3939

40-
<Border Grid.Column="4" x:Name="R3" Classes="cR3"
40+
<Border Grid.Column="4" x:Name="R3" Classes="Shape3"
4141
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RectangleHeight}"
4242
CornerRadius="2"
4343
Background="Transparent"
4444
BorderBrush="{DynamicResource TextControlBorderBrush}"
4545
BorderThickness="1"/>
4646

47-
<Border Grid.Column="6" x:Name="R4" Classes="cR4"
47+
<Border Grid.Column="6" x:Name="R4" Classes="Shape4"
4848
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RectangleHeight}"
4949
CornerRadius="2"
5050
Background="Transparent"
@@ -57,7 +57,7 @@
5757
</Setter>
5858
</Style>
5959

60-
<Style Selector="local|LinearProgress:active Border.cR1">
60+
<Style Selector="local|ActivityIndicator:active Border.Shape1">
6161
<Style.Animations>
6262
<Animation Duration="0:0:4.0" IterationCount="Infinite" Delay="0" FillMode="None">
6363
<KeyFrame KeyTime="0:0:0.0">
@@ -80,7 +80,7 @@
8080
</Style.Animations>
8181
</Style>
8282

83-
<Style Selector="local|LinearProgress:active Border.cR2">
83+
<Style Selector="local|ActivityIndicator:active Border.Shape2">
8484
<Style.Animations>
8585
<Animation Duration="0:0:4.0" IterationCount="Infinite" Delay="0" FillMode="None">
8686
<KeyFrame KeyTime="0:0:0.0">
@@ -111,7 +111,7 @@
111111
</Style.Animations>
112112
</Style>
113113

114-
<Style Selector="local|LinearProgress:active Border.cR3">
114+
<Style Selector="local|ActivityIndicator:active Border.Shape3">
115115
<Style.Animations>
116116
<Animation Duration="0:0:4.0" IterationCount="Infinite" Delay="0" FillMode="None">
117117
<KeyFrame KeyTime="0:0:0.0">
@@ -142,7 +142,7 @@
142142
</Style.Animations>
143143
</Style>
144144

145-
<Style Selector="local|LinearProgress:active Border.cR4">
145+
<Style Selector="local|ActivityIndicator:active Border.Shape4">
146146
<Style.Animations>
147147
<Animation Duration="0:0:4.0" IterationCount="Infinite" Delay="0" FillMode="None">
148148
<KeyFrame KeyTime="0:0:0.0">
@@ -169,22 +169,22 @@
169169
</Style.Animations>
170170
</Style>
171171

172-
<Style Selector="local|LinearProgress:inactive Border.cR1">
172+
<Style Selector="local|ActivityIndicator:inactive Border.Shape1">
173173
<Setter Property="Background" Value="Transparent"/>
174174
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}"/>
175175
</Style>
176176

177-
<Style Selector="local|LinearProgress:inactive Border.cR2">
177+
<Style Selector="local|ActivityIndicator:inactive Border.Shape2">
178178
<Setter Property="Background" Value="Transparent"/>
179179
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}"/>
180180
</Style>
181181

182-
<Style Selector="local|LinearProgress:inactive Border.cR3">
182+
<Style Selector="local|ActivityIndicator:inactive Border.Shape3">
183183
<Setter Property="Background" Value="Transparent"/>
184184
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}"/>
185185
</Style>
186186

187-
<Style Selector="local|LinearProgress:inactive Border.cR4">
187+
<Style Selector="local|ActivityIndicator:inactive Border.Shape4">
188188
<Setter Property="Background" Value="Transparent"/>
189189
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}"/>
190190
</Style>

src/ByteSync.Client/Assets/Themes/GeneralStyles.axaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@
175175
<Setter Property="Background" Value="{DynamicResource BsAccentButtonPointerOverBackGround}" />
176176
</Style>
177177

178+
<Style Selector="Button.Secondary">
179+
<Setter Property="Background" Value="{DynamicResource SecondaryButtonBackGround}"/>
180+
</Style>
181+
182+
<Style Selector="Button.Secondary:pointerover > ContentPresenter#PART_ContentPresenter2">
183+
<Setter Property="Background" Value="{DynamicResource SecondaryButtonPointerOverBackGround}" />
184+
</Style>
185+
178186
<!-- SEPARATOR -->
179187
<!-- SEPARATOR -->
180188
<!-- SEPARATOR -->

src/ByteSync.Client/Business/Themes/ColorScheme.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,7 @@ public ColorScheme(ThemeModes themeMode)
7979
public SolidColorBrush StatusMainBackGroundBrush { get; set; }
8080
public SolidColorBrush StatusSecondaryBackGroundBrush { get; set; }
8181
public SolidColorBrush VeryLightGrayBrush { get; set; }
82+
83+
public Color MainWindowTopColor { get; set; }
84+
public Color MainWindowBottomColor { get; set; }
8285
}

src/ByteSync.Client/Business/Themes/ThemeColor.cs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,62 @@
1-
namespace ByteSync.Business.Themes;
1+
using Avalonia.Media;
2+
using ByteSync.Helpers;
3+
4+
namespace ByteSync.Business.Themes;
25

36
public class ThemeColor
47
{
58
public ThemeColor(string hexaColor)
69
{
710
HexaColor = hexaColor;
8-
SystemColor = ColorUtils.FromHex(HexaColor);
9-
AvaloniaColor = FromSystemColor(SystemColor);
10-
InitializeHSV();
11+
AvaloniaColor = ColorUtils.FromHex(HexaColor);
12+
InitializeHsv();
1113
}
1214

13-
public ThemeColor(System.Drawing.Color systemColor)
15+
public ThemeColor(Color color)
1416
{
15-
SystemColor = systemColor;
16-
HexaColor = ColorUtils.ToHex(systemColor);
17-
AvaloniaColor = FromSystemColor(SystemColor);
18-
InitializeHSV();
17+
HexaColor = ColorUtils.ToHex(color);
18+
AvaloniaColor = color;
19+
InitializeHsv();
1920
}
2021

21-
private void InitializeHSV()
22+
private void InitializeHsv()
2223
{
23-
ColorUtils.ColorToHSV(SystemColor, out double hue, out double saturation, out double value);
24+
ColorUtils.ColorToHsv(AvaloniaColor, out double hue, out double saturation, out double value);
2425
Hue = hue;
2526
Saturation = saturation;
2627
Value = value;
2728
}
2829

2930
public string HexaColor { get; }
3031

31-
public Avalonia.Media.Color AvaloniaColor { get; }
32-
33-
public System.Drawing.Color SystemColor { get; }
32+
public Color AvaloniaColor { get; }
3433

3534
public double Hue { get; private set; }
3635

3736
public double Saturation { get; private set; }
3837

3938
public double Value { get; private set; }
4039

41-
42-
private Avalonia.Media.Color FromSystemColor(System.Drawing.Color color)
43-
{
44-
return Avalonia.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
45-
}
40+
4641

4742
public ThemeColor WithHue(double hue)
4843
{
49-
var newSystemColor = ColorUtils.ColorFromHSV(hue, this.Saturation, this.Value);
44+
var newSystemColor = ColorUtils.ColorFromHsv(hue, Saturation, Value);
5045
return new ThemeColor(newSystemColor);
5146
}
5247

5348
public ThemeColor WithSaturationValue(double saturation, double value)
5449
{
55-
var newSystemColor = ColorUtils.ColorFromHSV(this.Hue, saturation, value);
50+
var newSystemColor = ColorUtils.ColorFromHsv(Hue, saturation, value);
5651
return new ThemeColor(newSystemColor);
5752
}
5853

5954
public ThemeColor AdjustSaturationValue(double saturationPercent, double valuePercent)
6055
{
61-
double newSaturation = ComputeAdjustedValue(this.Saturation, saturationPercent);
62-
double newValue = ComputeAdjustedValue(this.Value, valuePercent);
56+
double newSaturation = ComputeAdjustedValue(Saturation, saturationPercent);
57+
double newValue = ComputeAdjustedValue(Value, valuePercent);
6358

64-
var newSystemColor = ColorUtils.ColorFromHSV(this.Hue, newSaturation, newValue);
59+
var newSystemColor = ColorUtils.ColorFromHsv(Hue, newSaturation, newValue);
6560
return new ThemeColor(newSystemColor);
6661
}
6762

src/ByteSync.Client/ByteSync.Client.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<AvaloniaXaml Remove="Assets\Themes\PowBlueAccentColors.axaml" />
4646
<None Remove=".gitignore" />
4747
<None Remove="Assets\ByteSyncLogo.png" />
48-
<AvaloniaXaml Remove="Assets\Themes\LinearProgress.axaml" />
48+
<AvaloniaXaml Remove="Assets\Themes\ActivityIndicator.axaml" />
4949
<None Update="local.settings.template.json">
5050
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
5151
</None>
@@ -128,8 +128,8 @@
128128
</EmbeddedResource>
129129
</ItemGroup>
130130
<ItemGroup>
131-
<Compile Update="Assets\Themes\LinearProgress.xaml.cs">
132-
<DependentUpon>LinearProgress.axaml</DependentUpon>
131+
<Compile Update="Assets\Themes\ActivityIndicator.xaml.cs">
132+
<DependentUpon>ActivityIndicator.axaml</DependentUpon>
133133
</Compile>
134134
<Compile Update="Views\Sessions\Managing\CurrentCloudSessionView.axaml.cs">
135135
<DependentUpon>CurrentCloudSessionView.axaml</DependentUpon>

0 commit comments

Comments
 (0)