init commit

This commit is contained in:
-SSS- 2025-01-29 19:49:00 +03:00
parent 9e30e876e5
commit a585d10741
16 changed files with 37 additions and 19 deletions

View File

@ -19,7 +19,7 @@
<ComboBoxItem Content="IT"/>
<ComboBoxItem Content="Чет еще"/>
</ComboBox>
<ComboBox Width="150" x:Name="Дата" Margin="5">
<ComboBox Width="150" x:Name="DateComboBox" SelectionChanged="DateComboBox_SelectionChanged" Margin="5">
<ComboBoxItem Content="Возрастание"/>
<ComboBoxItem Content="Убывание"/>
<ComboBoxItem Content="Все диапазоны"/>

View File

@ -13,15 +13,17 @@ namespace demo_2023
public partial class MainWindow : Window
{
private ObservableCollection<EventPresenter> events = new ObservableCollection<EventPresenter>();
private List<EventPresenter> dataSourceEvent;
private bool isAscending = true; // Флаг для сортировки
public MainWindow()
{
InitializeComponent();
using var context = new User15Context();
var dataSourceEvent = context.Events.Select(it => new EventPresenter
dataSourceEvent = context.Events.Select(it => new EventPresenter
{
Sobitie = it.Sobitie,
Date = it.Date,
@ -31,15 +33,31 @@ namespace demo_2023
}).ToList();
foreach (var eventItem in dataSourceEvent)
{
events.Add(eventItem);
}
EventListBox.ItemsSource = events;
ApplySortingAndFiltering();
}
private void ApplySortingAndFiltering()
{
var temp = dataSourceEvent;
if (DateComboBox.SelectedItem is DateTime selectedDateTime)
{
temp = temp.Where(it => it.Date.Date == selectedDateTime.Date).ToList();
}
temp = isAscending ? temp.OrderBy(it => it.Date).ToList() : temp.OrderByDescending(it => it.Date).ToList();
events.Clear();
foreach (var item in temp)
{
events.Add(item);
}
}
public class EventPresenter : Event
{
@ -49,15 +67,8 @@ namespace demo_2023
{
try
{
string absolutePath = Path.Combine(AppContext.BaseDirectory, Photo);
if (File.Exists(absolutePath))
{
return new Bitmap(absolutePath);
}
return null;
return File.Exists(absolutePath) ? new Bitmap(absolutePath) : null;
}
catch
{
@ -68,6 +79,13 @@ namespace demo_2023
}
private void DateComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{
isAscending = !isAscending;
ApplySortingAndFiltering();
}
private void Jury_reg(object? sender, RoutedEventArgs e)
{
new Additem().ShowDialog(this);

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_2023")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d38f832f0f4284353be6ed8b83b5daeff3682e53")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9e30e876e51b1e136cbd4b751c48573cc2771d37")]
[assembly: System.Reflection.AssemblyProductAttribute("demo_2023")]
[assembly: System.Reflection.AssemblyTitleAttribute("demo_2023")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
2ae409290fa8af1bf43909ade41f704793ba565a70d5881dd04bc0df6eec2e92
e3c78da2cdc6980fa77b2a133556306f70f364175f9f08b29318cf6e73502801