UI Update

This commit is contained in:
wangxiner55 2024-09-25 19:00:49 +08:00
parent a5d33f9f99
commit ab4d872f3e
17 changed files with 1004 additions and 299 deletions

View File

@ -34,8 +34,8 @@ namespace StudentManager.Common
public class DetailErrorSetInfo public class DetailErrorSetInfo
{ {
public int TotalCount { get; set; } = 0; public int TotalQuestionsCount { get; set; } = 0;
public int TotalErrorCount { get; set; } = 0; public int TotalErrorSetQuestionsCount { get; set; } = 0;
public int CorrectCount { get; set; } = 0; public int CorrectCount { get; set; } = 0;
public int ErrorCount { get; set; } = 0; public int ErrorCount { get; set; } = 0;
public float ErrorRate { get; set; } = 0; public float ErrorRate { get; set; } = 0;
@ -44,14 +44,15 @@ namespace StudentManager.Common
public class ErrorSet public class ErrorSet
{ {
public int TotalCount { get; set; } = 0; public int TotalCount { get { return Errores.Count; } }
public int CorrectCount { get; set; } = 0; public int CorrectCount { get { return CorrectArray.Count; } }
public int ErrorCount { get { return ErrorArray.Count; } }
public Dictionary<int, ErrorBase> Errores { get; set; } = new Dictionary<int, ErrorBase>(); public Dictionary<int, ErrorBase> Errores { get; set; } = new Dictionary<int, ErrorBase>();
public List<int> ErrorArray { get; set; } = new List<int>(); public List<int> ErrorArray { get; set; } = new List<int>();
public List<int> CorrectArray { get; set; } = new List<int>(); public List<int> CorrectArray { get; set; } = new List<int>();
public int CorrectThresholds { get; set; } = 2; public int CorrectThresholds { get; set; } = 2;
public void InitErrorSetData() public void UpdateErrorSetData()
{ {
foreach (var item in Errores) foreach (var item in Errores)
{ {
@ -64,11 +65,11 @@ namespace StudentManager.Common
{ {
return new DetailErrorSetInfo return new DetailErrorSetInfo
{ {
TotalCount = QuestionLib.GetQuestionCount(), TotalQuestionsCount = QuestionLib.TotalCount,
TotalErrorCount = Errores.Count(), TotalErrorSetQuestionsCount = Errores.Count(),
CorrectCount = CorrectArray.Count(), CorrectCount = CorrectArray.Count(),
ErrorCount = ErrorArray.Count(), ErrorCount = ErrorArray.Count(),
ErrorRate = QuestionLib.GetQuestionCount() == 0 ? 100 : ErrorArray.Count() / QuestionLib.GetQuestionCount(), ErrorRate = QuestionLib.TotalCount == 0 ? 100 : ErrorArray.Count() / QuestionLib.TotalCount,
CorrectRate = Errores.Count() == 0 ? 100 : CorrectArray.Count() / Errores.Count() CorrectRate = Errores.Count() == 0 ? 100 : CorrectArray.Count() / Errores.Count()
}; };
} }
@ -108,13 +109,6 @@ namespace StudentManager.Common
} }
} }
public void AddErrorQuestion(int id)
{
}
public void AddCorrectQuestion(int id)
{
}
public void AddErrorQuestion(QuestionBase question) public void AddErrorQuestion(QuestionBase question)
{ {
@ -127,24 +121,19 @@ namespace StudentManager.Common
} }
else else
{ {
TotalCount++;
Errores.Add(question.ID, new ErrorBase { QuestionBase = { ID = question.ID } }); Errores.Add(question.ID, new ErrorBase { QuestionBase = { ID = question.ID } });
ErrorArray.Add(question.ID); ErrorArray.Add(question.ID);
} }
} }
public void AddErrorQuestion(QuestionData question)
{
}
public void AddCorrectQuestion(QuestionBase id) public void AddCorrectQuestion(QuestionBase id)
{ {
if (Errores.ContainsKey(id.ID)) if (Errores.ContainsKey(id.ID))
{ {
CorrectCount++;
Errores[id.ID].QuestionBase.Status = true;
Errores[id.ID].CorrectCount++; Errores[id.ID].CorrectCount++;
Errores[id.ID].TotalUseCount++;
CompareToCorrectArray(Errores[id.ID]); CompareToCorrectArray(Errores[id.ID]);
} }

View File

@ -17,7 +17,7 @@ namespace StudentManager.Common
public bool Status { get; set; } = false; public bool Status { get; set; } = false;
} }
public class DetailHomeWorkInfo public class DetailHomeWorkInfo : BindableBase
{ {
//public DetailQuestionBase QuestionData { get; set; } = new DetailQuestionBase(); //public DetailQuestionBase QuestionData { get; set; } = new DetailQuestionBase();
public QuestionData QuestionData { get; set; } = new QuestionData(); public QuestionData QuestionData { get; set; } = new QuestionData();
@ -44,6 +44,7 @@ namespace StudentManager.Common
public int ErrorCount { get; set; } = 0; public int ErrorCount { get; set; } = 0;
public int CorrectCount { get; set; } = 0; public int CorrectCount { get; set; } = 0;
public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList() public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList()
{ {
ObservableCollection<DetailHomeWorkInfo> list = new ObservableCollection<DetailHomeWorkInfo>(); ObservableCollection<DetailHomeWorkInfo> list = new ObservableCollection<DetailHomeWorkInfo>();
@ -68,7 +69,7 @@ namespace StudentManager.Common
return list; return list;
} }
private void FreshData() public void UpdateData()
{ {
CorrectCount = 0; CorrectCount = 0;
ErrorCount = 0; ErrorCount = 0;
@ -85,19 +86,19 @@ namespace StudentManager.Common
public void AddHomeWork(QuestionBase workInfo) public void AddHomeWork(QuestionBase workInfo)
{ {
Questions.Add(workInfo); Questions.Add(workInfo);
FreshData(); UpdateData();
} }
public void AddHomeWork(int id) public void AddHomeWork(int id)
{ {
Questions.Add(new QuestionBase { ID = id }); Questions.Add(new QuestionBase { ID = id });
FreshData(); UpdateData();
} }
public void RemoveHomeWork(QuestionBase workInfo) public void RemoveHomeWork(QuestionBase workInfo)
{ {
Questions.Remove(workInfo); Questions.Remove(workInfo);
FreshData(); UpdateData();
} }
public void Append(HomeWork homeWork) public void Append(HomeWork homeWork)
@ -106,7 +107,7 @@ namespace StudentManager.Common
{ {
Questions.Add(item); Questions.Add(item);
} }
UpdateData();
} }
} }
@ -114,14 +115,14 @@ namespace StudentManager.Common
public class DetailHomeWorkSetInfo public class DetailHomeWorkSetInfo
{ {
public int TotalCount { get; set; } = 0;
public bool Status { get; set; } = false;
public DateTime DateTime { get; set; } = DateTime.Now;
public uint Lesson { get; set; } = 0; public uint Lesson { get; set; } = 0;
public int TotalCount { get; set; } = 0;
public int ErrorCount { get; set; } = 0; public int ErrorCount { get; set; } = 0;
public int CorrectCount { get; set; } = 0; public int CorrectCount { get; set; } = 0;
public bool Status { get; set; } = false;
public DateTime DateTime { get; set; } = DateTime.Now;
} }
@ -129,13 +130,31 @@ namespace StudentManager.Common
{ {
[JsonInclude] [JsonInclude]
private Dictionary<uint, HomeWork> HomeWorks { get; set; } = new Dictionary<uint, HomeWork>(); private Dictionary<uint, HomeWork> HomeWorks { get; set; } = new Dictionary<uint, HomeWork>();
public int TotalCount { get; set; } = 0; public int TotalSetCount { get; set; } = 0;
public int TotalQuestionCount { get; set; } = 0;
public int TotalErrorQuestionCount { get; set; } = 0;
public int TotalCorrectQuestionCount { get; set; } = 0;
public int TotalErrorQuestionRate { get; set; } = 0;
public void UpdateDate()
{
TotalSetCount = HomeWorks.Count;
TotalQuestionCount = 0;
foreach (var item in HomeWorks)
{
TotalQuestionCount = item.Value.TotalCount;
TotalErrorQuestionCount = item.Value.ErrorCount;
TotalCorrectQuestionCount = item.Value.CorrectCount;
}
TotalErrorQuestionRate = TotalErrorQuestionCount / TotalQuestionCount;
}
public void AddHomeWork(HomeWork homeWork) public void AddHomeWork(HomeWork homeWork)
{ {
HomeWorks.Add(homeWork.Lesson, homeWork); HomeWorks.Add(homeWork.Lesson, homeWork);
TotalCount = HomeWorks.Count; UpdateDate();
} }
public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList(uint lesson) public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList(uint lesson)
@ -186,6 +205,7 @@ namespace StudentManager.Common
public void RemoveHomeWork(HomeWork homeWork) public void RemoveHomeWork(HomeWork homeWork)
{ {
HomeWorks.Remove(homeWork.Lesson); HomeWorks.Remove(homeWork.Lesson);
UpdateDate();
} }
public HomeWork Get(uint cursonId) public HomeWork Get(uint cursonId)
@ -196,7 +216,7 @@ namespace StudentManager.Common
public HomeWork GetLast() public HomeWork GetLast()
{ {
return HomeWorks[(uint)TotalCount]; return HomeWorks[(uint)TotalSetCount];
} }
public List<HomeWork> GetAll() public List<HomeWork> GetAll()
@ -234,6 +254,8 @@ namespace StudentManager.Common
Status = x.Status == 1 Status = x.Status == 1
}); });
}); });
UpdateDate();
} }
} }

View File

@ -386,5 +386,54 @@ namespace StudentManager.Common
} }
} }
} }
internal static void UpdateQuestion(QuestionData ques)
{
using (MySqlConnection connection = new MySqlConnection(config))
{
try
{
connection.Open();
string query = @"UPDATE questions SET
problem_type = @Type,
problem_stem = @Stem,
problem_answer = @Answer,
difficulty_level = @DifficultyLevel,
category = @Category,
tags = @Tags,
source = @Source,
lesson = @Lesson,
status = @Status,
update_time = @UpdateTime
WHERE problem_id = @Id";
using (MySqlCommand command = new MySqlCommand(query, connection))
{
command.Parameters.AddWithValue("@Id", ques.Id);
command.Parameters.AddWithValue("@Type", ques.Type.ToString());
command.Parameters.AddWithValue("@Stem", ques.Stem);
command.Parameters.AddWithValue("@Answer", ques.Answer);
command.Parameters.AddWithValue("@DifficultyLevel", ques.DifficultyLevel.ToString());
command.Parameters.AddWithValue("@Category", ques.Category);
command.Parameters.AddWithValue("@Tags", ques.Tags);
command.Parameters.AddWithValue("@Source", ques.Source);
command.Parameters.AddWithValue("@Lesson", ques.Lesson);
command.Parameters.AddWithValue("@Status", ques.Status.ToString());
command.Parameters.AddWithValue("@UpdateTime", ques.UpdateTime);
int rowsAffected = command.ExecuteNonQuery();
Console.WriteLine($"{rowsAffected} rows updated.");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
}
}
}
} }
} }

View File

@ -30,13 +30,8 @@ namespace StudentManager.Data
public static Dictionary<int, QuestionData> QuestionDic { get; set; } = new Dictionary<int, QuestionData>(); public static Dictionary<int, QuestionData> QuestionDic { get; set; } = new Dictionary<int, QuestionData>();
public static Dictionary<uint, QuestionSetDesc> QuestionTableDesc { get; set; } = new Dictionary<uint, QuestionSetDesc>(); public static Dictionary<uint, QuestionSetDesc> QuestionTableDesc { get; set; } = new Dictionary<uint, QuestionSetDesc>();
public static Dictionary<uint, Dictionary<int, QuestionData>> QuestionTableDic { get; set; } = new Dictionary<uint, Dictionary<int, QuestionData>>(); public static Dictionary<uint, Dictionary<int, QuestionData>> QuestionTableDic { get; set; } = new Dictionary<uint, Dictionary<int, QuestionData>>();
public static int TotalCount { get; set; } = 0; public static int TotalCount { get { return QuestionDic.Count; } }
public static int GetQuestionCount()
{
TotalCount = QuestionDic.Count;
return TotalCount;
}
public static void Load() public static void Load()
{ {
QuestionDic.Clear(); QuestionDic.Clear();
@ -157,5 +152,13 @@ namespace StudentManager.Data
{ {
QuestionDic.Remove(id); QuestionDic.Remove(id);
} }
internal static void Update(QuestionData selectedQuestion)
{
if(QuestionDic[selectedQuestion.Id] != null)
QuestionDic[selectedQuestion.Id] = selectedQuestion;
else
QuestionDic.Add(selectedQuestion.Id, selectedQuestion);
}
} }
} }

View File

@ -126,7 +126,7 @@ namespace StudentManager.Data
public void PublicHomeWork(uint lesson, bool appendCommonWork = false, bool appendErrorSet = false, int workNum = -1) public void PublicHomeWork(uint lesson, bool appendCommonWork = false, bool appendErrorSet = false, int workNum = -1)
{ {
HomeWork homeWork = new HomeWork(); HomeWork homeWork = new HomeWork();
homeWork.Lesson = (uint)(HomeWorkSet.TotalCount + 1) ; homeWork.Lesson = (uint)(HomeWorkSet.TotalSetCount + 1) ;
homeWork.DateTime = DateTime.Now; homeWork.DateTime = DateTime.Now;
if(appendErrorSet) if(appendErrorSet)
{ {

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StudentManager.Editor" xmlns:local="clr-namespace:StudentManager.Editor"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
@ -70,16 +71,14 @@
<Border.Effect> <Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/> <DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect> </Border.Effect>
<Border.Style> <i:Interaction.Triggers>
<Style TargetType="Border"> <i:EventTrigger EventName="MouseEnter">
<Style.Triggers> <i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
<Trigger Property="IsMouseOver" Value="True"> </i:EventTrigger>
<Setter Property="Background" Value="Black"/> <i:EventTrigger EventName="MouseLeave">
<Setter Property="BorderBrush" Value="Red"/> <i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
</Trigger> </i:EventTrigger>
</Style.Triggers> </i:Interaction.Triggers>
</Style>
</Border.Style>
<StackPanel> <StackPanel>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding Type}" <TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding Type}"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/> VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>

View File

@ -11,6 +11,55 @@
<Style x:Key="TextStyle" TargetType="TextBlock"> <Style x:Key="TextStyle" TargetType="TextBlock">
<Setter Property="Width" Value="200"/> <Setter Property="Width" Value="200"/>
</Style> </Style>
<Style x:Key="ModernMenuItemStyle" TargetType="MenuItem">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Margin" Value="20,10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MenuItem">
<Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" CornerRadius="5" Height="20" Width="50">
<Grid>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" ContentSource="Header"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkGray"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- 定义 ContextMenu 的样式 -->
<Style x:Key="ModernContextMenuStyle" TargetType="ContextMenu">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="#FF007ACC"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContextMenu">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<StackPanel>
<ItemsPresenter/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ContextMenu x:Key="MyModernContextMenu" Style="{StaticResource ModernContextMenuStyle}">
<MenuItem Header="查看详情" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Command="{Binding DataContext.RegionTo, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="DetailCheckView" Style="{StaticResource ModernMenuItemStyle}"/>
<MenuItem Header="删除" Command="{Binding Option2Command}" Style="{StaticResource ModernMenuItemStyle}"/>
</ContextMenu>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="Transparent"> <Grid Background="Transparent">
@ -20,10 +69,56 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border CornerRadius="20"/> <Border CornerRadius="20"/>
<ListBox ItemsSource="{Binding StudentDatas}" Margin="10" <ListBox ItemsSource="{Binding StudentDatas}" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
SelectedItem="{Binding SelectedStudent}"> SelectedItem="{Binding SelectedStudent}">
<ListBox.Resources>
<Style TargetType="ListBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<ScrollViewer Margin="0" Focusable="false">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="White"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="5">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FF007ACC"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFBEE6FD"/>
<Setter Property="BorderBrush" Value="#FF3C7FB1"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged"> <i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction <i:InvokeCommandAction
@ -31,98 +126,124 @@
Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/> Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger> </i:EventTrigger>
</i:Interaction.Triggers> </i:Interaction.Triggers>
<ListBox.Style>
<Style TargetType="ListBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="10" Background="#FFEEEEEE">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Style>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5"/> <TextBlock Text="{Binding Name}"/>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<Grid Grid.Column="1"> <Border Grid.Column="1">
<ListView ItemsSource="{Binding HomeWorkSet}" Foreground="Black" <ScrollViewer Grid.Column="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden" Margin="0">
Margin="10" <ItemsControl ItemsSource="{Binding HomeWorkSet}" HorizontalAlignment="Left">
ScrollViewer.VerticalScrollBarVisibility="Disabled" <ItemsControl.ItemsPanel>
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ItemsPanelTemplate>
<ListView.Style> <WrapPanel/>
<Style TargetType="ListView"> </ItemsPanelTemplate>
<Setter Property="Background" Value="LightGray"/> </ItemsControl.ItemsPanel>
<Setter Property="BorderBrush" Value="Black"/> <ItemsControl.ItemTemplate>
<Setter Property="BorderThickness" Value="1"/> <DataTemplate>
<Setter Property="Template"> <Border Background="#FFF9F9F9" BorderBrush="Gray" BorderThickness="0" CornerRadius="10" Margin="5" MouseRightButtonUp="Border_MouseRightButtonUp"
<Setter.Value> Padding="5" Height="240" Width="140" IsHitTestVisible="True">
<ControlTemplate TargetType="ListView"> <Border.Effect>
<Border Background="{TemplateBinding Background}" <DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
BorderBrush="{TemplateBinding BorderBrush}" </Border.Effect>
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.Style>
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick"> <i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction <i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
CommandParameter="DetailCheckView"
Command="{Binding DataContext.RegionTo ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger> </i:EventTrigger>
<i:EventTrigger EventName="SelectionChanged"> <i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction <i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
Command="{Binding DataContext.HomeWorkSetSelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger> </i:EventTrigger>
<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.HomeWorkSetSelectedCommand ,RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding }"/>
</i:EventTrigger>
</i:Interaction.Triggers> </i:Interaction.Triggers>
<ListView.View> <DockPanel LastChildFill="False">
<GridView> <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<GridViewColumn
DisplayMemberBinding="{Binding DateTime}"
Header="创建时间"/>
<GridViewColumn
DisplayMemberBinding="{Binding Lesson}"
Header="第几课" />
<GridViewColumn
DisplayMemberBinding="{Binding TotalCount}"
Header="总题数" />
<GridViewColumn
DisplayMemberBinding="{Binding ErrorCount}"
Header="总错误题数" />
<GridViewColumn
DisplayMemberBinding="{Binding CorrectCount}"
Header="总正确题数" />
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="删除" Command="{Binding DeleteSelectedHomeworkCommand}"
CommandParameter="{Binding}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="Lesson:"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding Lesson}"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
</StackPanel>
<Border DockPanel.Dock="Top" BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="总题数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding TotalCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="总错误数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding ErrorCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</Grid> </Grid>
<Border DockPanel.Dock="Top" BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="错误率" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding TotalCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="总正确数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding ErrorCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom">
<StackPanel.Resources>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="true">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="false">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<TextBlock TextWrapping="Wrap" FontSize="8" Margin="0,2" FontWeight="Bold"
Text="{Binding DateTime}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<Border Height="10" Width="10" Margin="10,0" CornerRadius="20"/>
</StackPanel>
</DockPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -30,5 +30,20 @@ namespace StudentManager.Editor
{ {
} }
private void Border_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
if (e.OriginalSource is FrameworkElement element)
{
var contextMenu = element.FindResource("MyModernContextMenu") as ContextMenu;
if (contextMenu != null)
{
contextMenu.PlacementTarget = element;
contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
contextMenu.Style = (Style)element.FindResource("ModernContextMenuStyle");
contextMenu.IsOpen = true;
}
}
}
} }
} }

View File

@ -15,7 +15,11 @@
<Grid> <Grid>
<DockPanel HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding HomeWorkSet}"> <ListBox ItemsSource="{Binding HomeWorkSet}">
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged"> <i:EventTrigger EventName="SelectionChanged">
@ -31,9 +35,10 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<DockPanel LastChildFill="False" HorizontalAlignment="Stretch"> <!--<DockPanel LastChildFill="False" HorizontalAlignment="Stretch">
<ListView DockPanel.Dock="Top" ItemsSource="{Binding HomeWork}"> -->
<!--<ListView DockPanel.Dock="Top" ItemsSource="{Binding HomeWork}">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn <GridViewColumn
@ -51,17 +56,78 @@
</GridViewColumn> </GridViewColumn>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>-->
<!--<DataGrid DockPanel.Dock="Top" ItemsSource="{Binding HomeWork}" CanUserAddRows="False" CanUserDeleteRows="False" > <!--<DataGrid DockPanel.Dock="Top" ItemsSource="{Binding HomeWork}" CanUserAddRows="False" CanUserDeleteRows="False" >
--><!--<DataGrid.Columns> -->
<!--<DataGrid.Columns>
<DataGridCheckBoxColumn Header="正确?" Binding="{Binding Status}" /> <DataGridCheckBoxColumn Header="正确?" Binding="{Binding Status}" />
</DataGrid.Columns>--><!-- </DataGrid.Columns>-->
<!--
</DataGrid>--> </DataGrid>-->
<!--
<Button DockPanel.Dock="Bottom" MinHeight=" 50" Content="提交" Command="{Binding SubmitHomeWorkCommand}"/> </DockPanel>-->
</DockPanel>
</DockPanel> <Grid Grid.Column="1" >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<ScrollViewer DockPanel.Dock="Top" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden" Margin="0">
<ItemsControl ItemsSource="{Binding HomeWork}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="0" CornerRadius="10" Margin="5"
Padding="5" Height="150" Width="120" IsHitTestVisible="True">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
</i:EventTrigger>
<!--<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding DataContext.HomeWorkSelectedCommand ,RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding }"/>
</i:EventTrigger>-->
</i:Interaction.Triggers>
<Grid>
<StackPanel>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding QuestionData.Type}"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Margin="5" Height="60"
Text="{Binding QuestionData.Stem}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</StackPanel>
<CheckBox IsChecked="{Binding Status}" Padding="200,0" HorizontalAlignment="Stretch" VerticalContentAlignment="Bottom" VerticalAlignment="Stretch"/>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<Button Grid.Row="1" MinHeight=" 50" Content="提交" Command="{Binding SubmitHomeWorkCommand}" Style="{DynamicResource MaterialDesignFlatDarkButton}"/>
</Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -9,11 +9,11 @@
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources> <UserControl.Resources>
<Style x:Key="TextStyle" TargetType="{x:Type TextBlock}"> <!--<Style x:Key="TextStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="10,5"/> <Setter Property="Margin" Value="10,5"/>
<Setter Property="Width" Value="50"/> <Setter Property="Width" Value="50"/>
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
</Style> </Style>-->
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
@ -23,8 +23,56 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding StudentDatas}" ScrollViewer.VerticalScrollBarVisibility="Disabled" <ListBox ItemsSource="{Binding StudentDatas}" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0"
SelectedItem="{Binding SelectedStudent}"> SelectedItem="{Binding SelectedStudent}">
<ListBox.Resources>
<Style TargetType="ListBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<ScrollViewer Margin="0" Focusable="false">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="White"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="5">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FF007ACC"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFBEE6FD"/>
<Setter Property="BorderBrush" Value="#FF3C7FB1"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged"> <i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction <i:InvokeCommandAction
@ -32,6 +80,7 @@
Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/> Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger> </i:EventTrigger>
</i:Interaction.Triggers> </i:Interaction.Triggers>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Name}"/> <TextBlock Text="{Binding Name}"/>
@ -39,82 +88,175 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<Grid Grid.Column="1"> <Grid Grid.Column="1" Margin="0" Background="Transparent">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition Height="0.3*"/>
<RowDefinition/> <RowDefinition Height="0.2*"/>
<RowDefinition/> <RowDefinition Height="0.5*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Background="Transparent" Margin="5" Grid.RowSpan="2" Grid.ColumnSpan="2" CornerRadius="10"/>
<Border Grid.Row="0" Background="#FF0069FE" CornerRadius="10" Margin="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Margin="30">
<TextBlock Text="{Binding SelectedStudent.Name}" FontWeight="Black" FontSize="22" Foreground="White"/>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextStyle}" Text="姓名"/> <TextBlock Text="性别:" Foreground="LightGoldenrodYellow" HorizontalAlignment="Left" FontSize="14" Margin="5" />
<TextBlock Style="{StaticResource TextStyle}" Text="正确数"/> <TextBlock Text="{Binding SelectedStudent.Gender}" Foreground="LightGoldenrodYellow" HorizontalAlignment="Left" FontSize="14" Margin="5" />
<TextBlock Style="{StaticResource TextStyle}" Text="第几课"/>
<TextBlock Style="{StaticResource TextStyle}" Text="状态"/>
</StackPanel>
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextStyle}" Text="总题数量"/>
<TextBlock Style="{StaticResource TextStyle}" Text="总错题数量"/>
<TextBlock Style="{StaticResource TextStyle}" Text="修正数量"/>
<TextBlock Style="{StaticResource TextStyle}" Text="错误数量"/>
<TextBlock Style="{StaticResource TextStyle}" Text="错误率"/>
<TextBlock Style="{StaticResource TextStyle}" Text="修正率"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.TotalCount}"/> <TextBlock Text="年级:" Foreground="LightGoldenrodYellow" HorizontalAlignment="Left" FontSize="14" Margin="5" />
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.TotalErrorCount}"/> <TextBlock Text="{Binding SelectedStudent.Grade}" Foreground="LightGoldenrodYellow" HorizontalAlignment="Left" FontSize="14" Margin="5" />
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.CorrectCount}"/>
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.ErrorCount}"/>
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.ErrorRate}"/>
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding ErrorSet.CorrectRate}"/>
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Grid.Row="2">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextStyle}" Text="第几课"/> <TextBlock Text="地址:" Foreground="LightGray" HorizontalAlignment="Left" FontSize="8" Margin="5,2" />
<TextBlock Style="{StaticResource TextStyle}" Text="总数"/> <TextBlock Text="{Binding SelectedStudent.Address}" Width="350" Foreground="LightGray" HorizontalAlignment="Left" FontSize="8" Margin="5,2" TextWrapping="Wrap"/>
<TextBlock Style="{StaticResource TextStyle}" Text="正确数"/>
<TextBlock Style="{StaticResource TextStyle}" Text="状态"/>
</StackPanel> </StackPanel>
<ListBox ItemsSource="{Binding HomeWorkSet}"> <StackPanel Orientation="Horizontal">
<i:Interaction.Triggers> <TextBlock Text="联系方式:" Foreground="LightGray" HorizontalAlignment="Left" FontSize="8" Margin="5,2" />
<i:EventTrigger EventName="MouseDoubleClick"> <TextBlock Text="{Binding SelectedStudent.Contact}" Foreground="LightGray" HorizontalAlignment="Left" FontSize="8" Margin="5,2" />
<i:InvokeCommandAction </StackPanel>
CommandParameter="DetailCheckView"
Command="{Binding DataContext.RegionTo ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
Command="{Binding DataContext.HomeWorkSetSelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemTemplate> </StackPanel>
<StackPanel Margin="30" Grid.Column="1">
<TextBlock Text="DETAIL" FontWeight="Black" FontSize="22" Foreground="White"/>
<TextBlock Text="{Binding SelectedStudent.Address}" Width="350" Foreground="LightGoldenrodYellow" HorizontalAlignment="Left" FontSize="14" Margin="5" TextWrapping="Wrap"/>
<TextBlock Text="{Binding SelectedStudent.Gender}" TextWrapping="Wrap" FontSize="8" Margin="5,20" Foreground="LightGray"/>
</StackPanel>
</Grid>
</Border>
<Grid Grid.Row="1">
<Border Background="#FF666666" Margin="5" Grid.RowSpan="2" Grid.ColumnSpan="2" CornerRadius="10"/>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="1" Background="Transparent">
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden" Margin="10">
<ItemsControl Grid.Row="1" ItemsSource="{Binding ErrorSetDatas}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <Border Background="#FFFEFEFE" BorderBrush="Gray" BorderThickness="0" CornerRadius="10"
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding Lesson}"/> Padding="5" Height="200" Width="120" Margin="5" IsHitTestVisible="True" MouseRightButtonDown="Border_MouseRightButtonDown">
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding TotalCount}"/> <i:Interaction.Triggers>
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding CorrectCount}"/> <i:EventTrigger EventName="MouseEnter">
<TextBlock Style="{StaticResource TextStyle}" Text="{Binding Status}"/> <i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<!--<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.ShowContextMenuCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"/>
</i:EventTrigger>-->
</i:Interaction.Triggers>
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<StackPanel>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding QuestionData.Stem}" Height="60"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="使用数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding TotalUseCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="错误数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding ErrorCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="状态" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding TotalUseCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="正确数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding ErrorCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ItemsControl.ItemTemplate>
</ListBox> </ItemsControl>
</StackPanel> </ScrollViewer>
</Border>
<Border Grid.Column="0" Background="Gray" Margin="10" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<DataGrid ItemsSource="{Binding HomeWorkSet}" ScrollViewer.HorizontalScrollBarVisibility="Auto" IsReadOnly="True">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridRow">
<Border CornerRadius="10" Margin="5" Background="White">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<DataGridCellsPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</Border>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -29,6 +29,11 @@ namespace StudentManager.Editor
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
}
private void Border_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
} }
} }
} }

View File

@ -45,8 +45,11 @@
Command="{Binding SaveAllCommand}"/> Command="{Binding SaveAllCommand}"/>
<Button Margin="5" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom" Content="刷新数据" Style="{DynamicResource MaterialDesignFlatDarkButton}" <Button Margin="5" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom" Content="刷新数据" Style="{DynamicResource MaterialDesignFlatDarkButton}"
Command="{Binding FreshAllCommand}"/> Command="{Binding FreshAllCommand}"/>
</DockPanel> </DockPanel>
<Border BorderBrush="Gray" BorderThickness="1,0,0,0" Margin="2,50" Grid.Column="1"/>
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="100"/> <RowDefinition Height="100"/>

View File

@ -15,34 +15,185 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="0.4*"/> <RowDefinition Height="0.0*"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0"> <Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.22*"/>
</Grid.ColumnDefinitions>
<Border Background="Gray" CornerRadius="10" Margin="10" Height="20" /> <ScrollViewer Grid.Column="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden" Margin="0">
<Border Background="Gray" CornerRadius="10" Margin="10"/> <ItemsControl ItemsSource="{Binding QuestionDatas}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="#FFF9F9F9" BorderBrush="Gray" BorderThickness="0" CornerRadius="10" Margin="5"
Padding="5" Height="150" Width="120" IsHitTestVisible="True">
<Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding DataContext.SelectedQuestionChangedCommand ,RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding }"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<StackPanel>
<TextBlock TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Text="{Binding Type}"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="题干" Foreground="Gray" Margin="5,5"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="12" Margin="5"
Text="{Binding Stem}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel> </StackPanel>
<DataGrid ItemsSource="{Binding QuestionDatas}" Background="#22aaaaaa" Grid.Row="1"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" CanUserDeleteRows="False" CanUserAddRows="False" </StackPanel>
IsReadOnly="True" Foreground="#FF222222"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridRow">
<Border CornerRadius="10" Margin="5" Background="White">
<DataGridCellsPresenter/>
</Border> </Border>
</ControlTemplate> </DataTemplate>
</Setter.Value> </ItemsControl.ItemTemplate>
</Setter> </ItemsControl>
</ScrollViewer>
<Border Background="#FFF5F5F5" Grid.Column="1" CornerRadius="10" Padding="10">
<Border.Effect>
<DropShadowEffect Color="#FFA5A5A5" BlurRadius="10" ShadowDepth="5" />
</Border.Effect>
<DockPanel LastChildFill="False">
<StackPanel DockPanel.Dock="Top">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Margin" Value="10"/>
<Setter Property="TextWrapping" Value="Wrap"/>
</Style> </Style>
</DataGrid.RowStyle> </StackPanel.Resources>
</DataGrid>
<TextBlock Text="DETAIL DIALOG" FontSize="20" FontWeight="Bold" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="{Binding SelectedQuestion.Type, Mode=TwoWay}" FontSize="22" FontWeight="Bold"/>
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0">
<TextBlock Text="课文" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Lesson, Mode=TwoWay}" DockPanel.Dock="Right"/>
</StackPanel>
</Grid>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="题干" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Stem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0">
<TextBlock Text="答案:" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Answer, Mode=TwoWay}" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Category:" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Category, Mode=TwoWay}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0">
<TextBlock Text="难度:" Foreground="Gray"/>
<TextBlock Text="{Binding SelectedQuestion.DifficultyLevel, Mode=TwoWay}" />
</StackPanel>
</Grid>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Tags:" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Tags, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0">
<TextBlock Text="Source:" Foreground="Gray"/>
<TextBox Text="{Binding SelectedQuestion.Source, Mode=TwoWay}" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Status:" Foreground="Gray"/>
<TextBlock Text="{Binding SelectedQuestion.Status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0">
<TextBlock Text="Update Time:" Foreground="Gray"/>
<TextBlock Text="{Binding SelectedQuestion.UpdateTime, Mode=TwoWay}" />
</StackPanel>
</Grid>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5,0,5,10"/>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Stretch" Margin="0,0">
<Button Content="修改" HorizontalAlignment="Center" Command="{Binding UpdateQuestionCommand}" Style="{DynamicResource MaterialDesignFlatDarkButton}"/>
<Button Content="删除" HorizontalAlignment="Center" Command="{Binding DeleteQuestionCommand}" Style="{DynamicResource MaterialDesignFlatDarkButton}"/>
</StackPanel>
</DockPanel>
</Border>
</Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -12,6 +12,55 @@
<Setter Property="Margin" Value="10,5"/> <Setter Property="Margin" Value="10,5"/>
<Setter Property="Width" Value="50"/> <Setter Property="Width" Value="50"/>
</Style> </Style>
<Style x:Key="ModernMenuItemStyle" TargetType="MenuItem">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Margin" Value="20,10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MenuItem">
<Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" CornerRadius="5" Height="20" Width="50">
<Grid>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" ContentSource="Header"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkGray"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- 定义 ContextMenu 的样式 -->
<Style x:Key="ModernContextMenuStyle" TargetType="ContextMenu">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="#FF007ACC"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContextMenu">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<StackPanel>
<ItemsPresenter/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ContextMenu x:Key="MyModernContextMenu" Style="{StaticResource ModernContextMenuStyle}">
<MenuItem Header="查看详情" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Command="{Binding DataContext.RegionTo, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="DetailView" Style="{StaticResource ModernMenuItemStyle}"/>
<MenuItem Header="删除" Command="{Binding Option2Command}" Style="{StaticResource ModernMenuItemStyle}"/>
</ContextMenu>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="Transparent"> <Grid Background="Transparent">
<Border Background="#FFFAFAFA" CornerRadius="10"/> <Border Background="#FFFAFAFA" CornerRadius="10"/>
@ -26,24 +75,28 @@
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border Background="#FFFEFEFE" BorderBrush="Gray" BorderThickness="0" CornerRadius="10" <Border Background="#FFFEFEFE" BorderBrush="Gray" BorderThickness="0" CornerRadius="10"
Padding="5" Height="200" Width="120" Margin="5" IsHitTestVisible="True"> Padding="5" Height="200" Width="120" Margin="5" IsHitTestVisible="True" MouseRightButtonDown="Border_MouseRightButtonDown">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:ChangePropertyAction PropertyName="Background" Value="#FFFEFEFE"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:ChangePropertyAction PropertyName="Background" Value="#FFF9F9F9"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<!--<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.ShowContextMenuCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"/>
</i:EventTrigger>-->
</i:Interaction.Triggers>
<Border.Effect> <Border.Effect>
<DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/> <DropShadowEffect Color="#FFF5F5F5" BlurRadius="10" ShadowDepth="1" Direction="0"/>
</Border.Effect> </Border.Effect>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Black"/>
<Setter Property="BorderBrush" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel> <StackPanel>
<TextBlock TextWrapping="Wrap" FontSize="20" FontWeight="Bold" Text="{Binding Name}" <TextBlock TextWrapping="Wrap" FontSize="20" FontWeight="Bold" Text="{Binding Name}"
VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/> VerticalAlignment="Center" HorizontalAlignment="Left" Padding="10,10"/>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="总数" Margin="5" Foreground="Gray" <TextBlock TextWrapping="Wrap" FontSize="12" Text="总数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/> VerticalAlignment="Center" HorizontalAlignment="Left"/>
@ -51,7 +104,22 @@
Text="{Binding ErrorSet.TotalCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/> Text="{Binding ErrorSet.TotalCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="总数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Margin="5"
Text="{Binding ErrorSet.TotalCount}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</StackPanel>
<Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5"/> <Border BorderBrush="Gray" BorderThickness="0,0.5,0,0" Margin="5"/>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="Wrap" FontSize="12" Text="正确数" Margin="5" Foreground="Gray"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock TextWrapping="Wrap" FontSize="18" Text="{Binding ErrorSet.CorrectCount}" Margin="5"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
@ -61,6 +129,7 @@
VerticalAlignment="Center" HorizontalAlignment="Left"/> VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel>
</Border> </Border>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>

View File

@ -30,5 +30,20 @@ namespace StudentManager.Editor
{ {
var data = DataContext; var data = DataContext;
} }
private void Border_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.OriginalSource is FrameworkElement element)
{
var contextMenu = element.FindResource("MyModernContextMenu") as ContextMenu;
if (contextMenu != null)
{
contextMenu.PlacementTarget = element;
contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
contextMenu.Style = (Style)element.FindResource("ModernContextMenuStyle");
contextMenu.IsOpen = true;
}
}
}
} }
} }

View File

@ -1,4 +1,5 @@
using Mysqlx.Crud; using DryIoc.ImTools;
using Mysqlx.Crud;
using Newtonsoft.Json; using Newtonsoft.Json;
using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities;
using StudentManager.Common; using StudentManager.Common;
@ -13,6 +14,8 @@ using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace StudentManager.Model namespace StudentManager.Model
{ {
@ -65,7 +68,7 @@ namespace StudentManager.Model
public ObservableCollection<QuestionData> ADDQuestionDatas { get { return addQuestionDatas; } private set { addQuestionDatas = value; RaisePropertyChanged(); } } public ObservableCollection<QuestionData> ADDQuestionDatas { get { return addQuestionDatas; } private set { addQuestionDatas = value; RaisePropertyChanged(); } }
private ObservableCollection<DetailErrorInfo> errorSetDatas = new ObservableCollection<DetailErrorInfo>(); private ObservableCollection<DetailErrorInfo> errorSetDatas = new ObservableCollection<DetailErrorInfo>();
public ReadOnlyObservableCollection<DetailErrorInfo> ErrorSetDatas { get; private set; } public ObservableCollection<DetailErrorInfo> ErrorSetDatas { get { return errorSetDatas; } private set { errorSetDatas = value; RaisePropertyChanged(); } }
private ObservableCollection<CursonQuestionsData> cQDatas = new ObservableCollection<CursonQuestionsData>(); private ObservableCollection<CursonQuestionsData> cQDatas = new ObservableCollection<CursonQuestionsData>();
public ReadOnlyObservableCollection<CursonQuestionsData> CQDatas { get; private set; } public ReadOnlyObservableCollection<CursonQuestionsData> CQDatas { get; private set; }
@ -180,6 +183,13 @@ namespace StudentManager.Model
set { questionCount = value; RaisePropertyChanged(); } set { questionCount = value; RaisePropertyChanged(); }
} }
private QuestionData selectedQuestion = new QuestionData();
public QuestionData SelectedQuestion
{
get { return selectedQuestion; }
set { selectedQuestion = value; RaisePropertyChanged(); }
}
@ -190,8 +200,11 @@ namespace StudentManager.Model
public DelegateCommand<StudentInfo> SelectedCommand { get; set; } public DelegateCommand<StudentInfo> SelectedCommand { get; set; }
public DelegateCommand<DetailHomeWorkInfo> HomeWorkSelectedCommand { get; set; } public DelegateCommand<DetailHomeWorkInfo> HomeWorkSelectedCommand { get; set; }
public DelegateCommand<DetailHomeWorkSetInfo> HomeWorkSetSelectedCommand { get; set; } public DelegateCommand<DetailHomeWorkSetInfo> HomeWorkSetSelectedCommand { get; set; }
public DelegateCommand<QuestionData> DeleteQuestionCommand { get; set; } public DelegateCommand DeleteQuestionCommand { get; set; }
public DelegateCommand UpdateQuestionCommand { get; set; }
public DelegateCommand<MouseButtonEventArgs> ShowContextMenuCommand { get; set; }
public DelegateCommand<QuestionData> RemoveNewColumnCommand { get; set; } public DelegateCommand<QuestionData> RemoveNewColumnCommand { get; set; }
public DelegateCommand<QuestionData> SelectedQuestionChangedCommand { get; set; }
public DelegateCommand RegionToDetailCommand { get; set; } public DelegateCommand RegionToDetailCommand { get; set; }
public DelegateCommand SubmitHomeWorkCommand { get; set; } public DelegateCommand SubmitHomeWorkCommand { get; set; }
public DelegateCommand AddNewColumnCommand { get; set; } public DelegateCommand AddNewColumnCommand { get; set; }
@ -238,18 +251,49 @@ namespace StudentManager.Model
HomeWorkSelectedCommand = new DelegateCommand<DetailHomeWorkInfo>((e) => HomeWorkSelectedCommand = new DelegateCommand<DetailHomeWorkInfo>((e) =>
{ {
if (e == null) return; if (e == null) return;
//HomeWork = //selectedHomeWork = e;
e.Status = true;
}); });
DeleteQuestionCommand = new DelegateCommand<QuestionData>((x) => DeleteQuestionCommand = new DelegateCommand(() =>
{ {
if (x == null) return; if (SelectedQuestion == null) return;
var c = MessageBox.Show("确定删除吗?", "确认", MessageBoxButton.OKCancel); var c = MessageBox.Show("确定删除吗?", "确认", MessageBoxButton.OKCancel);
if (c != MessageBoxResult.OK) return; if (c != MessageBoxResult.OK) return;
QuestionLib.Remove(x); QuestionLib.Remove(SelectedQuestion);
QuestionDatas = QuestionLib.GetAllQuestion(); QuestionDatas = QuestionLib.GetAllQuestion();
}); });
UpdateQuestionCommand = new DelegateCommand(() =>
{
if(SelectedQuestion == null) return;
var c = MessageBox.Show("确定修改吗?", "确认", MessageBoxButton.OKCancel);
if (c != MessageBoxResult.OK) return;
QuestionLib.Update(SelectedQuestion);
SelectedQuestion.UpdateTime = DateTime.Now;
SQLHelper.UpdateQuestion(SelectedQuestion);
});
ShowContextMenuCommand = new DelegateCommand<MouseButtonEventArgs>((e) =>
{
if (e.OriginalSource is FrameworkElement element)
{
var contextMenu = element.FindResource("MyContextMenu") as ContextMenu;
if (contextMenu != null)
{
contextMenu.PlacementTarget = element;
contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
contextMenu.IsOpen = true;
}
}
});
SelectedQuestionChangedCommand = new DelegateCommand<QuestionData>((x) =>
{
if(x == null) return;
SelectedQuestion = x;
});
RemoveNewColumnCommand = new DelegateCommand<QuestionData>((x) => RemoveNewColumnCommand = new DelegateCommand<QuestionData>((x) =>
{ {
@ -306,7 +350,7 @@ namespace StudentManager.Model
StudentDatas = new ReadOnlyObservableCollection<StudentInfo>(studentDatas); StudentDatas = new ReadOnlyObservableCollection<StudentInfo>(studentDatas);
QuestionDatas = new ObservableCollection<QuestionData>(questionDatas); QuestionDatas = new ObservableCollection<QuestionData>(questionDatas);
ErrorSetDatas = new ReadOnlyObservableCollection<DetailErrorInfo>(errorSetDatas); ErrorSetDatas = new ObservableCollection<DetailErrorInfo>(errorSetDatas);
MenuBars = new ReadOnlyObservableCollection<MenuBar>(menuBars); MenuBars = new ReadOnlyObservableCollection<MenuBar>(menuBars);
HomeWorkSet = new ObservableCollection<DetailHomeWorkSetInfo>(homeWorkSet); HomeWorkSet = new ObservableCollection<DetailHomeWorkSetInfo>(homeWorkSet);
@ -329,7 +373,7 @@ namespace StudentManager.Model
// update error set and local homework // update error set and local homework
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Questions.ForEach(x => SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Questions.ForEach(x =>
{ {
if (x.Status != HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status) if (x.Status != HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status || selectedHomeWorkSet.Status == false)
{ {
x.Status = HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status; x.Status = HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status;
SelectedStudent.ErrorSet.AddQuestion(x); SelectedStudent.ErrorSet.AddQuestion(x);
@ -337,6 +381,10 @@ namespace StudentManager.Model
} }
}); });
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).UpdateData();
ErrorSet = SelectedStudent.ErrorSet.GetDetailErrorSetInfo();
ErrorSetDatas = SelectedStudent.ErrorSet.GetDetailErrorQuestionList();
// update homework other info and online info // update homework other info and online info
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status = true; SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status = true;
@ -354,6 +402,14 @@ namespace StudentManager.Model
JsonConvert.SerializeObject(correctHomeworkArray), SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).DateTime, JsonConvert.SerializeObject(correctHomeworkArray), SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).DateTime,
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status); SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status);
//TODO: Notify
}
private void UpdateData()
{
} }
private void RegionToDetailView() private void RegionToDetailView()