mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor layer list updates periodically
Profile editor profile dropdown updates properly Profile editor rename duplication check works properly
This commit is contained in:
parent
928fb675ab
commit
ae26ac2e18
@ -110,7 +110,6 @@ namespace Artemis.Profiles.Lua
|
|||||||
{
|
{
|
||||||
// Can be missing if the user script screwed up the globals
|
// Can be missing if the user script screwed up the globals
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,18 +155,24 @@ namespace Artemis.Profiles.Lua
|
|||||||
if (args.ChangeType != WatcherChangeTypes.Changed)
|
if (args.ChangeType != WatcherChangeTypes.Changed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
if (ProfileModel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock (ProfileModel)
|
||||||
{
|
{
|
||||||
using (var sr = new StreamReader(fs))
|
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{
|
{
|
||||||
ProfileModel.LuaScript = sr.ReadToEnd();
|
using (var sr = new StreamReader(fs))
|
||||||
|
{
|
||||||
|
ProfileModel.LuaScript = sr.ReadToEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfileProvider.AddOrUpdate(ProfileModel);
|
||||||
|
|
||||||
|
if (KeyboardProvider != null)
|
||||||
|
SetupLua(ProfileModel, KeyboardProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileProvider.AddOrUpdate(ProfileModel);
|
|
||||||
|
|
||||||
if (KeyboardProvider != null)
|
|
||||||
SetupLua(ProfileModel, KeyboardProvider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Dynamic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -25,6 +25,7 @@ using GongSolutions.Wpf.DragDrop;
|
|||||||
using MahApps.Metro.Controls.Dialogs;
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Parameters;
|
using Ninject.Parameters;
|
||||||
|
using NuGet;
|
||||||
using DragDropEffects = System.Windows.DragDropEffects;
|
using DragDropEffects = System.Windows.DragDropEffects;
|
||||||
using IDropTarget = GongSolutions.Wpf.DragDrop.IDropTarget;
|
using IDropTarget = GongSolutions.Wpf.DragDrop.IDropTarget;
|
||||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||||
@ -39,8 +40,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
private readonly EffectModel _gameModel;
|
private readonly EffectModel _gameModel;
|
||||||
private readonly Timer _saveTimer;
|
private readonly Timer _saveTimer;
|
||||||
private ImageSource _keyboardPreview;
|
private ImageSource _keyboardPreview;
|
||||||
private BindableCollection<LayerModel> _layers;
|
private ObservableCollection<LayerModel> _layers;
|
||||||
private BindableCollection<string> _profileNames;
|
private ObservableCollection<string> _profileNames;
|
||||||
private bool _saving;
|
private bool _saving;
|
||||||
private ProfileModel _selectedProfile;
|
private ProfileModel _selectedProfile;
|
||||||
|
|
||||||
@ -51,8 +52,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
_gameModel = gameModel;
|
_gameModel = gameModel;
|
||||||
|
|
||||||
ProfileNames = new BindableCollection<string>();
|
ProfileNames = new ObservableCollection<string>();
|
||||||
Layers = new BindableCollection<LayerModel>();
|
Layers = new ObservableCollection<LayerModel>();
|
||||||
ProfileViewModel = profileViewModel;
|
ProfileViewModel = profileViewModel;
|
||||||
DialogService = dialogService;
|
DialogService = dialogService;
|
||||||
WindowService = windowService;
|
WindowService = windowService;
|
||||||
@ -80,7 +81,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public bool EditorEnabled
|
public bool EditorEnabled
|
||||||
=> (SelectedProfile != null) && !SelectedProfile.IsDefault && (_deviceManager.ActiveKeyboard != null);
|
=> (SelectedProfile != null) && !SelectedProfile.IsDefault && (_deviceManager.ActiveKeyboard != null);
|
||||||
|
|
||||||
public BindableCollection<string> ProfileNames
|
public ObservableCollection<string> ProfileNames
|
||||||
{
|
{
|
||||||
get { return _profileNames; }
|
get { return _profileNames; }
|
||||||
set
|
set
|
||||||
@ -91,7 +92,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindableCollection<LayerModel> Layers
|
public ObservableCollection<LayerModel> Layers
|
||||||
{
|
{
|
||||||
get { return _layers; }
|
get { return _layers; }
|
||||||
set
|
set
|
||||||
@ -124,6 +125,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
_selectedProfile?.Deactivate();
|
_selectedProfile?.Deactivate();
|
||||||
_selectedProfile = value;
|
_selectedProfile = value;
|
||||||
NotifyOfPropertyChange(() => SelectedProfile);
|
NotifyOfPropertyChange(() => SelectedProfile);
|
||||||
|
NotifyOfPropertyChange(() => SelectedProfileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,21 +521,28 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
if (SelectedProfile == null)
|
if (SelectedProfile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var oldName = SelectedProfile.Name;
|
||||||
var name = await DialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
|
var name = await DialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
|
||||||
|
|
||||||
// Null when the user cancelled
|
// Null when the user cancelled
|
||||||
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SelectedProfile.Name = name;
|
||||||
|
|
||||||
// Verify the name
|
// Verify the name
|
||||||
while (!ProfileProvider.IsProfileUnique(SelectedProfile))
|
while (!ProfileProvider.IsProfileUnique(SelectedProfile))
|
||||||
{
|
{
|
||||||
name =
|
name = await DialogService
|
||||||
await DialogService.ShowInputDialog("Name already in use", "Please enter a unique new profile name");
|
.ShowInputDialog("Name already in use", "Please enter a unique new profile name");
|
||||||
|
|
||||||
// Null when the user cancelled
|
// Null when the user cancelled
|
||||||
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
||||||
|
{
|
||||||
|
SelectedProfile.Name = oldName;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
SelectedProfile.Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = SelectedProfile;
|
var profile = SelectedProfile;
|
||||||
@ -560,8 +569,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// Verify the name
|
// Verify the name
|
||||||
while (!ProfileProvider.IsProfileUnique(newProfile))
|
while (!ProfileProvider.IsProfileUnique(newProfile))
|
||||||
{
|
{
|
||||||
newProfile.Name =
|
newProfile.Name = await DialogService
|
||||||
await DialogService.ShowInputDialog("Name already in use", "Please enter a unique profile name");
|
.ShowInputDialog("Name already in use", "Please enter a unique profile name");
|
||||||
|
|
||||||
// Null when the user cancelled
|
// Null when the user cancelled
|
||||||
if (string.IsNullOrEmpty(newProfile.Name))
|
if (string.IsNullOrEmpty(newProfile.Name))
|
||||||
@ -717,7 +726,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
private void ProfileSaveHandler(object sender, ElapsedEventArgs e)
|
private void ProfileSaveHandler(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_saving || (SelectedProfile == null) || !IsActive)
|
if (_saving || (SelectedProfile == null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_saving = true;
|
_saving = true;
|
||||||
@ -730,6 +739,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
_saving = false;
|
_saving = false;
|
||||||
|
|
||||||
|
Execute.OnUIThread(() => UpdateLayerList(ProfileViewModel.SelectedLayer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user