mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 10:13:30 +00:00
Updated view models and views to work a lot smoother in combination with previewing
This commit is contained in:
parent
9ddde37333
commit
b936908274
@ -12,7 +12,6 @@ namespace Artemis.Managers
|
|||||||
{
|
{
|
||||||
private readonly DeviceManager _deviceManager;
|
private readonly DeviceManager _deviceManager;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private ModuleModel _activeModule;
|
|
||||||
private LoopManager _waitLoopManager;
|
private LoopManager _waitLoopManager;
|
||||||
private ModuleModel _waitEffect;
|
private ModuleModel _waitEffect;
|
||||||
private readonly GeneralSettings _generalSettings;
|
private readonly GeneralSettings _generalSettings;
|
||||||
@ -36,16 +35,7 @@ namespace Artemis.Managers
|
|||||||
public List<ModuleModel> Modules { get; set; }
|
public List<ModuleModel> Modules { get; set; }
|
||||||
public List<ModuleModel> ProcessModules { get; set; }
|
public List<ModuleModel> ProcessModules { get; set; }
|
||||||
public List<ModuleModel> OverlayModules { get; set; }
|
public List<ModuleModel> OverlayModules { get; set; }
|
||||||
|
public ModuleModel ActiveModule { get; private set; }
|
||||||
public ModuleModel ActiveModule
|
|
||||||
{
|
|
||||||
get { return _activeModule; }
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
_activeModule = value;
|
|
||||||
RaiseEffectChangedEvent(new ModuleChangedEventArgs(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler<ModuleChangedEventArgs> EffectChanged;
|
public event EventHandler<ModuleChangedEventArgs> EffectChanged;
|
||||||
|
|
||||||
@ -131,13 +121,14 @@ namespace Artemis.Managers
|
|||||||
loopManager.StartAsync();
|
loopManager.StartAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug("Changed active module to: {0}", moduleModel.Name);
|
if (!ActiveModule.IsBoundToProcess && !ActiveModule.IsOverlay && storeAsLast)
|
||||||
|
{
|
||||||
|
_generalSettings.LastModule = ActiveModule?.Name;
|
||||||
|
_generalSettings.Save();
|
||||||
|
}
|
||||||
|
|
||||||
if (ActiveModule.IsBoundToProcess || ActiveModule.IsOverlay || !storeAsLast)
|
_logger.Debug("Changed active module to: {0}", moduleModel.Name);
|
||||||
return;
|
RaiseEffectChangedEvent(new ModuleChangedEventArgs(moduleModel));
|
||||||
// Regular modules are stored as the last active module
|
|
||||||
_generalSettings.LastModule = ActiveModule?.Name;
|
|
||||||
_generalSettings.Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
|
private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
|
||||||
|
|||||||
@ -46,7 +46,8 @@ namespace Artemis.Managers
|
|||||||
if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard)
|
if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var activePreview = PreviewViewModules.FirstOrDefault(vm => vm.IsActive && vm.UsesProfileEditor);
|
var activePreview = PreviewViewModules.FirstOrDefault(
|
||||||
|
vm => vm.IsActive && vm.UsesProfileEditor && vm.ModuleModel.Settings.IsEnabled);
|
||||||
if (activePreview != null)
|
if (activePreview != null)
|
||||||
EnsurePreviewActive(activePreview);
|
EnsurePreviewActive(activePreview);
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Services;
|
using Artemis.Services;
|
||||||
|
using Artemis.Settings;
|
||||||
using Artemis.ViewModels.Profiles;
|
using Artemis.ViewModels.Profiles;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
@ -15,15 +16,18 @@ namespace Artemis.Modules.Abstract
|
|||||||
private readonly MainManager _mainManager;
|
private readonly MainManager _mainManager;
|
||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private ModuleSettings _settings;
|
private ModuleSettings _settings;
|
||||||
|
private GeneralSettings _generalSettings;
|
||||||
|
|
||||||
public ModuleViewModel(MainManager mainManager, ModuleModel moduleModel, IKernel kernel)
|
public ModuleViewModel(MainManager mainManager, ModuleModel moduleModel, IKernel kernel)
|
||||||
{
|
{
|
||||||
_mainManager = mainManager;
|
_mainManager = mainManager;
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_moduleManager = mainManager.ModuleManager;
|
_moduleManager = mainManager.ModuleManager;
|
||||||
|
_generalSettings = DAL.SettingsProvider.Load<GeneralSettings>();
|
||||||
ModuleModel = moduleModel;
|
ModuleModel = moduleModel;
|
||||||
Settings = moduleModel.Settings;
|
Settings = moduleModel.Settings;
|
||||||
|
|
||||||
|
|
||||||
_mainManager.EnabledChanged += MainManagerOnEnabledChanged;
|
_mainManager.EnabledChanged += MainManagerOnEnabledChanged;
|
||||||
_moduleManager.EffectChanged += ModuleManagerOnModuleChanged;
|
_moduleManager.EffectChanged += ModuleManagerOnModuleChanged;
|
||||||
}
|
}
|
||||||
@ -49,21 +53,33 @@ namespace Artemis.Modules.Abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsModuleActive => _moduleManager.ActiveModule == ModuleModel;
|
public virtual bool IsModuleActive => _moduleManager.ActiveModule == ModuleModel;
|
||||||
|
|
||||||
|
public virtual bool IsModuleEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ModuleModel.IsBoundToProcess || ModuleModel.IsBoundToProcess)
|
||||||
|
return Settings.IsEnabled;
|
||||||
|
return _generalSettings.LastModule == ModuleModel.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract bool UsesProfileEditor { get; }
|
public abstract bool UsesProfileEditor { get; }
|
||||||
|
|
||||||
private void MainManagerOnEnabledChanged(object sender, EnabledChangedEventArgs e)
|
private void MainManagerOnEnabledChanged(object sender, EnabledChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
UpdatedEnabledSetting();
|
||||||
NotifyOfPropertyChange(() => IsModuleActive);
|
NotifyOfPropertyChange(() => IsModuleActive);
|
||||||
UpdateIsEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModuleManagerOnModuleChanged(object sender, ModuleChangedEventArgs e)
|
private void ModuleManagerOnModuleChanged(object sender, ModuleChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
UpdatedEnabledSetting();
|
||||||
NotifyOfPropertyChange(() => IsModuleActive);
|
NotifyOfPropertyChange(() => IsModuleActive);
|
||||||
UpdateIsEnabled();
|
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateIsEnabled()
|
private void UpdatedEnabledSetting()
|
||||||
{
|
{
|
||||||
if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
|
if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
|
||||||
return;
|
return;
|
||||||
@ -81,13 +97,20 @@ namespace Artemis.Modules.Abstract
|
|||||||
|
|
||||||
// On process-bound modules, only set the module model
|
// On process-bound modules, only set the module model
|
||||||
if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
|
if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
|
||||||
|
{
|
||||||
|
NotifyOfPropertyChange(() => IsModuleActive);
|
||||||
|
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// On other modules, activate them if necessary
|
// On other modules, activate them if necessary
|
||||||
if (IsModuleActive && !Settings.IsEnabled)
|
if (IsModuleActive && !Settings.IsEnabled)
|
||||||
_moduleManager.ClearActiveModule();
|
_moduleManager.ClearActiveModule();
|
||||||
else if (!IsModuleActive && Settings.IsEnabled)
|
else if (!IsModuleActive && Settings.IsEnabled)
|
||||||
_moduleManager.ChangeActiveModule(ModuleModel, _mainManager.LoopManager);
|
_moduleManager.ChangeActiveModule(ModuleModel, _mainManager.LoopManager);
|
||||||
|
|
||||||
|
NotifyOfPropertyChange(() => IsModuleActive);
|
||||||
|
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SaveSettings()
|
public virtual void SaveSettings()
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -49,7 +49,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
<ToggleButton Margin="0 3 0 0" Width="25" Height="25"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
ToolTip="Note: You can't enable an module when Artemis is disabled"
|
||||||
IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
|
IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}"
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -69,7 +69,6 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
||||||
_moduleModel.ProfileChanged += ModuleModelOnProfileChanged;
|
_moduleModel.ProfileChanged += ModuleModelOnProfileChanged;
|
||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
ProfileViewModel.Activate();
|
|
||||||
|
|
||||||
_saveTimer = new Timer(5000);
|
_saveTimer = new Timer(5000);
|
||||||
_saveTimer.Elapsed += ProfileSaveHandler;
|
_saveTimer.Elapsed += ProfileSaveHandler;
|
||||||
@ -780,8 +779,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ProfileViewModel.Deactivate();
|
ProfileViewModel.Dispose();
|
||||||
|
|
||||||
_saveTimer?.Stop();
|
_saveTimer?.Stop();
|
||||||
_saveTimer?.Dispose();
|
_saveTimer?.Dispose();
|
||||||
_watcher?.Dispose();
|
_watcher?.Dispose();
|
||||||
|
|||||||
@ -20,9 +20,10 @@ using MahApps.Metro;
|
|||||||
|
|
||||||
namespace Artemis.ViewModels.Profiles
|
namespace Artemis.ViewModels.Profiles
|
||||||
{
|
{
|
||||||
public class ProfileViewModel : PropertyChangedBase
|
public class ProfileViewModel : PropertyChangedBase, IDisposable
|
||||||
{
|
{
|
||||||
private readonly DeviceManager _deviceManager;
|
private readonly DeviceManager _deviceManager;
|
||||||
|
private readonly LoopManager _loopManager;
|
||||||
private double _blurProgress;
|
private double _blurProgress;
|
||||||
private double _blurRadius;
|
private double _blurRadius;
|
||||||
private DateTime _downTime;
|
private DateTime _downTime;
|
||||||
@ -37,11 +38,12 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public ProfileViewModel(DeviceManager deviceManager, LoopManager loopManager)
|
public ProfileViewModel(DeviceManager deviceManager, LoopManager loopManager)
|
||||||
{
|
{
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
|
_loopManager = loopManager;
|
||||||
|
|
||||||
ShowAll = false;
|
ShowAll = false;
|
||||||
|
|
||||||
loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
_loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
||||||
deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModuleModel ModuleModel { get; set; }
|
public ModuleModel ModuleModel { get; set; }
|
||||||
@ -94,13 +96,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public ImageSource KeyboardImage => ImageUtilities
|
public ImageSource KeyboardImage => ImageUtilities
|
||||||
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
||||||
|
|
||||||
public bool Activated { get; set; }
|
|
||||||
|
|
||||||
private void LoopManagerOnRenderCompleted(object sender, EventArgs eventArgs)
|
private void LoopManagerOnRenderCompleted(object sender, EventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!Activated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update the glowing effect around the keyboard
|
// Update the glowing effect around the keyboard
|
||||||
if (_blurProgress > 2)
|
if (_blurProgress > 2)
|
||||||
_blurProgress = 0;
|
_blurProgress = 0;
|
||||||
@ -108,12 +105,9 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
BlurRadius = (Math.Sin(_blurProgress * Math.PI) + 1) * 10 + 10;
|
BlurRadius = (Math.Sin(_blurProgress * Math.PI) + 1) * 10 + 10;
|
||||||
|
|
||||||
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
|
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
|
||||||
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null ||
|
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null || _deviceManager.ActiveKeyboard.Slug == "none")
|
||||||
_deviceManager.ActiveKeyboard.Slug == "none")
|
|
||||||
{
|
{
|
||||||
var preview = new DrawingImage();
|
KeyboardPreview = null;
|
||||||
preview.Freeze();
|
|
||||||
KeyboardPreview = preview;
|
|
||||||
|
|
||||||
// Setup layers for the next frame
|
// Setup layers for the next frame
|
||||||
if (ModuleModel.IsInitialized)
|
if (ModuleModel.IsInitialized)
|
||||||
@ -192,17 +186,6 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
NotifyOfPropertyChange(() => KeyboardImage);
|
NotifyOfPropertyChange(() => KeyboardImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Activate()
|
|
||||||
{
|
|
||||||
Activated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Deactivate()
|
|
||||||
{
|
|
||||||
Activated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Processing
|
#region Processing
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -395,6 +378,13 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_keyboardPreviewCursor?.Dispose();
|
||||||
|
_loopManager.RenderCompleted -= LoopManagerOnRenderCompleted;
|
||||||
|
_deviceManager.OnKeyboardChanged -= DeviceManagerOnOnKeyboardChanged;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user