refactor: add dialogs
This commit is contained in:
44
HFUTCourseSimulation/Dialog/EditCourse.xaml
Normal file
44
HFUTCourseSimulation/Dialog/EditCourse.xaml
Normal file
@ -0,0 +1,44 @@
|
||||
<Window x:Class="HFUTCourseSimulation.Dialog.EditCourse"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:HFUTCourseSimulation.Dialog"
|
||||
xmlns:userdata="clr-namespace:HFUTCourseSimulation.Kernel.UserData"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance userdata:Course}"
|
||||
Title="编辑课程" Height="500" Width="600" WindowStyle="ToolWindow">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="所有数据均为即时保存(编辑即保存)" Grid.Row="0" Foreground="DarkGreen" Background="Cyan" Padding="10"/>
|
||||
|
||||
<TabControl Grid.Row="1">
|
||||
<TabItem Header="课程基本信息" Padding="5">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Vertical" Margin="10,0,10,0">
|
||||
<TextBlock Text="课程名称" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="uiCourseName" Text="{Binding name}" Width="200" HorizontalAlignment="Left" Margin="0,5,0,0"/>
|
||||
|
||||
<TextBlock Text="课程颜色" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<Rectangle x:Name="uiCourseColor" Height="20" Width="200" HorizontalAlignment="Left" Stroke="Black" StrokeThickness="1" Cursor="Hand" Margin="0,5,0,0">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding color}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
|
||||
<TextBlock Text="注释" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="uiCourseDescription" Text="{Binding description}" Height="100" Width="400" HorizontalAlignment="Left" AcceptsReturn="True" Margin="0,5,0,0"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="课程安排" Padding="5">
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
25
HFUTCourseSimulation/Dialog/EditCourse.xaml.cs
Normal file
25
HFUTCourseSimulation/Dialog/EditCourse.xaml.cs
Normal file
@ -0,0 +1,25 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace HFUTCourseSimulation.Dialog {
|
||||
/// <summary>
|
||||
/// Interaction logic for EditCourse.xaml
|
||||
/// </summary>
|
||||
public partial class EditCourse : Window {
|
||||
public EditCourse() {
|
||||
InitializeComponent();
|
||||
this.DataContext = Kernel.Context.Instance.currentCourse;
|
||||
}
|
||||
}
|
||||
}
|
38
HFUTCourseSimulation/Dialog/EditSchedule.xaml
Normal file
38
HFUTCourseSimulation/Dialog/EditSchedule.xaml
Normal file
@ -0,0 +1,38 @@
|
||||
<Window x:Class="HFUTCourseSimulation.Dialog.EditSchedule"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:HFUTCourseSimulation.Dialog"
|
||||
xmlns:userdata="clr-namespace:HFUTCourseSimulation.Kernel.UserData"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance userdata:Schedule}"
|
||||
Title="编辑课程安排" Height="450" Width="600" WindowStyle="ToolWindow">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="所有数据均为即时保存(编辑即保存)" Grid.Row="0" Foreground="DarkGreen" Background="Cyan" Padding="10"/>
|
||||
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel Orientation="Vertical" Margin="10,0,10,0">
|
||||
<TextBlock Text="周设置" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="输入格式:开始周-结束周 或 周号1,周号2,周号3" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="例如:3-11 或 1,3,5" Margin="0,5,0,0"/>
|
||||
<TextBox x:Name="uiScheduleWeek" Text="{Binding week}" Width="200" HorizontalAlignment="Left" Margin="0,5,0,0"/>
|
||||
|
||||
<TextBlock Text="课程星期" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="输入格式:开始星期-结束星期 或 星期号1,星期号2,星期号3 或 星期号" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="例如:3-7 或 1,3,5 或 6" Margin="0,5,0,0"/>
|
||||
<TextBox x:Name="uiScheduleDay" Text="{Binding day}" Width="200" HorizontalAlignment="Left" Margin="0,5,0,0"/>
|
||||
|
||||
<TextBlock Text="当日课程节次" FontWeight="Bold" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="输入格式:开始节次-结束节次 或 节次号1,节次号2,节次号3" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="例如:3-11 或 1,3,5" Margin="0,5,0,0"/>
|
||||
<TextBox x:Name="uiScheduleIndex" Text="{Binding index}" Width="200" HorizontalAlignment="Left" Margin="0,5,0,0"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
27
HFUTCourseSimulation/Dialog/EditSchedule.xaml.cs
Normal file
27
HFUTCourseSimulation/Dialog/EditSchedule.xaml.cs
Normal file
@ -0,0 +1,27 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace HFUTCourseSimulation.Dialog {
|
||||
/// <summary>
|
||||
/// Interaction logic for EditSchedule.xaml
|
||||
/// </summary>
|
||||
public partial class EditSchedule : Window {
|
||||
public EditSchedule() {
|
||||
InitializeComponent();
|
||||
this.DataContext = Kernel.Context.Instance.currentSchedule;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -75,6 +75,12 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Course.cs" />
|
||||
<Compile Include="Dialog\EditCourse.xaml.cs">
|
||||
<DependentUpon>EditCourse.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Dialog\EditSchedule.xaml.cs">
|
||||
<DependentUpon>EditSchedule.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="General.cs" />
|
||||
<Compile Include="ImageExport.cs" />
|
||||
<Compile Include="Kernel\Context.cs" />
|
||||
@ -86,6 +92,14 @@
|
||||
</Compile>
|
||||
<Compile Include="SimulationCore.cs" />
|
||||
<Compile Include="SimulationItem.cs" />
|
||||
<Page Include="Dialog\EditCourse.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Dialog\EditSchedule.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@ -129,5 +143,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Widget\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -7,18 +7,16 @@ using System.Threading.Tasks;
|
||||
namespace HFUTCourseSimulation.Kernel {
|
||||
|
||||
public class Context {
|
||||
private static Context s_Instance = new Context();
|
||||
public static Context GetSingleton() { return s_Instance; }
|
||||
|
||||
public static readonly Context Instance = new Context();
|
||||
private Context() {
|
||||
currentSemester = null;
|
||||
currentCourse = null;
|
||||
currentSchedule = null;
|
||||
}
|
||||
|
||||
private UserData.Semester currentSemester;
|
||||
private UserData.Course currentCourse;
|
||||
private UserData.Schedule currentSchedule;
|
||||
public UserData.Semester currentSemester;
|
||||
public UserData.Course currentCourse;
|
||||
public UserData.Schedule currentSchedule;
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,36 +5,55 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:HFUTCourseSimulation"
|
||||
mc:Ignorable="d"
|
||||
Title="HFUT课表模拟" Height="450" Width="800">
|
||||
Title="HFUT课表模拟" Height="600" Width="800">
|
||||
<Grid>
|
||||
|
||||
<Menu IsMainMenu="True">
|
||||
<MenuItem Header="文件">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Menu IsMainMenu="True" Grid.Row="0">
|
||||
<MenuItem Header="文件" Padding="5">
|
||||
<MenuItem x:Name="uiMenuNew" Header="新建" Click="uiMenuNew_Click" />
|
||||
<MenuItem x:Name="uiMenuOpen" Header="打开" Click="uiMenuOpen_Click" />
|
||||
<MenuItem x:Name="uiMenuSave" Header="保存" Click="uiMenuSave_Click"/>
|
||||
<MenuItem x:Name="uiMenuSaveAs" Header="另存为" Click="uiMenuSave_Click"/>
|
||||
<MenuItem x:Name="uiMenuClose" Header="关闭" Click="uiMenuClose_Click"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="输出">
|
||||
<MenuItem x:Name="uiMenuSimulation" Header="实时模拟" Click="uiMenuSimulation_Click"/>
|
||||
<MenuItem x:Name="uiMenuExport" Header="导出为图片" Click="uiMenuExport_Click"/>
|
||||
<MenuItem Header="输出" Padding="5">
|
||||
<MenuItem x:Name="uiMenuSimulator" Header="实时模拟" Click="uiMenuSimulator_Click"/>
|
||||
<MenuItem x:Name="uiMenuRender" Header="导出为图片" Click="uiMenuRender_Click"/>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="uiMenuAbout" Header="关于" Click="uiMenuAbout_Click"/>
|
||||
<MenuItem Header="关于" Padding="5">
|
||||
<MenuItem x:Name="uiMenuAbout" Header="关于" Click="uiMenuAbout_Click"/>
|
||||
</MenuItem>
|
||||
|
||||
</Menu>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="打开或新建一个课表文件" FontSize="20" Opacity="0.5"/>
|
||||
<TextBlock Text="打开或新建一个课表文件" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Opacity="0.5"/>
|
||||
|
||||
<TabControl x:Name="uiMainTab" Margin="0,20,0,0">
|
||||
<TabItem Header="通用设置">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="起始周日期(教学第一周星期一的日期)" Margin="10,10,10,5"/>
|
||||
<DatePicker x:Name="uiDate" Height="25" Width="200" HorizontalAlignment="Left" Margin="10,0,10,10" SelectedDateChanged="uiDate_SelectedDateChanged"/>
|
||||
|
||||
<TextBlock Text="本学年周数" Margin="10,10,10,5"/>
|
||||
<TextBox x:Name="uiWeekCount" Width="200" HorizontalAlignment="Left" Margin="10,0,10,10" TextChanged="uiWeekCount_TextChanged"/>
|
||||
</StackPanel>
|
||||
<TabControl x:Name="uiMainTab" Grid.Row="1">
|
||||
<TabItem Header="学期设置" Padding="5">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Vertical" Margin="10,0,10,0">
|
||||
<TextBlock Text="起始日期(教学第一周星期一的日期)" Margin="0,20,0,0"/>
|
||||
<DatePicker x:Name="uiStartDate" Height="25" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left" SelectedDateChanged="uiStartDate_SelectedDateChanged"/>
|
||||
|
||||
<TextBlock Text="本学期教学周数" Margin="0,20,0,0"/>
|
||||
<TextBox x:Name="uiWeekCount" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left" TextChanged="uiWeekCount_TextChanged"/>
|
||||
|
||||
<TextBlock Text="每天节次数" Margin="0,20,0,0"/>
|
||||
<TextBox x:Name="uiIndexCount" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="早餐在哪个节次后" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="uiBreakfastAt" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="午餐在哪个节次后" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="uiLunchAt" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="晚餐在哪个节次后" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="uiDinnerAt" Width="200" Margin="0,5,0,0" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="课程设置">
|
||||
<TabItem Header="课程设置" Padding="5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
|
@ -34,8 +34,8 @@ namespace HFUTCourseSimulation {
|
||||
uiMenuOpen.IsEnabled = true;
|
||||
uiMenuSave.IsEnabled = false;
|
||||
uiMenuClose.IsEnabled = false;
|
||||
uiMenuSimulation.IsEnabled = false;
|
||||
uiMenuExport.IsEnabled = false;
|
||||
uiMenuSimulator.IsEnabled = false;
|
||||
uiMenuRender.IsEnabled = false;
|
||||
|
||||
uiMainTab.Visibility = Visibility.Collapsed;
|
||||
/*
|
||||
@ -54,7 +54,7 @@ namespace HFUTCourseSimulation {
|
||||
uiCourseName.IsEnabled = false;
|
||||
uiCourseDescription.IsEnabled = false;
|
||||
|
||||
uiDate.IsEnabled = false;
|
||||
uiStartDate.IsEnabled = false;
|
||||
uiWeekCount.IsEnabled = false;
|
||||
|
||||
uiCoursesList.IsEnabled = false;
|
||||
@ -66,8 +66,8 @@ namespace HFUTCourseSimulation {
|
||||
uiMenuOpen.IsEnabled = false;
|
||||
uiMenuSave.IsEnabled = true;
|
||||
uiMenuClose.IsEnabled = true;
|
||||
uiMenuSimulation.IsEnabled = true;
|
||||
uiMenuExport.IsEnabled = true;
|
||||
uiMenuSimulator.IsEnabled = true;
|
||||
uiMenuRender.IsEnabled = true;
|
||||
|
||||
uiMainTab.Visibility = Visibility.Visible;
|
||||
/*
|
||||
@ -86,7 +86,7 @@ namespace HFUTCourseSimulation {
|
||||
uiCourseName.IsEnabled = true;
|
||||
uiCourseDescription.IsEnabled = true;
|
||||
|
||||
uiDate.IsEnabled = true;
|
||||
uiStartDate.IsEnabled = true;
|
||||
uiWeekCount.IsEnabled = true;
|
||||
|
||||
uiCoursesList.IsEnabled = true;
|
||||
@ -152,12 +152,12 @@ namespace HFUTCourseSimulation {
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void uiMenuSimulation_Click(object sender, RoutedEventArgs e) {
|
||||
private void uiMenuSimulator_Click(object sender, RoutedEventArgs e) {
|
||||
var win = new Simulation();
|
||||
win.ShowDialog();
|
||||
}
|
||||
|
||||
private void uiMenuExport_Click(object sender, RoutedEventArgs e) {
|
||||
private void uiMenuRender_Click(object sender, RoutedEventArgs e) {
|
||||
//convert data
|
||||
int weekCount;
|
||||
DateTime originDate;
|
||||
@ -190,7 +190,7 @@ namespace HFUTCourseSimulation {
|
||||
|
||||
void SyncMainData() {
|
||||
isUpdatingData = true;
|
||||
this.uiDate.SelectedDate = DateTime.Parse(General.GeneralSheet.StartDate);
|
||||
this.uiStartDate.SelectedDate = DateTime.Parse(General.GeneralSheet.StartDate);
|
||||
this.uiWeekCount.Text = General.GeneralSheet.WeekCount.ToString();
|
||||
|
||||
SyncCourseListData();
|
||||
@ -379,9 +379,9 @@ namespace HFUTCourseSimulation {
|
||||
}
|
||||
|
||||
//main
|
||||
private void uiDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e) {
|
||||
private void uiStartDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e) {
|
||||
if (isUpdatingData) return;
|
||||
General.GeneralSheet.StartDate = this.uiDate.SelectedDate.ToString();
|
||||
General.GeneralSheet.StartDate = this.uiStartDate.SelectedDate.ToString();
|
||||
}
|
||||
|
||||
private void uiWeekCount_TextChanged(object sender, TextChangedEventArgs e) {
|
||||
|
Reference in New Issue
Block a user