diff --git a/Arge/Arge.csproj b/Arge/Arge.csproj
index d565bee..366b35b 100644
--- a/Arge/Arge.csproj
+++ b/Arge/Arge.csproj
@@ -102,8 +102,8 @@
App.xaml
Code
+
-
@@ -113,15 +113,20 @@
+
-
+
+
-
- NavigationView.xaml
+
+ SettingsLayoutView.xaml
+
+
+ LightingLayoutView.xaml
ShellView.xaml
@@ -155,9 +160,7 @@
-
-
-
+
MSBuild:Compile
@@ -171,6 +174,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -183,11 +190,21 @@
MSBuild:Compile
Designer
+
+ PreserveNewest
+
+
+ PreserveNewest
+
Designer
Always
-
+
+ MSBuild:Compile
+ Designer
+
+
Designer
MSBuild:Compile
diff --git a/Arge/Attached/ListBoxExtension.cs b/Arge/Attached/ListBoxExtension.cs
new file mode 100644
index 0000000..b6255d6
--- /dev/null
+++ b/Arge/Attached/ListBoxExtension.cs
@@ -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
+ }
+}
diff --git a/Arge/Bootstrapper/ArgeBootstrapper.cs b/Arge/Bootstrapper/ArgeBootstrapper.cs
index 6aeb276..e3274ae 100644
--- a/Arge/Bootstrapper/ArgeBootstrapper.cs
+++ b/Arge/Bootstrapper/ArgeBootstrapper.cs
@@ -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();
- RegisterView();
+ RegisterView();
+ RegisterView();
}
protected override void InitializeHandlers()
@@ -42,14 +39,8 @@ namespace Arge.Bootstrapper
Config.Instance.Load();
Container.Resolve().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 window = Container.Resolve();
+ RegisterSingleton(typeof(IScreen), window.ViewModel);
Application.Current.MainWindow = window;
window.Show();
}
diff --git a/Arge/Bootstrapper/NavigationManager.cs b/Arge/Bootstrapper/NavigationManager.cs
deleted file mode 100644
index 2b47fe3..0000000
--- a/Arge/Bootstrapper/NavigationManager.cs
+++ /dev/null
@@ -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 _viewTypeMapping = new Dictionary();
-
- 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(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
- }
-}
diff --git a/Arge/Bootstrapper/UnityBootstrapper.cs b/Arge/Bootstrapper/UnityBootstrapper.cs
index 13397bb..d6862bb 100644
--- a/Arge/Bootstrapper/UnityBootstrapper.cs
+++ b/Arge/Bootstrapper/UnityBootstrapper.cs
@@ -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(bool registerTypeToo = true, bool registerAsSingleton = true, string uniqueName = null)
+ protected void RegisterService(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()
@@ -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()
@@ -70,7 +65,12 @@ namespace Arge.Bootstrapper
protected void RegisterSingleton(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)
diff --git a/Arge/Resources/Arge.xaml b/Arge/Resources/Arge.xaml
index 69d731f..c4005d3 100644
--- a/Arge/Resources/Arge.xaml
+++ b/Arge/Resources/Arge.xaml
@@ -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">
@@ -11,6 +12,7 @@
+
diff --git a/Arge/Resources/Fonts.cs b/Arge/Resources/Fonts.cs
new file mode 100644
index 0000000..a55e522
--- /dev/null
+++ b/Arge/Resources/Fonts.cs
@@ -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()?.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
+ }
+}
diff --git a/Arge/Resources/ImageSources.cs b/Arge/Resources/ImageSources.cs
index 3d96807..1fc2887 100644
--- a/Arge/Resources/ImageSources.cs
+++ b/Arge/Resources/ImageSources.cs
@@ -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()?.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
}
diff --git a/Arge/Styles/BlurredDecorationWindow.xaml b/Arge/Styles/BlurredDecorationWindow.xaml
index 7ffd793..eaf8303 100644
--- a/Arge/Styles/BlurredDecorationWindow.xaml
+++ b/Arge/Styles/BlurredDecorationWindow.xaml
@@ -34,6 +34,8 @@
+
+
diff --git a/Arge/Styles/ImageButton.xaml b/Arge/Styles/ImageButton.xaml
index c072bf3..ca09c23 100644
--- a/Arge/Styles/ImageButton.xaml
+++ b/Arge/Styles/ImageButton.xaml
@@ -3,7 +3,12 @@
xmlns:resources="clr-namespace:Arge.Resources"
xmlns:buttons="clr-namespace:Arge.Controls.Buttons">
+
+
+
+
-
+
\ No newline at end of file
diff --git a/Arge/Styles/Navigation.xaml b/Arge/Styles/Navigation.xaml
new file mode 100644
index 0000000..b69b22d
--- /dev/null
+++ b/Arge/Styles/Navigation.xaml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Arge/Styles/ToolTip.xaml b/Arge/Styles/ToolTip.xaml
index ae30986..e0d8dfb 100644
--- a/Arge/Styles/ToolTip.xaml
+++ b/Arge/Styles/ToolTip.xaml
@@ -1,10 +1,19 @@
+
+
+
+
-