Skip to content

Commit

Permalink
🎨 UI Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SydneyOwl committed Jul 22, 2024
1 parent 5e96682 commit 5f76efd
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 7 deletions.
16 changes: 16 additions & 0 deletions Constants/Common/TIPS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

namespace SenhaixFreqWriter.Constants.Common;

public class TIPS
{
public static List<String> TipList = new()
{
"Tips: 对信道进行拖动或清空等操作后序号可能会出现“27”,此时上下拉动右侧滚动条即可!",
"Tips: 如遇到任何问题,欢迎在github中提出issue或PR!",
$"Tips: 软件版本:{(Properties.Version.VersionTag == "@TAG_NAME@" ? "(内部版本)":Properties.Version.VersionTag)},可在github上检查、获取更新!",
"Tips: 体谅、忠诚、进步、友爱、适度、爱国",
"Tips: 目前仅8800支持蓝牙写频!"
};
}
9 changes: 6 additions & 3 deletions Views/Common/AboutWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
<Label Canvas.Top="50" Canvas.Right="0" Name="macos">macOS</Label>

<Label Canvas.Right="148" Canvas.Top="75"> 版本号:</Label>
<Label Content="{x:Static constants:Version.VersionTag}" Canvas.Left="250" Canvas.Top="75" />
<!-- <Label Content="{x:Static constants:Version.VersionTag}" Canvas.Left="250" Canvas.Top="75" /> -->
<Label Name="MVersionTag" Canvas.Left="250" Canvas.Top="75" />
<Label Canvas.Right="162" Canvas.Top="100"> 提交:</Label>
<Label Content="{x:Static constants:Version.GitCommitHash}" Canvas.Left="240" Canvas.Top="100" />
<!-- <Label Content="{x:Static constants:Version.GitCommitHash}" Canvas.Left="240" Canvas.Top="100" /> -->
<Label Name="MGitCommitHash" Canvas.Left="240" Canvas.Top="100" />
<Label Canvas.Right="134" Canvas.Top="125"> 编译时间:</Label>
<Label Content="{x:Static constants:Version.BuildTime}" Canvas.Right="0" Canvas.Top="125" />
<!-- <Label Content="{x:Static constants:Version.BuildTime}" Canvas.Right="0" Canvas.Top="125" /> -->
<Label Name="MBuildTime" Canvas.Right="0" Canvas.Top="125" />

<Button HorizontalAlignment="Left" Canvas.Bottom="10" Canvas.Right="10" Click="RepoButton_OnClick">
<StackPanel Orientation="Horizontal">
Expand Down
3 changes: 3 additions & 0 deletions Views/Common/AboutWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public AboutWindow()
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) windows.Background = Brushes.BlanchedAlmond;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) linux.Background = Brushes.BlanchedAlmond;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) macos.Background = Brushes.BlanchedAlmond;
MVersionTag.Content = Version.VersionTag == "@TAG_NAME@" ? "(内部版本)" : Version.VersionTag;
MGitCommitHash.Content = Version.GitCommitHash == "@COMMIT_HASH@" ? "(内部版本)" : Version.GitCommitHash;
MBuildTime.Content = Version.BuildTime == "@BUILD_TIME@" ? "(内部版本)" : Version.BuildTime;
}

private void RepoButton_OnClick(object? sender, RoutedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Views/Gt12/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<!-- <StackPanel Orientation="Horizontal"> -->
<!-- <Label Foreground="MediumBlue" Content="{x:Static verConstants:Version.VersionTag}" /> -->
<!-- <TextBlock Foreground="MediumBlue">|https://github.com/SydneyOwl/senhaix-freq-writer-enhanced|</TextBlock> -->
<TextBlock Foreground="Blue">Tips:对信道进行拖动等操作后序号可能会出现“27”,此时上下拉动右侧滚动条即可</TextBlock>
<TextBlock Foreground="Blue" Name="tipBlock"></TextBlock>
<!-- </StackPanel> -->
</Border>
<Border Height="40" Background="{DynamicResource tbBackgroundBrush}" BorderBrush="Black" BorderThickness="1"
Expand Down
21 changes: 19 additions & 2 deletions Views/Gt12/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
Expand Down Expand Up @@ -36,10 +38,14 @@ public partial class MainWindow : Window
private IBluetooth _osBle;

public int CurrentArea;

private CancellationTokenSource cancelTips;

public MainWindow()
{
InitializeComponent();
cancelTips = new CancellationTokenSource();
Task.Run(()=>updateTips(cancelTips.Token));
DataContext = this;
SetArea(0);
ListItems.CollectionChanged += CollectionChangedHandler;
Expand All @@ -62,8 +68,19 @@ public MainWindow()
}

public ObservableCollection<Channel> ListItems { get; set; } = new();



private async void updateTips(CancellationToken token)
{
while (!token.IsCancellationRequested)
{
Dispatcher.UIThread.Invoke(() =>
{
tipBlock.Text = TIPS.TipList[new Random().Next(TIPS.TipList.Count)];
});
await Task.Delay(5000,CancellationToken.None);
}
}

private void About_OnClick(object? sender, RoutedEventArgs e)
{
var aboutWindow = new AboutWindow();
Expand Down
2 changes: 1 addition & 1 deletion Views/Shx8x00/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<!-- <StackPanel Orientation="Horizontal"> -->
<!-- <Label Foreground="MediumBlue" Content="{x:Static verConstants:Version.VersionTag}" /> -->
<!-- <TextBlock Foreground="MediumBlue">|https://github.com/SydneyOwl/senhaix-freq-writer-enhanced|</TextBlock> -->
<TextBlock Foreground="Blue">Tips: 对信道进行拖动等操作后序号可能会出现“27”,此时上下拉动右侧滚动条即可</TextBlock>
<TextBlock Foreground="Blue" Name="tipBlock"></TextBlock>
<!-- </StackPanel> -->
</Border>
<Border Background="{DynamicResource dgvBackgroundBrush}" BorderBrush="Black" BorderThickness="1">
Expand Down
20 changes: 20 additions & 0 deletions Views/Shx8x00/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using Avalonia.Styling;
using Avalonia.Threading;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;
using SenhaixFreqWriter.Constants.Common;
Expand All @@ -34,17 +37,33 @@ public partial class MainWindow : Window
private BluetoothDeviceSelectionWindow bds;

private SHX_DEVICE shxDevice = SHX_DEVICE.SHX8600;

private CancellationTokenSource cancelTips;

public MainWindow(SHX_DEVICE shx)
{
InitializeComponent();
cancelTips = new CancellationTokenSource();
Task.Run(()=>updateTips(cancelTips.Token));
DataContext = this;
shxDevice = shx;
_listItems.CollectionChanged += CollectionChangedHandler;
Closed += OnWindowClosed;
DebugWindow.GetInstance().updateDebugContent("AppContext.BaseDirectory = " + AppContext.BaseDirectory);
}

private async void updateTips(CancellationToken token)
{
while (!token.IsCancellationRequested)
{
Dispatcher.UIThread.Invoke(() =>
{
tipBlock.Text = TIPS.TipList[new Random().Next(TIPS.TipList.Count)];
});
await Task.Delay(5000,CancellationToken.None);
}
}

public ObservableCollection<ChannelData> ListItems
{
get => _listItems;
Expand All @@ -63,6 +82,7 @@ private void CollectionChangedHandler(object sender, NotifyCollectionChangedEven

private void OnWindowClosed(object? sender, EventArgs e)
{
cancelTips.Cancel();
Close();
bds?.osBLE?.Dispose();
if (!_devSwitchFlag) Environment.Exit(0);
Expand Down

0 comments on commit 5f76efd

Please sign in to comment.