Did 3/6 from more info, full sponsorARunner, Registration, Menus of all roles, contactsWindow

This commit is contained in:
1eG0ist 2025-03-01 02:37:30 +03:00
parent f83570775b
commit 9adf371994
54 changed files with 2002 additions and 12 deletions

View File

@ -2,9 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="IposiGospodDemo.App"
xmlns:local="using:IposiGospodDemo"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
xmlns:global="clr-namespace:"
xmlns:convertors="clr-namespace:IposiGospodDemo.Convertors"
RequestedThemeVariant="Light">
<Application.Resources>
<global:RunnerConverter x:Key="RunnerConverter" />
<convertors:ImageConverter x:Key="ImageConverter" />
</Application.Resources>
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

View File

@ -0,0 +1,24 @@
using System;
using System.Globalization;
using System.IO;
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;
namespace IposiGospodDemo.Convertors;
public class ImageConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is string path)
{
return new Bitmap(Path.Combine(Session.AssetsPath, path.Trim()));
}
return null;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Linq;
using Avalonia.Data.Converters;
using IposiGospodDemo.Context;
public class RunnerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is User user)
{
return $"{user.FirstName} {user.LastName} - {user.Runners.FirstOrDefault()?.RunnerId} ({user.Runners.FirstOrDefault()?.CountryCode})";
}
return "Неизвестный бегун";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,8 @@
using IposiGospodDemo.Context;
namespace IposiGospodDemo.Helpers;
public static class DbHelper
{
public static readonly User3Context Database = new();
}

View File

@ -9,13 +9,13 @@
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\"/>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.1"/>
<PackageReference Include="Avalonia.Desktop" Version="11.2.1"/>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
@ -31,4 +31,8 @@
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Assets\Charity\" />
</ItemGroup>
</Project>

View File

@ -1,5 +1,6 @@
using Avalonia;
using System;
using Avalonia.ReactiveUI;
namespace IposiGospodDemo;
@ -17,5 +18,6 @@ sealed class Program
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
.LogToTrace()
.UseReactiveUI();
}

View File

@ -0,0 +1,23 @@
using System;
using IposiGospodDemo.Context;
namespace IposiGospodDemo;
public static class Session
{
public static readonly String Title = "MARATHON SKILLS 2016";
public static readonly DateTime MarathonData = new DateTime(2025, 4, 1, 12, 0, 0);
public static readonly String Location = "Москва, Россия";
public static readonly String Data = "Вторник 1 апреля 2025";
public static String RemainingTime = CalculateRemaningTime();
public static string AssetsPath = null!;
public static User User = null;
public static String CalculateRemaningTime()
{
TimeSpan timeLeft = MarathonData - DateTime.Now;
return RemainingTime = timeLeft.TotalSeconds > 0
? $"{timeLeft.Days} д. {timeLeft.Hours} ч. {timeLeft.Minutes} мин. до старта марафона"
: "Марафон уже начался!";
}
}

View File

@ -0,0 +1,17 @@
using IposiGospodDemo.Context;
namespace IposiGospodDemo.ViewModels;
public class CharityInfoViewModel
{
public string Name { get; }
public string ImagePath { get; }
public string Description { get; }
public CharityInfoViewModel(Charity charity)
{
Name = charity.CharityName;
ImagePath = charity.CharityLogo;
Description = charity.CharityDescription;
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using IposiGospodDemo.Context;
using IposiGospodDemo.Helpers;
using ReactiveUI;
namespace IposiGospodDemo.ViewModels;
public class ListOfCharitiesWindowViewModel : ViewModelBase
{
private ObservableCollection<Charity> _charities;
public ObservableCollection<Charity> Charities
{
get => _charities;
set => this.RaiseAndSetIfChanged(ref _charities, value);
}
public ListOfCharitiesWindowViewModel()
{
Charities = new(DbHelper.Database.Charities.ToList());
Console.WriteLine(Charities);
Console.WriteLine(Charities.Count);
}
}

View File

@ -1,6 +1,8 @@
namespace IposiGospodDemo.ViewModels;
using System;
using System.Timers;
namespace IposiGospodDemo.ViewModels;
public partial class MainWindowViewModel : ViewModelBase
{
public string Greeting { get; } = "Welcome to Avalonia!";
}

View File

@ -0,0 +1,22 @@
using System.Collections.ObjectModel;
using IposiGospodDemo.Context;
using ReactiveUI;
namespace IposiGospodDemo.ViewModels;
public class MySponsorshipWindowViewModel : ViewModelBase
{
private ObservableCollection<Registration> _registrations;
public ObservableCollection<Registration> Registrations
{
get => _registrations;
set => this.RaiseAndSetIfChanged(ref _registrations, value);
}
public MySponsorshipWindowViewModel()
{
}
}

View File

@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using IposiGospodDemo.Context;
using IposiGospodDemo.Helpers;
using IposiGospodDemo.Views;
using Microsoft.EntityFrameworkCore;
using ReactiveUI;
namespace IposiGospodDemo.ViewModels;
public class SponsorARunnerWindowViewModel : ViewModelBase
{
public List<Runner> Runners { get; set; }
private Runner _selectedRunner;
public Runner SelectedRunner
{
get => _selectedRunner;
set
{
if (_selectedRunner != value)
{
_selectedRunner = value;
this.RaisePropertyChanged();
}
SelectedCharity = value?.Registrations?.FirstOrDefault()?.Charity;
}
}
private Charity _selectedCharity;
public Charity SelectedCharity
{
get => _selectedCharity;
set => this.RaiseAndSetIfChanged(ref _selectedCharity, value);
}
private decimal _sum = 50;
public decimal Sum
{
get => _sum;
set => this.RaiseAndSetIfChanged(ref _sum, value);
}
private string _sponsorName;
public string SponsorName
{
get => _sponsorName;
set => this.RaiseAndSetIfChanged(ref _sponsorName, value);
}
private string _cardOwner;
public string CardOwner
{
get => _cardOwner;
set => this.RaiseAndSetIfChanged(ref _cardOwner, value);
}
private string _cardNumber;
public string CardNumber
{
get => _cardNumber;
set => this.RaiseAndSetIfChanged(ref _cardNumber, value);
}
private string _month;
public string Month
{
get => _month;
set => this.RaiseAndSetIfChanged(ref _month, value);
}
private string _year;
public string Year
{
get => _year;
set => this.RaiseAndSetIfChanged(ref _year, value);
}
private string _cvc;
public string Cvc
{
get => _cvc;
set => this.RaiseAndSetIfChanged(ref _cvc, value);
}
public ReactiveCommand<Unit, Unit> IncreaseSumCommand { get; }
public ReactiveCommand<Unit, Unit> DecreaseSumCommand { get; }
public ReactiveCommand<Unit, Unit> OpenCharityInfoWindow { get; }
public SponsorARunnerWindowViewModel()
{
Runners = DbHelper.Database.Runners
.Include(r => r.CountryCodeNavigation)
.Include(r => r.EmailNavigation)
.Include(r => r.Registrations)
.ThenInclude(reg => reg.Charity)
.ToList();
SelectedRunner = Runners[0];
IncreaseSumCommand = ReactiveCommand.Create(IncreaseSum);
DecreaseSumCommand = ReactiveCommand.Create(DecreaseSum);
OpenCharityInfoWindow = ReactiveCommand.Create(OpenCharityInfoWindowFunc);
}
void DecreaseSum()
{
if (Sum < 11)
Sum = 1;
else Sum -= 10;
}
void IncreaseSum()
{
Sum += 10;
}
void OpenCharityInfoWindowFunc()
{
new CharityInfoWindow(SelectedCharity).Show();
}
}

View File

@ -0,0 +1,17 @@
using System;
using IposiGospodDemo.Context;
namespace IposiGospodDemo.ViewModels;
public class SponsorshipConfirmationWindowViewModel : ViewModelBase
{
public User SupportedRunner { get; set; }
public decimal Amount { get; set; }
public String CharityName { get; set; }
public SponsorshipConfirmationWindowViewModel(User user, decimal amount, String charityName)
{
SupportedRunner = user;
Amount = amount;
CharityName = charityName;
}
}

View File

@ -1,7 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using ReactiveUI;
namespace IposiGospodDemo.ViewModels;
public class ViewModelBase : ObservableObject
public class ViewModelBase : ReactiveObject
{
}

View File

@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.AdministratorMenuWindow"
Title="AdministratorMenuWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical">
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class AdministratorMenuWindow : Window
{
public AdministratorMenuWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,125 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
Width="800" Height="600"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.BMICalculatorWindow"
Title="BMICalculatorWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Border Grid.Row="1" Padding="10">
<DockPanel>
<TextBlock Text="BMI Калькулятор" FontSize="32" HorizontalAlignment="Center" DockPanel.Dock="Top" Margin="0 0 0 20"/>
<StackPanel Orientation="Vertical" DockPanel.Dock="Left" Spacing="20">
<TextBlock Text="BMI (Body Mass Index) — это индекс массы тела, который используется для оценки соответствия массы человека его росту и определения возможных рисков для здоровья."
Width="300" TextWrapping="Wrap" FontSize="18" TextAlignment="Center" HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" Spacing="20" HorizontalAlignment="Center">
<ToggleButton x:Name="MaleButton" Content="Мужской"
IsChecked="True" Width="100" Height="100"
BorderThickness="5" BorderBrush="Black"
Click="GenderSelectionChanged"/>
<ToggleButton x:Name="FemaleButton" Content="Женский"
Width="100" Height="100"
BorderThickness="2" BorderBrush="Black"
Click="GenderSelectionChanged"/>
</StackPanel>
<Grid RowDefinitions="50 50" ColumnDefinitions="40 70 50" HorizontalAlignment="Center">
<TextBlock Grid.Column="0" Grid.Row="0" Text="Рост: " VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Вес: " VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="2" Grid.Row="0" Text=" см" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text=" кг" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBox Grid.Column="1" Grid.Row="0" Name="UserHeight" Watermark="170" VerticalAlignment="Center" TextAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="1" Name="UserWeight" Watermark="70" VerticalAlignment="Center" TextAlignment="Center"/>
</Grid>
<StackPanel Spacing="20" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Рассчитать" Click="Calculate_OnClick"/>
<Button Content="Отмена" Click="GoBack_OnClick"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="10" DockPanel.Dock="Right">
<Border Width="200" Height="300" Background="Gray" BorderBrush="DimGray" BorderThickness="2">
<TextBlock Name="TextResult" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"
FontSize="32" Foreground="DimGray"/>
</Border>
<TextBlock Name="NumberResult" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"
FontSize="32" Foreground="DimGray" Text="Результат"/>
<Grid RowDefinitions="20 40 50" ColumnDefinitions="120 120 120 120">
<Path Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" Stroke="Black" Fill="Gray"
StrokeThickness="2" Name="LessTriangle" IsVisible="False">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="9.62,16.67" IsClosed="True">
<LineSegment Point="19.25,0"/>
<LineSegment Point="0,0"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Border Grid.Column="0" Grid.Row="1" Background="Orange" Margin="0 10"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Недостаточный" HorizontalAlignment="Center"/>
<Path Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Stroke="Black" Fill="Gray"
StrokeThickness="2" Name="GoodTriangle" IsVisible="False">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="9.62,16.67" IsClosed="True">
<LineSegment Point="19.25,0"/>
<LineSegment Point="0,0"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Border Grid.Column="1" Grid.Row="1" Background="LimeGreen" Margin="0 10"/>
<TextBlock Grid.Column="1" Grid.Row="2" Text="Здоровый" HorizontalAlignment="Center"/>
<Path Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" Stroke="Black" Fill="Gray"
StrokeThickness="2" Name="MoreTriangle" IsVisible="False">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="9.62,16.67" IsClosed="True">
<LineSegment Point="19.25,0"/>
<LineSegment Point="0,0"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Border Grid.Column="2" Grid.Row="1" Background="Orange" Margin="0 10"/>
<TextBlock Grid.Column="2" Grid.Row="2" Text="Избыточный" HorizontalAlignment="Center"/>
<Path Grid.Column="3" Grid.Row="0" HorizontalAlignment="Center" Stroke="Black" Fill="Gray"
StrokeThickness="2" Name="BadTriangle" IsVisible="False">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="9.62,16.67" IsClosed="True">
<LineSegment Point="19.25,0"/>
<LineSegment Point="0,0"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Border Grid.Column="3" Grid.Row="1" Background="DarkRed" Margin="0 10"/>
<TextBlock Grid.Column="3" Grid.Row="2" Text="Ожирение" HorizontalAlignment="Center"/>
</Grid>
</StackPanel>
</DockPanel>
</Border>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,80 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class BMICalculatorWindow : Window
{
public BMICalculatorWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MoreInformationWindow().Show();
Close();
}
private void GenderSelectionChanged(object sender, RoutedEventArgs e)
{
if (sender == MaleButton)
{
MaleButton.IsChecked = true;
MaleButton.BorderThickness = new Thickness(5);
FemaleButton.IsChecked = false;
FemaleButton.BorderThickness = new Thickness(2);
}
else
{
FemaleButton.IsChecked = true;
FemaleButton.BorderThickness = new Thickness(5);
MaleButton.IsChecked = false;
MaleButton.BorderThickness = new Thickness(2);
}
}
private void Calculate_OnClick(object? sender, RoutedEventArgs e)
{
if (!double.TryParse(UserWeight.Text, out double weight) ||
!double.TryParse(UserHeight.Text, out double heightCm))
{
TextResult.Text = "Некорректные данные";
NumberResult.Text = "Ошибка";
return;
}
double heightM = heightCm / 100.0;
double bmi = weight / (heightM * heightM);
NumberResult.Text = bmi.ToString("F1");
LessTriangle.IsVisible = false;
GoodTriangle.IsVisible = false;
MoreTriangle.IsVisible = false;
BadTriangle.IsVisible = false;
if (bmi < 18.5)
{
TextResult.Text = "Недостаточный";
LessTriangle.IsVisible = true;
}
else if (bmi >= 18.5 && bmi <= 24.9)
{
TextResult.Text = "Здоровый";
GoodTriangle.IsVisible = true;
}
else if (bmi >= 25 && bmi <= 29.9)
{
TextResult.Text = "Избыточный";
MoreTriangle.IsVisible = true;
}
else
{
TextResult.Text = "Ожирение";
BadTriangle.IsVisible = true;
}
}
}

View File

@ -0,0 +1,96 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
Width="800" Height="600"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.BMRCalculatorWindow"
Title="BMRCalculatorWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Border Grid.Row="1" Padding="10">
<DockPanel>
<TextBlock Text="BMI Калькулятор" FontSize="32" HorizontalAlignment="Center" DockPanel.Dock="Top" Margin="0 0 0 20"/>
<StackPanel Orientation="Vertical" DockPanel.Dock="Left" Spacing="20">
<TextBlock Text="BMR — это количество калорий, которое организм тратит в состоянии покоя для поддержания жизненно важных функций (дыхание, кровообращение, температура тела и т.д.)."
Width="400" TextWrapping="Wrap" FontSize="18" TextAlignment="Center" HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" Spacing="20" HorizontalAlignment="Center">
<ToggleButton x:Name="MaleButton" Content="Мужской"
IsChecked="True" Width="100" Height="100"
BorderThickness="5" BorderBrush="Black"
Click="GenderSelectionChanged"/>
<ToggleButton x:Name="FemaleButton" Content="Женский"
Width="100" Height="100"
BorderThickness="2" BorderBrush="Black"
Click="GenderSelectionChanged"/>
</StackPanel>
<Grid RowDefinitions="40 40 40" ColumnDefinitions="70 70 50" HorizontalAlignment="Center">
<TextBlock Grid.Column="0" Grid.Row="0" Text="Рост: " VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Вес: " VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Возраст: " VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="2" Grid.Row="0" Text=" см" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text=" кг" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="2" Grid.Row="2" Text=" лет" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBox Grid.Column="1" Grid.Row="0" Name="UserHeight" Watermark="170" VerticalAlignment="Center" TextAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="1" Name="UserWeight" Watermark="70" VerticalAlignment="Center" TextAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="2" Name="UserAge" Watermark="30" VerticalAlignment="Center" TextAlignment="Center"/>
</Grid>
<StackPanel Spacing="20" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Рассчитать" Click="Calculate_OnClick"/>
<Button Content="Отмена" Click="GoBack_OnClick"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="10" DockPanel.Dock="Right">
<TextBlock Text="Информация о показателях калорий показывается здесь" VerticalAlignment="Center"
HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Foreground="DimGray"
FontSize="18"/>
<TextBlock Text="Ваш BMR" VerticalAlignment="Center"
HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Foreground="DimGray"
FontSize="18"/>
<TextBlock Name="NumberResult" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"
FontSize="32" Foreground="DimGray" Text="Результат"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="20">
<TextBlock Text="Ежедневно тратится калорий" VerticalAlignment="Center" TextAlignment="Center"/>
<Button Content="i" FontWeight="Bold" Foreground="Orange" FontSize="24" CornerRadius="50" BorderBrush="Orange" VerticalAlignment="Center"
BorderThickness="2" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Click="OpenBMRInfoWindow_OnClick"
VerticalContentAlignment="Center" Background="Transparent" Height="30" Width="30" Padding="5 0"/>
</StackPanel>
<Grid RowDefinitions="30 30 30 30 30" ColumnDefinitions="200 80">
<TextBlock Grid.Column="0" Grid.Row="0" Text="Сидячий: " HorizontalAlignment="Right" TextAlignment="Right" Foreground="Blue"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Маленькая активность: " HorizontalAlignment="Right" TextAlignment="Right" Foreground="LimeGreen"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Среднаяя активность: " HorizontalAlignment="Right" TextAlignment="Right" Foreground="Orange"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Сильная активность: " HorizontalAlignment="Right" TextAlignment="Right" Foreground="Red"/>
<TextBlock Grid.Column="0" Grid.Row="4" Text="Максимальная активность: " HorizontalAlignment="Right" TextAlignment="Right" Foreground="DarkRed"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="-" Name="ChearActive" HorizontalAlignment="Left" TextAlignment="Left" Foreground="Blue"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="-" Name="MiniActive" HorizontalAlignment="Left" TextAlignment="Left" Foreground="LimeGreen"/>
<TextBlock Grid.Column="1" Grid.Row="2" Text="-" Name="MidActive" HorizontalAlignment="Left" TextAlignment="Left" Foreground="Orange"/>
<TextBlock Grid.Column="1" Grid.Row="3" Text="-" Name="StrongActive" HorizontalAlignment="Left" TextAlignment="Left" Foreground="Red"/>
<TextBlock Grid.Column="1" Grid.Row="4" Text="-" Name="MaxActive" HorizontalAlignment="Left" TextAlignment="Left" Foreground="DarkRed"/>
</Grid>
</StackPanel>
</DockPanel>
</Border>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,72 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class BMRCalculatorWindow : Window
{
public BMRCalculatorWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MoreInformationWindow().Show();
Close();
}
private void GenderSelectionChanged(object sender, RoutedEventArgs e)
{
if (sender == MaleButton)
{
MaleButton.IsChecked = true;
MaleButton.BorderThickness = new Thickness(5);
FemaleButton.IsChecked = false;
FemaleButton.BorderThickness = new Thickness(2);
}
else
{
FemaleButton.IsChecked = true;
FemaleButton.BorderThickness = new Thickness(5);
MaleButton.IsChecked = false;
MaleButton.BorderThickness = new Thickness(2);
}
}
private void Calculate_OnClick(object? sender, RoutedEventArgs e)
{
if (!double.TryParse(UserWeight.Text, out double weight) ||
!double.TryParse(UserHeight.Text, out double height) ||
!double.TryParse(UserAge.Text, out double age))
{
NumberResult.Text = "Ошибка ввода";
return;
}
double bmr;
if (MaleButton.IsChecked == true)
{
bmr = 66 + (13.7 * weight) + (5 * height) - (6.8 * age);
}
else
{
bmr = 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age);
}
NumberResult.Text = bmr.ToString("F1") + " ккал";
ChearActive.Text = (bmr * 1.2).ToString("F1");
MiniActive.Text = (bmr * 1.375).ToString("F1");
MidActive.Text = (bmr * 1.55).ToString("F1");
StrongActive.Text = (bmr * 1.725).ToString("F1");
MaxActive.Text = (bmr * 1.9).ToString("F1");
}
private void OpenBMRInfoWindow_OnClick(object? sender, RoutedEventArgs e)
{
new BMRInfoWindow().Show();
}
}

View File

@ -0,0 +1,38 @@
<Window xmlns="https://github.com/avaloniaui"
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"
Height="400" Width="500"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="400"
x:Class="IposiGospodDemo.Views.BMRInfoWindow"
Title="BMRInfoWindow" Padding="10">
<DockPanel>
<TextBlock HorizontalAlignment="Center" Text="Уровни активностей" FontSize="32" TextAlignment="Center" DockPanel.Dock="Top"/>
<TextBlock HorizontalAlignment="Left" Text="Это описание всех уровней активности" FontSize="24" TextAlignment="Center" DockPanel.Dock="Top" Margin="0 10"/>
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top">
<TextBlock FontWeight="Bold" Text="Сидячий: "/>
<TextBlock TextWrapping="Wrap" Width="300"
Text="Нет работы или работа за столом "/>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top" Margin="0 10">
<TextBlock FontWeight="Bold" Text="Маленькая активность: "/>
<TextBlock TextWrapping="Wrap" Width="300"
Text="Мало физических работы или занятия спортом 1-3 раза в неделю "/>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top" Margin="0 10">
<TextBlock FontWeight="Bold" Text="Средняя активность: "/>
<TextBlock TextWrapping="Wrap" Width="300"
Text="Умеренная физическая работа или занятия спортом 3 - 5 дней в неделю"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top" Margin="0 10">
<TextBlock FontWeight="Bold" Text="Сильная активность: "/>
<TextBlock TextWrapping="Wrap" Width="300"
Text="Сильные физическая нагрузка или занятия спортом 6 - 7 дней в неделю"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top" Margin="0 10">
<TextBlock FontWeight="Bold" Text="Максимальная активность: "/>
<TextBlock TextWrapping="Wrap" Width="250"
Text="Сильная ежедневная физическая нагрузка или спорт и физическая работа"/>
</StackPanel>
</DockPanel>
</Window>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class BMRInfoWindow : Window
{
public BMRInfoWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,21 @@
<Window xmlns="https://github.com/avaloniaui"
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:vm="using:IposiGospodDemo.ViewModels"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="400"
Width="500" Height="400"
x:Class="IposiGospodDemo.Views.CharityInfoWindow"
x:DataType="vm:CharityInfoViewModel"
Title="Charity Info" Padding="10">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="20">
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" FontSize="18" FontWeight="Bold"/>
<Border Height="100" ClipToBounds="True">
<Image Source="{Binding ImagePath, Converter={StaticResource ImageConverter}}" Stretch="UniformToFill"/>
</Border>
<TextBlock Text="{Binding Description}" TextWrapping="WrapWithOverflow" TextAlignment="Center" Width="400"/>
</StackPanel>
</Window>

View File

@ -0,0 +1,20 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using IposiGospodDemo.Context;
using IposiGospodDemo.ViewModels;
namespace IposiGospodDemo.Views;
public partial class CharityInfoWindow : Window
{
public CharityInfoWindow()
{
InitializeComponent();
}
public CharityInfoWindow(Charity charity) : this()
{
DataContext = new CharityInfoViewModel(charity);
}
}

View File

@ -0,0 +1,34 @@
<Window xmlns="https://github.com/avaloniaui"
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"
Height="300" Width="400"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300"
x:Class="IposiGospodDemo.Views.ContactsWindow"
Title="ContactsWindow">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Height="50" Orientation="Vertical">
<Button Content="X" Foreground="Red" Click="CloseWindow_OnClick" HorizontalAlignment="Right" Margin="2"/>
<TextBlock Text="Контакты" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Vertical" DockPanel.Dock="Left" Spacing="10" Margin="20 20">
<TextBlock TextWrapping="Wrap" Text="Для получения дополнительной информации пожалуйста свяжитесь с координаторами"/>
<TextBlock>
<Run FontWeight="Black">
Телефон:
</Run>
<Run>
+55 11 9988 7766
</Run>
</TextBlock>
<TextBlock>
<Run FontWeight="Black">
Email:
</Run>
<Run>
coordinators@marathonskills.org
</Run>
</TextBlock>
</StackPanel>
</DockPanel>
</Window>

View File

@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class ContactsWindow : Window
{
public ContactsWindow()
{
InitializeComponent();
}
private void CloseWindow_OnClick(object? sender, RoutedEventArgs e)
{
Close();
}
}

View File

@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.CoordinatorMenuWindow"
Title="CoordinatorMenuWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical">
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class CoordinatorMenuWindow : Window
{
public CoordinatorMenuWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.EditRunnerProfileWindow"
Title="EditRunnerProfileWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical">
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class EditRunnerProfileWindow : Window
{
public EditRunnerProfileWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new RunnerMenuWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,56 @@
<Window xmlns="https://github.com/avaloniaui"
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:vm="using:IposiGospodDemo.ViewModels"
xmlns:local="using:IposiGospodDemo"
Width="1200"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.ListOfCharitiesWindow"
x:DataType="vm:ListOfCharitiesWindowViewModel"
Title="ListOfCharitiesWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical" Spacing="10">
<TextBlock Text="Список благотворительных организаций"
TextAlignment="Center" HorizontalAlignment="Center"
FontSize="32" />
<TextBlock Text="Это - список всех благотворительных учреждений, которые поддерживаются в Marathon Skills 2016. Спасибо за помощь, вы поддерживаете их, спонсируя бегунов!"
TextAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap"
FontSize="18" Width="800"/>
<ListBox ItemsSource="{Binding Charities}" Width="1000">
<ListBox.ItemTemplate>
<DataTemplate>
<Border HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Left" Width="800">
<Image MaxHeight="100" MaxWidth="100" Stretch="UniformToFill" HorizontalAlignment="Left"
Source="{Binding CharityLogo, Converter={StaticResource ImageConverter}}"
VerticalAlignment="Center"/>
<StackPanel Orientation="Vertical" Spacing="10" Width="700">
<TextBlock Text="{Binding CharityName}" FontSize="24" TextWrapping="Wrap"/>
<TextBlock Text="{Binding CharityDescription}" FontSize="20" TextWrapping="Wrap"/>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,22 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using IposiGospodDemo.ViewModels;
namespace IposiGospodDemo.Views;
public partial class ListOfCharitiesWindow : Window
{
public ListOfCharitiesWindow()
{
InitializeComponent();
DataContext = new ListOfCharitiesWindowViewModel();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MoreInformationWindow().Show();
Close();
}
}

View File

@ -0,0 +1,44 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.LoginWindow"
Title="LoginWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10 20" Spacing="10">
<TextBlock Text="Форма Авторизации" FontSize="24" HorizontalAlignment="Center" Foreground="Black"/>
<TextBlock Text="Пожалуйста, авторизуйтесь в системе, используя вас адрес электронной почты и пароль"
FontSize="18" TextWrapping="Wrap" TextAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
<TextBlock Text="Email: " VerticalAlignment="Center"/>
<TextBox Name="EmailBox" Watermark="Enter your email address"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
<TextBlock Text="Password: " VerticalAlignment="Center"/>
<TextBox Name="PasswordBox" Watermark="Enter your password"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="20" HorizontalAlignment="Center">
<Button Content="Login" Click="Login_OnClick"/>
<Button Content="Cancel" Click="Cancel_OnClick"/>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,85 @@
using System;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using IposiGospodDemo.Context;
using IposiGospodDemo.Helpers;
using Microsoft.EntityFrameworkCore;
namespace IposiGospodDemo.Views;
public partial class LoginWindow : Window
{
public LoginWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void Login_OnClick(object? sender, RoutedEventArgs e)
{
User user = DbHelper.Database.Users
.Include(u => u.Role)
.Single(u =>
EmailBox.Text != null && u.Email == EmailBox.Text.Trim() &&
PasswordBox.Text != null && u.Password == PasswordBox.Text.Trim());
Session.User = user;
Console.WriteLine("USERROLEID: " + user.Role.RoleId.ToString());
switch (user.Role.RoleId)
{
case 'R':
new RunnerMenuWindow().Show();
break;
case 'C':
new CoordinatorMenuWindow().Show();
break;
case 'A':
new AdministratorMenuWindow().Show();
break;
}
Close();
// try
// {
// User user = DbHelper.Database.Users
// .Include(u => u.Role)
// .Single(u =>
// EmailBox.Text != null && u.Email == EmailBox.Text.Trim() &&
// PasswordBox.Text != null && u.Password == PasswordBox.Text.Trim());
//
// Session.User = user;
// Console.WriteLine("USERROLEID: " + user.Role.RoleId.ToString());
// switch (user.Role.RoleId)
// {
// case 'R':
// new RunnerMenuWindow().Show();
// break;
// case 'C':
// new CoordinatorMenuWindow().Show();
// break;
// case 'A':
// new AdministratorMenuWindow().Show();
// break;
// }
// Close();
// }
// catch (Exception exception)
// {
// Console.WriteLine("Unlucky");
// Console.WriteLine(exception.Message);
// }
}
private void Cancel_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
}

View File

@ -3,18 +3,51 @@
xmlns:vm="using:IposiGospodDemo.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="IposiGospodDemo">
Title="IposiGospodDemo" Background="White">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Grid RowDefinitions="100 * Auto">
<StackPanel Grid.Row="0" Orientation="Vertical" Background="DarkGray">
<TextBlock FontSize="36" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" Text="{x:Static local:Session.Title}"/>
<TextBlock HorizontalAlignment="Center" Text="{x:Static local:Session.Location}" Margin="0 10 0 0" Foreground="LightGray"/>
<TextBlock HorizontalAlignment="Center" Text="{x:Static local:Session.Data}" Foreground="LightGray"/>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="100 * 100">
<StackPanel Grid.Column="1" Orientation="Vertical" VerticalAlignment="Center" Spacing="10">
<Button Padding="20" HorizontalAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black"
FontSize="24" CornerRadius="15" MinWidth="450" HorizontalContentAlignment="Center">
Я хочу стать бегуном
</Button>
<Button Padding="20" HorizontalAlignment="Center" Click="SwapToSponsorARunnerWindow_OnClick"
Background="LightGray" BorderThickness="1" BorderBrush="Black"
FontSize="24" CornerRadius="15" MinWidth="450" HorizontalContentAlignment="Center">
Я хочу стать спонсором бегуна
</Button>
<Button Padding="20" HorizontalAlignment="Center" Click="SwapToMoreInformationWindow_OnClick"
Background="LightGray" BorderThickness="1" BorderBrush="Black"
FontSize="24" CornerRadius="15" MinWidth="450" HorizontalContentAlignment="Center">
Я хочу узнать больше о событии
</Button>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Vertical" VerticalAlignment="Bottom">
<Button Content="Login" Padding="20 10" CornerRadius="10"
Click="SwapToLoginWindow_OnClick" Margin="0 20"
Background="LightGray" BorderThickness="1" BorderBrush="Black"/>
</StackPanel>
</Grid>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -1,4 +1,8 @@
using System;
using System.IO;
using System.Reflection;
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace IposiGospodDemo.Views;
@ -7,5 +11,36 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
Loaded += OnLoaded;
}
private void OnLoaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
string mainPath = Assembly.GetEntryAssembly().Location;
Session.AssetsPath = string.Concat(Path.GetDirectoryName(mainPath)!, "\\Assets\\");
}
private void SwapToLoginWindow_OnClick(object? sender, RoutedEventArgs e)
{
try
{
new LoginWindow().Show();
Close();
} catch (Exception exception)
{
Console.WriteLine("Unlucky, something went wrong by going to login window");
}
}
private void SwapToSponsorARunnerWindow_OnClick(object? sender, RoutedEventArgs e)
{
new SponsorARunnerWindow().Show();
Close();
}
private void SwapToMoreInformationWindow_OnClick(object? sender, RoutedEventArgs e)
{
new MoreInformationWindow().Show();
Close();
}
}

View File

@ -0,0 +1,66 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
Width="800" Height="600"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.MoreInformationWindow"
Title="MoreInformationWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" HorizontalAlignment="Center" Spacing="40">
<TextBlock Text="Подробная информация" FontSize="24" TextAlignment="Center"/>
<Grid ColumnDefinitions="320 320" RowDefinitions="120 120 120">
<Button Grid.Column="0" Grid.Row="0" Padding="20" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="Marathon Skills 2016" TextAlignment="Center"/>
</Button>
<Button Grid.Column="0" Grid.Row="1" Padding="20" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="Предыдущие результаты" TextAlignment="Center"/>
</Button>
<Button Grid.Column="0" Grid.Row="2" Padding="20" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100" Click="SwapToBMICalculatorWindow_OnClick"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="BMI Калькулятор" TextAlignment="Center"/>
</Button>
<Button Grid.Column="1" Grid.Row="0" Padding="20" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="Насколько долгий марафон" TextAlignment="Center"/>
</Button>
<Button Grid.Column="1" Grid.Row="1" Padding="5" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100" Click="SwapToListOfCharitiesWindow_OnClick"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="Список благотворительных организаций" TextAlignment="Center"/>
</Button>
<Button Grid.Column="1" Grid.Row="2" Padding="20" HorizontalAlignment="Center" VerticalContentAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100" Click="SwapToBMRCalculatorWindow_OnClick"
FontSize="24" CornerRadius="15" Width="300" HorizontalContentAlignment="Center">
<TextBlock TextWrapping="Wrap" Text="BMR Калькулятор"/>
</Button>
</Grid>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,38 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class MoreInformationWindow : Window
{
public MoreInformationWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void SwapToBMICalculatorWindow_OnClick(object? sender, RoutedEventArgs e)
{
new BMICalculatorWindow().Show();
Close();
}
private void SwapToBMRCalculatorWindow_OnClick(object? sender, RoutedEventArgs e)
{
new BMRCalculatorWindow().Show();
Close();
}
private void SwapToListOfCharitiesWindow_OnClick(object? sender, RoutedEventArgs e)
{
new ListOfCharitiesWindow().Show();
Close();
}
}

View File

@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.MyResultsWindow"
Title="MyResultsWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical">
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class MyResultsWindow : Window
{
public MyResultsWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new RunnerMenuWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,39 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.MySponsorshipWindow"
Title="MySponsorshipWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<DockPanel Grid.Row="1">
<TextBlock DockPanel.Dock="Top" Text="Мои спонсоры" HorizontalAlignment="Center" FontSize="24" Margin="0 20"/>
<TextBlock DockPanel.Dock="Top" Text="Здесь показаны все ваши спонсоры в Marathon Skills 2016"
HorizontalAlignment="Center" Margin="0 0 0 20"/>
<StackPanel Orientation="Vertical" DockPanel.Dock="Right">
<DataGrid>
</DataGrid>
</StackPanel>
</DockPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class MySponsorshipWindow : Window
{
public MySponsorshipWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new RunnerMenuWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.RegistrationForAnEventWindow"
Title="RegistrationForAnEventWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical">
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class RegistrationForAnEventWindow : Window
{
public RegistrationForAnEventWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new RunnerMenuWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
}

View File

@ -0,0 +1,66 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo" Height="600"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.RunnerMenuWindow"
Title="RunnerMenuWindow">
<Grid RowDefinitions="Auto * Auto">
<Border Grid.Row="0" Background="DarkGray" Padding="10">
<DockPanel VerticalAlignment="Center">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
<Button Content="Назад" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
Click="Logout_OnClick"/>
</DockPanel>
</Border>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="20 20" Spacing="20">
<TextBlock Text="Меню бегуна" FontSize="24" Foreground="Black" HorizontalAlignment="Center"/>
<Grid ColumnDefinitions="300 300" RowDefinitions="100 100 100" HorizontalAlignment="Center">
<Button Grid.Row="0" Grid.Column="0" Padding="20" HorizontalAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100" Width="300"
FontSize="24" CornerRadius="15" HorizontalContentAlignment="Center" Margin="10 10"
Click="RegistrationOnMarathon_OnClick">
<TextBlock TextWrapping="Wrap" Text="Регистрация на марафон" TextAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button Grid.Row="1" Grid.Column="0" Padding="20" HorizontalAlignment="Center"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100" Width="300"
FontSize="24" CornerRadius="15" HorizontalContentAlignment="Center" Margin="10 10"
Click="EditProfile_OnClick">
<TextBlock TextWrapping="Wrap" Text="Редактирование профиля" TextAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button Grid.Row="2" Grid.Column="0" Padding="20" HorizontalAlignment="Center" Width="300"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" HorizontalContentAlignment="Center" Margin="10 10"
Click="Contacts_OnClick">
<TextBlock TextWrapping="Wrap" Text="Контакты" TextAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button Grid.Row="0" Grid.Column="1" Padding="20" HorizontalAlignment="Center" Width="300"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" HorizontalContentAlignment="Center" Margin="10 10"
Click="MyResults_OnClick">
<TextBlock TextWrapping="Wrap" Text="Мои результаты" TextAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button Grid.Row="1" Grid.Column="1" Padding="20" HorizontalAlignment="Center" Width="300"
Background="LightGray" BorderThickness="1" BorderBrush="Black" Height="100"
FontSize="24" CornerRadius="15" HorizontalContentAlignment="Center" Margin="10 10"
Click="MySponsor_OnClick">
<TextBlock TextWrapping="Wrap" Text="Мой спонсор" TextAlignment="Center" VerticalAlignment="Center"/>
</Button>
</Grid>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,56 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class RunnerMenuWindow : Window
{
public RunnerMenuWindow()
{
InitializeComponent();
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void Logout_OnClick(object? sender, RoutedEventArgs e)
{
Session.User = null;
new MainWindow().Show();
Close();
}
private void RegistrationOnMarathon_OnClick(object? sender, RoutedEventArgs e)
{
new RegistrationForAnEventWindow().Show();
Close();
}
private void EditProfile_OnClick(object? sender, RoutedEventArgs e)
{
new EditRunnerProfileWindow().Show();
Close();
}
private void Contacts_OnClick(object? sender, RoutedEventArgs e)
{
new ContactsWindow().Show();
}
private void MyResults_OnClick(object? sender, RoutedEventArgs e)
{
new MyResultsWindow().Show();
Close();
}
private void MySponsor_OnClick(object? sender, RoutedEventArgs e)
{
new MySponsorshipWindow().Show();
Close();
}
}

View File

@ -0,0 +1,9 @@
<Window xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.RunnerRegistrationWindow"
Title="RunnerRegistrationWindow">
Welcome to Avalonia!
</Window>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class RunnerRegistrationWindow : Window
{
public RunnerRegistrationWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,95 @@
<Window xmlns="https://github.com/avaloniaui"
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="using:IposiGospodDemo" Height="600" Width="800"
xmlns:vm="using:IposiGospodDemo.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="IposiGospodDemo.Views.SponsorARunnerWindow"
x:DataType="vm:SponsorARunnerWindowViewModel"
Title="SponsorARunnerWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<Border Grid.Row="1" Padding=" 20">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="Спонсор бегуна" FontSize="24" HorizontalAlignment="Center"/>
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center"
Text="Пожалуйста выберите бегуна, которого вы хотели бы спонсировать и сумму, которую вы хотели бы спонсировать. Спасибо ща вашу поддержку бегунов и их благотворительных учреждений"
FontSize="18" Padding="0 20"/>
<StackPanel Orientation="Vertical" DockPanel.Dock="Left">
<TextBlock HorizontalAlignment="Center" Text="Информация о спонсоре" FontSize="24" FontWeight="Bold" Margin="0 0 0 20"/>
<Grid ColumnDefinitions="120 200" RowDefinitions="50 50 50 50 50 50">
<TextBlock Grid.Column="0" Grid.Row="0" Text="Ваше имя: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Бегун: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Карта: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Номер карты: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="4" Text="Срок действия: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="5" Text="CVC: " HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="0" Watermark="Ваше имя"
Text="{Binding SponsorName, Mode=TwoWay}" VerticalAlignment="Center"/>
<ComboBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Width="200"
ItemsSource="{Binding Runners}"
SelectedItem="{Binding SelectedRunner}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding EmailNavigation, Converter={StaticResource RunnerConverter}}"
FontSize="10"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Column="1" Grid.Row="2" Watermark="Владелец карты"
Text="{Binding CardOwner, Mode=TwoWay}" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="3" Watermark="1234 1234 1234 1234"
Text="{Binding CardNumber, Mode=TwoWay}" VerticalAlignment="Center"/>
<StackPanel Grid.Column="1" Grid.Row="4" Orientation="Horizontal" Width="200" Spacing="10">
<TextBox Watermark="01" Text="{Binding Month, Mode=TwoWay}"
VerticalAlignment="Center" MinWidth="40" Width="40"/>
<TextBox Watermark="2017" Text="{Binding Year, Mode=TwoWay}"
VerticalAlignment="Center" Width="50"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="5" Watermark="123" VerticalAlignment="Center" Width="70"
Text="{Binding Cvc, Mode=TwoWay}" HorizontalAlignment="Left"/>
</Grid>
</StackPanel>
<StackPanel DockPanel.Dock="Right" HorizontalAlignment="Center" Spacing="10">
<TextBlock HorizontalAlignment="Center" Text="Благотворительность" FontSize="24" FontWeight="Bold"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="30">
<TextBlock Text="{Binding SelectedCharity.CharityName}"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="i" FontWeight="Bold" Foreground="Orange" FontSize="24" CornerRadius="50" BorderBrush="Orange"
BorderThickness="2" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Command="{Binding OpenCharityInfoWindow}"
VerticalContentAlignment="Center" Background="Transparent" Height="30" Width="30" Padding="5 0"/>
</StackPanel>
<TextBlock HorizontalAlignment="Center" Text="Сумма пожертвования" FontSize="24" FontWeight="Bold"/>
<TextBlock FontSize="52" HorizontalAlignment="Center">
<Run>$</Run>
<Run Text="{Binding Sum}"/>
</TextBlock>
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Center">
<Button Content="-" VerticalAlignment="Center" VerticalContentAlignment="Center" Command="{Binding DecreaseSumCommand}"/>
<TextBox Text="{Binding Sum}" Width="100" TextAlignment="Center"/>
<Button Content="+" VerticalAlignment="Center" VerticalContentAlignment="Center" Command="{Binding IncreaseSumCommand}" ClickMode="Press"/>
</StackPanel>
<StackPanel Margin="0 20 0 0" Spacing="20" HorizontalAlignment="Center" Orientation="Horizontal">
<Button Content="Заплатить" HorizontalAlignment="Center" Click="Pay_OnClick"/>
<Button Content="Отмена" HorizontalAlignment="Center" Click="GoBack_OnClick"/>
</StackPanel>
</StackPanel>
</DockPanel>
</Border>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,95 @@
using System;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using IposiGospodDemo.Context;
using IposiGospodDemo.Helpers;
using IposiGospodDemo.ViewModels;
namespace IposiGospodDemo.Views;
public partial class SponsorARunnerWindow : Window
{
private SponsorARunnerWindowViewModel? _viewModel;
public SponsorARunnerWindow()
{
InitializeComponent();
DataContext = new SponsorARunnerWindowViewModel();
Loaded += OnLoaded;
}
private void OnLoaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
_viewModel = (DataContext as SponsorARunnerWindowViewModel)!;
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
private void Pay_OnClick(object? sender, RoutedEventArgs e)
{
string? SponsorName = _viewModel?.SponsorName;
string? CardOwner = _viewModel?.CardOwner;
string? CardNumber = _viewModel?.CardNumber;
string? Month = _viewModel?.Month;
string? Year = _viewModel?.Year;
string? Cvc = _viewModel?.Cvc;
if (_viewModel.SelectedRunner == null)
{
Console.WriteLine("Не выбран бегун");
return;
}
if (string.IsNullOrWhiteSpace(SponsorName) ||
string.IsNullOrWhiteSpace(CardOwner) ||
string.IsNullOrWhiteSpace(CardNumber) ||
string.IsNullOrWhiteSpace(Month) ||
string.IsNullOrWhiteSpace(Year) ||
string.IsNullOrWhiteSpace(Cvc))
{
Console.WriteLine("Ошибка: Заполните все поля!");
return;
}
if (!long.TryParse(CardNumber.Replace(" ", ""), out _) || CardNumber.Length < 16)
{
Console.WriteLine("Ошибка: Некорректный номер карты!");
return;
}
if (!int.TryParse(Month, out var month) || month < 1 || month > 12)
{
Console.WriteLine("Ошибка: Некорректный месяц!");
return;
}
if (!int.TryParse(Year, out var year))
{
Console.WriteLine("Ошибка: Некорректный год!");
return;
}
if (!int.TryParse(Cvc, out _) || Cvc.Length != 3)
{
Console.WriteLine("Ошибка: Некорректный CVC!");
return;
}
Sponsorship newSponsorship = new Sponsorship();
newSponsorship.SponsorName = SponsorName;
newSponsorship.Registration = _viewModel.SelectedRunner.Registrations.FirstOrDefault()!;
newSponsorship.Amount = _viewModel.Sum;
DbHelper.Database.Sponsorships.Add(newSponsorship);
new SponsorshipConfirmationWindow(_viewModel.SelectedRunner.EmailNavigation, _viewModel.Sum, _viewModel.SelectedCharity.CharityName).Show();
Close();
}
}

View File

@ -0,0 +1,9 @@
<Window xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.SponsorRegistrationWindow"
Title="SponsorRegistrationWindow">
Welcome to Avalonia!
</Window>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace IposiGospodDemo.Views;
public partial class SponsorRegistrationWindow : Window
{
public SponsorRegistrationWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,43 @@
<Window xmlns="https://github.com/avaloniaui"
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:vm="using:IposiGospodDemo.ViewModels"
xmlns:local="using:IposiGospodDemo"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.SponsorshipConfirmationWindow"
x:DataType="vm:SponsorshipConfirmationWindowViewModel"
Title="SponsorshipConfirmationWindow">
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Background="DarkGray" Orientation="Horizontal"
VerticalAlignment="Center">
<Button Content="Назад" Margin="10" Click="GoBack_OnClick"/>
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
FontSize="24" FontWeight="Bold" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" HorizontalAlignment="Center">
<TextBlock Text="Спасибо за вашу спонсорскую поддержку!"
FontSize="24" HorizontalAlignment="Center"/>
<TextBlock Text="Спасибо за поддержку бегуна в Marathon Skills 2016! Ваше вожертвование пойдет в его благотворительную организацию"
TextWrapping="Wrap" TextAlignment="Center"
FontSize="20" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding SupportedRunner, Converter={StaticResource RunnerConverter}}"
FontSize="20" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding CharityName}" FontSize="24"
HorizontalAlignment="Center"/>
<TextBlock FontSize="52" HorizontalAlignment="Center">
<Run Text="$"/>
<Run Text="{Binding Amount}"/>
</TextBlock>
<Button Content="Назад" Margin="10" Click="GoBack_OnClick" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using IposiGospodDemo.Context;
using IposiGospodDemo.ViewModels;
namespace IposiGospodDemo.Views;
public partial class SponsorshipConfirmationWindow : Window
{
public SponsorshipConfirmationWindow()
{
InitializeComponent();
}
public SponsorshipConfirmationWindow(User user, decimal amount, String charityName)
{
InitializeComponent();
DataContext = new SponsorshipConfirmationWindowViewModel(user, amount, charityName);
}
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
{
new MainWindow().Show();
Close();
}
}