Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit c2384b74 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

more work on gui

parent c4d1b0c9
Branches
Tags
No related merge requests found
......@@ -70,8 +70,9 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="ViewModel\HomeViewModel.cs" />
<Compile Include="ViewModel\IMainView.cs" />
<Compile Include="ViewModel\MainWindowViewModel.cs" />
<Compile Include="ViewModel\ApplicationViewModel.cs" />
<Compile Include="ViewModel\ObservableObject.cs" />
<Compile Include="ViewModel\RelayCommand.cs" />
<Compile Include="ViewModel\HashComponentDataViewModel.cs" />
......@@ -79,6 +80,9 @@
<Compile Include="Views\HashComponentData.xaml.cs">
<DependentUpon>HashComponentData.xaml</DependentUpon>
</Compile>
<Compile Include="Views\HomeView.xaml.cs">
<DependentUpon>HomeView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\VerifyInputData.xaml.cs">
<DependentUpon>VerifyInputData.xaml</DependentUpon>
</Compile>
......@@ -98,6 +102,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\HomeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\VerifyInputData.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -4,34 +4,25 @@
xmlns:viewModel="clr-namespace:HashingTool.ViewModel"
xmlns:views="clr-namespace:HashingTool.Views"
x:Class="HashingTool.MainWindow"
Title="VECTO Hashing Tool" Height="552" Width="593">
Title="VECTO Hashing Tool" Height="243" Width="593">
<Window.DataContext>
<viewModel:MainWindowViewModel />
<viewModel:ApplicationViewModel />
</Window.DataContext>
<Window.Resources>
<DataTemplate DataType="{x:Type viewModel:HomeViewModel}">
<views:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:HashComponentDataViewModel}">
<views:HashComponentData />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:VerifyInputDataViewModel}">
<views:VerifyInputData />
</DataTemplate>
</Window.Resources>
<Grid Margin="10">
<DockPanel>
<Border DockPanel.Dock="Left" BorderBrush="Black" BorderThickness="0,0,1,0">
<ItemsControl ItemsSource="{Binding MainViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,5">
<Button Content="{Binding Name}" Margin="2,5"
Command="{Binding DataContext.ChangeViewCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding }" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
<ContentControl Content="{Binding CurrentViewModel}" />
</DockPanel>
</Grid>
</Window>
\ No newline at end of file
......@@ -7,30 +7,31 @@ using HashingTool.Views;
namespace HashingTool.ViewModel
{
public class MainWindowViewModel : ObservableObject
public class ApplicationViewModel : ObservableObject
{
private ICommand _changeViewCommand;
public static ICommand HomeView;
private IMainView _currentView;
private List<IMainView> _availableViews;
private ICommand _homeView;
public static List<IMainView> AvailableViews;
public MainWindowViewModel()
public ApplicationViewModel()
{
//var homeView = new HomeViewModel();
_availableViews = new List<IMainView> {
var homeView = new HomeViewModel(this);
AvailableViews = new List<IMainView> {
new HashComponentDataViewModel(this),
new VerifyInputDataViewModel(this)
};
CurrentViewModel = _availableViews[0];
CurrentViewModel = homeView;
_homeView = new RelayCommand(() => CurrentViewModel = _availableViews[0]);
HomeView = new RelayCommand(() => CurrentViewModel = homeView);
}
public List<IMainView> MainViewModels
{
get { return _availableViews ?? (_availableViews = new List<IMainView>()); }
get { return AvailableViews ?? (AvailableViews = new List<IMainView>()); }
}
public IMainView CurrentViewModel
......@@ -50,9 +51,9 @@ namespace HashingTool.ViewModel
get { return _changeViewCommand ?? (_changeViewCommand = new RelayCommand<IMainView>(ChangeViewModel)); }
}
public ICommand ShowHomeView
public ICommand ShowHomeViewCommand
{
get { return _homeView; }
get { return HomeView; }
}
private void ChangeViewModel(IMainView mainView)
......
using System;
using System.ComponentModel;
using System.Windows.Input;
using HashingTool.Model;
namespace HashingTool.ViewModel
{
public class HashComponentDataViewModel : ObservableObject, IMainView
{
private MainWindowViewModel _homeView;
private readonly ApplicationViewModel _applicationViewModel;
public HashComponentDataViewModel(MainWindowViewModel homeView)
public HashComponentDataViewModel() {}
public HashComponentDataViewModel(ApplicationViewModel applicationViewModel)
{
_homeView = homeView;
_applicationViewModel = applicationViewModel;
}
public string Name
{
get { return "Hash Component Data"; }
}
public ICommand ShowHomeViewCommand
{
get { return ApplicationViewModel.HomeView; }
}
}
}
using System.Collections.Generic;
using System.Windows.Input;
namespace HashingTool.ViewModel
{
public class HomeViewModel : ObservableObject, IMainView
{
private readonly ApplicationViewModel _applicationViewModel;
public HomeViewModel() {}
public HomeViewModel(ApplicationViewModel applicationViewModel)
{
_applicationViewModel = applicationViewModel;
}
public string Name
{
get { return "Home"; }
}
public List<IMainView> MainViewModels
{
get { return ApplicationViewModel.AvailableViews; }
}
public ICommand ChangeViewCommand
{
get { return _applicationViewModel == null ? null : _applicationViewModel.ChangeViewCommand; }
}
public ICommand ShowHomeViewCommand
{
get { return ApplicationViewModel.HomeView; }
}
}
}
using System.Windows.Input;
namespace HashingTool.ViewModel
{
public interface IMainView
{
string Name { get; }
ICommand ShowHomeViewCommand { get; }
}
}
namespace HashingTool.ViewModel
using System.Windows.Input;
namespace HashingTool.ViewModel
{
public class VerifyInputDataViewModel : ObservableObject, IMainView
{
public VerifyInputDataViewModel(MainWindowViewModel mainWindowViewModel) {}
private readonly ApplicationViewModel _applicationViewModel;
public VerifyInputDataViewModel() {}
public VerifyInputDataViewModel(ApplicationViewModel applicationViewModel)
{
_applicationViewModel = applicationViewModel;
}
public string Name
{
get { return "Verify Input Data"; }
}
public ICommand ShowHomeViewCommand
{
get { return ApplicationViewModel.HomeView; }
}
}
}
<UserControl x:Class="HashingTool.Views.HashComponentData"
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ViewModel="clr-namespace:HashingTool.ViewModel" x:Class="HashingTool.Views.HashComponentData"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.DataContext>
<ViewModel:HashComponentDataViewModel />
</UserControl.DataContext>
<Grid>
<Label Content="Hash Component Data" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
<Label HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"
Content="{Binding Name}" />
<Button Content="Home" Command="{Binding ShowHomeViewCommand}" HorizontalAlignment="Left" Margin="201,194,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</UserControl>
\ No newline at end of file
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModel="clr-namespace:HashingTool.ViewModel" x:Class="HashingTool.Views.HomeView"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.DataContext>
<viewModel:HomeViewModel/>
</Grid.DataContext>
<ItemsControl ItemsSource="{Binding MainViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,5">
<Button Content="{Binding Name}" Margin="2,5"
Command="{Binding DataContext.ChangeViewCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding ''}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
using System.Windows.Controls;
namespace HashingTool.Views
{
/// <summary>
/// Interaction logic for HomeView.xaml
/// </summary>
public partial class HomeView : UserControl
{
public HomeView()
{
InitializeComponent();
}
}
}
<UserControl x:Class="HashingTool.Views.VerifyInputData"
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ViewModel="clr-namespace:HashingTool.ViewModel" x:Class="HashingTool.Views.VerifyInputData"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Label Content="Verify Input Data" HorizontalAlignment="Left" Margin="131,115,0,0" VerticalAlignment="Top" />
<Grid.DataContext>
<ViewModel:VerifyInputDataViewModel />
</Grid.DataContext>
<Label Content="{Binding Name}" HorizontalAlignment="Left" Margin="131,115,0,0" VerticalAlignment="Top" />
<Button Content="Home" Command="{Binding ShowHomeViewCommand}" HorizontalAlignment="Left" Margin="150,201,0,0"
VerticalAlignment="Top" Width="75" />
</Grid>
</UserControl>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment