1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

And the winner is... Stylet!

This commit is contained in:
SpoinkyNL 2017-12-27 19:34:13 +01:00
parent 59a84e9db6
commit 529e52b35d
24 changed files with 299 additions and 370 deletions

View File

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,12 +1,18 @@
<Application x:Class="Artemis.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
xmlns:s="https://github.com/canton7/Stylet"
xmlns:local="clr-namespace:Artemis.UI">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary.MergedDictionaries>
<s:ApplicationLoader>
<s:ApplicationLoader.Bootstrapper>
<local:Bootstrapper />
</s:ApplicationLoader.Bootstrapper>
</s:ApplicationLoader>
<!-- MahApps -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />

View File

@ -1,17 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
namespace Artemis.UI
{
/// <summary>
/// Interaction logic for App.xaml
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
}

View File

@ -1,61 +0,0 @@
using System;
using System.Linq;
using Artemis.UI.Ninject;
using Artemis.UI.ViewModels;
using Ninject;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Splat;
namespace Artemis.UI
{
public class AppBootstrapper : ReactiveObject, IScreen
{
public AppBootstrapper()
{
Router = new RoutingState();
Kernel = new StandardKernel(new ViewsModule());
// Configure the Ninject kernel and set it up as the default for ReactiveUI
SetupNinject(Kernel);
// Update the title on view change
this.WhenAnyValue(x => x.Router.CurrentViewModel)
.Subscribe(o => o.Subscribe(vm => { ViewTitle = vm != null ? vm.UrlPathSegment : ""; }));
// Setup the sidebar that lives throughout the app
SidebarViewModel = Kernel.Get<ISidebarViewModel>();
// Navigate to the opening page of the application
Router.Navigate.Execute(Kernel.Get<IMainViewModel>());
}
public IKernel Kernel { get; set; }
public ISidebarViewModel SidebarViewModel { get; }
public RoutingState Router { get; }
[Reactive]
public string ViewTitle { get; set; }
private void SetupNinject(IKernel kernel)
{
// Bind the main screen to IScreen
kernel.Bind<IScreen>().ToConstant(this);
// Set up NInject to do DI
var customResolver = new FuncDependencyResolver(
(service, contract) =>
{
if (contract != null) return kernel.GetAll(service, contract);
var items = kernel.GetAll(service);
var list = items.ToList();
return list;
},
(factory, service, contract) =>
{
var binding = kernel.Bind(service).ToMethod(_ => factory());
if (contract != null) binding.Named(contract);
});
Locator.Current = customResolver;
}
}
}

View File

@ -36,6 +36,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.2.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
@ -51,33 +54,22 @@
<Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath>
</Reference>
<Reference Include="ReactiveUI, Version=7.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\reactiveui-core.7.4.0\lib\Net45\ReactiveUI.dll</HintPath>
<Reference Include="Ninject.Extensions.Conventions, Version=3.3.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.Extensions.Conventions.3.3.0\lib\net45\Ninject.Extensions.Conventions.dll</HintPath>
</Reference>
<Reference Include="ReactiveUI.Fody.Helpers, Version=2.2.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveUI.Fody.2.2.11\lib\net45\ReactiveUI.Fody.Helpers.dll</HintPath>
<Reference Include="Ninject.Extensions.Factory, Version=3.3.2.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.0\lib\Net45\Splat.dll</HintPath>
<Reference Include="PropertyChanged, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.2.2.4.0\lib\net452\PropertyChanged.dll</HintPath>
</Reference>
<Reference Include="Stylet, Version=1.1.21.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Stylet.1.1.21\lib\net45\Stylet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Windows.Threading, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-XAML.2.2.5\lib\net45\System.Reactive.Windows.Threading.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
@ -99,34 +91,21 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AppBootstrapper.cs" />
<Compile Include="Ninject\ViewsModule.cs" />
<Compile Include="Bootstrapper.cs" />
<Compile Include="Ninject\UIModule.cs" />
<Compile Include="Stylet\NinjectBootstrapper.cs" />
<Compile Include="ViewModels\Interfaces\IArtemisViewModel.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\SidebarViewModel.cs" />
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SidebarView.xaml.cs">
<DependentUpon>SidebarView.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="ViewModels\HomeViewModel.cs" />
<Compile Include="ViewModels\RootViewModel.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\MainView.xaml">
<Page Include="Views\HomeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SidebarView.xaml">
<Page Include="Views\RootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -178,14 +157,14 @@
<Folder Include="Controls\RgbDevice\" />
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets" Condition="Exists('..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets')" />
<Import Project="..\packages\Fody.2.3.8\build\net452\Fody.targets" Condition="Exists('..\packages\Fody.2.3.8\build\net452\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.2.3.8\build\net452\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.3.8\build\net452\Fody.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,16 @@
using Artemis.UI.Ninject;
using Artemis.UI.Stylet;
using Artemis.UI.ViewModels;
using Ninject;
namespace Artemis.UI
{
public class Bootstrapper : NinjectBootstrapper<RootViewModel>
{
protected override void ConfigureIoC(IKernel kernel)
{
kernel.Load<UIModule>();
base.ConfigureIoC(kernel);
}
}
}

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<ReactiveUI />
<PropertyChanged />
</Weavers>

View File

@ -1,20 +0,0 @@
using MahApps.Metro.Controls;
namespace Artemis.UI
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
AppBootstrapper = new AppBootstrapper();
DataContext = AppBootstrapper;
}
public AppBootstrapper AppBootstrapper { get; }
}
}

View File

@ -0,0 +1,18 @@
using Artemis.UI.ViewModels.Interfaces;
using Ninject.Extensions.Conventions;
using Ninject.Modules;
namespace Artemis.UI.Ninject
{
public class UIModule : NinjectModule
{
public override void Load()
{
// Bind all viewmodels
Kernel.Bind(x =>
{
x.FromThisAssembly().SelectAllClasses().InheritedFrom<IArtemisViewModel>().BindAllInterfaces();
});
}
}
}

View File

@ -1,14 +0,0 @@
using Artemis.UI.ViewModels;
using Ninject.Modules;
namespace Artemis.UI.Ninject
{
public class ViewsModule : NinjectModule
{
public override void Load()
{
Bind<IMainViewModel>().To<MainViewModel>();
Bind<ISidebarViewModel>().To<SidebarViewModel>().InSingletonScope();
}
}
}

View File

@ -1,6 +1,4 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
@ -33,11 +31,11 @@ using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
@ -52,4 +50,4 @@ using System.Windows;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,4 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Ninject;
using Stylet;
namespace Artemis.UI.Stylet
{
public class NinjectBootstrapper<TRootViewModel> : BootstrapperBase where TRootViewModel : class
{
private object _rootViewModel;
private IKernel kernel;
protected virtual object RootViewModel =>
_rootViewModel ?? (_rootViewModel = GetInstance(typeof(TRootViewModel)));
protected override void ConfigureBootstrapper()
{
kernel = new StandardKernel();
DefaultConfigureIoC(kernel);
ConfigureIoC(kernel);
}
/// <summary>
/// Carries out default configuration of the IoC container. Override if you don't want to do this
/// </summary>
protected virtual void DefaultConfigureIoC(IKernel kernel)
{
var viewManagerConfig = new ViewManagerConfig
{
ViewFactory = GetInstance,
ViewAssemblies = new List<Assembly> {GetType().Assembly}
};
kernel.Bind<IViewManager>().ToConstant(new ViewManager(viewManagerConfig));
kernel.Bind<IWindowManagerConfig>().ToConstant(this).InTransientScope();
kernel.Bind<IWindowManager>().ToMethod(c => new WindowManager(c.Kernel.Get<IViewManager>(),
() => c.Kernel.Get<IMessageBoxViewModel>(), c.Kernel.Get<IWindowManagerConfig>())).InSingletonScope();
kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
kernel.Bind<IMessageBoxViewModel>().To<MessageBoxViewModel>(); // Not singleton!
}
/// <summary>
/// Override to add your own types to the IoC container.
/// </summary>
protected virtual void ConfigureIoC(IKernel kernel)
{
}
public override object GetInstance(Type type)
{
return kernel.Get(type);
}
protected override void Launch()
{
DisplayRootView(RootViewModel);
}
public override void Dispose()
{
base.Dispose();
ScreenExtensions.TryDispose(_rootViewModel);
if (kernel != null)
kernel.Dispose();
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Diagnostics;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels
{
public class HomeViewModel : Screen, IMainViewModel
{
public string Title => "Home";
public void OpenUrl(string url)
{
// Don't open anything but valid URIs
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
Process.Start(url);
}
}
public interface IMainViewModel : IArtemisViewModel
{
}
}

View File

@ -1,10 +1,7 @@
using ReactiveUI;
namespace Artemis.UI.ViewModels.Interfaces
namespace Artemis.UI.ViewModels.Interfaces
{
public interface IArtemisViewModel : IRoutableViewModel
public interface IArtemisViewModel
{
string Title { get; }
string Icon { get; }
}
}

View File

@ -1,36 +0,0 @@
using System.Diagnostics;
using System.Threading.Tasks;
using Artemis.UI.ViewModels.Interfaces;
using ReactiveUI;
namespace Artemis.UI.ViewModels
{
public class MainViewModel : ReactiveObject, IMainViewModel
{
public MainViewModel(IScreen screen, ISidebarViewModel sidebarViewModel)
{
HostScreen = screen;
OpenUrl = ReactiveCommand.CreateFromTask<string>(OpenUrlAsync);
// Add this view as a menu item
sidebarViewModel.MenuItems.Add(this);
}
public IScreen HostScreen { get; }
public string UrlPathSegment => Title.ToLower();
public string Title => "Home";
public string Icon => "Home";
public ReactiveCommand OpenUrl { get; }
private async Task OpenUrlAsync(string url)
{
await Task.Run(() => Process.Start(url));
}
}
public interface IMainViewModel : IArtemisViewModel
{
ReactiveCommand OpenUrl { get; }
}
}

View File

@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels
{
public class RootViewModel : Conductor<IArtemisViewModel>.Collection.OneActive
{
public RootViewModel(ICollection<IArtemisViewModel> artemisViewModels)
{
// Add the built-in items
Items.AddRange(artemisViewModels);
// Activate the home item
ActiveItem = artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel));
}
}
}

View File

@ -1,23 +0,0 @@
using System.Collections.ObjectModel;
using Artemis.UI.ViewModels.Interfaces;
using ReactiveUI;
namespace Artemis.UI.ViewModels
{
public class SidebarViewModel : ReactiveObject, ISidebarViewModel
{
public SidebarViewModel(IScreen screen)
{
HostScreen = screen;
MenuItems = new ObservableCollection<IArtemisViewModel>();
}
public IScreen HostScreen { get; }
public ObservableCollection<IArtemisViewModel> MenuItems { get; set; }
}
public interface ISidebarViewModel
{
ObservableCollection<IArtemisViewModel> MenuItems { get; set; }
}
}

View File

@ -1,23 +1,27 @@
<UserControl x:Class="Artemis.UI.Views.MainView"
<UserControl x:Class="Artemis.UI.Views.HomeView"
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:Artemis.UI.ViewModels"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vms="clr-namespace:Artemis.UI.ViewModels"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="574.026"
d:DesignWidth="1029.87"
d:DataContext="{d:DesignInstance viewModels:MainViewModel,
IsDesignTimeCreatable=True}">
mc:Ignorable="d"
d:DesignHeight="574.026"
d:DesignWidth="1029.87"
d:DataContext="{d:DesignInstance vms:HomeViewModel, IsDesignTimeCreatable=True}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
<!-- throw in some extra colour for our floating action button -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/MaterialDesignColor.Green.Named.Primary.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignColors;component/Themes/MaterialDesignColor.Green.Named.Primary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
@ -59,42 +63,57 @@
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Kind="Discord" Width="140" Height="140" HorizontalAlignment="Center" VerticalAlignment="Center" />
<materialDesign:PackIcon Kind="Discord" Width="140" Height="140"
HorizontalAlignment="Center" VerticalAlignment="Center" />
<StackPanel Grid.Column="1">
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}" Margin="16 16 16 8">Have a chat</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8" Foreground="{DynamicResource MaterialDesignBodyLight}"
VerticalAlignment="Top"><Run Text="If you need help, have some feedback or have any other questions feel free to contact us through any of the following channels"/><Run Text=". "/></TextBlock>
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8"
Foreground="{DynamicResource MaterialDesignBodyLight}"
VerticalAlignment="Top">
<Run
Text="If you need help, have some feedback or have any other questions feel free to contact us through any of the following channels" />
<Run Text=". " />
</TextBlock>
</StackPanel>
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0"
BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
<DockPanel>
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Button Style="{DynamicResource MaterialDesignFlatButton}" HorizontalAlignment="Left"
x:Name="GitHubButton" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<Button Style="{DynamicResource MaterialDesignFlatButton}"
HorizontalAlignment="Left"
x:Name="GitHubButton" Command="{s:Action OpenUrl}"
CommandParameter="https://github.com/SpoinkyNL/Artemis">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="GithubCircle" />
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">GitHub</TextBlock>
</StackPanel>
</Button>
<Button Style="{DynamicResource MaterialDesignFlatButton}" HorizontalAlignment="Right"
x:Name="TwitterButton" Command="{Binding OpenUrl}" CommandParameter="https://twitter.com/spoinkynl">
<Button Style="{DynamicResource MaterialDesignFlatButton}"
HorizontalAlignment="Right"
x:Name="TwitterButton" Command="{s:Action OpenUrl}"
CommandParameter="https://twitter.com/spoinkynl">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Twitter" />
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">Twitter</TextBlock>
</StackPanel>
</Button>
<Button Grid.Row="1" Style="{DynamicResource MaterialDesignFlatButton}" HorizontalAlignment="Left"
x:Name="DiscordButton" Command="{Binding OpenUrl}" CommandParameter="https://discordapp.com/invite/S3MVaC9">
<Button Grid.Row="1" Style="{DynamicResource MaterialDesignFlatButton}"
HorizontalAlignment="Left"
x:Name="DiscordButton" Command="{s:Action OpenUrl}"
CommandParameter="https://discordapp.com/invite/S3MVaC9">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Discord" />
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">Discord</TextBlock>
</StackPanel>
</Button>
<Button Grid.Row="1" Style="{DynamicResource MaterialDesignFlatButton}" HorizontalAlignment="Right"
x:Name="MailButton" Command="{Binding OpenUrl}" CommandParameter="mailto:spoinky.nl@gmail.com">
<Button Grid.Row="1" Style="{DynamicResource MaterialDesignFlatButton}"
HorizontalAlignment="Right"
x:Name="MailButton" Command="{s:Action OpenUrl}"
CommandParameter="mailto:spoinky.nl@gmail.com">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Email" />
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">E-mail</TextBlock>
@ -115,23 +134,36 @@
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Kind="GithubCircle" Width="160" Height="160" HorizontalAlignment="Center" VerticalAlignment="Center" />
<materialDesign:PackIcon Kind="GithubCircle" Width="160" Height="160"
HorizontalAlignment="Center" VerticalAlignment="Center" />
<StackPanel Grid.Column="1">
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}" Margin="16 16 16 8">Open Source</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8" Foreground="{DynamicResource MaterialDesignBodyLight}"
VerticalAlignment="Top"><Run Text="This project is completely open source. If you like it and want to say thanks you could hit the GitHub Star button, tweet or post about it"/><Run Text=". You can also make your own modules!"/></TextBlock>
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8"
Foreground="{DynamicResource MaterialDesignBodyLight}"
VerticalAlignment="Top">
<Run
Text="This project is completely open source. If you like it and want to say thanks you could hit the GitHub Star button, tweet or post about it" />
<Run Text=". You can also make your own modules!" />
</TextBlock>
</StackPanel>
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0"
BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
<DockPanel>
<Button Style="{DynamicResource MaterialDesignFlatButton}"
<Button Style="{DynamicResource MaterialDesignFlatButton}"
DockPanel.Dock="Right"
x:Name="DonateButton" Command="{Binding OpenUrl}" CommandParameter="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=VQBAEJYUFLU4J">
x:Name="DonateButton" Command="{s:Action OpenUrl}"
CommandParameter="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=VQBAEJYUFLU4J">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Gift" />
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">Donate</TextBlock>
</StackPanel>
</Button>
<TextBlock Foreground="{DynamicResource MaterialDesignBodyLight}" TextWrapping="Wrap" Margin="16" VerticalAlignment="Center"><Run Text="Feel like you want to make a donation? It would be gratefully received. Click the button to donate via "/><Run Text="Paypal"/><Run Text="."/></TextBlock>
<TextBlock Foreground="{DynamicResource MaterialDesignBodyLight}"
TextWrapping="Wrap" Margin="16" VerticalAlignment="Center">
<Run
Text="Feel like you want to make a donation? It would be gratefully received. Click the button to donate via " />
<Run Text="Paypal" /><Run Text="." />
</TextBlock>
</DockPanel>
</Border>
</Grid>
@ -145,15 +177,15 @@
Margin="32" Grid.Row="1">
--><!-- add the visibility binding https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/723 --><!--
<StackPanel Visibility="{Binding Path=IsPopupOpen, ElementName=MyPopupBox, Converter={StaticResource BoolToVisibilityConverter}}">
<Button ToolTip="GitHub" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<Button ToolTip="GitHub" Command="{s:Action OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<materialDesign:PackIcon Kind="GithubCircle" Height="20" Width="20" />
</Button>
<Button ToolTip="Twitter" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis"
<Button ToolTip="Twitter" Command="{s:Action OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis"
Background="{DynamicResource PrimaryHueMidBrush}"
Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
<materialDesign:PackIcon Kind="Twitter" />
</Button>
<Button ToolTip="Chat" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<Button ToolTip="Chat" Command="{s:Action OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
--><!-- mix up the colours by brinking in a named palette (see merged dictionaries at top) --><!--
<Button.Background>
<SolidColorBrush Color="{StaticResource GreenPrimary500}" />
@ -163,14 +195,14 @@
</Button.Foreground>
<materialDesign:PackIcon Kind="Message" />
</Button>
<Button ToolTip="Email" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis"
<Button ToolTip="Email" Command="{s:Action OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis"
Background="{DynamicResource SecondaryAccentBrush}"
Foreground="{DynamicResource SecondaryAccentForegroundBrush}"
>
<materialDesign:PackIcon Kind="Email" />
</Button>
<Button ToolTip="Feel like you want to make a donation? It would be gratefully received. Click the button to donate via Pledgie."
Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
Command="{s:Action OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<Button.Background>
<SolidColorBrush Color="{StaticResource GreenPrimary200}" />
</Button.Background>
@ -182,4 +214,4 @@
</StackPanel>
</materialDesign:PopupBox>-->
</Grid>
</UserControl>
</UserControl>

View File

@ -1,30 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using Artemis.UI.ViewModels;
using ReactiveUI;
namespace Artemis.UI.Views
{
/// <summary>
/// Interaction logic for MainView.xaml
/// </summary>
public partial class MainView : UserControl, IViewFor<IMainViewModel>
{
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(IMainViewModel), typeof(MainView), new PropertyMetadata(null));
public MainView()
{
InitializeComponent();
this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext);
}
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (IMainViewModel) value;
}
public IMainViewModel ViewModel { get; set; }
}
}

View File

@ -1,18 +1,19 @@
<metro:MetroWindow x:Class="Artemis.UI.MainWindow"
<metro:MetroWindow x:Class="Artemis.UI.Views.RootView"
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:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:views="clr-namespace:Artemis.UI.Views"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:vms="clr-namespace:Artemis.UI.ViewModels"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
Title="Artemis"
d:DesignHeight="639.411"
d:DesignWidth="1113.251">
d:DesignWidth="1113.251"
d:DataContext="{d:DesignInstance vms:RootViewModel}">
<metro:MetroWindow.Resources>
<DrawingImage x:Key="BowIcon">
<DrawingImage.Drawing>
@ -71,33 +72,42 @@
<DockPanel MinWidth="212">
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
DockPanel.Dock="Top"
HorizontalAlignment="Right" Margin="16"
HorizontalAlignment="Right"
Margin="16"
IsChecked="{Binding ElementName=MenuToggleButton, Path=IsChecked, Mode=TwoWay}" />
<views:SidebarView DataContext="{Binding SidebarViewModel}"></views:SidebarView>
<ListBox Margin="0 16 0 16" SelectedIndex="0">
</ListBox>
</DockPanel>
</materialDesign:DrawerHost.LeftDrawerContent>
<DockPanel>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2"
Mode="PrimaryMid" DockPanel.Dock="Top">
<materialDesign:ColorZone Padding="16"
materialDesign:ShadowAssist.ShadowDepth="Depth2"
Mode="PrimaryMid"
DockPanel.Dock="Top">
<DockPanel>
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" IsChecked="False"
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
IsChecked="False"
x:Name="MenuToggleButton" />
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges"
<materialDesign:PopupBox DockPanel.Dock="Right"
PlacementMode="BottomAndAlignRightEdges"
StaysOpen="False">
<StackPanel>
<Button Content="Hello World" />
<Button Content="Nice Popup" />
<Button Content="Can't Touch This" IsEnabled="False" />
<Button Content="Can't Touch This"
IsEnabled="False" />
<Separator />
<Button Content="Goodbye" />
</StackPanel>
</materialDesign:PopupBox>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Text="{Binding ViewTitle}" />
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="22"
Text="{Binding ActiveItem.Title}" />
</DockPanel>
</materialDesign:ColorZone>
<reactiveUi:RoutedViewHost Router="{Binding Router}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
<ContentControl s:View.Model="{Binding ActiveItem}" />
</DockPanel>
</materialDesign:DrawerHost>
</materialDesign:DialogHost>

View File

@ -1,22 +0,0 @@
<UserControl x:Class="Artemis.UI.Views.SidebarView"
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:interfaces="clr-namespace:Artemis.UI.ViewModels.Interfaces"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<ListBox Margin="0 16 0 16"
SelectedIndex="0"
ItemsSource="{Binding MenuItems}">
<ListBox.ItemTemplate>
<DataTemplate DataType="interfaces:IArtemisViewModel">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="{Binding Icon}" />
<TextBlock Text="{Binding Title}" Margin="32 0 32 0" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</UserControl>

View File

@ -1,30 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using Artemis.UI.ViewModels;
using ReactiveUI;
namespace Artemis.UI.Views
{
/// <summary>
/// Interaction logic for SidebarView.xaml
/// </summary>
public partial class SidebarView : UserControl, IViewFor<ISidebarViewModel>
{
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(ISidebarViewModel), typeof(SidebarView), new PropertyMetadata(null));
public SidebarView()
{
InitializeComponent();
this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext);
}
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (ISidebarViewModel)value;
}
public ISidebarViewModel ViewModel { get; set; }
}
}

View File

@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fody" version="2.0.7" targetFramework="net461" developmentDependency="true" />
<package id="Castle.Core" version="4.2.0" targetFramework="net461" />
<package id="Fody" version="2.3.8" targetFramework="net461" developmentDependency="true" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net461" />
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" />
<package id="MaterialDesignThemes.MahApps" version="0.0.11" targetFramework="net461" />
<package id="Ninject" version="3.3.4" targetFramework="net461" />
<package id="reactiveui" version="7.4.0" targetFramework="net461" />
<package id="ReactiveUI.Fody" version="2.2.11" targetFramework="net461" />
<package id="reactiveui-core" version="7.4.0" targetFramework="net461" />
<package id="Rx-Core" version="2.2.5" targetFramework="net461" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net461" />
<package id="Rx-Linq" version="2.2.5" targetFramework="net461" />
<package id="Rx-Main" version="2.2.5" targetFramework="net461" />
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="net461" />
<package id="Rx-XAML" version="2.2.5" targetFramework="net461" />
<package id="Splat" version="1.6.0" targetFramework="net461" />
<package id="Ninject.Extensions.Conventions" version="3.3.0" targetFramework="net461" />
<package id="Ninject.Extensions.Factory" version="3.3.2" targetFramework="net461" />
<package id="PropertyChanged.Fody" version="2.2.4.0" targetFramework="net461" developmentDependency="true" />
<package id="Stylet" version="1.1.21" targetFramework="net461" />
</packages>