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

Restructured the VM/Vs folder layout while it's still feasible

This commit is contained in:
Robert 2019-11-15 15:53:55 +01:00
parent 48acb10db4
commit 002cc6a6db
48 changed files with 397 additions and 469 deletions

View File

@ -21,6 +21,7 @@ namespace Artemis.Plugins.Modules.General
_settings = settings;
DisplayName = "General";
ExpandsMainDataModel = true;
DeviceBrushes= new Dictionary<Device, TextureBrush>();
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
@ -82,17 +83,18 @@ namespace Artemis.Plugins.Modules.General
{
foreach (var device in surface.Devices)
{
using (var gradient = RenderGradientForDevice(device))
{
using (var brush = new TextureBrush(gradient, WrapMode.Tile))
{
brush.TranslateTransform((int) Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage), 0);
graphics.FillPath(brush, device.RenderPath);
}
}
if (!DeviceBrushes.ContainsKey(device))
DeviceBrushes.Add(device, new TextureBrush(RenderGradientForDevice(device), WrapMode.Tile));
var brush = DeviceBrushes[device];
brush.TranslateTransform((int) Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage), 0);
graphics.FillPath(brush, device.RenderPath);
brush.TranslateTransform((int)Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage) * -1, 0);
}
}
public Dictionary<Device, TextureBrush> DeviceBrushes { get; set; }
private Image RenderGradientForDevice(Device device)
{
var brush = new LinearGradientBrush(device.RenderRectangle, Color.Black, Color.Black, 0, false)

View File

@ -174,93 +174,103 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Services\DialogService.cs" />
<Compile Include="Screens\News\NewsViewModel.cs" />
<Compile Include="Screens\Workshop\WorkshopViewModel.cs" />
<Compile Include="Services\Dialog\DialogService.cs" />
<Compile Include="Services\Interfaces\IDialogService.cs" />
<Compile Include="Services\Interfaces\IArtemisUIService.cs" />
<Compile Include="Stylet\ArtemisViewManager.cs" />
<Compile Include="Stylet\FluentValidationAdapter.cs" />
<Compile Include="Stylet\NinjectBootstrapper.cs" />
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileDeviceViewModel.cs" />
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileEditorViewModel.cs" />
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileLedViewModel.cs" />
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceLedViewModel.cs" />
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceDeviceViewModel.cs" />
<Compile Include="ViewModels\Dialogs\ConfirmDialogViewModel.cs" />
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModelValidator.cs" />
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModel.cs" />
<Compile Include="ViewModels\Screens\ModuleRootViewModel.cs" />
<Compile Include="ViewModels\Screens\SplashViewModel.cs" />
<Compile Include="ViewModels\Utilities\DialogViewModelHost.cs" />
<Compile Include="ViewModels\Dialogs\DialogViewModelBase.cs" />
<Compile Include="ViewModels\Utilities\PanZoomViewModel.cs" />
<Compile Include="ViewModels\Screens\DebugViewModel.cs" />
<Compile Include="ViewModels\Screens\SurfaceEditorViewModel.cs" />
<Compile Include="ViewModels\Controls\Settings\DeviceSettingsViewModel.cs" />
<Compile Include="ViewModels\Interfaces\IScreenViewModel.cs" />
<Compile Include="ViewModels\Screens\HomeViewModel.cs" />
<Compile Include="ViewModels\Screens\RootViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\Visualization\ProfileDeviceViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\ProfileEditorViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\Visualization\ProfileLedViewModel.cs" />
<Compile Include="Screens\SurfaceEditor\Visualization\SurfaceLedViewModel.cs" />
<Compile Include="Screens\SurfaceEditor\Visualization\SurfaceDeviceViewModel.cs" />
<Compile Include="Screens\Dialogs\ConfirmDialogViewModel.cs" />
<Compile Include="Screens\SurfaceEditor\Dialogs\SurfaceCreateViewModelValidator.cs" />
<Compile Include="Screens\SurfaceEditor\Dialogs\SurfaceCreateViewModel.cs" />
<Compile Include="Screens\Module\ModuleRootViewModel.cs" />
<Compile Include="Screens\Splash\SplashViewModel.cs" />
<Compile Include="Services\Dialog\DialogViewModelHost.cs" />
<Compile Include="Services\Dialog\DialogViewModelBase.cs" />
<Compile Include="Screens\Shared\PanZoomViewModel.cs" />
<Compile Include="Screens\Settings\Debug\DebugViewModel.cs" />
<Compile Include="Screens\SurfaceEditor\SurfaceEditorViewModel.cs" />
<Compile Include="Screens\Settings\Tabs\Devices\DeviceSettingsViewModel.cs" />
<Compile Include="Screens\IScreenViewModel.cs" />
<Compile Include="Screens\Home\HomeViewModel.cs" />
<Compile Include="Screens\RootViewModel.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ViewModels\Screens\SettingsViewModel.cs" />
<Page Include="Views\Controls\ProfileEditor\ProfileEditorView.xaml">
<Compile Include="Screens\Settings\SettingsViewModel.cs" />
<Page Include="Screens\Module\ProfileEditor\ProfileEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\SurfaceEditor\SurfaceLedView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Controls\SurfaceEditor\SurfaceDeviceView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Dialogs\ConfirmDialogView.xaml">
<Page Include="Screens\News\NewsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Dialogs\SurfaceCreateView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\DebugView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\HomeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\ProfileEditor\ProfileDeviceView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\ProfileEditor\ProfileLedView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\ModuleRootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\RootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\SplashView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\SurfaceEditorView.xaml">
<Page Include="Screens\SurfaceEditor\Visualization\SurfaceLedView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Controls\Settings\DeviceSettingsView.xaml">
<Page Include="Screens\SurfaceEditor\Visualization\SurfaceDeviceView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Screens\Dialogs\ConfirmDialogView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Screens\SettingsView.xaml">
<Page Include="Screens\SurfaceEditor\Dialogs\SurfaceCreateView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Settings\Debug\DebugView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Home\HomeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\Visualization\ProfileDeviceView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\Visualization\ProfileLedView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ModuleRootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\RootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Splash\SplashView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\SurfaceEditor\SurfaceEditorView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Screens\Settings\Tabs\Devices\DeviceSettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Settings\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Workshop\WorkshopView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View File

@ -3,8 +3,9 @@ using System.Windows;
using Artemis.Core.Ninject;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject;
using Artemis.UI.Screens;
using Artemis.UI.Screens.Splash;
using Artemis.UI.Stylet;
using Artemis.UI.ViewModels.Screens;
using Ninject;
using Stylet;

View File

@ -1,5 +1,5 @@
using Artemis.Core.Plugins.Abstract;
using Artemis.UI.ViewModels.Screens;
using Artemis.UI.Screens.Module;
namespace Artemis.UI.Ninject.Factories
{

View File

@ -1,5 +1,5 @@
using Artemis.Core.Plugins.Abstract;
using Artemis.UI.ViewModels.Controls.ProfileEditor;
using Artemis.UI.Screens.Module.ProfileEditor;
namespace Artemis.UI.Ninject.Factories
{

View File

@ -1,8 +1,8 @@
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Stylet;
using Artemis.UI.ViewModels.Dialogs;
using Artemis.UI.ViewModels.Interfaces;
using FluentValidation;
using Ninject.Extensions.Conventions;
using Ninject.Extensions.Factory;

View File

@ -1,12 +1,11 @@
<UserControl x:Class="Artemis.UI.Views.Dialogs.ConfirmDialogView"
<UserControl x:Class="Artemis.UI.Screens.Dialogs.ConfirmDialogView"
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:Artemis.UI.Views.Dialogs"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:dialogs="clr-namespace:Artemis.UI.ViewModels.Dialogs"
xmlns:dialogs="clr-namespace:Artemis.UI.Screens.Dialogs"
mc:Ignorable="d"
d:DesignHeight="163.274" d:DesignWidth="254.425"
d:DataContext="{d:DesignInstance dialogs:ConfirmDialogViewModel}">

View File

@ -1,4 +1,6 @@
namespace Artemis.UI.ViewModels.Dialogs
using Artemis.UI.ViewModels.Dialogs;
namespace Artemis.UI.Screens.Dialogs
{
public class ConfirmDialogViewModel : DialogViewModelBase
{

View File

@ -1,15 +1,15 @@
<UserControl x:Class="Artemis.UI.Views.Screens.HomeView"
<UserControl x:Class="Artemis.UI.Screens.Home.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
xmlns:home="clr-namespace:Artemis.UI.Screens.Home"
mc:Ignorable="d"
d:DesignHeight="574.026"
d:DesignWidth="1029.87"
d:DataContext="{d:DesignInstance screens:HomeViewModel, IsDesignTimeCreatable=True}">
d:DataContext="{d:DesignInstance home:HomeViewModel, IsDesignTimeCreatable=True}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View File

@ -1,9 +1,8 @@
using System;
using System.Diagnostics;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens.Home
{
public class HomeViewModel : Screen, IScreenViewModel
{

View File

@ -1,6 +1,6 @@
using Stylet;
namespace Artemis.UI.ViewModels.Interfaces
namespace Artemis.UI.Screens
{
public interface IScreenViewModel : IScreen
{

View File

@ -1,15 +1,14 @@
<UserControl x:Class="Artemis.UI.Views.Screens.ModuleRootView"
<UserControl x:Class="Artemis.UI.Screens.Module.ModuleRootView"
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:Artemis.UI.Views.Screens"
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:module="clr-namespace:Artemis.UI.Screens.Module"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance screens:ModuleRootViewModel}">
d:DataContext="{d:DesignInstance module:ModuleRootViewModel}">
<dragablz:TabablzControl Margin="0 -1 0 0" ItemsSource="{Binding Items}" SelectedItem="{Binding ActiveItem}" FixedHeaderCount="{Binding FixedHeaderCount}">
<dragablz:TabablzControl.HeaderItemTemplate>
<DataTemplate>
@ -18,7 +17,7 @@
</dragablz:TabablzControl.HeaderItemTemplate>
<dragablz:TabablzControl.ContentTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding}" IsTabStop="False"/>
<ContentControl s:View.Model="{Binding}" IsTabStop="False" />
</DataTemplate>
</dragablz:TabablzControl.ContentTemplate>
</dragablz:TabablzControl>

View File

@ -2,11 +2,11 @@
using Artemis.UI.Ninject.Factories;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens.Module
{
public class ModuleRootViewModel : Conductor<ModuleViewModel>.Collection.OneActive
{
public ModuleRootViewModel(Module module, IProfileEditorViewModelFactory profileEditorViewModelFactory)
public ModuleRootViewModel(Core.Plugins.Abstract.Module module, IProfileEditorViewModelFactory profileEditorViewModelFactory)
{
Module = module;
@ -19,8 +19,8 @@ namespace Artemis.UI.ViewModels.Screens
ActiveItem = profileEditor;
}
public Module Module { get; }
public string Title => Module?.DisplayName;
public Core.Plugins.Abstract.Module Module { get; }
public int FixedHeaderCount => Items.Count;
}
}

View File

@ -1,13 +1,11 @@
<UserControl x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileEditorView"
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.ProfileEditorView"
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:Artemis.UI.Views.Controls.ProfileEditor"
xmlns:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:models="clr-namespace:Artemis.Core.Models.Surface;assembly=Artemis.Core"
xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileEditorViewModel}}">
@ -24,23 +22,25 @@
<Grid Margin="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="200" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<TextBlock>
<materialDesign:PackIcon Kind="AboutOutline" Margin="0 0 0 -3" /> The profile defines what colors the LEDs will have. Multiple groups of LEDs are defined into layers. On these layers you can apply effects.
</TextBlock>
<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0 0 0 1" Margin="0 10" />
</StackPanel>
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch" Margin="0,0,5,0">
<!-- Design area -->
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch">
<Grid ClipToBounds="True"
KeyUp="{s:Action EditorGridKeyUp}"
KeyDown="{s:Action EditorGridKeyDown}"
@ -90,8 +90,7 @@
<Grid Name="EditorDisplayGrid">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}"
ScaleY="{Binding PanZoomViewModel.Zoom}" />
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
<TranslateTransform X="{Binding PanZoomViewModel.PanX}" Y="{Binding PanZoomViewModel.PanY}" />
</TransformGroup>
</Grid.RenderTransform>
@ -145,40 +144,57 @@
<materialDesign:PackIcon Kind="ImageFilterCenterFocus" Height="24" Width="24" />
</Button>
</StackPanel>
<Grid Background="{StaticResource MaterialDesignPaper}" Visibility="{Binding IsInitializing, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
Initializing LED visualization...
</TextBlock>
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
</StackPanel>
</Grid>
</Grid>
</materialDesign:Card>
<Grid Grid.Row="1" Grid.Column="1">
<GridSplitter Grid.Row="1" Grid.Column="1" Width="5" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeWE" Margin="5 0" />
<!-- Right panels -->
<Grid Grid.Row="1" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="5,0,0,0" />
<GridSplitter Grid.Row="1" Width="5" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeWE" />
<materialDesign:Card Grid.Row="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="5,0,0,0" />
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
<TextBlock>Right top</TextBlock>
</materialDesign:Card>
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeNS" Margin="0 5" />
<materialDesign:Card Grid.Row="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
<TextBlock>Right bottom</TextBlock>
</materialDesign:Card>
</Grid>
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
<GridSplitter Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Height="5" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeNS" Margin="0 5" />
<!-- Bottom panels -->
<Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<materialDesign:Card Grid.Column="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="5,0,0,0" />
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeWE" />
<materialDesign:Card Grid.Column="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="5,0,0,0" />
<materialDesign:Card Grid.Column="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
<TextBlock>Bottom left</TextBlock>
</materialDesign:Card>
<GridSplitter Grid.Column="1" Width="5" Margin="5 0" HorizontalAlignment="Stretch" ShowsPreview="True" Cursor="SizeWE" />
<materialDesign:Card Grid.Column="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
<TextBlock>Bottom right</TextBlock>
</materialDesign:Card>
</Grid>
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
<materialDesign:PackIcon Kind="Keyboard" Margin="0 0 0 -3" />
<Run Text="Hold" />
<Run FontWeight="Bold" Text="shift" />
<Run Text="or click and drag to select multiple LEDs at once. To move around the surface hold down" />
<Run FontWeight="Bold" Text="ctrl" />
<Run Text="and drag." />
</TextBlock>
</Grid>
</UserControl>

View File

@ -9,19 +9,20 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services;
using Artemis.Core.Services.Storage;
using Artemis.UI.ViewModels.Screens;
using Artemis.UI.ViewModels.Utilities;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Screens.Shared;
using Artemis.UI.Screens.SurfaceEditor;
using RGB.NET.Core;
using Stylet;
using Point = System.Windows.Point;
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
namespace Artemis.UI.Screens.Module.ProfileEditor
{
public class ProfileEditorViewModel : ModuleViewModel
{
private readonly TimerUpdateTrigger _updateTrigger;
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ISettingsService settingsService) : base(module, "Profile Editor")
public ProfileEditorViewModel(Core.Plugins.Abstract.Module module, ISurfaceService surfaceService, ISettingsService settingsService) : base(module, "Profile Editor")
{
surfaceService.ActiveSurfaceConfigurationChanged += OnActiveSurfaceConfigurationChanged;
Devices = new ObservableCollection<ProfileDeviceViewModel>();
@ -33,13 +34,16 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
// Borrow RGB.NET's update trigger, update up to 25 FPS, ignore higher settings than that
var targetFps = Math.Min(settingsService.GetSetting("TargetFrameRate", 25).Value, 25);
// Borrow RGB.NET's update trigger but limit the FPS
var targetFpsSetting = settingsService.GetSetting("TargetFrameRate", 25);
var editorTargetFpsSetting = settingsService.GetSetting("EditorTargetFrameRate", 15);
var targetFps = Math.Min(targetFpsSetting.Value, editorTargetFpsSetting.Value);
_updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / targetFps};
_updateTrigger.Update += UpdateLeds;
}
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
public bool IsInitializing { get; private set; }
public RectangleGeometry SelectionRectangle { get; set; }
public PanZoomViewModel PanZoomViewModel { get; set; }
@ -50,6 +54,9 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
private void UpdateLeds(object sender, CustomUpdateData customUpdateData)
{
if (IsInitializing)
IsInitializing = Devices.Any(d => !d.AddedLeds);
foreach (var profileDeviceViewModel in Devices)
profileDeviceViewModel.Update();
}
@ -62,7 +69,16 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
// Create VMs for missing devices
var viewModel = Devices.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice);
if (viewModel == null)
Execute.OnUIThread(() => Devices.Add(new ProfileDeviceViewModel(surfaceDeviceConfiguration)));
{
// Create outside the UI thread to avoid slowdowns as much as possible
var profileDeviceViewModel = new ProfileDeviceViewModel(surfaceDeviceConfiguration);
Execute.OnUIThread(() =>
{
// Gotta call IsInitializing on the UI thread or its never gets picked up
IsInitializing = true;
Devices.Add(profileDeviceViewModel);
});
}
// Update existing devices
else
viewModel.Device = surfaceDeviceConfiguration;
@ -71,7 +87,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
// Sort the devices by ZIndex
Execute.OnUIThread(() =>
{
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
Devices.Move(Devices.IndexOf(device), device.ZIndex - 1);
});
}

View File

@ -1,13 +1,13 @@
<UserControl x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileDeviceView"
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.ProfileDeviceView"
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:s="https://github.com/canton7/Stylet"
xmlns:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:visualization="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileDeviceViewModel}}"
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileDeviceViewModel}}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<converters:NullToImageConverter x:Key="NullToImageConverter" />
@ -15,14 +15,14 @@
</UserControl.Resources>
<Grid>
<!-- Device image with fallback -->
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}, Mode=OneWay}" />
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
Stroke="{DynamicResource ControlBorderBrush}"
StrokeThickness="1"
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}" />
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}" />
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.DeviceName}"
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}"
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextWrapping="Wrap"
@ -37,13 +37,13 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" />
<Setter Property="Canvas.Left" Value="{Binding X, Mode=OneWay}" />
<Setter Property="Canvas.Top" Value="{Binding Y, Mode=OneWay}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl Width="{Binding Width}" Height="{Binding Height}" s:View.Model="{Binding}" />
<ContentControl Width="{Binding Width, Mode=OneWay}" Height="{Binding Height, Mode=OneWay}" s:View.Model="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

View File

@ -0,0 +1,79 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Artemis.Core.Models.Surface;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
public class ProfileDeviceViewModel : PropertyChangedBase
{
public ProfileDeviceViewModel(Device device)
{
Device = device;
Leds = new ObservableCollection<ProfileLedViewModel>();
if (Device.RgbDevice != null)
Task.Run(AddLedsAsync);
}
public ObservableCollection<ProfileLedViewModel> Leds { get; set; }
public Device Device { get; set; }
public bool AddedLeds { get; private set; }
public double X
{
get => Device.X;
set => Device.X = value;
}
public double Y
{
get => Device.Y;
set => Device.Y = value;
}
public int ZIndex
{
get => Device.ZIndex;
set => Device.ZIndex = value;
}
public Rect DeviceRectangle => Device.RgbDevice == null
? new Rect()
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
/// <summary>
/// Adds LEDs in batches of 5 to avoid UI freezes
/// </summary>
/// <returns></returns>
private async Task AddLedsAsync()
{
var index = 0;
foreach (var led in Device.RgbDevice.ToList())
{
Execute.OnUIThreadSync(() => Leds.Add(new ProfileLedViewModel(led)));
if (index % 5 == 0)
await Task.Delay(1);
index++;
}
AddedLeds = true;
}
/// <summary>
/// Update the color of all LEDs if finished adding
/// </summary>
public void Update()
{
if (!AddedLeds)
return;
foreach (var ledViewModel in Leds)
ledViewModel.Update();
}
}
}

View File

@ -0,0 +1,32 @@
<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:converters="clr-namespace:Artemis.UI.Converters"
xmlns:visualization="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.ProfileLedView"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileLedViewModel}}"
d:DesignHeight="25" d:DesignWidth="25">
<UserControl.Resources>
<converters:NullToImageConverter x:Key="NullToImageConverter" />
</UserControl.Resources>
<Canvas Width="{Binding Width, Mode=OneWay}" Height="{Binding Height, Mode=OneWay}">
<Canvas.Background>
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill"
ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}, Mode=OneWay}" />
</Canvas.Background>
<Path Data="{Binding DisplayGeometry, Mode=OneWay}" ClipToBounds="False">
<Path.Fill>
<SolidColorBrush Color="{Binding DisplayColor, Mode=OneWay}" Opacity="0.333" />
</Path.Fill>
</Path>
<Path Data="{Binding StrokeGeometry, Mode=OneWay}" ClipToBounds="False">
<Path.Fill>
<SolidColorBrush Color="{Binding DisplayColor, Mode=OneWay}" />
</Path.Fill>
</Path>
</Canvas>
</UserControl>

View File

@ -6,7 +6,7 @@ using RGB.NET.Core;
using Stylet;
using Color = System.Windows.Media.Color;
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
public class ProfileLedViewModel : PropertyChangedBase
{
@ -23,10 +23,10 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
public Led Led { get; }
public double X { get; private set; }
public double Y { get; private set; }
public double Width { get; private set; }
public double Height { get; private set; }
public double X { get; }
public double Y { get; }
public double Width { get; }
public double Height { get; }
public Geometry DisplayGeometry { get; private set; }
public Geometry StrokeGeometry { get; private set; }
@ -89,7 +89,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
Children = new TransformCollection
{
new ScaleTransform(Led.LedRectangle.Width - deflateAmount, Led.LedRectangle.Height - deflateAmount),
new TranslateTransform(deflateAmount/2, deflateAmount/2)
new TranslateTransform(deflateAmount / 2, deflateAmount / 2)
}
}
);

View File

@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.UI.Screens.News.NewsView"
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:Artemis.UI.Screens.News"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock>Today's news: There is no news (yet)!</TextBlock>
</Grid>
</UserControl>

View File

@ -0,0 +1,9 @@
using Stylet;
namespace Artemis.UI.Screens.News
{
public class NewsViewModel : Screen, IScreenViewModel
{
public string Title => "News";
}
}

View File

@ -1,4 +1,4 @@
<metro:MetroWindow x:Class="Artemis.UI.Views.Screens.RootView"
<metro:MetroWindow x:Class="Artemis.UI.Screens.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"
@ -7,7 +7,6 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:abstract="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"

View File

@ -4,13 +4,16 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Controls;
using Artemis.Core.Events;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.ViewModels.Interfaces;
using Artemis.UI.Screens.Home;
using Artemis.UI.Screens.News;
using Artemis.UI.Screens.Settings;
using Artemis.UI.Screens.SurfaceEditor;
using Artemis.UI.Screens.Workshop;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens
{
public class RootViewModel : Conductor<IScreen>.Collection.OneActive
{
@ -30,8 +33,8 @@ namespace Artemis.UI.ViewModels.Screens
ActiveItem = _artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel));
// Sync up with the plugin service
Modules = new BindableCollection<Module>();
Modules.AddRange(_pluginService.GetPluginsOfType<Module>());
Modules = new BindableCollection<Core.Plugins.Abstract.Module>();
Modules.AddRange(_pluginService.GetPluginsOfType<Core.Plugins.Abstract.Module>());
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
@ -39,10 +42,10 @@ namespace Artemis.UI.ViewModels.Screens
PropertyChanged += OnSelectedPageChanged;
}
public IObservableCollection<Module> Modules { get; set; }
public IObservableCollection<Core.Plugins.Abstract.Module> Modules { get; set; }
public bool MenuOpen { get; set; }
public ListBoxItem SelectedPage { get; set; }
public Module SelectedModule { get; set; }
public Core.Plugins.Abstract.Module SelectedModule { get; set; }
public async Task NavigateToSelectedModule()
{
@ -67,7 +70,7 @@ namespace Artemis.UI.ViewModels.Screens
Modules.Remove(existing);
}
if (e.PluginInfo.Instance is Module module)
if (e.PluginInfo.Instance is Core.Plugins.Abstract.Module module)
Modules.Add(module);
}
@ -96,19 +99,19 @@ namespace Artemis.UI.ViewModels.Screens
switch (SelectedPage.Name)
{
case "Home":
ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel)));
ActivateItem(_artemisViewModels.First(v => v is HomeViewModel));
break;
case "News":
// ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(NewsViewModel)));
ActivateItem(_artemisViewModels.First(v => v is NewsViewModel));
break;
case "Workshop":
// ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(WorkshopViewModel)));
ActivateItem(_artemisViewModels.First(v => v is WorkshopViewModel));
break;
case "SurfaceEditor":
ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(SurfaceEditorViewModel)));
ActivateItem(_artemisViewModels.First(v => v is SurfaceEditorViewModel));
break;
case "Settings":
ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(SettingsViewModel)));
ActivateItem(_artemisViewModels.First(v => v is SettingsViewModel));
break;
}

View File

@ -1,10 +1,9 @@
<UserControl x:Class="Artemis.UI.Views.Screens.SettingsView"
<UserControl x:Class="Artemis.UI.Screens.Settings.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
xmlns:xaml="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance screens:SettingsViewModel}"

View File

@ -1,12 +1,12 @@
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage;
using Artemis.UI.ViewModels.Controls.Settings;
using Artemis.UI.ViewModels.Interfaces;
using Artemis.UI.Screens.Settings.Debug;
using Artemis.UI.Screens.Settings.Tabs.Devices;
using Ninject;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens.Settings
{
public class SettingsViewModel : Screen, IScreenViewModel
{

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.Views.Controls.Settings.DeviceSettingsView"
<UserControl x:Class="Artemis.UI.Screens.Settings.Tabs.Devices.DeviceSettingsView"
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:settings="clr-namespace:Artemis.UI.ViewModels.Controls.Settings"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
d:DataContext="{d:DesignInstance settings:DeviceSettingsViewModel}"

View File

@ -6,7 +6,7 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Services.Interfaces;
using Humanizer;
namespace Artemis.UI.ViewModels.Controls.Settings
namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
public class DeviceSettingsViewModel
{

View File

@ -5,7 +5,7 @@ using System.Windows.Input;
using System.Windows.Media;
using Stylet;
namespace Artemis.UI.ViewModels.Utilities
namespace Artemis.UI.Screens.Shared
{
public class PanZoomViewModel : PropertyChangedBase
{

View File

@ -1,10 +1,10 @@
<mah:MetroWindow x:Class="Artemis.UI.Views.Screens.SplashView"
<mah:MetroWindow x:Class="Artemis.UI.Screens.Splash.SplashView"
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:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
xmlns:splash="clr-namespace:Artemis.UI.Screens.Splash"
mc:Ignorable="d"
Title="Artemis"
Height="450"
@ -16,7 +16,7 @@
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
d:DataContext="{d:DesignInstance screens:SplashViewModel}">
d:DataContext="{d:DesignInstance splash:SplashViewModel}">
<Grid Background="{DynamicResource PrimaryHueMidBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="250" />
@ -25,8 +25,7 @@
<RowDefinition />
</Grid.RowDefinitions>
<Image Source="{StaticResource BowIcon}" Stretch="Uniform" Margin="6,50,6,6" />
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="White"
FontSize="16">
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="White" FontSize="16">
Artemis is initializing...
</TextBlock>
<TextBlock Grid.Row="2" HorizontalAlignment="Center" Foreground="#FFDDDDDD" Text="{Binding Status}" />

View File

@ -2,7 +2,7 @@
using Ninject;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens.Splash
{
public class SplashViewModel : Screen
{

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.Views.Dialogs.SurfaceCreateView"
<UserControl x:Class="Artemis.UI.Screens.SurfaceEditor.Dialogs.SurfaceCreateView"
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:Artemis.UI.Views.Dialogs"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"

View File

@ -1,7 +1,8 @@
using System.Threading.Tasks;
using Artemis.UI.ViewModels.Dialogs;
using Stylet;
namespace Artemis.UI.ViewModels.Dialogs
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
{
public class SurfaceCreateViewModel : DialogViewModelBase
{

View File

@ -1,6 +1,6 @@
using FluentValidation;
namespace Artemis.UI.ViewModels.Dialogs
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
{
public class SurfaceCreateViewModelValidator : AbstractValidator<SurfaceCreateViewModel>
{

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.Views.Screens.SurfaceEditorView"
<UserControl x:Class="Artemis.UI.Screens.SurfaceEditor.SurfaceEditorView"
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"

View File

@ -9,14 +9,13 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services;
using Artemis.Core.Services.Storage;
using Artemis.UI.Screens.Shared;
using Artemis.UI.Screens.SurfaceEditor.Dialogs;
using Artemis.UI.Screens.SurfaceEditor.Visualization;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.ViewModels.Controls.SurfaceEditor;
using Artemis.UI.ViewModels.Dialogs;
using Artemis.UI.ViewModels.Interfaces;
using Artemis.UI.ViewModels.Utilities;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
namespace Artemis.UI.Screens.SurfaceEditor
{
public class SurfaceEditorViewModel : Screen, IScreenViewModel
{
@ -65,7 +64,7 @@ namespace Artemis.UI.ViewModels.Screens
{
SurfaceListWidth = _settingsService.GetSetting("SurfaceEditor.SurfaceListWidth", new GridLength(300.0));
}
private void SaveWorkspaceSettings()
{
SurfaceListWidth.Save();

View File

@ -1,12 +1,12 @@
<UserControl x:Class="Artemis.UI.Views.Controls.SurfaceEditor.SurfaceDeviceView"
<UserControl x:Class="Artemis.UI.Screens.SurfaceEditor.Visualization.SurfaceDeviceView"
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:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:surfaceEditor="clr-namespace:Artemis.UI.ViewModels.Controls.SurfaceEditor"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:surfaceEditor="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Visualization"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type surfaceEditor:SurfaceDeviceViewModel}}"
d:DesignHeight="450" d:DesignWidth="800"

View File

@ -5,7 +5,7 @@ using System.Windows.Input;
using Artemis.Core.Models.Surface;
using Stylet;
namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
namespace Artemis.UI.Screens.SurfaceEditor.Visualization
{
public class SurfaceDeviceViewModel : PropertyChangedBase
{

View File

@ -3,9 +3,9 @@
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:surfaceEditor="clr-namespace:Artemis.UI.ViewModels.Controls.SurfaceEditor"
xmlns:Converters="clr-namespace:Artemis.UI.Converters"
x:Class="Artemis.UI.Views.Controls.SurfaceEditor.SurfaceLedView"
xmlns:surfaceEditor="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Visualization"
x:Class="Artemis.UI.Screens.SurfaceEditor.Visualization.SurfaceLedView"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type surfaceEditor:SurfaceLedViewModel}}"
d:DesignHeight="25" d:DesignWidth="25">

View File

@ -1,7 +1,7 @@
using RGB.NET.Core;
using Stylet;
namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
namespace Artemis.UI.Screens.SurfaceEditor.Visualization
{
public class SurfaceLedViewModel : PropertyChangedBase
{

View File

@ -0,0 +1,12 @@
<UserControl x:Class="Artemis.UI.Screens.Workshop.WorkshopView"
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:Artemis.UI.Screens.Workshop"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock>Work work!</TextBlock>
</Grid>
</UserControl>

View File

@ -0,0 +1,9 @@
using Stylet;
namespace Artemis.UI.Screens.Workshop
{
public class WorkshopViewModel : Screen, IScreenViewModel
{
public string Title => "Workshop";
}
}

View File

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Artemis.UI.Screens.Dialogs;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.ViewModels.Dialogs;
using MaterialDesignThemes.Wpf;

View File

@ -1,56 +0,0 @@
using System.Collections.Generic;
using System.Windows;
using Artemis.Core.Models.Surface;
using Stylet;
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
{
public class ProfileDeviceViewModel : PropertyChangedBase
{
private readonly List<ProfileLedViewModel> _leds;
public ProfileDeviceViewModel(Device device)
{
Device = device;
_leds = new List<ProfileLedViewModel>();
if (Device.RgbDevice != null)
{
foreach (var led in Device.RgbDevice)
_leds.Add(new ProfileLedViewModel(led));
}
}
public Device Device { get; set; }
public double X
{
get => Device.X;
set => Device.X = value;
}
public double Y
{
get => Device.Y;
set => Device.Y = value;
}
public int ZIndex
{
get => Device.ZIndex;
set => Device.ZIndex = value;
}
public IReadOnlyCollection<ProfileLedViewModel> Leds => _leds.AsReadOnly();
public Rect DeviceRectangle => Device.RgbDevice == null
? new Rect()
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
public void Update()
{
foreach (var ledViewModel in _leds)
ledViewModel.Update();
}
}
}

View File

@ -1,80 +0,0 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Core.Events;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
{
public class DebugViewModel : Screen, IScreenViewModel
{
private readonly ICoreService _coreService;
private readonly IRgbService _rgbService;
public DebugViewModel(ICoreService coreService, IRgbService rgbService)
{
_coreService = coreService;
_rgbService = rgbService;
_coreService.FrameRendered += CoreServiceOnFrameRendered;
_coreService.FrameRendering += CoreServiceOnFrameRendering;
}
public ImageSource CurrentFrame { get; set; }
public double CurrentFps { get; set; }
public string Title => "Debugger";
public void ForceGarbageCollection()
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
private void CoreServiceOnFrameRendered(object sender, FrameRenderedEventArgs e)
{
if (e.Bitmap == null)
return;
var imageSource = ImageSourceFromBitmap(e.Bitmap);
imageSource.Freeze();
Execute.OnUIThread(() => { CurrentFrame = imageSource; });
}
private void CoreServiceOnFrameRendering(object sender, FrameRenderingEventArgs e)
{
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2);
}
protected override void OnClose()
{
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
base.OnClose();
}
// This is much quicker than saving the bitmap into a memory stream and converting it
private static ImageSource ImageSourceFromBitmap(Bitmap bmp)
{
var handle = bmp.GetHbitmap();
try
{
return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
finally
{
DeleteObject(handle);
}
}
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject([In] IntPtr hObject);
}
}

View File

@ -1,33 +0,0 @@
<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:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
xmlns:Converters="clr-namespace:Artemis.UI.Converters"
x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileLedView"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileLedViewModel}}"
d:DesignHeight="25" d:DesignWidth="25"
ToolTip="{Binding Tooltip}">
<UserControl.Resources>
<Converters:NullToImageConverter x:Key="NullToImageConverter" />
</UserControl.Resources>
<Canvas Width="{Binding Width}" Height="{Binding Height}">
<Canvas.Background>
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill"
ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
</Canvas.Background>
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False">
<Path.Fill>
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.333" />
</Path.Fill>
</Path>
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False">
<Path.Fill>
<SolidColorBrush Color="{Binding DisplayColor}" />
</Path.Fill>
</Path>
</Canvas>
</UserControl>

View File

@ -1,99 +0,0 @@
<metro:MetroWindow x:Class="Artemis.UI.Views.Screens.DebugView"
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:s="https://github.com/canton7/Stylet"
xmlns:abstract="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
Title="Artemis debugger"
Width="800"
Height="800"
d:DesignHeight="639.411"
d:DesignWidth="1113.251"
d:DataContext="{d:DesignInstance screens:DebugViewModel}"
Icon="/Artemis.UI;component/Resources/logo-512.png">
<metro:MetroWindow.Resources>
<DrawingImage x:Key="BowIcon">
<DrawingImage.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="{DynamicResource IdealForegroundColorBrush}"
Geometry="M1518 3378 c-48 -63 -61 -101 -66 -184 -4 -70 -1 -91 27
-170 l31 -89 -27 -20 c-32 -24 -849 -601 -981 -693 l-93 -64 -87 40
c-48 22 -91 37 -95 32 -5 -4 9 -41 29 -83 l37 -75 -28 -24 c-23 -20
-29 -35 -33 -81 l-4 -56 -82 -19 c-109 -25 -109 -41 4 -91 l85 -38 7
-64 c15 -137 90 -1279 85 -1293 -3 -7 -35 -24 -70 -35 -159 -53 -257
-168 -257 -302 0 -35 2 -38 47 -53 54 -18 185 -21 232 -5 29 10 31
14 31 58 0 26 6 56 14 66 13 18 15 18 46 -8 44 -37 78 -35 119 7 l34
35 -17 41 c-9 23 -12 39 -6 35 6 -4 43 -1 83 6 39 6 219 14 398 18
l327 6 113 57 c158 78 256 166 317 282 24 46 27 62 27 152 0 98 -1
103 -41 184 l-42 83 44 69 c24 37 51 68 59 68 9 0 44 -14 78 -32 l62
-31 -93 -44 c-58 -26 -92 -48 -90 -55 9 -27 353 -68 570 -68 108 0
108 0 108 24 0 34 -105 171 -220 286 -122 122 -238 216 -250 204 -6
-6 -1 -42 16 -98 14 -49 23 -91 19 -94 -3 -3 -36 9 -73 27 l-69 33 24
71 c13 39 23 76 23 82 0 6 28 17 63 24 279 58 399 300 314 632 -32
121 -49 155 -134 255 -37 45 -106 126 -152 180 -73 87 -241 326 -241
343 0 3 15 13 32 21 21 10 35 25 40 45 15 60 -16 103 -81 108 -43 3
-39 22 14 74 l45 43 -25 50 c-35 69 -77 114 -130 139 -63 30 -88 27
-117 -11z m215 -835 c188 -279 250 -417 250 -548 0 -133 -74 -214 -243
-265 l-55 -16 -37 -138 c-21 -76 -39 -140 -40 -141 -6 -5 -814 377 -823
390 -6 7 -19 46 -29 86 -10 41 -25 81 -33 91 -8 9 -57 35 -109 59 -52
23 -93 46 -92 51 2 4 233 169 513 366 l510 358 26 -46 c15 -25 88 -136
162 -247z m-1108 -898 c61 21 88 26 107 19 14 -5 204 -92 421 -194 l395
-185 -27 -35 c-15 -19 -53 -72 -84 -117 l-57 -81 30 -90 c39 -117 40
-179 2 -253 -45 -90 -147 -145 -347 -189 -71 -15 -435 -59 -600 -73 l
-29 -2 -37 540 c-20 297 -40 581 -43 632 l-7 92 98 -46 97 -46 81 28z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</metro:MetroWindow.Resources>
<metro:MetroWindow.IconTemplate>
<DataTemplate>
<Grid Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Background="Transparent"
RenderOptions.BitmapScalingMode="HighQuality"
Margin="0,0,-10,0">
<Image Source="{DynamicResource BowIcon}"
Stretch="Uniform"
Margin="6" />
</Grid>
</DataTemplate>
</metro:MetroWindow.IconTemplate>
<StackPanel Margin="10, 10, 10, 10">
<TextBlock>
In this window you can view the inner workings of Artemis.
Please not that having this window open can have a performance impact on your system.
</TextBlock>
<Grid Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0">
This image shows what is being rendered and dispatched to RGB.NET
</TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Margin="0,0,5,0" FontWeight="Bold">
FPS:
</TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Right" Text="{Binding CurrentFps}" />
</Grid>
<materialDesign:Card VerticalAlignment="Stretch" Margin="0, 5,0,0">
<Image Source="{Binding CurrentFrame}" />
</materialDesign:Card>
<Button Command="{s:Action ForceGarbageCollection}" Style="{StaticResource MaterialDesignRaisedButton}"
HorizontalAlignment="Left" Margin="0, 10, 0, 0">
Force garbage collection
</Button>
</StackPanel>
</metro:MetroWindow>