Skip to content

Commit

Permalink
Выполненно задание №4
Browse files Browse the repository at this point in the history
  • Loading branch information
TotKtoSmog committed Dec 14, 2023
1 parent be07220 commit 0f1abb7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
19 changes: 19 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@
</ListBox.ItemTemplate>
</ListBox>
</TabItem>
<TabItem Header="Задание №4">
<StackPanel Margin="15">
<StackPanel Orientation="Horizontal">
<ListBox x:Name="ListTerm" ItemsSource="{Binding terms}" SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DataGrid x:Name="SubjectTable" AutoGenerateColumns="False" IsReadOnly="True" Margin="10,0">
<DataGrid.Columns >
<DataGridTextColumn Header="Шифр" Binding="{Binding index}"/>
<DataGridTextColumn Header="Название дисциплины" Binding="{Binding title}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
</TabItem>
</TabControl>


Expand Down
21 changes: 19 additions & 2 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class MainWindow : Window
public List<Standart> standart { get; set; }
public List<Subject> subject { get; set; }
public List<ProgressIdentifier> progressIdentifier { get; set; }
public Term[] terms { get; set; }

public MainWindow()
{
Expand All @@ -22,6 +23,8 @@ public MainWindow()
standart = getStandartInData(jsonProfStandart);
progressIdentifier = getProgressIdentifierInData(jsonProfStandart);
subject = getSubjectsInfoInData(jsonProfStandart);
terms = GetTerms(subject);

this.DataContext = this;
}
public JsonProfStandart LoadJsonFile(string PathJsonFile)
Expand Down Expand Up @@ -50,7 +53,6 @@ private List<Standart> getStandartInData(JsonProfStandart jsonProfStandart)
}
return returnResult;
}

private List<ProgressIdentifier> getProgressIdentifierInData(JsonProfStandart jsonProfStandart)
{
List<ProgressIdentifier> returnResult = new List<ProgressIdentifier>();
Expand All @@ -69,7 +71,6 @@ private List<ProgressIdentifier> getProgressIdentifierInData(JsonProfStandart js
}
return returnResult;
}

private List<Subject> getSubjectsInfoInData(JsonProfStandart jsonProfStandart)
{
List<Subject> returnResult = new List<Subject>();
Expand All @@ -92,5 +93,21 @@ private List<Subject> getSubjectsInfoInData(JsonProfStandart jsonProfStandart)

return returnResult;
}

private Term[] GetTerms(List<Subject> subject)
{
const ushort countTerm = 8;
Term[] terms = new Term[countTerm];
for (ushort i = 0; i < countTerm; i++)
terms[i] = new Term($"Семестр №{i + 1}", i, GetSubjectsInTerm(i, subject));
return terms;
}
private List<Subject> GetSubjectsInTerm(ushort trem, List<Subject> subject)
=> subject.Where(n => n.terms[trem].terms == true).ToList();

private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
SubjectTable.ItemsSource = terms[ListTerm.SelectedIndex].subject;
}
}
}
19 changes: 19 additions & 0 deletions Term.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;

namespace laba4
{
public class Term
{
public string name { get; set; }
public ushort number { get; set; }
public List<Subject> subject { get; set; }

public Term() { }
public Term(string name, ushort number, List<Subject> subject)
{
this.name = name;
this.number = number;
this.subject = subject;
}
}
}
1 change: 1 addition & 0 deletions laba4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="ProgressIdentifier.cs" />
<Compile Include="Standart.cs" />
<Compile Include="Subject.cs" />
<Compile Include="Term.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit 0f1abb7

Please sign in to comment.