Skip to content

Commit

Permalink
新增置底开关,优化编辑器
Browse files Browse the repository at this point in the history
优化课程表编辑器:新增深色主题,为复制粘贴按钮增加动画,优化粘贴体验

优化启动台编辑器:新增深色主题
  • Loading branch information
STBBRD committed Apr 20, 2024
1 parent 999c8d6 commit d35871e
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 73 deletions.
1 change: 1 addition & 0 deletions ZongziTEK_Blackboard_Sticker/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class InfoBoard
public class Automation
{
public bool IsAutoHideHugoAssistantEnabled { get; set; } = false;
public bool IsBottomMost { get; set; } = true;
}

public class Update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</Style>
</UserControl.Resources>
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="48"
Background="#FFFBFBFB"
CornerRadius="2" BorderBrush="#FFE1E6EA" BorderThickness="1">
Background="{DynamicResource CardBorderBackgroundColor}"
CornerRadius="2" BorderBrush="{DynamicResource CardBorderBrush}" BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
Expand Down
12 changes: 6 additions & 6 deletions ZongziTEK_Blackboard_Sticker/LauncherEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker"
mc:Ignorable="d"
Title="ZongziTEK 黑板贴 - 启动台编辑器" Height="450" Width="800" MinHeight="450" MinWidth="800"
ui:WindowHelper.SystemBackdropType="Mica" ui:WindowHelper.UseModernWindowStyle="True" ui:WindowHelper.FixMaximizedWindow="False" ui:ThemeManager.RequestedTheme="Light"
ui:WindowHelper.SystemBackdropType="Mica" ui:WindowHelper.UseModernWindowStyle="True" ui:WindowHelper.FixMaximizedWindow="False"
WindowStartupLocation="CenterScreen">
<Grid>
<TextBlock Text="编辑启动台" Margin="24,12,24,12" FontSize="32"/>
<ui:ProgressRing Name="ListProgressBar" IsIndeterminate="True" Margin="48" Visibility="Collapsed"/>
<ScrollViewer Name="ListScrollViewer" Margin="24,64,24,64" PanningMode="VerticalOnly">
<ui:ScrollViewerEx Name="ListScrollViewer" Margin="24,64,24,64" PanningMode="VerticalOnly">
<ui:SimpleStackPanel x:Name="ListStackPanel" Spacing="8"/>
</ScrollViewer>
</ui:ScrollViewerEx>
<ui:SimpleStackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="24,12,24,12" Height="32" Spacing="8" Orientation="Horizontal" >
<Button Content="刷新" Width="80" Click="ButtonRefresh_Click" VerticalAlignment="Stretch"/>
<Button Content="新建" Width="80" Click="ButtonNew_Click" VerticalAlignment="Stretch"/>
</ui:SimpleStackPanel>

<Border Name="BorderNew" Background="#ffF1F3F9" Visibility="Collapsed">
<Border Name="BorderNew" Background="{DynamicResource CardBorderBackgroundColor}" Visibility="Collapsed">
<Grid>
<ui:SimpleStackPanel Margin="24,12,24,12" Spacing="8">
<TextBlock Text="新建项" FontSize="32"/>
<ui:InfoBar Title="实验性功能" Message="已知问题:某些文件无法添加,或添加后不在启动台中显示" IsOpen="True" IsClosable="False"/>
</ui:SimpleStackPanel>
<ScrollViewer Margin="24,128,24,64" PanningMode="VerticalOnly">
<ui:ScrollViewerEx Margin="24,128,24,64" PanningMode="VerticalOnly">
<ui:SimpleStackPanel Spacing="8">
<TextBlock Text="文件路径" FontSize="16"/>
<Grid Name="GridDataLocation">
Expand All @@ -41,7 +41,7 @@
<TextBlock Text="名称" FontSize="16"/>
<TextBox Name="TextBoxLinkName"/>
</ui:SimpleStackPanel>
</ScrollViewer>
</ui:ScrollViewerEx>
<ui:SimpleStackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="24,12,24,12" Spacing="8" Orientation="Horizontal" >
<Button Name="ButtonCancelNew" Content="取消" Width="80" Click="ButtonCancelNew_Click"/>
<Button Name="ButtonSaveNew" Content="保存" Style="{StaticResource AccentButtonStyle}" Width="80" Click="ButtonSaveNew_Click"/>
Expand Down
2 changes: 1 addition & 1 deletion ZongziTEK_Blackboard_Sticker/LauncherEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private async void LoadList()
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Stretch,
Height = 48,
Background = new SolidColorBrush(Color.FromArgb(255, 251, 251, 251))
//Background = new SolidColorBrush(Color.FromArgb(255, 251, 251, 251))
};

//按钮里面的布局
Expand Down
23 changes: 12 additions & 11 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ui:ProgressRing Name="ProgressBarLauncher" Grid.Row="0" VerticalAlignment="Bottom" IsIndeterminate="True" Margin="20" Visibility="Collapsed"/>
<ScrollViewer Name="ScrollViewerLauncher" PanningMode="VerticalOnly" Grid.Row="0" Margin="8" VerticalAlignment="Bottom" MaxHeight="216">
<ui:ScrollViewerEx Name="ScrollViewerLauncher" PanningMode="VerticalOnly" Grid.Row="0" Margin="8" VerticalAlignment="Bottom" MaxHeight="216">
<ui:SimpleStackPanel x:Name="StackPanelLauncher" Spacing="8" VerticalAlignment="Bottom">
<Button Name="buttonExplorer" HorizontalAlignment="Stretch" Height="36" Click="buttonExplorer_Click" HorizontalContentAlignment="Left" Background="#00000000" BorderThickness="0">
<ui:SimpleStackPanel Spacing="8" Margin="0" Orientation="Horizontal">
Expand All @@ -158,7 +158,7 @@
</ui:SimpleStackPanel>
</Button>
</ui:SimpleStackPanel>
</ScrollViewer>
</ui:ScrollViewerEx>

<Border Grid.Row="1" Height="40" Margin="8" CornerRadius="4" VerticalAlignment="Bottom" Background="{Binding Background, ElementName=btnHideSettingsPanel}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Grid>
Expand All @@ -184,15 +184,15 @@
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer Name="ScrollViewerShowCurriculum" PanningMode="VerticalOnly">
<ui:ScrollViewerEx Name="ScrollViewerShowCurriculum" PanningMode="VerticalOnly">
<Grid Margin="16">
<TextBlock Visibility="Collapsed" Name="textBlockCurriculum" TextWrapping="Wrap"
Text="语文&#10;数学&#10;英语&#10;物理&#10;化学&#10;生物&#10;历史&#10;政治&#10;地理&#10;活动&#10;体育"
FontSize="28" Foreground="{DynamicResource ForegroundColor}" TextAlignment="Center"/>
<ui:SimpleStackPanel Name="StackPanelShowTimetable"/>
</Grid>
</ScrollViewer>
<ScrollViewer x:Name="scrollViewerCurriculum" Visibility="Collapsed" PanningMode="VerticalOnly">
</ui:ScrollViewerEx>
<ui:ScrollViewerEx x:Name="ScrollViewerCurriculum" Visibility="Collapsed" PanningMode="VerticalOnly">
<ui:SimpleStackPanel Spacing="8" Margin="24">
<TextBlock Text="编辑课程表" FontSize="36" Foreground="{DynamicResource ForegroundColor}"/>
<TextBlock Text="在文本框内输入课程,可回车换行,建议一行一节课" TextWrapping="Wrap" FontSize="16" Foreground="{DynamicResource ForegroundColor}"/>
Expand Down Expand Up @@ -220,7 +220,7 @@
<TextBlock Text="临时" FontSize="24" Foreground="{DynamicResource ForegroundColor}"/>
<TextBox x:Name="textBoxTempCurriculums" AcceptsReturn="True" TextWrapping="Wrap" FontSize="16" Foreground="{DynamicResource ForegroundColor}"/>
</ui:SimpleStackPanel>
</ScrollViewer>
</ui:ScrollViewerEx>
<Border Grid.Row="1" Height="40" Margin="8" CornerRadius="4" VerticalAlignment="Bottom" Background="{Binding Background, ElementName=btnHideSettingsPanel}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Grid>
<Label Content="课程表" VerticalAlignment="Center" Margin="8,0" FontSize="20"/>
Expand Down Expand Up @@ -267,13 +267,13 @@
<!--其它-->
<Border x:Name="borderFirstOpening" CornerRadius="8" Grid.RowSpan="4" Grid.ColumnSpan="2" Background="{DynamicResource OtherPanelsBackgroundColor}" Visibility="Collapsed">
<Grid Margin="48">
<ScrollViewer PanningMode="VerticalOnly">
<ui:ScrollViewerEx PanningMode="VerticalOnly">
<ui:SimpleStackPanel Spacing="16">
<TextBlock FontSize="32" Text="初次使用,请查看以下常用设置项" Foreground="{DynamicResource ForegroundColor}"/>
<ui:ToggleSwitch Header="开机时运行" OnContent="" OffContent="" IsOn="{Binding IsOn, ElementName=ToggleSwitchRunAtStartup}"/>
<TextBox ui:ControlHelper.Header="天气城市" Text="{Binding Text, ElementName=TextBoxWeatherCity}"/>
</ui:SimpleStackPanel>
</ScrollViewer>
</ui:ScrollViewerEx>
<Grid VerticalAlignment="Bottom">
<Button x:Name="btnCloseFirstOpening" HorizontalAlignment="Right" Content="完成" Width="120" Click="btnCloseFirstOpening_Click" Foreground="{DynamicResource ForegroundColor}"/>
</Grid>
Expand All @@ -294,13 +294,14 @@
<Border Name="borderSettingsPanel" Grid.ColumnSpan="2" Background="{DynamicResource OtherPanelsBackgroundColor}" Visibility="Collapsed">
<Grid Margin="48">
<TextBlock Text="设置" Foreground="{DynamicResource ForegroundColor}" FontSize="32"/>
<ScrollViewer PanningMode="VerticalOnly" Margin="12,64,12,64">
<ui:ScrollViewerEx PanningMode="VerticalOnly" Margin="12,64,12,64">
<ui:SimpleStackPanel Spacing="16">
<GroupBox Header="行为" Foreground="{DynamicResource ForegroundColor}">
<ui:SimpleStackPanel Spacing="12">
<Button x:Name="btnRestart" Content="重新启动黑板贴" Width="240" Click="btnRestart_Click"
Foreground="{DynamicResource ForegroundColor}"/>
<ui:ToggleSwitch Name="ToggleSwitchRunAtStartup" Header="开机时运行" OnContent="" OffContent="" Toggled="ToggleSwitchRunAtStartup_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<ui:ToggleSwitch Name="ToggleSwitchRunAtStartup" Header="开机时运行" OnContent="启用" OffContent="禁用" Toggled="ToggleSwitchRunAtStartup_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
<ui:ToggleSwitch Name="ToggleSwitchBottomMost" Header="将黑板贴置于底层" OnContent="启用" OffContent="禁用" Toggled="ToggleSwitchBottomMost_Toggled" Foreground="{DynamicResource ForegroundColor}"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="外观" Foreground="{DynamicResource ForegroundColor}">
Expand Down Expand Up @@ -426,7 +427,7 @@
</ui:SimpleStackPanel>
</GroupBox>
</ui:SimpleStackPanel>
</ScrollViewer>
</ui:ScrollViewerEx>
<Grid VerticalAlignment="Bottom">
<Button x:Name="btnHideSettingsPanel" Click="btnHideSettingsPanel_Click" HorizontalAlignment="Right" Content="关闭" Width="120" Foreground="{DynamicResource ForegroundColor}"/>
</Grid>
Expand Down
102 changes: 62 additions & 40 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public MainWindow()
private void window_StateChanged(object sender, EventArgs e)
{
WindowState = WindowState.Normal;
WindowsHelper.SetBottom(window);

if (Settings.Automation.IsBottomMost) WindowsHelper.SetBottom(window);
}

private void window_Loaded(object sender, RoutedEventArgs e)
Expand All @@ -119,7 +120,7 @@ private void window_Loaded(object sender, RoutedEventArgs e)

private void window_Activated(object sender, EventArgs e)
{
WindowsHelper.SetBottom(window);
if (Settings.Automation.IsBottomMost) WindowsHelper.SetBottom(window);
}

public static bool CloseIsFromButton = false;
Expand Down Expand Up @@ -1033,7 +1034,7 @@ private void editCurriculumButton_Click(object sender, RoutedEventArgs e)
editCurriculumButton.Visibility = Visibility.Collapsed;

saveCurriculumButton.Visibility = Visibility.Visible;
scrollViewerCurriculum.Visibility = Visibility.Visible;
ScrollViewerCurriculum.Visibility = Visibility.Visible;
}
}

Expand All @@ -1045,7 +1046,7 @@ private void saveCurriculumButton_Click(object sender, RoutedEventArgs e)
editCurriculumButton.Visibility = Visibility.Visible;

saveCurriculumButton.Visibility = Visibility.Collapsed;
scrollViewerCurriculum.Visibility = Visibility.Collapsed;
ScrollViewerCurriculum.Visibility = Visibility.Collapsed;

LoadTimetableorCurriculum();
}
Expand Down Expand Up @@ -1123,7 +1124,7 @@ private void LoadTimetable()
Foreground = (SolidColorBrush)FindResource("ForegroundColor"),
Text = lesson.Subject
};
if(lesson.IsSplitBelow)
if (lesson.IsSplitBelow)
{
textBlock.Margin = new Thickness(0, 0, 0, 8);
}
Expand Down Expand Up @@ -1402,8 +1403,39 @@ private void buttonExplorer_Click(object sender, RoutedEventArgs e)
{
Process.Start(@"C:\Windows\System32\explorer.exe", "/s,");
}
catch (Exception)
{ }
catch (Exception) { }
}
private void ButtonReloadLauncher_Click(object sender, RoutedEventArgs e)
{
ScrollViewerLauncher.Visibility = Visibility.Collapsed;
ProgressBarLauncher.Visibility = Visibility.Visible;

Button buttonExplorerBackup = buttonExplorer;

StackPanelLauncher.Children.Clear();

Task.Run(() =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
StackPanelLauncher.Children.Add(buttonExplorerBackup);
}));
});

Task.Run(() =>
{
Dispatcher.BeginInvoke(() =>
{
LoadLauncher();
});
});
btnHideSettingsPanel_Click(null, null);
}

private void ButtonEditLauncher_Click(object sender, RoutedEventArgs e)
{
new LauncherEditor().ShowDialog();
ButtonReloadLauncher_Click(null, null);
}

#endregion
Expand Down Expand Up @@ -1440,38 +1472,6 @@ private void btnRestart_Click(object sender, RoutedEventArgs e)
CloseIsFromButton = true;
System.Windows.Application.Current.Shutdown();
}
private void ButtonReloadLauncher_Click(object sender, RoutedEventArgs e)
{
ScrollViewerLauncher.Visibility = Visibility.Collapsed;
ProgressBarLauncher.Visibility = Visibility.Visible;

Button buttonExplorerBackup = buttonExplorer;

StackPanelLauncher.Children.Clear();

Task.Run(() =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
StackPanelLauncher.Children.Add(buttonExplorerBackup);
}));
});

Task.Run(() =>
{
Dispatcher.BeginInvoke(() =>
{
LoadLauncher();
});
});
btnHideSettingsPanel_Click(null, null);
}

private void ButtonEditLauncher_Click(object sender, RoutedEventArgs e)
{
new LauncherEditor().ShowDialog();
ButtonReloadLauncher_Click(null, null);
}

private void ToggleSwitchRunAtStartup_Toggled(object sender, RoutedEventArgs e)
{
Expand All @@ -1486,6 +1486,26 @@ private void ToggleSwitchRunAtStartup_Toggled(object sender, RoutedEventArgs e)
}
}

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

Settings.Automation.IsBottomMost = ToggleSwitchBottomMost.IsOn;
SaveSettings();

if (!ToggleSwitchBottomMost.IsOn)
{
if (MessageBox.Show("需要重新启动黑板贴来使此设置生效\n确定要重新启动黑板贴吗", "ZongziTEK 黑板贴", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
btnRestart_Click(null, null);
}
else
{
ToggleSwitchBottomMost.IsOn = true;
}
}
}

private void SliderWindowScale_MouseUp(object sender, MouseButtonEventArgs e)
{
SetWindowScaleTransform(SliderWindowScale.Value);
Expand Down Expand Up @@ -1828,6 +1848,8 @@ private void LoadSettings()
SetTheme("Dark");
}

ToggleSwitchBottomMost.IsOn = Settings.Automation.IsBottomMost;

SliderWindowScale.Value = Settings.Look.WindowScaleMultiplier;
SetWindowScaleTransform(SliderWindowScale.Value);

Expand Down Expand Up @@ -2206,7 +2228,7 @@ public static string GetBNSPath()

private void SwitchLookMode()
{
switch(Settings.Look.LookMode)
switch (Settings.Look.LookMode)
{
case 0: // 默认
BorderMain.ClearValue(WidthProperty);
Expand Down
2 changes: 2 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Style/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<SolidColorBrush x:Key="OtherPanelsBackgroundColor" Color="#FF222222"/>
<SolidColorBrush x:Key="ForegroundColor" Color="White"/>
<SolidColorBrush x:Key="BorderBrush" Color="#12FFFFFF"/>
<SolidColorBrush x:Key="CardBorderBackgroundColor" Color="#262b3c"/>
<SolidColorBrush x:Key="CardBorderBrush" Color="#2b2b2b"/>
</ResourceDictionary>
2 changes: 2 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Style/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<SolidColorBrush x:Key="OtherPanelsBackgroundColor" Color="#FFDDDDDD"/>
<SolidColorBrush x:Key="ForegroundColor" Color="Black"/>
<SolidColorBrush x:Key="BorderBrush" Color="#0F000000"/>
<SolidColorBrush x:Key="CardBorderBackgroundColor" Color="#FBFBFB"/>
<SolidColorBrush x:Key="CardBorderBrush" Color="#E1E6EA"/>
</ResourceDictionary>
Loading

0 comments on commit d35871e

Please sign in to comment.