Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
savaged committed Apr 4, 2019
1 parent 0a33762 commit dd052a1
Show file tree
Hide file tree
Showing 46 changed files with 1,169 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.config
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
13 changes: 13 additions & 0 deletions App.xaml
@@ -0,0 +1,13 @@
<Application x:Class="UiDesignTinkering.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UiDesignTinkering"
Startup="Application_Startup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
19 changes: 19 additions & 0 deletions App.xaml.cs
@@ -0,0 +1,19 @@
using System.Windows;

namespace UiDesignTinkering
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
var mainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
};
mainWindow.Show();
}
}
}
6 changes: 6 additions & 0 deletions BaseModel.cs
@@ -0,0 +1,6 @@
namespace UiDesignTinkering
{
public abstract class BaseModel : IModel
{
}
}
8 changes: 8 additions & 0 deletions BaseViewModel.cs
@@ -0,0 +1,8 @@
using GalaSoft.MvvmLight;

namespace UiDesignTinkering
{
public abstract class BaseViewModel : ViewModelBase, IViewModel
{
}
}
6 changes: 6 additions & 0 deletions Client.cs
@@ -0,0 +1,6 @@
namespace UiDesignTinkering
{
public class Client : BaseModel
{
}
}
12 changes: 12 additions & 0 deletions ClientView.xaml
@@ -0,0 +1,12 @@
<UserControl x:Class="UiDesignTinkering.ClientView"
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:local="clr-namespace:UiDesignTinkering"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock>Client</TextBlock>
</Grid>
</UserControl>
28 changes: 28 additions & 0 deletions ClientView.xaml.cs
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UiDesignTinkering
{
/// <summary>
/// Interaction logic for ClientView.xaml
/// </summary>
public partial class ClientView : UserControl
{
public ClientView()
{
InitializeComponent();
}
}
}
7 changes: 7 additions & 0 deletions IMainViewModel.cs
@@ -0,0 +1,7 @@
namespace UiDesignTinkering
{
public interface IMainViewModel : IViewModel
{
bool HasFocus { get; set; }
}
}
6 changes: 6 additions & 0 deletions IModel.cs
@@ -0,0 +1,6 @@
namespace UiDesignTinkering
{
public interface IModel
{
}
}
7 changes: 7 additions & 0 deletions IViewModel.cs
@@ -0,0 +1,7 @@
namespace UiDesignTinkering
{
public interface IViewModel
{

}
}
6 changes: 6 additions & 0 deletions InsuranceStore.cs
@@ -0,0 +1,6 @@
namespace UiDesignTinkering
{
public class InsuranceStore : Store
{
}
}
12 changes: 12 additions & 0 deletions InsuranceView.xaml
@@ -0,0 +1,12 @@
<UserControl x:Class="UiDesignTinkering.InsuranceView"
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:local="clr-namespace:UiDesignTinkering"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock>Insurance</TextBlock>
</Grid>
</UserControl>
28 changes: 28 additions & 0 deletions InsuranceView.xaml.cs
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UiDesignTinkering
{
/// <summary>
/// Interaction logic for InsuranceView.xaml
/// </summary>
public partial class InsuranceView : UserControl
{
public InsuranceView()
{
InitializeComponent();
}
}
}
20 changes: 20 additions & 0 deletions InverseBoolToVisibilityConverter.cs
@@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows.Controls;
using System.Windows.Data;

namespace UiDesignTinkering
{
class InverseBoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new BooleanToVisibilityConverter().Convert(value, targetType, parameter, culture);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return new BooleanToVisibilityConverter().ConvertBack(value, targetType, parameter, culture);
}
}
}
16 changes: 16 additions & 0 deletions MainViewModel.cs
@@ -0,0 +1,16 @@
using GalaSoft.MvvmLight;

namespace UiDesignTinkering
{
public class MainViewModel<T> : BaseViewModel, IMainViewModel
where T : IModel
{
private bool _hasFocus;

public bool HasFocus
{
get => _hasFocus;
set => Set(ref _hasFocus, value);
}
}
}
13 changes: 13 additions & 0 deletions MainViews.cs
@@ -0,0 +1,13 @@
namespace UiDesignTinkering
{
public enum MainViews
{
ServiceCharge,
Insurance,
Rent,
Scheme,
Client,
News,
Task
}
}
72 changes: 72 additions & 0 deletions MainWindow.xaml
@@ -0,0 +1,72 @@
<Window x:Class="UiDesignTinkering.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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="clr-namespace:UiDesignTinkering"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<local:RadioButtonCheckedConverter x:Key="RadioButtonConverter"/>
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
</Window.Resources>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.ServiceCharge}}">
Service Charge
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.Insurance}}">
Insurance
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.Rent}}">
Rent
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.Scheme}}">
Scheme
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.Client}}">
Client
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.News}}">
News
</RadioButton>
<RadioButton GroupName="MainViews"
IsChecked="{Binding MainViewSelected, Converter={StaticResource RadioButtonConverter}, ConverterParameter={x:Static local:MainViews.Task}}">
Task
</RadioButton>
</StackPanel>
<Grid Grid.Column="1" Margin="5">
<StackPanel Visibility="{Binding ServiceChargeStoreViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:ServiceChargeView DataContext="{Binding ServiceChargeStoreViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding InsuranceStoreViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:InsuranceView DataContext="{Binding InsuranceStoreViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding RentStoreViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:RentView DataContext="{Binding RentStoreViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding SchemeViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:SchemeView DataContext="{Binding SchemeViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding ClientViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:ClientView DataContext="{Binding ClientViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding NewsViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:NewsView DataContext="{Binding NewsViewModel}"/>
</StackPanel>
<StackPanel Visibility="{Binding TaskViewModel.HasFocus, Converter={StaticResource BoolToVisibilityConverter}}">
<local:TaskView DataContext="{Binding TaskViewModel}"/>
</StackPanel>
</Grid>
</Grid>
</Window>
27 changes: 27 additions & 0 deletions MainWindow.xaml.cs
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UiDesignTinkering
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}


}
}
66 changes: 66 additions & 0 deletions MainWindowViewModel.cs
@@ -0,0 +1,66 @@
using GalaSoft.MvvmLight;
using System.Collections.Generic;

namespace UiDesignTinkering
{
public class MainWindowViewModel : ViewModelBase
{
private MainViews _mainViewSelected;
private readonly IDictionary<int, IMainViewModel> _mainViewModels;

public MainWindowViewModel()
{
ServiceChargeStoreViewModel = new MainViewModel<ServiceChargeStore>();
InsuranceStoreViewModel = new MainViewModel<InsuranceStore>();
RentStoreViewModel = new MainViewModel<RentStore>();
SchemeViewModel = new MainViewModel<Scheme>();
ClientViewModel = new MainViewModel<Client>();
NewsViewModel = new MainViewModel<News>();
TaskViewModel = new MainViewModel<Task>();
_mainViewModels = new Dictionary<int, IMainViewModel>
{
{ (int)MainViews.ServiceCharge, ServiceChargeStoreViewModel },
{ (int)MainViews.Insurance, InsuranceStoreViewModel },
{ (int)MainViews.Rent, RentStoreViewModel },
{ (int)MainViews.Scheme, SchemeViewModel },
{ (int)MainViews.Client, ClientViewModel },
{ (int)MainViews.News, NewsViewModel },
{ (int)MainViews.Task, TaskViewModel }
};
MainViewSelected = MainViews.News;
}

public MainViews MainViewSelected
{
get => _mainViewSelected;
set
{
Set(ref _mainViewSelected, value);
SetFocusOnMainViewModels();
}
}

public IMainViewModel ServiceChargeStoreViewModel { get; }

public IMainViewModel InsuranceStoreViewModel { get; }

public IMainViewModel RentStoreViewModel { get; }

public IMainViewModel SchemeViewModel { get; }

public IMainViewModel ClientViewModel { get; }

public IMainViewModel NewsViewModel { get; }

public IMainViewModel TaskViewModel { get; }

private void SetFocusOnMainViewModels()
{
foreach (var key in _mainViewModels.Keys)
{
var isSelected = key == (int)MainViewSelected;
_mainViewModels[key].HasFocus = isSelected;
}
}
}
}

0 comments on commit dd052a1

Please sign in to comment.