mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added the views and VM's I'm planning to use
This commit is contained in:
parent
5677cdf498
commit
5921f8ab54
@ -72,10 +72,10 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="x64\CUESDK.dll">
|
||||
<Content Include="x64\CUESDK.x64_2017.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="x86\CUESDK.dll">
|
||||
<Content Include="x86\CUESDK_2017.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
@ -20,8 +20,8 @@ namespace Artemis.Plugins.Devices.Corsair
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args);
|
||||
CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.dll"));
|
||||
CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK.dll"));
|
||||
CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll"));
|
||||
CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK_2017.dll"));
|
||||
_rgbService.AddDeviceProvider(DeviceProvider);
|
||||
}
|
||||
|
||||
|
||||
@ -174,6 +174,13 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionsViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertyViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Layers\LayersViewModel.cs" />
|
||||
<Compile Include="Screens\News\NewsViewModel.cs" />
|
||||
<Compile Include="Screens\Workshop\WorkshopViewModel.cs" />
|
||||
<Compile Include="Services\Dialog\DialogService.cs" />
|
||||
@ -206,6 +213,34 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Settings\SettingsViewModel.cs" />
|
||||
<Page Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionsView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertyView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerElements\LayerElementView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Layers\LayersView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\ProfileEditorView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
50
src/Artemis.UI/SDK bug
Normal file
50
src/Artemis.UI/SDK bug
Normal file
@ -0,0 +1,50 @@
|
||||
Ok so with the following code:
|
||||
|
||||
```cpp
|
||||
bool errorCheck(const std::string &msg) {
|
||||
auto error = CorsairGetLastError();
|
||||
if (error != CorsairError::CE_Success) {
|
||||
std::cerr << msg << " (Error: " << toString(error) << ')' << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CorsairPerformProtocolHandshake();
|
||||
if (errorCheck("Handshake error")) {
|
||||
getchar();
|
||||
return -1;
|
||||
}
|
||||
|
||||
const auto devicesCount = CorsairGetDeviceCount();
|
||||
for (int i = 0; i < devicesCount; ++i) {
|
||||
const auto info = CorsairGetDeviceInfo(i);
|
||||
if (!info) {
|
||||
errorCheck("Get device info error");
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << "Model: " << info->model << "Logical layout: " << info->logicalLayout << std::endl;
|
||||
}
|
||||
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
I'm getting this output, which is as expected:
|
||||
```
|
||||
Model: K95 RGB PLATINUMLogical layout: 13
|
||||
```
|
||||
|
||||
Then when I put the PC to full stand-by and wake it up again the code returns the following:
|
||||
```
|
||||
Model: K95 RGB PLATINUMLogical layout: 0
|
||||
```
|
||||
|
||||
Windows 10 Home 1903
|
||||
iCUE v. 3.22.74
|
||||
SDK: 3.0.301
|
||||
@ -6,9 +6,11 @@
|
||||
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:module="clr-namespace:Artemis.UI.Screens.Module"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
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>
|
||||
@ -17,7 +19,9 @@
|
||||
</dragablz:TabablzControl.HeaderItemTemplate>
|
||||
<dragablz:TabablzControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" IsTabStop="False" />
|
||||
<materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect FadeIn}">
|
||||
<ContentControl s:View.Model="{Binding}" IsTabStop="False"/>
|
||||
</materialDesign:TransitioningContent>
|
||||
</DataTemplate>
|
||||
</dragablz:TabablzControl.ContentTemplate>
|
||||
</dragablz:TabablzControl>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Stylet;
|
||||
|
||||
@ -6,21 +7,34 @@ namespace Artemis.UI.Screens.Module
|
||||
{
|
||||
public class ModuleRootViewModel : Conductor<ModuleViewModel>.Collection.OneActive
|
||||
{
|
||||
private readonly IProfileEditorViewModelFactory _profileEditorViewModelFactory;
|
||||
|
||||
public ModuleRootViewModel(Core.Plugins.Abstract.Module module, IProfileEditorViewModelFactory profileEditorViewModelFactory)
|
||||
{
|
||||
Module = module;
|
||||
_profileEditorViewModelFactory = profileEditorViewModelFactory;
|
||||
|
||||
// Add the profile editor and module VMs
|
||||
var profileEditor = profileEditorViewModelFactory.CreateModuleViewModel(Module);
|
||||
Items.Add(profileEditor);
|
||||
Items.AddRange(Module.GetViewModels());
|
||||
|
||||
// Activate the profile editor
|
||||
ActiveItem = profileEditor;
|
||||
Task.Run(AddTabsAsync);
|
||||
}
|
||||
|
||||
public string Title => Module?.DisplayName;
|
||||
public Core.Plugins.Abstract.Module Module { get; }
|
||||
public int FixedHeaderCount => Items.Count;
|
||||
|
||||
private async Task AddTabsAsync()
|
||||
{
|
||||
// Give the screen a moment to active without freezing the UI thread
|
||||
await Task.Delay(400);
|
||||
|
||||
// Create the profile editor and module VMs
|
||||
var profileEditor = _profileEditorViewModelFactory.CreateModuleViewModel(Module);
|
||||
var moduleViewModels = Module.GetViewModels();
|
||||
|
||||
Items.Add(profileEditor);
|
||||
Items.AddRange(moduleViewModels);
|
||||
|
||||
// Activate the profile editor
|
||||
ActiveItem = profileEditor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.DisplayConditionView"
|
||||
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.Module.ProfileEditor.DisplayConditions"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||
{
|
||||
public class DisplayConditionViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.DisplayConditionsView"
|
||||
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.Module.ProfileEditor.DisplayConditions"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||
{
|
||||
class DisplayConditionsViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.ElementProperties.ElementPropertiesView"
|
||||
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.Module.ProfileEditor.ElementProperties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties
|
||||
{
|
||||
class ElementPropertiesViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.ElementProperties.ElementPropertyView"
|
||||
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.Module.ProfileEditor.ElementProperties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties
|
||||
{
|
||||
public class ElementPropertyViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerElements.LayerElementView"
|
||||
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.Module.ProfileEditor.LayerElements"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements
|
||||
{
|
||||
public class LayerElementViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerElements.LayerElementsView"
|
||||
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.Module.ProfileEditor.LayerElements"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements
|
||||
{
|
||||
public class LayerElementsViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Layers.LayersView"
|
||||
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.Module.ProfileEditor.Layers"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Layers
|
||||
{
|
||||
public class LayersViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -17,8 +17,34 @@
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="Grid" x:Key="InitializingFade">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsInitializing}" Value="False">
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:0.5">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<QuadraticEase EasingMode="EaseInOut" />
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
@ -145,7 +171,8 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Background="{StaticResource MaterialDesignPaper}" Visibility="{Binding IsInitializing, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
|
||||
<!-- Loading indicator -->
|
||||
<Grid Background="{StaticResource MaterialDesignPaper}" Style="{StaticResource InitializingFade}">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
Initializing LED visualization...
|
||||
|
||||
@ -76,7 +76,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
{
|
||||
// Gotta call IsInitializing on the UI thread or its never gets picked up
|
||||
IsInitializing = true;
|
||||
Devices.Add(profileDeviceViewModel);
|
||||
lock (Devices)
|
||||
{
|
||||
Devices.Add(profileDeviceViewModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Update existing devices
|
||||
@ -87,8 +90,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
// Sort the devices by ZIndex
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
|
||||
Devices.Move(Devices.IndexOf(device), device.ZIndex - 1);
|
||||
lock (Devices)
|
||||
{
|
||||
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
|
||||
Devices.Move(Devices.IndexOf(device), device.ZIndex - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
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.Screens"
|
||||
mc:Ignorable="d"
|
||||
GlowBrush="{DynamicResource AccentColorBrush}"
|
||||
FontFamily="{StaticResource DefaultFont}"
|
||||
@ -16,6 +17,32 @@
|
||||
d:DataContext="{d:DesignInstance screens:RootViewModel}"
|
||||
SaveWindowPosition="True"
|
||||
Icon="/Artemis.UI;component/Resources/logo-512.png">
|
||||
<metro:MetroWindow.Resources>
|
||||
<Style TargetType="ContentControl" x:Key="InitializingFade">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ActiveItemReady}" Value="False">
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:0.4">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<QuadraticEase EasingMode="EaseInOut" />
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:0" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</metro:MetroWindow.Resources>
|
||||
<metro:MetroWindow.LeftWindowCommands>
|
||||
<metro:WindowCommands>
|
||||
<!-- Make the window title dissapear by providing an empty overwrite of WindowCommands -->
|
||||
@ -112,34 +139,24 @@
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<DockPanel>
|
||||
<materialDesign:ColorZone Padding="10"
|
||||
materialDesign:ShadowAssist.ShadowDepth="Depth2"
|
||||
Mode="PrimaryMid"
|
||||
DockPanel.Dock="Top">
|
||||
<materialDesign:ColorZone Padding="10" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" DockPanel.Dock="Top">
|
||||
<DockPanel>
|
||||
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
|
||||
IsChecked="{Binding MenuOpen}"
|
||||
x:Name="MenuToggleButton" />
|
||||
<materialDesign:PopupBox DockPanel.Dock="Right"
|
||||
PlacementMode="BottomAndAlignRightEdges"
|
||||
StaysOpen="False">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" IsChecked="{Binding MenuOpen}" x:Name="MenuToggleButton" />
|
||||
<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 ActiveItem.Title}" />
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Text="{Binding ActiveItem.Title}" />
|
||||
</DockPanel>
|
||||
</materialDesign:ColorZone>
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" />
|
||||
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" IsTabStop="False" />
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost>
|
||||
</materialDesign:DialogHost>
|
||||
|
||||
@ -11,11 +11,13 @@ using Artemis.UI.Screens.News;
|
||||
using Artemis.UI.Screens.Settings;
|
||||
using Artemis.UI.Screens.SurfaceEditor;
|
||||
using Artemis.UI.Screens.Workshop;
|
||||
using MahApps.Metro.Controls;
|
||||
using MaterialDesignThemes.Wpf.Transitions;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens
|
||||
{
|
||||
public class RootViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
public class RootViewModel : Conductor<IScreen>
|
||||
{
|
||||
private readonly ICollection<IScreenViewModel> _artemisViewModels;
|
||||
private readonly IModuleViewModelFactory _moduleViewModelFactory;
|
||||
@ -27,10 +29,9 @@ namespace Artemis.UI.Screens
|
||||
_pluginService = pluginService;
|
||||
_moduleViewModelFactory = moduleViewModelFactory;
|
||||
|
||||
// Add the built-in items
|
||||
Items.AddRange(artemisViewModels);
|
||||
// Activate the home item
|
||||
ActiveItem = _artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel));
|
||||
ActiveItemReady = true;
|
||||
|
||||
// Sync up with the plugin service
|
||||
Modules = new BindableCollection<Core.Plugins.Abstract.Module>();
|
||||
@ -46,18 +47,19 @@ namespace Artemis.UI.Screens
|
||||
public bool MenuOpen { get; set; }
|
||||
public ListBoxItem SelectedPage { get; set; }
|
||||
public Core.Plugins.Abstract.Module SelectedModule { get; set; }
|
||||
public bool ActiveItemReady { get; set; }
|
||||
|
||||
public async Task NavigateToSelectedModule()
|
||||
{
|
||||
if (SelectedModule == null)
|
||||
return;
|
||||
|
||||
MenuOpen = false;
|
||||
SelectedPage = null;
|
||||
|
||||
// Create a view model for the given plugin info (which will be a module)
|
||||
var viewModel = await Task.Run(() => _moduleViewModelFactory.CreateModuleViewModel(SelectedModule));
|
||||
ActivateItem(viewModel);
|
||||
|
||||
SelectedPage = null;
|
||||
MenuOpen = false;
|
||||
}
|
||||
|
||||
private void PluginServiceOnPluginEnabled(object sender, PluginEventArgs e)
|
||||
@ -91,11 +93,18 @@ namespace Artemis.UI.Screens
|
||||
await NavigateToSelectedModule();
|
||||
}
|
||||
|
||||
private void OnSelectedPageChanged(object sender, PropertyChangedEventArgs e)
|
||||
private async void OnSelectedPageChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName != "SelectedPage" || SelectedPage == null)
|
||||
return;
|
||||
|
||||
SelectedModule = null;
|
||||
MenuOpen = false;
|
||||
ActiveItemReady = false;
|
||||
|
||||
// Let the menu close smoothly to avoid a sluggish feeling
|
||||
await Task.Delay(400);
|
||||
|
||||
switch (SelectedPage.Name)
|
||||
{
|
||||
case "Home":
|
||||
@ -115,8 +124,7 @@ namespace Artemis.UI.Screens
|
||||
break;
|
||||
}
|
||||
|
||||
SelectedModule = null;
|
||||
MenuOpen = false;
|
||||
ActiveItemReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user