Skip to content

Commit

Permalink
新增了几个设置项
Browse files Browse the repository at this point in the history
- 课程表字号
- 自动更新开关
- 更新频道(没放到 UI 里,为想使用预览版的用户增加了一道门槛)
  • Loading branch information
STBBRD committed Apr 4, 2024
1 parent d0e7295 commit 9dc69b8
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 23 deletions.
8 changes: 0 additions & 8 deletions ZongziTEK_Blackboard_Sticker/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ void App_Startup(object sender, StartupEventArgs e)
MessageBox.Show("已有一个黑板贴正在运行", "ZongziTEK 黑板贴", MessageBoxButton.OK, MessageBoxImage.Warning);
Environment.Exit(0);
}

// Auto Updater
AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider("AutoUpdater.json");
AutoUpdater.Start($"http://s.zztek.top:1573/zbsupdate.xml");
AutoUpdater.ApplicationExitEvent += () =>
{
Environment.Exit(0);
};
}
}

Expand Down
3 changes: 2 additions & 1 deletion ZongziTEK_Blackboard_Sticker/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class TimetableSettings
public bool IsTimetableNotificationEnabled { get; set; } = true;
/*public bool UseDefaultBNSPath { get; set; } = true;
public string BNSPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Blackboard Notification Service";*/
public double FontSize { get; set; } = 24;
public double BeginNotificationTime { get; set; } = 4;
public double BeginNotificationPreTime { get; set; } = 10;
public double OverNotificationTime { get; set; } = 4;
Expand Down Expand Up @@ -69,6 +70,6 @@ public class Automation
public class Update
{
public bool IsUpdateAutomatic { get; set; } = true;
public int UpdateChannel { get; set; } = 0; // 0 代表 Release 频道,1 代表 Preview 频道,暂未完成
public int UpdateChannel { get; set; } = 0; // 0 代表 Release 频道,1 代表 Preview 频道
}
}
14 changes: 10 additions & 4 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Background="#00000000"
ResizeMode="NoResize" ShowInTaskbar="False"
Icon="/黑板贴.png" WindowStyle="None" AllowsTransparency="True" Closing="window_Closing" AllowDrop="True" Loaded="window_Loaded"
DragEnter="window_DragEnter" DragLeave="window_DragLeave" Drop="window_Drop" Activated="window_Activated"
DragEnter="window_DragEnter" DragLeave="window_DragLeave" Drop="window_Drop"
ui:ThemeManager.RequestedTheme="Light">

<Grid>
Expand Down Expand Up @@ -326,21 +326,25 @@
TextWrapping="Wrap" Opacity="0.75"/>
<ui:ToggleSwitch Name="ToggleSwitchTimetableNotification" Header="启用上下课提醒" OnContent="" OffContent="" IsOn="True" Toggled="ToggleSwitchTimetableNotification_Toggled" Foreground="{DynamicResource ForegroundColor}" IsEnabled="{Binding IsOn, ElementName=ToggleSwitchUseTimetable}"/>
<StackPanel Orientation="Horizontal">
<TextBlock Name="TextBlockBNSStatus" Opacity="0.75" Text="黑板通知服务" VerticalAlignment="Center"/>
<TextBlock Name="TextBlockBNSStatus" Opacity="0.75" VerticalAlignment="Center"/>
<ui:HyperlinkButton Name="ButtonRefreshBNSStatus" HorizontalContentAlignment="Left" Padding="0" Margin="4,0,0,0" VerticalAlignment="Center" Click="ButtonRefreshBNSStatus_Click">
<StackPanel Orientation="Horizontal">
<ui:FontIcon FontSize="12" FontFamily="{StaticResource SegoeFluentIcons}" Glyph="{x:Static ui:SegoeIcons.Refresh}"/>
<TextBlock FontSize="12" Margin="4,0,0,0" Text="重新检测"/>
</StackPanel>
</ui:HyperlinkButton>
</StackPanel>
<ui:SimpleStackPanel Spacing="4">
<Slider Name="SliderBeginNotificationTime" ui:ControlHelper.Header="课前通知持续时间(秒)" Minimum="3" Maximum="30" TickFrequency="1" IsSnapToTickEnabled="True" Value="4" TickPlacement="Both" HorizontalAlignment="Left" Width="400" ValueChanged="SliderBeginNotificationTime_ValueChanged"/>
<TextBlock FontSize="14" Text="{Binding Value, ElementName=SliderBeginNotificationTime}"/>
</ui:SimpleStackPanel>
<ui:ToggleSwitch Name="ToggleSwitchTempTimetable" Header="展示临时课表" OnContent="" OffContent="" IsOn="False" Toggled="ToggleSwitchTempTimetable_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<!--<ui:ToggleSwitch Name="ToggleSwitchUseDefaultBNSPath" Header="使用默认黑板通知服务路径" OnContent="开" OffContent="关" IsOn="True" Toggled="ToggleSwitchUseDefaultBNSPath_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<TextBlock Text="黑板通知服务路径" FontSize="14"/>
<TextBox Name="TextBoxBNSPath" TextChanged="TextBoxBNSPath_TextChanged" Foreground="{DynamicResource ForegroundColor}" IsEnabled="{Binding IsOn, ElementName=ToggleSwitchUseDefaultBNSPath,Converter={StaticResource InverseBooleanConverter}}"/>-->
<ui:SimpleStackPanel Spacing="4">
<Slider Name="SliderBeginNotificationTime" ui:ControlHelper.Header="课前通知持续时间(秒)" Minimum="3" Maximum="30" TickFrequency="1" IsSnapToTickEnabled="True" Value="4" TickPlacement="Both" HorizontalAlignment="Left" Width="400" ValueChanged="SliderBeginNotificationTime_ValueChanged"/>
<TextBlock FontSize="14" Text="{Binding Value, ElementName=SliderBeginNotificationTime}"/>
<Slider Name="SliderTimetableFontSize" ui:ControlHelper.Header="课程表字号" Minimum="16" Maximum="32" TickFrequency="1" IsSnapToTickEnabled="True" Value="24" TickPlacement="Both" HorizontalAlignment="Left" Width="400" PreviewMouseUp="SliderTimetableFontSize_PreviewMouseUp"/>
<TextBlock FontSize="14" Text="{Binding Value, ElementName=SliderTimetableFontSize}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Spacing="4">
<Slider Name="SliderBeginNotificationPreTime" ui:ControlHelper.Header="课前通知提前时间(秒)" Minimum="6" Maximum="60" TickFrequency="1" IsSnapToTickEnabled="True" Value="10" TickPlacement="Both" HorizontalAlignment="Left" Width="400" ValueChanged="SliderBeginNotificationPreTime_ValueChanged"/>
Expand Down Expand Up @@ -379,6 +383,8 @@
</GroupBox>
<GroupBox Header="关于" Foreground="{DynamicResource ForegroundColor}">
<ui:SimpleStackPanel Spacing="12">
<ui:ToggleSwitch Name="ToggleSwitchAutoUpdate" Header="自动更新"
IsOn="True" OnContent="启用" OffContent="禁用" Toggled="ToggleSwitchAutoUpdate_Toggled"/>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="4">
<TextBlock FontSize="14">
<Bold>当前版本:</Bold>
Expand Down
83 changes: 73 additions & 10 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using iNKORE.UI.WPF.Modern;
using iNKORE.UI.WPF.Modern.Controls;
using System.Reflection;
using AutoUpdaterDotNET;

namespace ZongziTEK_Blackboard_Sticker
{
Expand All @@ -38,7 +39,7 @@ public MainWindow()
{
InitializeComponent();

//小黑板 1
// 小黑板 1
drawingAttributes = new DrawingAttributes();
inkCanvas.DefaultDrawingAttributes = drawingAttributes;
drawingAttributes.Color = Colors.White;
Expand All @@ -48,10 +49,13 @@ public MainWindow()
drawingAttributes.FitToCurve = true;
squarePicker.SelectedColor = inkCanvas.DefaultDrawingAttributes.Color;

//窗体
// 窗体
SetWindowMaximized();

//加载文件
windowTimer.Tick += windowTimer_Tick;
windowTimer.Start();

// 加载文件
LoadSettings();
LoadStrokes();
LoadTimetableorCurriculum();
Expand All @@ -63,7 +67,10 @@ public MainWindow()
});
});

//看板
// 检查更新
if (Settings.Update.IsUpdateAutomatic) CheckUpdate();

// 看板
textBlockTime.Text = DateTime.Now.ToString(("HH:mm:ss"));
clockTimer = new DispatcherTimer();
clockTimer.Tick += ClockTimer_Tick;
Expand All @@ -75,26 +82,26 @@ public MainWindow()
frameInfoNavigationTimer.Interval = TimeSpan.FromSeconds(4);
frameInfoNavigationTimer.Start();

//课程表
// 课程表
timetableTimer = new DispatcherTimer();
timetableTimer.Tick += CheckTimetable;
timetableTimer.Interval = new TimeSpan(0, 0, 1);
timetableTimer.Start();

TimetableEditor.EditorButtonUseCurriculum_Click += EditorButtonSettingUseCurriculum;

//颜色主题
// 颜色主题
Microsoft.Win32.SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
SystemEvents_UserPreferenceChanged(null, null);

//小黑板 2
// 小黑板 2
CheckIsBlackboardLocked();

//显示版本号
// 显示版本号
Version version = Assembly.GetExecutingAssembly().GetName().Version;
TextBlockVersion.Text = version.ToString();

//隐藏管家助手
// 隐藏管家助手
timerHideSeewoServiceAssistant.Tick += TimerHideSeewoServiceAssistant_Tick;
timerHideSeewoServiceAssistant.Interval = TimeSpan.FromSeconds(1);
}
Expand Down Expand Up @@ -172,6 +179,16 @@ private void iconSwitchRight_MouseDown(object sender, MouseButtonEventArgs e)
iconSwitchRight.Visibility = Visibility.Collapsed;
iconSwitchLeft.Visibility = Visibility.Visible;
}

private DispatcherTimer windowTimer = new DispatcherTimer()
{
Interval = new TimeSpan(0, 0, 0, 0, 500)
};

private void windowTimer_Tick(object sender, EventArgs e)
{
WindowsHelper.SetBottom(window);
}
#endregion

#region Blackboard
Expand Down Expand Up @@ -884,6 +901,8 @@ private void LoadCurriculum()
textBoxSunday.Text = Curriculums.Sunday.Curriculums;
textBoxTempCurriculums.Text = Curriculums.Temp.Curriculums;

textBlockCurriculum.FontSize = Settings.TimetableSettings.FontSize;

string day = DateTime.Today.DayOfWeek.ToString();

if (!ToggleSwitchTempTimetable.IsOn)
Expand Down Expand Up @@ -1007,7 +1026,7 @@ private void LoadTimetable()
{
TextBlock textBlock = new TextBlock()
{
FontSize = 28,
FontSize = Settings.TimetableSettings.FontSize,
HorizontalAlignment = HorizontalAlignment.Center,
Foreground = (SolidColorBrush)FindResource("ForegroundColor"),
Text = lesson.Subject
Expand Down Expand Up @@ -1494,6 +1513,16 @@ private void TextBoxBNSPath_TextChanged(object sender, TextChangedEventArgs e)
SaveSettings();
}*/

private void SliderTimetableFontSize_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
if (!isSettingsLoaded) return;

Settings.TimetableSettings.FontSize = SliderTimetableFontSize.Value;
SaveSettings();

LoadTimetableorCurriculum();
}

private void ButtonRefreshBNSStatus_Click(object sender, RoutedEventArgs e)
{
if (GetBNSPath() == null)
Expand Down Expand Up @@ -1656,6 +1685,19 @@ private void ToggleSwitchAutoHideSeewoHugoAssistant_Toggled(object sender, Route
else
timerHideSeewoServiceAssistant.Stop();
}

private void ToggleSwitchAutoUpdate_Toggled(object sender, RoutedEventArgs e)
{
if (!isSettingsLoaded) return;

Settings.Update.IsUpdateAutomatic = ToggleSwitchAutoUpdate.IsOn;
SaveSettings();

if (Settings.Update.IsUpdateAutomatic)
{
CheckUpdate();
}
}
#endregion

private void LoadSettings()
Expand Down Expand Up @@ -1713,6 +1755,7 @@ private void LoadSettings()
ToggleSwitchTimetableNotification.IsOn = Settings.TimetableSettings.IsTimetableNotificationEnabled;
//ToggleSwitchUseDefaultBNSPath.IsOn = Settings.TimetableSettings.UseDefaultBNSPath;
//TextBoxBNSPath.Text = Settings.TimetableSettings.BNSPath;
SliderTimetableFontSize.Value = Settings.TimetableSettings.FontSize;
SliderBeginNotificationTime.Value = Settings.TimetableSettings.BeginNotificationTime;
SliderBeginNotificationPreTime.Minimum = SliderBeginNotificationTime.Value;
SliderBeginNotificationPreTime.Maximum = SliderBeginNotificationTime.Value + 20;
Expand All @@ -1733,6 +1776,8 @@ private void LoadSettings()
ToggleSwitchAutoHideSeewoHugoAssistant.IsOn = Settings.Automation.IsAutoHideHugoAssistantEnabled;
if (Settings.Automation.IsAutoHideHugoAssistantEnabled) timerHideSeewoServiceAssistant.Start();

ToggleSwitchAutoUpdate.IsOn = Settings.Update.IsUpdateAutomatic;

isSettingsLoaded = true;
}
public static Settings Settings = new Settings();
Expand Down Expand Up @@ -2101,6 +2146,24 @@ private void SwitchLookMode()
frameInfoNavigationTimer.Start();
}
}

private void CheckUpdate()
{
AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider("AutoUpdater.json");
switch (Settings.Update.UpdateChannel)
{
case 0: // Release 频道
AutoUpdater.Start($"http://s.zztek.top:1573/zbsupdate.xml");
break;
case 1: // Preview 频道
AutoUpdater.Start($"http://s.zztek.top:1573/zbsupdatepreview.xml");
break;
}
AutoUpdater.ApplicationExitEvent += () =>
{
Environment.Exit(0);
};
}
#endregion
}
}

0 comments on commit 9dc69b8

Please sign in to comment.