-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
231 additions
and
32 deletions.
There are no files selected for viewing
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
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
42 changes: 42 additions & 0 deletions
42
src/Plugins/ColorDesktop.MonitorPlugin/Controls/ProgressBar5Control.axaml
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,42 @@ | ||
<UserControl | ||
x:Class="ColorDesktop.MonitorPlugin.Controls.ProgressBar5Control" | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:ColorDesktop.MonitorPlugin.Controls" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:svg="clr-namespace:ColorDesktop.CoreLib.View.Svg;assembly=ColorDesktop.CoreLib" | ||
xmlns:vm="clr-namespace:ColorDesktop.MonitorPlugin.Models" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
x:DataType="vm:ProgressBar5Model" | ||
mc:Ignorable="d"> | ||
<Border Background="{Binding BackColor}" CornerRadius="5"> | ||
<StackPanel Margin="{Binding BorderSize}"> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
FontSize="{Binding FontSize}" | ||
Foreground="{Binding TextColor}" | ||
Text="{Binding Name}" /> | ||
<Panel Margin="0,0,0,-10"> | ||
<svg:SvgControl | ||
Width="{Binding Width}" | ||
Height="{Binding Height}" | ||
Path="/Resource/svg1.svg" | ||
Stroke="{Binding BackColor1}" /> | ||
<svg:SvgControl | ||
Width="{Binding Width}" | ||
Height="{Binding Height}" | ||
Fill="{Binding BarColor}" | ||
Path="/Resource/svg1_1.svg" | ||
RenderTransform="{Binding Pointer1}" | ||
Stroke="{Binding BarColor}" /> | ||
</Panel> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
FontSize="{Binding FontSize}" | ||
Foreground="{Binding TextColor}" | ||
Text="{Binding Text}" /> | ||
</StackPanel> | ||
</Border> | ||
</UserControl> |
14 changes: 14 additions & 0 deletions
14
src/Plugins/ColorDesktop.MonitorPlugin/Controls/ProgressBar5Control.axaml.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,14 @@ | ||
using System.ComponentModel; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Media; | ||
|
||
namespace ColorDesktop.MonitorPlugin.Controls; | ||
|
||
public partial class ProgressBar5Control : UserControl | ||
{ | ||
public ProgressBar5Control() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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
97 changes: 97 additions & 0 deletions
97
src/Plugins/ColorDesktop.MonitorPlugin/Models/ProgressBar5Model.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,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Primitives; | ||
using Avalonia.Media; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
namespace ColorDesktop.MonitorPlugin.Models; | ||
|
||
public partial class ProgressBar5Model : ObservableObject, IUpdate | ||
{ | ||
[ObservableProperty] | ||
private IBrush _backColor; | ||
[ObservableProperty] | ||
private IBrush _backColor1; | ||
[ObservableProperty] | ||
private IBrush _textColor; | ||
[ObservableProperty] | ||
private IBrush _barColor; | ||
[ObservableProperty] | ||
private int _fontSize; | ||
[ObservableProperty] | ||
private double _width; | ||
[ObservableProperty] | ||
private double _height; | ||
[ObservableProperty] | ||
private Thickness _borderSize; | ||
|
||
private double _min; | ||
private double _max; | ||
|
||
[ObservableProperty] | ||
private string _name; | ||
|
||
[ObservableProperty] | ||
private string _text; | ||
|
||
[ObservableProperty] | ||
private RotateTransform _pointer1 = new(); | ||
|
||
public ProgressBar5Model(MonitorItemModel model) | ||
{ | ||
Reload(model); | ||
} | ||
|
||
public void Reload(MonitorItemModel model) | ||
{ | ||
var item = model.Obj; | ||
FontSize = item.FontSize; | ||
BackColor = Brush.Parse(item.Color1 ?? "#FFFFFF"); | ||
TextColor = Brush.Parse(item.Color2 ?? "#FFFFFF"); | ||
BarColor = Brush.Parse(item.Color3 ?? "#FFFFFF"); | ||
BackColor1 = Brush.Parse(item.Color4 ?? "#FFFFFF"); | ||
Width = item.Width <= 0 ? double.NaN : item.Width; | ||
Height = item.Height <= 0 ? double.NaN : item.Height; | ||
BorderSize = new(item.BorderSize); | ||
|
||
_min = item.Min; | ||
_max = item.Max; | ||
Name = item.Name; | ||
} | ||
|
||
public void Update(MonitorItemModel model) | ||
{ | ||
switch (model.ValueType) | ||
{ | ||
case ValueType.Now: | ||
var angle = (model.Value - _min) / (_max - _min) * 270; | ||
if (Pointer1.Angle != angle) | ||
{ | ||
Pointer1.Angle = angle; | ||
} | ||
Text = model.Format; | ||
break; | ||
case ValueType.Max: | ||
angle = (model.MaxValue - _min) / (_max - _min) * 270; | ||
if (Pointer1.Angle != angle) | ||
{ | ||
Pointer1.Angle = angle; | ||
} | ||
Text = model.FormatMax; | ||
break; | ||
case ValueType.Min: | ||
angle = (model.MinValue - _min) / (_max - _min) * 270; | ||
if (Pointer1.Angle != angle) | ||
{ | ||
Pointer1.Angle = angle; | ||
} | ||
Text = model.FormatMin; | ||
break; | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.