mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
UI - Made module tabs uppercase since that's what we do
Modules - Finished module ordering
This commit is contained in:
1 parent
3128bd7270
commit
2f41b52a03
20 files changed
+272
-208
No files matched your search
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Settings.Tabs.Modules.ModuleOrderModuleView"
|
||||
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.Settings.Tabs.Modules"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:ModuleOrderModuleViewModel}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Priority}"
|
||||
Style="{StaticResource MaterialDesignTextBlock}"
|
||||
Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Module.DisplayName}" Style="{StaticResource MaterialDesignTextBlock}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Modules
|
||||
{
|
||||
public class ModuleOrderModuleViewModel : PropertyChangedBase
|
||||
{
|
||||
private string _priority;
|
||||
|
||||
public ModuleOrderModuleViewModel(Module module)
|
||||
{
|
||||
Module = module;
|
||||
Update();
|
||||
}
|
||||
|
||||
public Module Module { get; }
|
||||
|
||||
public string Priority
|
||||
{
|
||||
get => _priority;
|
||||
set => SetAndNotify(ref _priority, value);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
switch (Module.PriorityCategory)
|
||||
{
|
||||
case ModulePriorityCategory.Normal:
|
||||
Priority = "3." + (Module.Priority + 1);
|
||||
break;
|
||||
case ModulePriorityCategory.Application:
|
||||
Priority = "2." + (Module.Priority + 1);
|
||||
break;
|
||||
case ModulePriorityCategory.Overlay:
|
||||
Priority = "1." + (Module.Priority + 1);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,19 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Profile editor settings -->
|
||||
<StackPanel>
|
||||
<Grid Margin="0 15">
|
||||
<TextBlock TextWrapping="Wrap" Style="{StaticResource MaterialDesignTextBlock}">
|
||||
Drag and drop the modules below to change their rendering priority. <LineBreak/><LineBreak/>
|
||||
- Like in the profile editor, the modules at the top render over modules at the bottom <LineBreak/>
|
||||
- The categories serve as a starting point for new modules, you may freely move modules between the categories <LineBreak/>
|
||||
</TextBlock>
|
||||
|
||||
<Grid Margin="0 0 0 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">Overlays</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">1 - Overlays</TextBlock>
|
||||
<TextBlock Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||
VerticalAlignment="Bottom"
|
||||
@@ -36,25 +41,41 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding OverlayModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
<Border BorderThickness="2" >
|
||||
<Border.BorderBrush>
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle StrokeDashArray="4 2" Stroke="{DynamicResource MaterialDesignDivider}" StrokeThickness="2"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
<ListBox ItemsSource="{Binding OverlayModules}"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding}"
|
||||
MinHeight="40">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<Grid Margin="0 15">
|
||||
<Grid Margin="0 15 0 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">Applications/games</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">2 - Applications/games</TextBlock>
|
||||
<TextBlock Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||
VerticalAlignment="Bottom"
|
||||
@@ -65,25 +86,41 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding ApplicationModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
<Border BorderThickness="2" >
|
||||
<Border.BorderBrush>
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle StrokeDashArray="4 2" Stroke="{DynamicResource MaterialDesignDivider}" StrokeThickness="2"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
<ListBox ItemsSource="{Binding ApplicationModules}"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding}"
|
||||
MinHeight="40">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="2">
|
||||
<Grid Margin="0 15">
|
||||
<Grid Margin="0 15 0 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">Normal</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">3 - Normal</TextBlock>
|
||||
<TextBlock Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||
VerticalAlignment="Bottom"
|
||||
@@ -94,14 +131,30 @@
|
||||
</Grid>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<ListBox ItemsSource="{Binding NormalModules}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding ModulesDropHandler}"
|
||||
MinHeight="30"/>
|
||||
<Border BorderThickness="2" >
|
||||
<Border.BorderBrush>
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle StrokeDashArray="4 2" Stroke="{DynamicResource MaterialDesignDivider}" StrokeThickness="2"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
<ListBox ItemsSource="{Binding NormalModules}"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding}"
|
||||
MinHeight="40">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,54 +1,84 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Modules
|
||||
{
|
||||
public class ModuleOrderTabViewModel : Screen
|
||||
public class ModuleOrderTabViewModel : Screen, IDropTarget
|
||||
{
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IModuleService _moduleService;
|
||||
private List<ModuleOrderModuleViewModel> _modules;
|
||||
private DefaultDropHandler _defaultDropHandler;
|
||||
|
||||
public ModuleOrderTabViewModel(IPluginService pluginService, IModuleService moduleService)
|
||||
{
|
||||
DisplayName = "MODULE PRIORITY";
|
||||
|
||||
_pluginService = pluginService;
|
||||
NormalModules = new BindableCollection<Core.Plugins.Modules.Module>();
|
||||
ApplicationModules = new BindableCollection<Core.Plugins.Modules.Module>();
|
||||
OverlayModules = new BindableCollection<Core.Plugins.Modules.Module>();
|
||||
_moduleService = moduleService;
|
||||
_modules = new List<ModuleOrderModuleViewModel>(pluginService.GetPluginsOfType<Module>().Select(m => new ModuleOrderModuleViewModel(m)));
|
||||
_defaultDropHandler = new DefaultDropHandler();
|
||||
|
||||
ModulesDropHandler = new ModulesDropHandler(moduleService, NormalModules, ApplicationModules, OverlayModules);
|
||||
NormalModules = new BindableCollection<ModuleOrderModuleViewModel>();
|
||||
ApplicationModules = new BindableCollection<ModuleOrderModuleViewModel>();
|
||||
OverlayModules = new BindableCollection<ModuleOrderModuleViewModel>();
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
public BindableCollection<Core.Plugins.Modules.Module> NormalModules { get; set; }
|
||||
public BindableCollection<Core.Plugins.Modules.Module> ApplicationModules { get; set; }
|
||||
public BindableCollection<Core.Plugins.Modules.Module> OverlayModules { get; set; }
|
||||
public BindableCollection<ModuleOrderModuleViewModel> NormalModules { get; set; }
|
||||
public BindableCollection<ModuleOrderModuleViewModel> ApplicationModules { get; set; }
|
||||
public BindableCollection<ModuleOrderModuleViewModel> OverlayModules { get; set; }
|
||||
|
||||
public ModulesDropHandler ModulesDropHandler { get; }
|
||||
|
||||
|
||||
protected override void OnActivate()
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
// Take it off the UI thread to avoid freezing on tab change
|
||||
Task.Run(() =>
|
||||
{
|
||||
NormalModules.Clear();
|
||||
ApplicationModules.Clear();
|
||||
OverlayModules.Clear();
|
||||
_defaultDropHandler.DragOver(dropInfo);
|
||||
}
|
||||
|
||||
var instances = _pluginService.GetPluginsOfType<Core.Plugins.Modules.Module>().ToList();
|
||||
foreach (var module in instances)
|
||||
{
|
||||
if (module.PriorityCategory == ModulePriorityCategory.Normal)
|
||||
NormalModules.Add(module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Application)
|
||||
ApplicationModules.Add(module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Overlay)
|
||||
OverlayModules.Add(module);
|
||||
}
|
||||
});
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
if (dropInfo.TargetItem == dropInfo.Data)
|
||||
return;
|
||||
|
||||
var viewModel = (ModuleOrderModuleViewModel) dropInfo.Data;
|
||||
var targetCollection = (BindableCollection<ModuleOrderModuleViewModel>) dropInfo.TargetCollection;
|
||||
var insertIndex = dropInfo.InsertIndex;
|
||||
|
||||
ModulePriorityCategory category;
|
||||
if (targetCollection == NormalModules)
|
||||
category = ModulePriorityCategory.Normal;
|
||||
else if (targetCollection == ApplicationModules)
|
||||
category = ModulePriorityCategory.Application;
|
||||
else
|
||||
category = ModulePriorityCategory.Overlay;
|
||||
|
||||
// If moving down, take the removal of ourselves into consideration with the insert index
|
||||
if (targetCollection.Contains(viewModel) && targetCollection.IndexOf(viewModel) < insertIndex)
|
||||
insertIndex--;
|
||||
|
||||
_moduleService.UpdateModulePriority(viewModel.Module, category, insertIndex);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
NormalModules.Clear();
|
||||
NormalModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Normal).OrderBy(m => m.Module.Priority));
|
||||
|
||||
ApplicationModules.Clear();
|
||||
ApplicationModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Application).OrderBy(m => m.Module.Priority));
|
||||
|
||||
OverlayModules.Clear();
|
||||
OverlayModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Overlay).OrderBy(m => m.Module.Priority));
|
||||
|
||||
foreach (var moduleOrderModuleViewModel in _modules)
|
||||
moduleOrderModuleViewModel.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Modules
|
||||
{
|
||||
public class ModulesDropHandler : IDropTarget
|
||||
{
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly BindableCollection<Core.Plugins.Modules.Module> _normalModules;
|
||||
private readonly BindableCollection<Core.Plugins.Modules.Module> _applicationModules;
|
||||
private readonly BindableCollection<Core.Plugins.Modules.Module> _overlayModules;
|
||||
private DefaultDropHandler _defaultDropHandler;
|
||||
|
||||
public ModulesDropHandler(IModuleService moduleService,
|
||||
BindableCollection<Core.Plugins.Modules.Module> normalModules,
|
||||
BindableCollection<Core.Plugins.Modules.Module> applicationModules,
|
||||
BindableCollection<Core.Plugins.Modules.Module> overlayModules)
|
||||
{
|
||||
_defaultDropHandler = new DefaultDropHandler();
|
||||
_moduleService = moduleService;
|
||||
_normalModules = normalModules;
|
||||
_applicationModules = applicationModules;
|
||||
_overlayModules = overlayModules;
|
||||
}
|
||||
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
_defaultDropHandler.DragOver(dropInfo);
|
||||
}
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
var module = (Core.Plugins.Modules.Module) dropInfo.Data;
|
||||
var target = (BindableCollection<Core.Plugins.Modules.Module>) dropInfo.TargetCollection;
|
||||
var insertIndex = dropInfo.InsertIndex;
|
||||
|
||||
ModulePriorityCategory category;
|
||||
if (target == _applicationModules)
|
||||
category = ModulePriorityCategory.Application;
|
||||
else if (target == _normalModules)
|
||||
category = ModulePriorityCategory.Normal;
|
||||
else
|
||||
category = ModulePriorityCategory.Overlay;
|
||||
|
||||
|
||||
if (target.Contains(module))
|
||||
{
|
||||
target.Move(target.IndexOf(module), Math.Min(target.Count - 1, insertIndex));
|
||||
_moduleService.UpdateModulePriority(module, category, insertIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (module.PriorityCategory == ModulePriorityCategory.Application)
|
||||
_applicationModules.Remove(module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Normal)
|
||||
_normalModules.Remove(module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Overlay)
|
||||
_overlayModules.Remove(module);
|
||||
|
||||
_moduleService.UpdateModulePriority(module, category, insertIndex);
|
||||
|
||||
if (module.PriorityCategory == ModulePriorityCategory.Application)
|
||||
_applicationModules.Insert(insertIndex, module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Normal)
|
||||
_normalModules.Insert(insertIndex, module);
|
||||
else if (module.PriorityCategory == ModulePriorityCategory.Overlay)
|
||||
_overlayModules.Insert(insertIndex, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user