1
0
mirror of https://github.com/DarthAffe/Arge.git synced 2022-11-28 19:26:16 +00:00

Refactored and added more basic stuff

This commit is contained in:
Darth Affe 2017-06-11 16:04:47 +02:00
parent 2576ff2ca2
commit 0f79ad4b87
29 changed files with 522 additions and 196 deletions

View File

@ -102,8 +102,8 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Attached\ListBoxExtension.cs" />
<Compile Include="Attributes\FileNameAttribute.cs" />
<Compile Include="Bootstrapper\NavigationManager.cs" />
<Compile Include="Bootstrapper\UnityBootstrapper.cs" />
<Compile Include="Bootstrapper\UnityDependencyResolver.cs" />
<Compile Include="Configuration\Config.cs" />
@ -113,15 +113,20 @@
<Compile Include="Enums\NavigationTargets.cs" />
<Compile Include="Extensions\EnumExtension.cs" />
<Compile Include="Resources\CachedResourceDictionary.cs" />
<Compile Include="Resources\Fonts.cs" />
<Compile Include="Resources\ImageSources.cs" />
<Compile Include="Themes\Theme.cs" />
<Compile Include="Themes\ThemeManager.cs" />
<Compile Include="ViewModels\AbstractViewModel.cs" />
<Compile Include="ViewModels\NavigationViewModel.cs" />
<Compile Include="ViewModels\SettingsLayoutViewModel.cs" />
<Compile Include="ViewModels\LightingLayoutViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\AbstractView.cs" />
<Compile Include="Views\NavigationView.xaml.cs">
<DependentUpon>NavigationView.xaml</DependentUpon>
<Compile Include="Views\SettingsLayoutView.xaml.cs">
<DependentUpon>SettingsLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LightingLayoutView.xaml.cs">
<DependentUpon>LightingLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon>
@ -155,9 +160,7 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="AttachedProperties\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Converter\Converter.xaml">
<Generator>MSBuild:Compile</Generator>
@ -171,6 +174,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\Navigation.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\FrameworkElement.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -183,11 +190,21 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<None Include="Themes\Default\default.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Themes\Default\navigation.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Themes\Default\Theme.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Page Include="Views\NavigationView.xaml">
<Page Include="Views\SettingsLayoutView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\LightingLayoutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View File

@ -0,0 +1,59 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace Arge.Attached
{
public class ListBoxExtension
{
#region AttachedProperties
// ReSharper disable once InconsistentNaming
public static readonly DependencyProperty AlwaysSelectItemProperty = DependencyProperty.RegisterAttached(
"AlwaysSelectItem", typeof(bool), typeof(ListBoxExtension), new PropertyMetadata(default(bool), AlwaysSelectItemChanged));
public static void SetAlwaysSelectItem(DependencyObject element, bool value) => element.SetValue(AlwaysSelectItemProperty, value);
public static bool GetAlwaysSelectItem(DependencyObject element) => (bool)element.GetValue(AlwaysSelectItemProperty);
#endregion
#region Methods
private static void AlwaysSelectItemChanged(DependencyObject dependencyObject,
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
ListBox listBox = dependencyObject as ListBox;
if (listBox == null) return;
if (dependencyPropertyChangedEventArgs.NewValue as bool? == true)
listBox.SelectionChanged += AlwaysSelectItemSelectionChanged;
else
listBox.SelectionChanged -= AlwaysSelectItemSelectionChanged;
}
private static void AlwaysSelectItemSelectionChanged(object sender,
SelectionChangedEventArgs selectionChangedEventArgs)
{
ListBox listBox = sender as ListBox;
if (listBox == null) return;
if (listBox.SelectedItem != null) return;
object selectionTarget = null;
if (selectionChangedEventArgs.RemovedItems.Count > 0)
{
object unselectedItem = selectionChangedEventArgs.RemovedItems[0];
if (listBox.Items.Contains(unselectedItem))
selectionTarget = unselectedItem;
}
if ((selectionTarget == null) && (listBox.Items.Count > 0))
selectionTarget = listBox.Items[0];
if (selectionTarget != null)
listBox.Dispatcher.BeginInvoke(new Action(() => listBox.SelectedItem = selectionTarget));
}
#endregion
}
}

View File

@ -1,9 +1,5 @@
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows;
using Arge.Configuration;
using Arge.Controls.Window;
using Arge.Themes;
using Arge.ViewModels;
using Arge.Views;
@ -30,7 +26,8 @@ namespace Arge.Bootstrapper
private void RegisterViews()
{
RegisterView<ShellView, ShellViewModel>();
RegisterView<NavigationView, NavigationViewModel>();
RegisterView<LightingLayoutView, LightingLayoutViewModel>();
RegisterView<SettingsLayoutView, SettingsLayoutViewModel>();
}
protected override void InitializeHandlers()
@ -42,14 +39,8 @@ namespace Arge.Bootstrapper
Config.Instance.Load();
Container.Resolve<ThemeManager>().LoadTheme(Config.Instance[ConfigEntryType.Theme]);
BlurredDecorationWindow window = new BlurredDecorationWindow
{
Width = 1280,
Height = 720,
Icon = new BitmapImage(new Uri("pack://application:,,,/Arge;component/Resources/ArgeBee.ico")),
IconCommand = ReactiveCommand.Create(() => Process.Start("http://arge.be")),
Content = Container.Resolve<ShellView>()
};
ShellView window = Container.Resolve<ShellView>();
RegisterSingleton(typeof(IScreen), window.ViewModel);
Application.Current.MainWindow = window;
window.Show();
}

View File

@ -1,90 +0,0 @@
using System;
using System.Collections.Generic;
using Arge.Enums;
using Microsoft.Practices.Unity;
namespace Arge.Bootstrapper
{
//TODO DarthAffe 21.05.2017: This allows some sort of fake VM-first - One day I should make this cleaner ...
public class NavigationManager
{
#region Properties & Fields
public static NavigationManager Instance { get; private set; }
private readonly Dictionary<Type, Type> _viewTypeMapping = new Dictionary<Type, Type>();
private readonly IUnityContainer _container;
public object Navigation { get; private set; }
public object Layers { get; private set; }
public object Selection { get; private set; }
public object Action { get; private set; }
public object Surface { get; private set; }
#endregion
#region Constructors
private NavigationManager(IUnityContainer container)
{
this._container = container;
}
#endregion
#region Methods
public static void Initialize(IUnityContainer container)
{
Instance = new NavigationManager(container);
}
public void RegisterViewTypes(Type viewType, Type viewModelType)
{
_viewTypeMapping[viewModelType] = viewType;
}
public void Navigate<TTarget>(NavigationTargets target)
{
Navigate(target, typeof(TTarget));
}
public void Navigate(NavigationTargets target, Type targetType)
{
Type viewType;
if (!_viewTypeMapping.TryGetValue(targetType, out viewType))
viewType = targetType;
Navigate(target, _container.Resolve(viewType));
}
public void Navigate(NavigationTargets target, object view)
{
switch (target)
{
case NavigationTargets.Navigation:
Navigation = view;
break;
case NavigationTargets.Layers:
Layers = view;
break;
case NavigationTargets.Selection:
Selection = view;
break;
case NavigationTargets.Action:
Action = view;
break;
case NavigationTargets.Surface:
Surface = view;
break;
}
}
#endregion
}
}

View File

@ -34,7 +34,6 @@ namespace Arge.Bootstrapper
RegisterSingleton(Container);
Locator.Current = new UnityDependencyResolver(Container);
NavigationManager.Initialize(Container);
}
protected abstract void RegisterTypes();
@ -45,12 +44,10 @@ namespace Arge.Bootstrapper
#region Container-Registration
protected void RegisterService<TInterface, TImplementation>(bool registerTypeToo = true, bool registerAsSingleton = true, string uniqueName = null)
protected void RegisterService<TInterface, TImplementation>(bool registerAsSingleton = true, string uniqueName = null)
where TImplementation : TInterface
{
RegisterTypeIfMissing(typeof(TInterface), typeof(TImplementation), registerAsSingleton, uniqueName);
if (registerTypeToo)
RegisterTypeIfMissing(typeof(TImplementation), typeof(TImplementation), registerAsSingleton, uniqueName);
}
protected void RegisterView<TView, TViewModel>()
@ -59,8 +56,6 @@ namespace Arge.Bootstrapper
{
RegisterTypeIfMissing(typeof(TView), typeof(TView), false);
RegisterTypeIfMissing(typeof(TViewModel), typeof(TViewModel), false);
NavigationManager.Instance.RegisterViewTypes(typeof(TView), typeof(TViewModel));
}
protected void RegisterSingleton<T>()
@ -70,7 +65,12 @@ namespace Arge.Bootstrapper
protected void RegisterSingleton<T>(T instance)
{
Container.RegisterInstance(typeof(T), instance, new ContainerControlledLifetimeManager());
RegisterSingleton(typeof(T), instance);
}
protected void RegisterSingleton(Type t, object instance)
{
Container.RegisterInstance(t, instance, new ContainerControlledLifetimeManager());
}
protected void RegisterTypeIfMissing(Type fromType, Type toType, bool registerAsSingleton, string uniqueName = null)

View File

@ -2,7 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:resources="clr-namespace:Arge.Resources"
xmlns:buttons="clr-namespace:Arge.Controls.Buttons"
xmlns:window="clr-namespace:Arge.Controls.Window">
xmlns:window="clr-namespace:Arge.Controls.Window"
xmlns:views="clr-namespace:Arge.Views">
<resources:CachedResourceDictionary.MergedDictionaries>
<resources:CachedResourceDictionary Source="/Arge;component/Styles/BlurredDecorationWindow.xaml" />
@ -11,6 +12,7 @@
</resources:CachedResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type window:BlurredDecorationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
<Style TargetType="{x:Type views:ShellView}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
<Style TargetType="{x:Type buttons:ImageButton}" BasedOn="{StaticResource StyleImageButton}" />
<Style TargetType="ToolTip" BasedOn="{StaticResource StyleToolTip}" />

71
Arge/Resources/Fonts.cs Normal file
View File

@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Media;
using Arge.Attributes;
using ReactiveUI;
namespace Arge.Resources
{
public sealed class Fonts : ReactiveObject
{
#region Properties & Fields
public static Fonts Instance { get; } = new Fonts();
private FontFamily _default;
[FileName("default")]
public FontFamily Default
{
get => _default ?? new FontFamily("Segoe UI");
set => _default = value;
}
private FontFamily _tooltip;
[FileName("tooltip")]
public FontFamily Tooltip
{
get => _tooltip ?? Default;
set => _tooltip = value;
}
private FontFamily _navigation;
[FileName("navigation")]
public FontFamily Navigation
{
get => _navigation ?? Default;
set => _navigation = value;
}
#endregion
#region Constructors
private Fonts()
{ }
#endregion
#region Methods
public void Update(string baseDirectory)
{
string[] files = Directory.GetFiles(baseDirectory);
foreach (PropertyInfo propertyInfo in GetType().GetProperties())
{
string fileName = propertyInfo.GetCustomAttribute<FileNameAttribute>()?.FileName;
if (string.IsNullOrWhiteSpace(fileName)) continue;
propertyInfo.SetValue(this, ConvertToFontFamily(files.FirstOrDefault(x => string.Equals(Path.GetFileNameWithoutExtension(x), fileName, StringComparison.OrdinalIgnoreCase))));
// ReSharper disable once ExplicitCallerInfoArgument - impossible!
this.RaisePropertyChanged(propertyInfo.Name);
}
}
private FontFamily ConvertToFontFamily(string path) => string.IsNullOrWhiteSpace(path) ? null : System.Windows.Media.Fonts.GetFontFamilies(path).FirstOrDefault();
#endregion
}
}

View File

@ -8,12 +8,11 @@ using ReactiveUI;
namespace Arge.Resources
{
public class ImageSources : ReactiveObject
public sealed class ImageSources : ReactiveObject
{
#region Properties & Fields
private static ImageSources _instace;
public static ImageSources Instance => _instace ?? (_instace = new ImageSources());
public static ImageSources Instance { get; } = new ImageSources();
private readonly ImageSourceConverter _imageSourceConverter = new ImageSourceConverter();
@ -41,7 +40,7 @@ namespace Arge.Resources
{
string[] files = Directory.GetFiles(baseDirectory);
foreach (PropertyInfo propertyInfo in typeof(ImageSources).GetProperties())
foreach (PropertyInfo propertyInfo in GetType().GetProperties())
{
string fileName = propertyInfo.GetCustomAttribute<FileNameAttribute>()?.FileName;
if (string.IsNullOrWhiteSpace(fileName)) continue;
@ -52,10 +51,7 @@ namespace Arge.Resources
}
}
private ImageSource ConvertToImageSource(string path)
{
return string.IsNullOrWhiteSpace(path) ? null : _imageSourceConverter.ConvertFromString(path) as ImageSource;
}
private ImageSource ConvertToImageSource(string path) => string.IsNullOrWhiteSpace(path) ? null : _imageSourceConverter.ConvertFromString(path) as ImageSource;
#endregion
}

View File

@ -34,6 +34,8 @@
<Setter Property="MinWidth" Value="256" />
<Setter Property="MinHeight" Value="144" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeDefault}" />
<Setter Property="FontFamily" Value="{Binding Source={x:Static resources:Fonts.Instance}, Path=Default}" />
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>

View File

@ -3,7 +3,12 @@
xmlns:resources="clr-namespace:Arge.Resources"
xmlns:buttons="clr-namespace:Arge.Controls.Buttons">
<resources:CachedResourceDictionary.MergedDictionaries>
<resources:CachedResourceDictionary Source="/Arge;component/Styles/FrameworkElement.xaml" />
</resources:CachedResourceDictionary.MergedDictionaries>
<Style x:Key="StyleImageButton"
BasedOn="{StaticResource StyleFrameworkElement}"
TargetType="{x:Type buttons:ImageButton}">
<Setter Property="Padding" Value="0" />
@ -62,6 +67,7 @@
</Style>
<Style x:Key="StyleImageButtonWithOpacity"
BasedOn="{StaticResource StyleFrameworkElement}"
TargetType="{x:Type buttons:ImageButton}">
<Setter Property="Opacity" Value="0.66" />
<Setter Property="Padding" Value="0" />
@ -105,6 +111,6 @@
<Setter Property="Margin" Value="0,16" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</resources:CachedResourceDictionary>

108
Arge/Styles/Navigation.xaml Normal file
View File

@ -0,0 +1,108 @@
<resources:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:resources="clr-namespace:Arge.Resources">
<resources:CachedResourceDictionary.MergedDictionaries>
<resources:CachedResourceDictionary Source="/Arge;component/Styles/FrameworkElement.xaml" />
</resources:CachedResourceDictionary.MergedDictionaries>
<Style x:Key="StyleNavigationListBoxItemContainer"
TargetType="{x:Type ListBoxItem}">
<Setter Property="FontSize" Value="{DynamicResource FontSizeNavigation}" />
<Setter Property="FontFamily" Value="{Binding Source={x:Static resources:Fonts.Instance}, Path=Navigation}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Margin="8,0"
Padding="4"
IsHitTestVisible="True"
BorderThickness="0"
Background="Transparent">
<Grid>
<TextBlock x:Name="TxtBlurred"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontWeight="Black"
Opacity="0"
Foreground="{DynamicResource BrushNavigationItemBlur}"
Text="{Binding UrlPathSegment}">
<TextBlock.Effect>
<BlurEffect Radius="{DynamicResource DoubleNavigationBlurRadius}" />
</TextBlock.Effect>
</TextBlock>
<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Center"
Foreground="{DynamicResource BrushNavigationItem}"
Text="{Binding UrlPathSegment}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetName="TxtBlurred">
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.150" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard TargetName="TxtBlurred">
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.250" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetName="TxtBlurred">
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.150" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard TargetName="TxtBlurred">
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.250" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StyleNavigationListBox"
TargetType="ListBox">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ItemContainerStyle" Value="{StaticResource StyleNavigationListBoxItemContainer}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<ItemsPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
</resources:CachedResourceDictionary>

View File

@ -1,10 +1,19 @@
<resources:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:resources="clr-namespace:Arge.Resources">
<resources:CachedResourceDictionary.MergedDictionaries>
<resources:CachedResourceDictionary Source="/Arge;component/Styles/FrameworkElement.xaml" />
</resources:CachedResourceDictionary.MergedDictionaries>
<Style x:Key="StyleToolTip" TargetType="ToolTip">
<Style x:Key="StyleToolTip"
BasedOn="{StaticResource StyleFrameworkElement}"
TargetType="ToolTip">
<Style.Setters>
<Setter Property="Foreground" Value="{DynamicResource BrushTooltipForeground}" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeTooltip}" />
<Setter Property="FontFamily" Value="{Binding Source={x:Static resources:Fonts.Instance}, Path=Tooltip}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">

View File

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:presentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
<!-- ### Colors ### -->
@ -7,6 +8,7 @@
<Color x:Key="ColorJetBlack">#111111</Color>
<Color x:Key="ColorJetBlackTransparent">#A0111111</Color>
<Color x:Key="ColorBlackTransparent">#50000000</Color>
<Color x:Key="ColorBananaYellow">#FFE135</Color>
<!-- ### Brushes ### -->
<SolidColorBrush x:Key="BrushBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlack}" />
@ -20,4 +22,17 @@
<SolidColorBrush x:Key="BrushTooltipBorder" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlack}" />
<SolidColorBrush x:Key="BrushTooltipBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlackTransparent}" />
<!-- Navigation -->
<SolidColorBrush x:Key="BrushNavigationItem" presentationOptions:Freeze="True" Color="{StaticResource ColorTelegrey}" />
<SolidColorBrush x:Key="BrushNavigationItemBlur" presentationOptions:Freeze="True" Color="{StaticResource ColorBananaYellow}" />
<!-- ### Border'n'stuff ### -->
<sys:Double x:Key="DoubleNavigationBlurRadius">40</sys:Double>
<!-- ### Fonts ### -->
<sys:Double x:Key="FontSizeDefault">13</sys:Double>
<sys:Double x:Key="FontSizeTooltip">14</sys:Double>
<sys:Double x:Key="FontSizeNavigation">28</sys:Double>
</ResourceDictionary>

Binary file not shown.

Binary file not shown.

View File

@ -67,6 +67,7 @@ namespace Arge.Themes
CurrentTheme = theme;
ImageSources.Instance.Update(CurrentThemeFolder);
Fonts.Instance.Update(CurrentThemeFolder);
}
public void CheckAvailableThemes()

View File

@ -2,12 +2,25 @@
namespace Arge.ViewModels
{
public abstract class AbstractViewModel : ReactiveObject, ISupportsActivation
public abstract class AbstractViewModel : ReactiveObject, ISupportsActivation, IRoutableViewModel
{
#region Properties & Fields
public ViewModelActivator Activator { get; } = new ViewModelActivator();
public string UrlPathSegment { get; }
public IScreen HostScreen { get; }
#endregion
#region Constructors
public AbstractViewModel(string urlPathSegment, IScreen screen)
{
this.UrlPathSegment = urlPathSegment;
this.HostScreen = screen;
}
#endregion
}
}

View File

@ -0,0 +1,23 @@
using ReactiveUI;
namespace Arge.ViewModels
{
public class LightingLayoutViewModel : AbstractViewModel
{
#region Properties & Fields
#endregion
#region Constructors
public LightingLayoutViewModel(IScreen screen)
: base("Lighting", screen)
{ }
#endregion
#region Methods
#endregion
}
}

View File

@ -1,7 +0,0 @@
using ReactiveUI;
namespace Arge.ViewModels
{
public class NavigationViewModel : ReactiveObject
{ }
}

View File

@ -0,0 +1,23 @@
using ReactiveUI;
namespace Arge.ViewModels
{
public class SettingsLayoutViewModel : AbstractViewModel
{
#region Properties & Fields
#endregion
#region Constructors
public SettingsLayoutViewModel(IScreen screen)
: base("Settings", screen)
{ }
#endregion
#region Methods
#endregion
}
}

View File

@ -1,15 +1,36 @@
using System;
using Arge.Bootstrapper;
using Arge.Enums;
using System.Diagnostics;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using ReactiveUI;
using Splat;
namespace Arge.ViewModels
{
public class ShellViewModel : AbstractViewModel
public class ShellViewModel : ReactiveObject, IScreen, ISupportsActivation
{
#region Properties & Fields
public NavigationManager NavigationManager => NavigationManager.Instance;
public ViewModelActivator Activator { get; } = new ViewModelActivator();
public RoutingState Router { get; }
public ReactiveList<IRoutableViewModel> NavigationTargets { get; private set; }
private IRoutableViewModel _selectedNavigationTarget;
public IRoutableViewModel SelectedNavigationTarget
{
get => _selectedNavigationTarget;
set => this.RaiseAndSetIfChanged(ref _selectedNavigationTarget, value);
}
#endregion
#region Commands
public ReactiveCommand OpenHomepage { get; }
public ReactiveCommand<IRoutableViewModel, Unit> Navigate { get; }
#endregion
@ -17,16 +38,25 @@ namespace Arge.ViewModels
public ShellViewModel()
{
Router = new RoutingState();
OpenHomepage = ReactiveCommand.Create(() => Process.Start("http://arge.be"));
Navigate = ReactiveCommand.Create<IRoutableViewModel>(x => Router.Navigate.Execute(x));
this.WhenAnyValue(vm => vm.NavigationTargets).Where(x => x != null).Subscribe(x => SelectedNavigationTarget = x.FirstOrDefault());
this.WhenAnyValue(vm => vm.SelectedNavigationTarget).Where(x => x != null).InvokeCommand(Navigate);
//TODO DarthAffe 28.05.2017: I don't really like this ...
this.WhenActivated(delegate (Action<IDisposable> action)
{
NavigationManager.Navigate<NavigationViewModel>(NavigationTargets.Navigation);
});
{
NavigationTargets = new ReactiveList<IRoutableViewModel>(new[]
{
(IRoutableViewModel)Locator.Current.GetService(typeof(LightingLayoutViewModel)),
(IRoutableViewModel)Locator.Current.GetService(typeof(SettingsLayoutViewModel))
});
});
}
#endregion
#region Methods
#endregion
}
}

View File

@ -0,0 +1,12 @@
<views:SettingsLayoutViewBase x:Class="Arge.Views.SettingsLayoutView"
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:viewModels="clr-namespace:Arge.ViewModels"
xmlns:views="clr-namespace:Arge.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:SettingsLayoutViewModel, IsDesignTimeCreatable=true}"
d:DesignWidth="1278" d:DesignHeight="639">
</views:SettingsLayoutViewBase>

View File

@ -0,0 +1,15 @@
using Arge.ViewModels;
namespace Arge.Views
{
public class SettingsLayoutViewBase : AbstractView<SettingsLayoutViewModel> { }
public partial class SettingsLayoutView : SettingsLayoutViewBase
{
public SettingsLayoutView(SettingsLayoutViewModel viewModel)
{
InitializeComponent();
this.ViewModel = viewModel;
}
}
}

View File

@ -1,14 +0,0 @@
<local:NavigationViewBase x:Class="Arge.Views.NavigationView"
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:Arge.Views"
xmlns:viewModels="clr-namespace:Arge.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:NavigationViewModel, IsDesignTimeCreatable=true}"
d:DesignWidth="300" d:DesignHeight="72">
<Grid>
</Grid>
</local:NavigationViewBase>

View File

@ -1,18 +0,0 @@
using Arge.ViewModels;
using ReactiveUI;
namespace Arge.Views
{
public class NavigationViewBase : ReactiveUserControl<NavigationViewModel>
{ }
public partial class NavigationView : NavigationViewBase
{
public NavigationView(NavigationViewModel viewModel)
{
InitializeComponent();
this.ViewModel = viewModel;
}
}
}

View File

@ -0,0 +1,12 @@
<views:LightingLayoutViewBase x:Class="Arge.Views.LightingLayoutView"
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:viewModels="clr-namespace:Arge.ViewModels"
xmlns:views="clr-namespace:Arge.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:LightingLayoutViewModel, IsDesignTimeCreatable=true}"
d:DesignWidth="1278" d:DesignHeight="639">
</views:LightingLayoutViewBase>

View File

@ -0,0 +1,15 @@
using Arge.ViewModels;
namespace Arge.Views
{
public class LightingLayoutViewBase : AbstractView<LightingLayoutViewModel> { }
public partial class LightingLayoutView : LightingLayoutViewBase
{
public LightingLayoutView(LightingLayoutViewModel viewModel)
{
InitializeComponent();
this.ViewModel = viewModel;
}
}
}

View File

@ -5,16 +5,28 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Arge.ViewModels"
xmlns:views="clr-namespace:Arge.Views"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:resources="clr-namespace:Arge.Resources"
xmlns:attached="clr-namespace:Arge.Attached"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ShellViewModel, IsDesignTimeCreatable=true}">
d:DataContext="{d:DesignInstance Type=viewModels:ShellViewModel, IsDesignTimeCreatable=true}"
Width="1280" Height="720"
Icon="pack://application:,,,/Arge;component/Resources/ArgeBee.ico">
<views:ShellViewBase.Resources>
<resources:CachedResourceDictionary Source="/Arge;component/Styles/Navigation.xaml" />
</views:ShellViewBase.Resources>
<Grid>
<ContentControl x:Name="TargetNavigation" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="72" Margin="80,-72,72,0" />
<DockPanel LastChildFill="True">
<ContentControl x:Name="TargetLayers" DockPanel.Dock="Left" />
<ContentControl x:Name="TargetSelection" DockPanel.Dock="Right" />
<ContentControl x:Name="TargetActions" DockPanel.Dock="Bottom" />
<ContentControl x:Name="TargetSurface" />
</DockPanel>
<ListBox x:Name="ListBoxNavigation" VerticalAlignment="Top" Height="72" Margin="80,-72,72,0"
attached:ListBoxExtension.AlwaysSelectItem="True"
SelectedIndex="0"
Style="{StaticResource StyleNavigationListBox}" />
<reactiveUi:RoutedViewHost HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Router="{Binding Router}" />
</Grid>
</views:ShellViewBase>

View File

@ -1,9 +1,31 @@
using Arge.ViewModels;
using Arge.Controls.Window;
using Arge.ViewModels;
using ReactiveUI;
namespace Arge.Views
{
public class ShellViewBase : AbstractView<ShellViewModel> { }
public class ShellViewBase : BlurredDecorationWindow, IViewFor<ShellViewModel>
{
#region Properties & Fields
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = value as ShellViewModel;
}
public ShellViewModel ViewModel { get; set; }
#endregion
#region Constructors
protected ShellViewBase()
{
this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext);
}
#endregion
}
public partial class ShellView : ShellViewBase
{
@ -12,13 +34,14 @@ namespace Arge.Views
public ShellView(ShellViewModel viewModel)
{
InitializeComponent();
this.ViewModel = viewModel;
this.WhenActivated(d =>
{
d(this.OneWayBind(ViewModel, vm => vm.NavigationManager.Navigation, v => v.TargetNavigation.Content));
});
{
d(this.OneWayBind(ViewModel, vm => vm.OpenHomepage, view => view.IconCommand));
d(this.OneWayBind(ViewModel, vm => vm.NavigationTargets, view => view.ListBoxNavigation.ItemsSource));
d(this.Bind(ViewModel, vm => vm.SelectedNavigationTarget, view => view.ListBoxNavigation.SelectedItem));
});
}
#endregion