Skip to content

Commit

Permalink
完成看板中页面轮播效果,修复 Timetable 有时没有课程开始通知的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Jan 31, 2024
1 parent 7845468 commit 66fcc8c
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ZongziTEK_Blackboard_Sticker/FullScreenClock.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker"
mc:Ignorable="d"
Title="FullScreenClock" Height="450" Width="800" Top="0" Left="0" Margin="0,0,2,0"
Title="ZongziTEK 黑板贴 - 全屏时钟" Height="450" Width="800" Top="0" Left="0" Margin="0,0,2,0"
ResizeMode="NoResize" WindowStyle="None" WindowState="Maximized" Loaded="Window_Loaded">
<Grid Background="Black" MouseDown="Grid_MouseDown">
<Grid>
Expand Down
17 changes: 15 additions & 2 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@
</Grid.ColumnDefinitions>

<!--看板-->
<Border Grid.ColumnSpan="2" Background="{DynamicResource WindowBackgroundColor}" Margin="8" CornerRadius="8" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Border Height="72" Grid.ColumnSpan="2" Background="{DynamicResource WindowBackgroundColor}" Margin="8" CornerRadius="8" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Grid>
<TextBlock x:Name="textBlockTime" FontSize="40" Foreground="{DynamicResource ForegroundColor}" Text="08:00:00" Margin="12,8"/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock x:Name="textBlockTime" FontSize="40" Foreground="{DynamicResource ForegroundColor}" Text="08:00:00" Margin="16,8" VerticalAlignment="Center"/>
<ui:Frame Grid.Column="1" Name="FrameInfo">
<ui:Frame.ContentTransitions>
<ui:TransitionCollection>
<ui:NavigationThemeTransition/>
</ui:TransitionCollection>
</ui:Frame.ContentTransitions>
</ui:Frame>
<Border Name="BorderSwitchFrameInfoPage" Grid.Column="1" Background="#00000000" MouseDown="BorderSwitchFrameInfoPage_MouseDown"/>
</Grid>
</Border>

Expand Down
63 changes: 57 additions & 6 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
using ZongziTEK_Blackboard_Sticker.Helpers;
using iNKORE.UI.WPF.Modern;
using iNKORE.UI.WPF.Modern.Controls;
using Page = System.Windows.Controls.Page;
using ZongziTEK_Blackboard_Sticker.Pages;
using System.Collections;

namespace ZongziTEK_Blackboard_Sticker
{
Expand All @@ -39,21 +42,24 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();

//小黑板 1
drawingAttributes = new DrawingAttributes();
inkCanvas.DefaultDrawingAttributes = drawingAttributes;
drawingAttributes.Color = Colors.White;
drawingAttributes.Width = 1.75;
drawingAttributes.Height = 1.75;
drawingAttributes.StylusTip = StylusTip.Ellipse;
drawingAttributes.FitToCurve = true;
//drawingAttributes.IgnorePressure = true;
squarePicker.SelectedColor = inkCanvas.DefaultDrawingAttributes.Color;

//窗体
Height = System.Windows.SystemParameters.WorkArea.Height;
Width = System.Windows.SystemParameters.WorkArea.Width;
Top = 0;
Left = 0;

textBlockTime.Text = DateTime.Now.ToString(("HH:mm:ss"));
//加载文件
LoadSettings();
isSettingsLoaded = true;
LoadStrokes();
Expand All @@ -66,23 +72,32 @@ public MainWindow()
});
});

//看板
textBlockTime.Text = DateTime.Now.ToString(("HH:mm:ss"));
clockTimer = new DispatcherTimer();
clockTimer.Tick += new EventHandler(Clock);
clockTimer.Tick += Clock;
clockTimer.Interval = new TimeSpan(0, 0, 0, 0, 5);
clockTimer.Start();

FrameInfo.Navigate(new Uri("Pages/WeatherPage.xaml", UriKind.Relative));
frameInfoNavigationTimer = new DispatcherTimer();
frameInfoNavigationTimer.Tick += FrameInfoNavigationTimer_Tick;
frameInfoNavigationTimer.Interval = TimeSpan.FromSeconds(5);
frameInfoNavigationTimer.Start();

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

TimetableEditor.EditorButtonUseCurriculum_Click += EditorButtonSettingUseCurriculum;

squarePicker.SelectedColor = inkCanvas.DefaultDrawingAttributes.Color;

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

//小黑板 2
CheckIsBlackboardLocked();
}
#region Window
Expand Down Expand Up @@ -951,10 +966,14 @@ private void LoadTimetable()
{
textBlockCurriculum.Text = Timetable.ToCurriculums(Timetable.Temp);
}

lessonIndex = -1;
}
private int lessonIndex = -1;
private void CheckTimetable(object sender, EventArgs e)
{
timetableTimer.Stop();

List<Lesson> today = Timetable.Monday;
string day = DateTime.Today.DayOfWeek.ToString();
if (!ToggleSwitchTempTimetable.IsOn)
Expand Down Expand Up @@ -1016,6 +1035,8 @@ private void CheckTimetable(object sender, EventArgs e)
if (currentTime < lesson.EndTime) break;
}
}

timetableTimer.Start();
}

private void ShowClassBeginPreNotification(List<Lesson> today, int index)
Expand Down Expand Up @@ -1684,5 +1705,35 @@ private void ShowNotificationBNS(string title, string subtitle, int time, bool i
catch { }
}
#endregion

#region InfoBoard
private List<Uri> frameInfoPages = new List<Uri>
{
new Uri("Pages/WeatherPage.xaml", UriKind.Relative),
new Uri("Pages/CountdownPage.xaml", UriKind.Relative)
};
private int frameInfoPageIndex = 0;
private DispatcherTimer frameInfoNavigationTimer;
private void BorderSwitchFrameInfoPage_MouseDown(object sender, MouseButtonEventArgs e)
{
SwitchFrameInfoPage();
}

private void FrameInfoNavigationTimer_Tick(object sender, EventArgs e)
{
SwitchFrameInfoPage();
}

private void SwitchFrameInfoPage()
{
frameInfoNavigationTimer.Stop();

frameInfoPageIndex++;
if (frameInfoPageIndex >= frameInfoPages.Count) frameInfoPageIndex = 0;
FrameInfo.Navigate(frameInfoPages[frameInfoPageIndex]);

frameInfoNavigationTimer.Start();
}
#endregion
}
}
16 changes: 16 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/CountdownPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Page x:Class="ZongziTEK_Blackboard_Sticker.Pages.CountdownPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker.Pages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="CountdownPage">

<Grid Margin="16,8" HorizontalAlignment="Right">
<Viewbox>
<TextBlock Text="距离期末考试还有 100 天"/>
</Viewbox>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/CountdownPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZongziTEK_Blackboard_Sticker.Pages
{
/// <summary>
/// CountdownPage.xaml 的交互逻辑
/// </summary>
public partial class CountdownPage : Page
{
public CountdownPage()
{
InitializeComponent();
}
}
}
16 changes: 16 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/WeatherPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Page x:Class="ZongziTEK_Blackboard_Sticker.Pages.WeatherPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker.Pages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WeatherPage">

<Grid Margin="16,8" HorizontalAlignment="Right">
<Viewbox>
<TextBlock Text="🌤晴 12℃~20℃ 当前 15℃"/>
</Viewbox>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/WeatherPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZongziTEK_Blackboard_Sticker.Pages
{
/// <summary>
/// WeatherPage.xaml 的交互逻辑
/// </summary>
public partial class WeatherPage : Page
{
public WeatherPage()
{
InitializeComponent();
}
}
}
14 changes: 14 additions & 0 deletions ZongziTEK_Blackboard_Sticker/ZongziTEK_Blackboard_Sticker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Pages\CountdownPage.xaml.cs">
<DependentUpon>CountdownPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\WeatherPage.xaml.cs">
<DependentUpon>WeatherPage.xaml</DependentUpon>
</Compile>
<Compile Include="Resources\Controls\TimetableEditorItem.xaml.cs">
<DependentUpon>TimetableEditorItem.xaml</DependentUpon>
</Compile>
Expand All @@ -93,6 +99,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\CountdownPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\WeatherPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\Controls\TimetableEditorItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

0 comments on commit 66fcc8c

Please sign in to comment.