some ui fixes
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
using Autofac;
|
||||
using Autofac.Extras.AggregateService;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using JiraTimeBot.Ui.ViewModels;
|
||||
using JiraTimeBot.UI.Tray;
|
||||
using System;
|
||||
using System.Threading;
|
||||
@@ -22,6 +19,8 @@ namespace JiraTimeBot.Ui
|
||||
{
|
||||
if (Mutex.WaitOne(TimeSpan.Zero, true))
|
||||
{
|
||||
Bootstrapper bootstrapper = new Bootstrapper();
|
||||
_container = bootstrapper.Build();
|
||||
Mutex.ReleaseMutex();
|
||||
}
|
||||
else
|
||||
@@ -34,32 +33,6 @@ namespace JiraTimeBot.Ui
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
builder.Register(c =>
|
||||
{
|
||||
var result = new MainWindow();
|
||||
result.DataContext = c.Resolve<ApplicationViewModel>();
|
||||
return result;
|
||||
}).SingleInstance();
|
||||
|
||||
builder.RegisterType<ApplicationModel>().SingleInstance();
|
||||
|
||||
builder.RegisterType<ApplicationViewModel>().SingleInstance();
|
||||
builder.RegisterType<MainPageViewModel>().SingleInstance();
|
||||
builder.RegisterType<SettingsViewModel>().SingleInstance();
|
||||
|
||||
builder.RegisterType<MainPage>().SingleInstance();
|
||||
builder.RegisterType<SettingsPage>().SingleInstance();
|
||||
|
||||
builder.RegisterAggregateService<IRegisteredViewModels>();
|
||||
|
||||
builder.RegisterType<ApplicationNavigator>()
|
||||
.As<IApplicationNavigator>()
|
||||
.SingleInstance();
|
||||
|
||||
_container = builder.Build();
|
||||
|
||||
var mainWindow = _container.Resolve<MainWindow>();
|
||||
var nav = _container.Resolve<IApplicationNavigator>();
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Autofac;
|
||||
using Autofac.Extras.AggregateService;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using JiraTimeBot.Ui.ViewModels;
|
||||
|
||||
namespace JiraTimeBot.Ui
|
||||
{
|
||||
public class Bootstrapper
|
||||
{
|
||||
public IContainer Build()
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
builder.Register(c =>
|
||||
{
|
||||
var result = new MainWindow();
|
||||
result.DataContext = c.Resolve<ApplicationViewModel>();
|
||||
return result;
|
||||
}).SingleInstance();
|
||||
|
||||
builder.RegisterType<ApplicationModel>().SingleInstance();
|
||||
builder.RegisterType<SettingsModel>().SingleInstance();
|
||||
builder.RegisterType<MainModel>().SingleInstance();
|
||||
|
||||
builder.RegisterType<ApplicationViewModel>().SingleInstance();
|
||||
builder.RegisterType<MainPageViewModel>().SingleInstance();
|
||||
builder.RegisterType<SettingsViewModel>().SingleInstance();
|
||||
|
||||
builder.RegisterType<MainPage>().SingleInstance();
|
||||
builder.RegisterType<SettingsPage>().SingleInstance();
|
||||
|
||||
builder.RegisterAggregateService<IRegisteredViewModels>();
|
||||
|
||||
builder.RegisterType<ApplicationNavigator>()
|
||||
.As<IApplicationNavigator>()
|
||||
.SingleInstance();
|
||||
|
||||
var container = builder.Build();
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -109,11 +113,15 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationNavigator.cs" />
|
||||
<Compile Include="Bootstrapper.cs" />
|
||||
<Compile Include="Commands\RelayCommand%27.cs" />
|
||||
<Compile Include="Commands\RelayCommand.cs" />
|
||||
<Compile Include="Commands\RelayCommandAsync%27.cs" />
|
||||
<Compile Include="IApplicationNavigator.cs" />
|
||||
<Compile Include="Models\ApplicationModel.cs" />
|
||||
<Compile Include="Models\IModel.cs" />
|
||||
<Compile Include="Models\MainModel.cs" />
|
||||
<Compile Include="Models\SettingsModel.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="ViewModels\ApplicationViewModel.cs" />
|
||||
<Compile Include="ViewModels\MainPageViewModel.cs" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace JiraTimeBot.Ui.Models
|
||||
{
|
||||
public class ApplicationModel
|
||||
public class ApplicationModel : IModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using JiraTimeBot.Ui.Annotations;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace JiraTimeBot.Ui.Models
|
||||
{
|
||||
public interface IModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface INotifyModel : IModel, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract class NotifyModelBase : INotifyModel
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace JiraTimeBot.Ui.Models
|
||||
{
|
||||
public class MainModel : IModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace JiraTimeBot.Ui.Models
|
||||
{
|
||||
public class SettingsModel : IModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:JiraTimeBot.Ui"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DatePicker">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="xctk:DateTimePicker">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,26 +1,16 @@
|
||||
using Aeroclub.CL.ASIA.Application.UI.Wpf.Commands;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class ApplicationViewModel : ViewModelBase
|
||||
public class ApplicationViewModel : ViewModelBase<ApplicationModel>
|
||||
{
|
||||
private readonly Func<IApplicationNavigator> _appNavigator;
|
||||
|
||||
private ViewModelBase _currentViewModel;
|
||||
|
||||
public ApplicationViewModel(Func<IApplicationNavigator> appNavigator)
|
||||
public ApplicationViewModel(ApplicationModel model) : base(model)
|
||||
{
|
||||
_appNavigator = appNavigator;
|
||||
|
||||
NavigateToSettings = new RelayCommand(() =>
|
||||
{
|
||||
_appNavigator().NavigateToSettings();
|
||||
});
|
||||
|
||||
NavigateToMain = new RelayCommand(() =>
|
||||
{
|
||||
_appNavigator().NavigateToMain();
|
||||
});
|
||||
}
|
||||
|
||||
public ViewModelBase CurrentViewModel
|
||||
@@ -32,9 +22,5 @@ namespace JiraTimeBot.Ui.ViewModels
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand NavigateToSettings { get; set; }
|
||||
|
||||
public RelayCommand NavigateToMain { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,24 @@
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class MainPageViewModel : ViewModelBase
|
||||
{
|
||||
using Aeroclub.CL.ASIA.Application.UI.Wpf.Commands;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class MainPageViewModel : ViewModelBase<MainModel>
|
||||
{
|
||||
private readonly Func<IApplicationNavigator> _navigator;
|
||||
|
||||
public MainPageViewModel(MainModel model, Func<IApplicationNavigator> navigator) : base(model)
|
||||
{
|
||||
_navigator = navigator;
|
||||
OpenSettingsCommand = new RelayCommand(NavigateToSettings);
|
||||
}
|
||||
|
||||
public RelayCommand OpenSettingsCommand { get; set; }
|
||||
|
||||
private void NavigateToSettings()
|
||||
{
|
||||
_navigator().NavigateToSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,25 @@
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
using Aeroclub.CL.ASIA.Application.UI.Wpf.Commands;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : ViewModelBase<SettingsModel>
|
||||
{
|
||||
private readonly Func<IApplicationNavigator> _navigator;
|
||||
|
||||
public SettingsViewModel(SettingsModel model, Func<IApplicationNavigator> navigator) : base(model)
|
||||
{
|
||||
_navigator = navigator;
|
||||
SaveSettingsCommand = new RelayCommand(SaveSettings);
|
||||
}
|
||||
|
||||
public RelayCommand SaveSettingsCommand { get; set; }
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
//TODO: SaveSettingsHere
|
||||
_navigator().NavigateToMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using JiraTimeBot.Ui.Annotations;
|
||||
using JiraTimeBot.Ui.Models;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace JiraTimeBot.Ui.ViewModels
|
||||
{
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
public abstract class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -14,4 +15,14 @@ namespace JiraTimeBot.Ui.ViewModels
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ViewModelBase<T> : ViewModelBase where T : IModel
|
||||
{
|
||||
protected T Model { get; }
|
||||
|
||||
protected ViewModelBase(T model)
|
||||
{
|
||||
Model = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,42 @@
|
||||
xmlns:local="clr-namespace:JiraTimeBot.Ui"
|
||||
xmlns:viewModels="clr-namespace:JiraTimeBot.Ui.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
Height="100"
|
||||
Width="400"
|
||||
d:DataContext="{d:DesignInstance viewModels:MainPageViewModel}" >
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary Source="../Styles.xaml"/>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Row="0" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0"
|
||||
Orientation="Vertical">
|
||||
<Button Content="Настройки" Command="{Binding Path=OpenSettingsCommand}" />
|
||||
<DatePicker />
|
||||
<Button>
|
||||
<TextBlock TextWrapping="Wrap" TextAlignment="Center" Text="Проставить на дату" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2">
|
||||
<CheckBox>Тестовый прогон</CheckBox>
|
||||
<Button Content="Проставить время"/>
|
||||
<Button Content="Митинг"/>
|
||||
<Button Content="Отменить"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<TextBox Grid.Row="0" Grid.Column="1"
|
||||
IsReadOnly="True"
|
||||
Width="400"
|
||||
Height="300"
|
||||
></TextBox>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Application"></TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
Title="ApplicationWindow"
|
||||
Icon="../app.ico"
|
||||
ShowInTaskbar="True"
|
||||
ResizeMode="NoResize"
|
||||
d:DesignWidth="517.579" d:DesignHeight="260.977"
|
||||
>
|
||||
<Window.Resources>
|
||||
@@ -22,20 +23,7 @@
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0"
|
||||
Content="NavToMain" Command="{Binding Path=NavigateToMain}" />
|
||||
<Button Grid.Row="0" Grid.Column="1"
|
||||
Content="NavToSettings" Command="{Binding Path=NavigateToSettings}" />
|
||||
<ContentControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Content="{Binding Path=CurrentViewModel}" />
|
||||
<ContentControl Content="{Binding Path=CurrentViewModel}" />
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
|
||||
@@ -5,15 +5,26 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:JiraTimeBot.Ui"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:viewModels="clr-namespace:JiraTimeBot.Ui.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="250"
|
||||
d:DesignHeight="300"
|
||||
d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}"
|
||||
>
|
||||
|
||||
<Grid>
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center"></Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="../Styles.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Width="250" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -92,6 +103,7 @@
|
||||
<CheckBox Content="Добавлять описание" />
|
||||
</StackPanel>
|
||||
<Button Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Command="{Binding Path=SaveSettingsCommand}"
|
||||
Content="Сохранить"/>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user