mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added ProfileEditorModel
Refactored some namespaces Got rid of ProfileViewModel
This commit is contained in:
parent
15275c83a0
commit
afb6315ec6
@ -356,6 +356,8 @@
|
||||
<Compile Include="Managers\LuaManager.cs" />
|
||||
<Compile Include="Managers\MainManager.cs" />
|
||||
<Compile Include="Managers\PreviewManager.cs" />
|
||||
<Compile Include="Models\LayerEditorModel.cs" />
|
||||
<Compile Include="Models\ProfileEditorModel.cs" />
|
||||
<Compile Include="Modules\Abstract\ModuleDataModel.cs" />
|
||||
<Compile Include="Modules\Abstract\ModuleModel.cs" />
|
||||
<Compile Include="Modules\Abstract\ModuleSettings.cs" />
|
||||
@ -654,17 +656,16 @@
|
||||
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\LayerTweenViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\Events\EventPropertiesViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\ProfileViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\LayerConditionViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\LayerDynamicPropertiesViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\LayerEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\LayerEditorViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Abstract\LayerPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Headset\HeadsetPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Folder\FolderPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Mouse\MousePropertiesViewModel.cs" />
|
||||
<Compile Include="ViewModels\OverlaysViewModel.cs" />
|
||||
<Compile Include="ViewModels\Profiles\ProfileEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\ProfileEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||
<Compile Include="ViewModels\WelcomeViewModel.cs" />
|
||||
<Compile Include="Views\DebugView.xaml.cs">
|
||||
@ -709,7 +710,7 @@
|
||||
<Compile Include="Views\Profiles\LayerDynamicPropertiesView.xaml.cs">
|
||||
<DependentUpon>LayerDynamicPropertiesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Profiles\LayerEditorView.xaml.cs">
|
||||
<Compile Include="Views\LayerEditorView.xaml.cs">
|
||||
<DependentUpon>LayerEditorView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Profiles\Layers\Types\Mouse\MousePropertiesView.xaml.cs">
|
||||
@ -721,7 +722,7 @@
|
||||
<Compile Include="Views\Profiles\LayerTweenView.xaml.cs">
|
||||
<DependentUpon>LayerTweenView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Profiles\ProfileEditorView.xaml.cs">
|
||||
<Compile Include="Views\ProfileEditorView.xaml.cs">
|
||||
<DependentUpon>ProfileEditorView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ShellView.xaml.cs">
|
||||
@ -952,7 +953,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Profiles\LayerEditorView.xaml">
|
||||
<Page Include="Views\LayerEditorView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@ -968,7 +969,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Profiles\ProfileEditorView.xaml">
|
||||
<Page Include="Views\ProfileEditorView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Models;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||
@ -8,7 +9,6 @@ using Artemis.Utilities.DataReaders;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Ninject.Extensions.Conventions;
|
||||
using Ninject.Modules;
|
||||
|
||||
@ -18,10 +18,16 @@ namespace Artemis.InjectionModules
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
#region Models
|
||||
|
||||
Bind<ProfileEditorModel>().ToSelf();
|
||||
Bind<LayerEditorModel>().ToSelf();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ViewModels
|
||||
|
||||
Bind<ShellViewModel>().ToSelf().InSingletonScope();
|
||||
Bind<ProfileViewModel>().ToSelf();
|
||||
Bind<ProfileEditorViewModel>().ToSelf();
|
||||
Bind<DebugViewModel>().ToSelf().InSingletonScope();
|
||||
Kernel.Bind(x =>
|
||||
|
||||
12
Artemis/Artemis/Models/LayerEditorModel.cs
Normal file
12
Artemis/Artemis/Models/LayerEditorModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class LayerEditorModel
|
||||
{
|
||||
}
|
||||
}
|
||||
354
Artemis/Artemis/Models/ProfileEditorModel.cs
Normal file
354
Artemis/Artemis/Models/ProfileEditorModel.cs
Normal file
@ -0,0 +1,354 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Folder;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class ProfileEditorModel : IDisposable
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly LuaManager _luaManager;
|
||||
private readonly DialogService _dialogService;
|
||||
private readonly WindowService _windowService;
|
||||
private FileSystemWatcher _watcher;
|
||||
private ProfileModel _luaProfile;
|
||||
|
||||
public ProfileEditorModel(WindowService windowService, MetroDialogService dialogService,
|
||||
DeviceManager deviceManager, LuaManager luaManager)
|
||||
{
|
||||
_windowService = windowService;
|
||||
_dialogService = dialogService;
|
||||
_deviceManager = deviceManager;
|
||||
_luaManager = luaManager;
|
||||
}
|
||||
|
||||
#region Layers
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new LayerEditorView for the given layer
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to open the view for</param>
|
||||
/// <param name="dataModel">The datamodel to bind the editor to</param>
|
||||
public void EditLayer(LayerModel layer, ModuleDataModel dataModel)
|
||||
{
|
||||
IParameter[] args =
|
||||
{
|
||||
new ConstructorArgument("dataModel", dataModel),
|
||||
new ConstructorArgument("layer", layer)
|
||||
};
|
||||
_windowService.ShowDialog<LayerEditorViewModel>(args);
|
||||
|
||||
// If the layer was a folder, but isn't anymore, assign it's children to it's parent.
|
||||
if (layer.LayerType is FolderType || !layer.Children.Any())
|
||||
return;
|
||||
|
||||
while (layer.Children.Any())
|
||||
{
|
||||
var child = layer.Children[0];
|
||||
layer.Children.Remove(child);
|
||||
if (layer.Parent != null)
|
||||
{
|
||||
layer.Parent.Children.Add(child);
|
||||
layer.Parent.FixOrder();
|
||||
}
|
||||
else
|
||||
{
|
||||
layer.Profile.Layers.Add(child);
|
||||
layer.Profile.FixOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given layer from the profile
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to remove</param>
|
||||
/// <param name="profileModel">The profile to remove it from</param>
|
||||
public void RemoveLayer(LayerModel layer, ProfileModel profileModel)
|
||||
{
|
||||
if (layer == null)
|
||||
return;
|
||||
|
||||
if (layer.Parent != null)
|
||||
{
|
||||
var parent = layer.Parent;
|
||||
layer.Parent.Children.Remove(layer);
|
||||
parent.FixOrder();
|
||||
}
|
||||
else if (layer.Profile != null)
|
||||
{
|
||||
var profile = layer.Profile;
|
||||
layer.Profile.Layers.Remove(layer);
|
||||
profile.FixOrder();
|
||||
}
|
||||
|
||||
// Extra cleanup in case of a wonky layer that has no parent
|
||||
if (profileModel.Layers.Contains(layer))
|
||||
profileModel.Layers.Remove(layer);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profiles
|
||||
|
||||
public async Task<ProfileModel> AddProfile(ModuleModel moduleModel)
|
||||
{
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
{
|
||||
_dialogService.ShowMessageBox("Cannot add profile.",
|
||||
"To add a profile, please select a keyboard in the options menu first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var name = await GetValidProfileName("Name profile", "Please enter a unique name for your new profile");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
var profile = new ProfileModel
|
||||
{
|
||||
Name = name,
|
||||
KeyboardSlug = _deviceManager.ActiveKeyboard.Slug,
|
||||
Width = _deviceManager.ActiveKeyboard.Width,
|
||||
Height = _deviceManager.ActiveKeyboard.Height,
|
||||
GameName = moduleModel.Name
|
||||
};
|
||||
|
||||
if (!ProfileProvider.IsProfileUnique(profile))
|
||||
{
|
||||
var overwrite = await _dialogService.ShowQuestionMessageBox("Overwrite existing profile",
|
||||
"A profile with this name already exists for this game. Would you like to overwrite it?");
|
||||
if (!overwrite.Value)
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileProvider.AddOrUpdate(profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public async Task RenameProfile(ProfileModel profileModel)
|
||||
{
|
||||
var name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return;
|
||||
var doRename = await MakeProfileUnique(profileModel, name, profileModel.Name);
|
||||
if (!doRename)
|
||||
return;
|
||||
|
||||
ProfileProvider.RenameProfile(profileModel, profileModel.Name);
|
||||
}
|
||||
|
||||
public async Task DuplicateProfile(ProfileModel selectedProfile)
|
||||
{
|
||||
var newProfile = GeneralHelpers.Clone(selectedProfile);
|
||||
var name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return;
|
||||
var doRename = await MakeProfileUnique(newProfile, name, newProfile.Name);
|
||||
if (!doRename)
|
||||
return;
|
||||
|
||||
// Make sure it's not default, in case of copying a default profile
|
||||
newProfile.IsDefault = false;
|
||||
ProfileProvider.AddOrUpdate(newProfile);
|
||||
}
|
||||
|
||||
public async Task DeleteProfile(ProfileModel selectedProfile, ModuleModel moduleModel)
|
||||
{
|
||||
var confirm = await _dialogService.ShowQuestionMessageBox("Delete profile",
|
||||
$"Are you sure you want to delete the profile named: {selectedProfile.Name}?\n\n" +
|
||||
"This cannot be undone.");
|
||||
if (!confirm.Value)
|
||||
return;
|
||||
|
||||
var defaultProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, moduleModel, "Default");
|
||||
var deleteProfile = selectedProfile;
|
||||
|
||||
moduleModel.ChangeProfile(defaultProfile);
|
||||
ProfileProvider.DeleteProfile(deleteProfile);
|
||||
}
|
||||
|
||||
public async Task ImportProfile(ModuleModel moduleModel)
|
||||
{
|
||||
var dialog = new OpenFileDialog {Filter = "Artemis profile (*.json)|*.json"};
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var profileModel = ProfileProvider.LoadProfileIfValid(dialog.FileName);
|
||||
if (profileModel == null)
|
||||
{
|
||||
_dialogService.ShowErrorMessageBox("Oh noes, the profile you provided is invalid. " +
|
||||
"If this keeps happening, please make an issue on GitHub and provide the profile.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the game
|
||||
if (profileModel.GameName != moduleModel.Name)
|
||||
{
|
||||
_dialogService.ShowErrorMessageBox(
|
||||
$"Oh oops! This profile is ment for {profileModel.GameName}, not {moduleModel.Name} :c");
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the keyboard
|
||||
var deviceManager = _deviceManager;
|
||||
if (profileModel.KeyboardSlug != deviceManager.ActiveKeyboard.Slug)
|
||||
{
|
||||
var adjustKeyboard = await _dialogService.ShowQuestionMessageBox("Profile not made for this keyboard",
|
||||
$"Watch out, this profile wasn't ment for this keyboard, but for the {profileModel.KeyboardSlug}. " +
|
||||
"You can still import it but you'll probably have to do some adjusting\n\n" +
|
||||
"Continue?");
|
||||
if (!adjustKeyboard.Value)
|
||||
return;
|
||||
|
||||
// Resize layers that are on the full keyboard width
|
||||
profileModel.ResizeLayers(deviceManager.ActiveKeyboard);
|
||||
// Put layers back into the canvas if they fell outside it
|
||||
profileModel.FixBoundaries(deviceManager.ActiveKeyboard.KeyboardRectangle(1));
|
||||
|
||||
// Setup profile metadata to match the new keyboard
|
||||
profileModel.KeyboardSlug = deviceManager.ActiveKeyboard.Slug;
|
||||
profileModel.Width = deviceManager.ActiveKeyboard.Width;
|
||||
profileModel.Height = deviceManager.ActiveKeyboard.Height;
|
||||
}
|
||||
|
||||
var name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return;
|
||||
var doRename = await MakeProfileUnique(profileModel, name, profileModel.Name);
|
||||
if (!doRename)
|
||||
return;
|
||||
|
||||
profileModel.IsDefault = false;
|
||||
ProfileProvider.AddOrUpdate(profileModel);
|
||||
}
|
||||
|
||||
private async Task<string> GetValidProfileName(string title, string text)
|
||||
{
|
||||
var name = await _dialogService.ShowInputDialog(title, text);
|
||||
|
||||
// Null when the user cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
if (name.Length >= 2)
|
||||
return name;
|
||||
|
||||
_dialogService.ShowMessageBox("Invalid profile name",
|
||||
"Please provide a valid profile name that's longer than 2 symbols");
|
||||
|
||||
return await GetValidProfileName(title, text);
|
||||
}
|
||||
|
||||
private async Task<bool> MakeProfileUnique(ProfileModel profileModel, string name, string oldName)
|
||||
{
|
||||
profileModel.Name = name;
|
||||
if (ProfileProvider.IsProfileUnique(profileModel))
|
||||
return true;
|
||||
|
||||
name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
if (name != null)
|
||||
return await MakeProfileUnique(profileModel, name, oldName);
|
||||
|
||||
// If cancelled, restore old name and stop
|
||||
profileModel.Name = oldName;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LUA
|
||||
|
||||
public void OpenLuaEditor(ProfileModel profileModel)
|
||||
{
|
||||
// Clean up old environment
|
||||
DisposeLuaWatcher();
|
||||
|
||||
// Create a temp file
|
||||
var fileName = Guid.NewGuid() + ".lua";
|
||||
var file = File.Create(Path.GetTempPath() + fileName);
|
||||
file.Dispose();
|
||||
|
||||
// Add instructions to LUA script if it's a new file
|
||||
if (string.IsNullOrEmpty(profileModel.LuaScript))
|
||||
profileModel.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
|
||||
File.WriteAllText(Path.GetTempPath() + fileName, profileModel.LuaScript);
|
||||
|
||||
// Watch the file for changes
|
||||
_luaProfile = profileModel;
|
||||
_watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
|
||||
_watcher.Changed += LuaFileChanged;
|
||||
_watcher.EnableRaisingEvents = true;
|
||||
_watcher.Path = Path.GetTempPath();
|
||||
_watcher.Filter = fileName;
|
||||
|
||||
// Open the temp file with the default editor
|
||||
System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
|
||||
}
|
||||
|
||||
private void LuaFileChanged(object sender, FileSystemEventArgs args)
|
||||
{
|
||||
if (_luaProfile == null)
|
||||
{
|
||||
DisposeLuaWatcher();
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.ChangeType != WatcherChangeTypes.Changed)
|
||||
return;
|
||||
|
||||
lock (_luaProfile)
|
||||
{
|
||||
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
_luaProfile.LuaScript = sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
ProfileProvider.AddOrUpdate(_luaProfile);
|
||||
_luaManager.SetupLua(_luaProfile);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeLuaWatcher()
|
||||
{
|
||||
if (_watcher == null) return;
|
||||
_watcher.Changed -= LuaFileChanged;
|
||||
_watcher.Dispose();
|
||||
_watcher = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisposeLuaWatcher();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rendering
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using Artemis.Managers;
|
||||
using Artemis.Services;
|
||||
using Artemis.Settings;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.AmbientLight
|
||||
|
||||
@ -13,6 +13,7 @@ using Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions;
|
||||
using Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Folder
|
||||
|
||||
@ -6,6 +6,7 @@ using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Folder
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Generic
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Headset
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||
|
||||
@ -13,6 +13,7 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Windows.Forms;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Animations;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Keyboard
|
||||
|
||||
@ -9,6 +9,7 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Mouse
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Mousemat
|
||||
|
||||
@ -10,13 +10,14 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Profiles.Layers.Types.KeyboardGif;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Artemis.ViewModels.Profiles.Events;
|
||||
using Caliburn.Micro;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using static Artemis.Utilities.GeneralHelpers;
|
||||
|
||||
namespace Artemis.ViewModels.Profiles
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public sealed class LayerEditorViewModel : Screen
|
||||
{
|
||||
@ -30,13 +31,13 @@ namespace Artemis.ViewModels.Profiles
|
||||
IEnumerable<ILayerAnimation> layerAnimations)
|
||||
{
|
||||
Layer = layer;
|
||||
ProposedLayer = Clone(layer);
|
||||
ProposedLayer = GeneralHelpers.Clone(layer);
|
||||
ProposedLayer.Children.Clear();
|
||||
DataModel = DataModel;
|
||||
LayerTypes = new BindableCollection<ILayerType>(types.OrderBy(t => t.Name));
|
||||
LayerAnimations = layerAnimations.OrderBy(l => l.Name).ToList();
|
||||
|
||||
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
|
||||
DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>(GeneralHelpers.GenerateTypeMap(dataModel));
|
||||
|
||||
if (Layer.Properties == null)
|
||||
Layer.SetupProperties();
|
||||
@ -57,7 +58,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
public MetroDialogService DialogService { get; set; }
|
||||
|
||||
public BindableCollection<ILayerType> LayerTypes { get; set; }
|
||||
public BindableCollection<PropertyCollection> DataModelProps { get; set; }
|
||||
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
|
||||
public BindableCollection<LayerConditionViewModel> LayerConditionVms { get; set; }
|
||||
public bool KeyboardGridIsVisible => ProposedLayer.LayerType is KeyboardType;
|
||||
public bool GifGridIsVisible => ProposedLayer.LayerType is KeyboardGifType;
|
||||
@ -215,7 +216,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
|
||||
// Ignore the children, can't just temporarily add them to the proposed layer because
|
||||
// that would upset the child layers' relations (sounds like Dr. Phil amirite?)
|
||||
var currentObj = Clone(Layer);
|
||||
var currentObj = GeneralHelpers.Clone(Layer);
|
||||
currentObj.Children.Clear();
|
||||
|
||||
// Apply the IsEvent boolean
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,382 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Folder;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Caliburn.Micro;
|
||||
using Castle.Components.DictionaryAdapter;
|
||||
using MahApps.Metro;
|
||||
|
||||
namespace Artemis.ViewModels.Profiles
|
||||
{
|
||||
public class ProfileViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly LoopManager _loopManager;
|
||||
private double _blurProgress;
|
||||
private double _blurRadius;
|
||||
private DateTime _downTime;
|
||||
private LayerModel _draggingLayer;
|
||||
private Point? _draggingLayerOffset;
|
||||
private DrawingImage _keyboardPreview;
|
||||
private Cursor _keyboardPreviewCursor;
|
||||
private bool _resizing;
|
||||
private bool _showAll;
|
||||
|
||||
public ProfileViewModel(DeviceManager deviceManager, LoopManager loopManager)
|
||||
{
|
||||
_deviceManager = deviceManager;
|
||||
_loopManager = loopManager;
|
||||
|
||||
ShowAll = false;
|
||||
|
||||
_loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
||||
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
||||
}
|
||||
|
||||
public ModuleModel ModuleModel { get; set; }
|
||||
public LayerModel SelectedLayer { get; set; }
|
||||
|
||||
public ProfileModel SelectedProfile => ModuleModel?.ProfileModel;
|
||||
|
||||
public DrawingImage KeyboardPreview
|
||||
{
|
||||
get { return _keyboardPreview; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _keyboardPreview)) return;
|
||||
_keyboardPreview = value;
|
||||
NotifyOfPropertyChange(() => KeyboardPreview);
|
||||
}
|
||||
}
|
||||
|
||||
public double BlurRadius
|
||||
{
|
||||
get { return _blurRadius; }
|
||||
set
|
||||
{
|
||||
if (value.Equals(_blurRadius)) return;
|
||||
_blurRadius = value;
|
||||
NotifyOfPropertyChange(() => BlurRadius);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowAll
|
||||
{
|
||||
get { return _showAll; }
|
||||
set
|
||||
{
|
||||
if (value == _showAll) return;
|
||||
_showAll = value;
|
||||
NotifyOfPropertyChange(() => ShowAll);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource KeyboardImage => ImageUtilities
|
||||
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
||||
|
||||
private void LoopManagerOnRenderCompleted(object sender, EventArgs eventArgs)
|
||||
{
|
||||
// Update the glowing effect around the keyboard
|
||||
if (_blurProgress > 2)
|
||||
_blurProgress = 0;
|
||||
_blurProgress = _blurProgress + 0.025;
|
||||
BlurRadius = (Math.Sin(_blurProgress * Math.PI) + 1) * 10 + 10;
|
||||
|
||||
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
|
||||
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null || _deviceManager.ActiveKeyboard.Slug == "none")
|
||||
{
|
||||
KeyboardPreview = null;
|
||||
|
||||
// Setup layers for the next frame
|
||||
if (ModuleModel.IsInitialized && ActiveWindowHelper.MainWindowActive)
|
||||
ModuleModel.PreviewLayers = new List<LayerModel>();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var renderLayers = GetRenderLayers();
|
||||
// Draw the current frame to the preview
|
||||
var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle();
|
||||
var visual = new DrawingVisual();
|
||||
using (var drawingContext = visual.RenderOpen())
|
||||
{
|
||||
// Setup the DrawingVisual's size
|
||||
drawingContext.PushClip(new RectangleGeometry(keyboardRect));
|
||||
drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
|
||||
|
||||
// Draw the layers
|
||||
foreach (var layer in renderLayers)
|
||||
{
|
||||
layer.Update(null, true, false);
|
||||
if (layer.LayerType.ShowInEdtor)
|
||||
layer.Draw(null, drawingContext, true, false);
|
||||
}
|
||||
|
||||
// Get the selection color
|
||||
var accentColor = ThemeManager.DetectAppStyle(Application.Current)?.Item2?.Resources["AccentColor"];
|
||||
if (accentColor == null)
|
||||
{
|
||||
var preview = new DrawingImage();
|
||||
preview.Freeze();
|
||||
KeyboardPreview = preview;
|
||||
return;
|
||||
}
|
||||
|
||||
var pen = new Pen(new SolidColorBrush((Color) accentColor), 0.4);
|
||||
|
||||
// Draw the selection outline and resize indicator
|
||||
if (SelectedLayer != null && SelectedLayer.MustDraw())
|
||||
{
|
||||
var layerRect = SelectedLayer.Properties.PropertiesRect();
|
||||
// Deflate the rect so that the border is drawn on the inside
|
||||
layerRect.Inflate(-0.2, -0.2);
|
||||
|
||||
// Draw an outline around the selected layer
|
||||
drawingContext.DrawRectangle(null, pen, layerRect);
|
||||
// Draw a resize indicator in the bottom-right
|
||||
drawingContext.DrawLine(pen,
|
||||
new Point(layerRect.BottomRight.X - 1, layerRect.BottomRight.Y - 0.5),
|
||||
new Point(layerRect.BottomRight.X - 1.2, layerRect.BottomRight.Y - 0.7));
|
||||
drawingContext.DrawLine(pen,
|
||||
new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 1),
|
||||
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 1.2));
|
||||
drawingContext.DrawLine(pen,
|
||||
new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 0.5),
|
||||
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
|
||||
}
|
||||
|
||||
SelectedProfile?.RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(DrawType.Preview, null, true, drawingContext));
|
||||
|
||||
// Remove the clip
|
||||
drawingContext.Pop();
|
||||
}
|
||||
var drawnPreview = new DrawingImage(visual.Drawing);
|
||||
drawnPreview.Freeze();
|
||||
KeyboardPreview = drawnPreview;
|
||||
|
||||
// Setup layers for the next frame
|
||||
if (ModuleModel.IsInitialized && ActiveWindowHelper.MainWindowActive)
|
||||
ModuleModel.PreviewLayers = renderLayers;
|
||||
}
|
||||
|
||||
private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => KeyboardImage);
|
||||
}
|
||||
|
||||
#region Processing
|
||||
|
||||
/// <summary>
|
||||
/// Handler for clicking
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void MouseDownKeyboardPreview(MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
_downTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Second handler for clicking, selects a the layer the user clicked on.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void MouseUpKeyboardPreview(MouseButtonEventArgs e)
|
||||
{
|
||||
if (SelectedProfile == null || SelectedProfile.IsDefault)
|
||||
return;
|
||||
|
||||
var timeSinceDown = DateTime.Now - _downTime;
|
||||
if (!(timeSinceDown.TotalMilliseconds < 500))
|
||||
return;
|
||||
if (_draggingLayer != null)
|
||||
return;
|
||||
|
||||
var keyboard = _deviceManager.ActiveKeyboard;
|
||||
var pos = e.GetPosition((Image) e.OriginalSource);
|
||||
var x = pos.X / ((double) keyboard.PreviewSettings.Width / keyboard.Width);
|
||||
var y = pos.Y / ((double) keyboard.PreviewSettings.Height / keyboard.Height);
|
||||
|
||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||
|
||||
if (hoverLayer != null)
|
||||
SelectedLayer = hoverLayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for resizing and moving the currently selected layer
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void MouseMoveKeyboardPreview(MouseEventArgs e)
|
||||
{
|
||||
if (SelectedProfile == null)
|
||||
return;
|
||||
|
||||
var pos = e.GetPosition((Image) e.OriginalSource);
|
||||
var keyboard = _deviceManager.ActiveKeyboard;
|
||||
var x = pos.X / ((double) keyboard.PreviewSettings.Width / keyboard.Width);
|
||||
var y = pos.Y / ((double) keyboard.PreviewSettings.Height / keyboard.Height);
|
||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||
|
||||
HandleDragging(e, x, y, hoverLayer);
|
||||
|
||||
if (hoverLayer == null)
|
||||
{
|
||||
KeyboardPreviewCursor = Cursors.Arrow;
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn the mouse pointer into a hand if hovering over an active layer
|
||||
if (hoverLayer == SelectedLayer)
|
||||
{
|
||||
var rect = hoverLayer.Properties.PropertiesRect(1);
|
||||
KeyboardPreviewCursor =
|
||||
Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
|
||||
? Cursors.SizeNWSE
|
||||
: Cursors.SizeAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyboardPreviewCursor = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor KeyboardPreviewCursor
|
||||
{
|
||||
get { return _keyboardPreviewCursor; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _keyboardPreviewCursor)) return;
|
||||
_keyboardPreviewCursor = value;
|
||||
NotifyOfPropertyChange(() => KeyboardPreviewCursor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles dragging the given layer
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="hoverLayer"></param>
|
||||
private void HandleDragging(MouseEventArgs e, double x, double y, LayerModel hoverLayer)
|
||||
{
|
||||
// Reset the dragging state on mouse release
|
||||
if (e.LeftButton == MouseButtonState.Released ||
|
||||
_draggingLayer != null && SelectedLayer != _draggingLayer)
|
||||
{
|
||||
_draggingLayerOffset = null;
|
||||
_draggingLayer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectedLayer == null || SelectedLayer.LayerType != null && !SelectedLayer.LayerType.ShowInEdtor)
|
||||
return;
|
||||
|
||||
// Setup the dragging state on mouse press
|
||||
if (_draggingLayerOffset == null && hoverLayer != null && e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var layerRect = hoverLayer.Properties.PropertiesRect(1);
|
||||
|
||||
_draggingLayerOffset = new Point(x - SelectedLayer.Properties.X, y - SelectedLayer.Properties.Y);
|
||||
_draggingLayer = hoverLayer;
|
||||
// Detect dragging if cursor is in the bottom right
|
||||
_resizing = Math.Sqrt(Math.Pow(x - layerRect.BottomRight.X, 2) +
|
||||
Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6;
|
||||
}
|
||||
|
||||
if (_draggingLayerOffset == null || _draggingLayer == null || _draggingLayer != SelectedLayer)
|
||||
return;
|
||||
|
||||
var draggingProps = _draggingLayer.Properties;
|
||||
// If no setup or reset was done, handle the actual dragging action
|
||||
if (_resizing)
|
||||
{
|
||||
var newWidth = Math.Round(x - draggingProps.X);
|
||||
var newHeight = Math.Round(y - draggingProps.Y);
|
||||
|
||||
// Ensure the layer doesn't leave the canvas
|
||||
if (newWidth < 1 || draggingProps.X + newWidth <= 0)
|
||||
newWidth = draggingProps.Width;
|
||||
if (newHeight < 1 || draggingProps.Y + newHeight <= 0)
|
||||
newHeight = draggingProps.Height;
|
||||
|
||||
draggingProps.Width = newWidth;
|
||||
draggingProps.Height = newHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newX = Math.Round(x - _draggingLayerOffset.Value.X);
|
||||
var newY = Math.Round(y - _draggingLayerOffset.Value.Y);
|
||||
|
||||
// Ensure the layer doesn't leave the canvas
|
||||
if (newX >= SelectedProfile.Width || newX + draggingProps.Width <= 0)
|
||||
newX = draggingProps.X;
|
||||
if (newY >= SelectedProfile.Height || newY + draggingProps.Height <= 0)
|
||||
newY = draggingProps.Y;
|
||||
|
||||
draggingProps.X = newX;
|
||||
draggingProps.Y = newY;
|
||||
}
|
||||
}
|
||||
|
||||
public List<LayerModel> GetRenderLayers()
|
||||
{
|
||||
// Get the layers that must be drawn
|
||||
List<LayerModel> drawLayers;
|
||||
if (ShowAll)
|
||||
return SelectedProfile.GetRenderLayers(null, false, true);
|
||||
|
||||
if (SelectedLayer == null || !SelectedLayer.Enabled)
|
||||
return new EditableList<LayerModel>();
|
||||
|
||||
if (SelectedLayer.LayerType is FolderType)
|
||||
drawLayers = SelectedLayer.GetRenderLayers(null, false, true);
|
||||
else
|
||||
drawLayers = new List<LayerModel> {SelectedLayer};
|
||||
|
||||
return drawLayers;
|
||||
}
|
||||
|
||||
|
||||
private List<LayerModel> GetLayers()
|
||||
{
|
||||
if (ShowAll)
|
||||
return SelectedProfile.GetLayers();
|
||||
if (SelectedLayer == null)
|
||||
return new List<LayerModel>();
|
||||
|
||||
lock (SelectedLayer)
|
||||
{
|
||||
// Get the layers that must be drawn
|
||||
if (SelectedLayer.LayerType is FolderType)
|
||||
return SelectedLayer.GetLayers().ToList();
|
||||
return new List<LayerModel> {SelectedLayer};
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disposed = true;
|
||||
_loopManager.RenderCompleted -= LoopManagerOnRenderCompleted;
|
||||
_deviceManager.OnKeyboardChanged -= DeviceManagerOnOnKeyboardChanged;
|
||||
}
|
||||
|
||||
public bool Disposed { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<controls:MetroWindow x:Class="Artemis.Views.Profiles.LayerEditorView"
|
||||
<controls:MetroWindow x:Class="Artemis.Views.LayerEditorView"
|
||||
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"
|
||||
@ -1,6 +1,6 @@
|
||||
using MahApps.Metro.Controls;
|
||||
|
||||
namespace Artemis.Views.Profiles
|
||||
namespace Artemis.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LayerEditorView.xaml
|
||||
@ -1,288 +1,297 @@
|
||||
<UserControl x:Class="Artemis.Views.Profiles.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:cal="http://www.caliburnproject.org"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours"
|
||||
xmlns:utilities="clr-namespace:Artemis.Utilities"
|
||||
xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
|
||||
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="510" Width="1055">
|
||||
<UserControl.Resources>
|
||||
<converters:LayerOrderConverter x:Key="LayerOrderConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Width="Auto" Height="Auto">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Preview Background="#FF232323" -->
|
||||
<Label Grid.Column="0" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Preview" />
|
||||
<Border Grid.Column="0" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
|
||||
BorderThickness="3" Width="800" Height="400">
|
||||
<Border>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1"
|
||||
BlurRadius="{Binding Path=ProfileViewModel.BlurRadius, Mode=OneWay}" />
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=ProfileViewModel.KeyboardImage}"
|
||||
Margin="50" />
|
||||
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=ProfileViewModel.KeyboardPreview}"
|
||||
Opacity="0.8"
|
||||
Width="{Binding Path=PreviewSettings.Width}"
|
||||
Height="{Binding Path=PreviewSettings.Height}"
|
||||
Margin="{Binding Path=PreviewSettings.Margin}"
|
||||
Stretch="Fill" Cursor="{Binding Path=ProfileViewModel.KeyboardPreviewCursor}"
|
||||
cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
|
||||
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
|
||||
[Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
<!-- Profile management -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="2">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||
<Label Content="Active profile" />
|
||||
<ComboBox Width="220" VerticalAlignment="Top" x:Name="ProfileNames" Margin="5,0,0,0" />
|
||||
<Button x:Name="AddProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Add profile">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="RenameProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="DuplicateProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0"
|
||||
ToolTip="Duplicate profile"
|
||||
IsEnabled="{Binding Path=ProfileSelected, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="DeleteProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<TextBlock VerticalAlignment="Top" Foreground="{DynamicResource HighlightBrush}" HorizontalAlignment="Left"
|
||||
Margin="5,5,0,0" Text="Note: To edit a default profile, duplicate it first." FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Right">
|
||||
<Button x:Name="ImportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" ToolTip="Import profile">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_cabinet_in}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">import profile</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="ExportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" IsEnabled="{Binding ProfileSelected}">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_cabinet_out}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">export profile</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="EditLua" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Import profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_code_xml}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">edit lua</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Layer list -->
|
||||
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
|
||||
<Label FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
|
||||
<Label HorizontalAlignment="Right" ToolTip="Show all layers instead of just the one you have selected"
|
||||
Content="Show all" Margin="88,0,0,0" VerticalAlignment="Center" />
|
||||
<ToggleButton x:Name="ShowAll" ToolTip="Show all layers instead of just the one you have selected"
|
||||
Margin="0 3 0 0" Width="25" Height="25"
|
||||
IsChecked="{Binding Path=ProfileViewModel.ShowAll, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" HorizontalAlignment="Right" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
|
||||
BorderThickness="3" Margin="10,0,0,0" Height="400" Width="233">
|
||||
<TreeView x:Name="ProfileTree"
|
||||
dragDrop:DragDrop.IsDragSource="True"
|
||||
dragDrop:DragDrop.IsDropTarget="True"
|
||||
dragDrop:DragDrop.DropHandler="{Binding}"
|
||||
ItemsSource="{Binding Path=Layers, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
cal:Message.Attach="[Event MouseDoubleClick] = [Action EditLayerFromDoubleClick]">
|
||||
<i:Interaction.Behaviors>
|
||||
<itemBehaviours:BindableSelectedItemBehavior
|
||||
SelectedItem="{Binding SelectedLayer, Mode=TwoWay}" />
|
||||
</i:Interaction.Behaviors>
|
||||
<TreeView.Resources>
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate
|
||||
ItemsSource="{Binding Children, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}">
|
||||
<StackPanel Orientation="Horizontal" Tag="{Binding DataContext, ElementName=ProfileTree}">
|
||||
<StackPanel.ContextMenu>
|
||||
<ContextMenu
|
||||
cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Rename" cal:Message.Attach="RenameLayer($datacontext)" />
|
||||
<MenuItem Header="Duplicate" cal:Message.Attach="CloneLayer($datacontext)" />
|
||||
<MenuItem Header="Delete" cal:Message.Attach="RemoveLayer($datacontext)" />
|
||||
<MenuItem Header="Properties" cal:Message.Attach="EditLayer($datacontext)" />
|
||||
</ContextMenu>
|
||||
</StackPanel.ContextMenu>
|
||||
<CheckBox VerticalAlignment="Center" ToolTip="Layer enabled" IsChecked="{Binding Enabled}" />
|
||||
<Image Height="18" Width="18" Source="{Binding LayerImage}" />
|
||||
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">
|
||||
<Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="10,5,0,0" HorizontalAlignment="Right">
|
||||
<Button x:Name="AddLayer" VerticalAlignment="Top"
|
||||
Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
Width="26" Height="26" ToolTip="Add layer" HorizontalAlignment="Left">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="AddFolder" VerticalAlignment="Top"
|
||||
Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
Width="26" Height="26" ToolTip="Add folder" HorizontalAlignment="Left" Margin="10,0,0,0">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_folder}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="EditLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Edit layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="CloneLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="RemoveLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<UserControl x:Class="Artemis.Views.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:cal="http://www.caliburnproject.org"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours"
|
||||
xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
|
||||
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="510" Width="1055">
|
||||
<UserControl.Resources>
|
||||
<converters:LayerOrderConverter x:Key="LayerOrderConverter" />
|
||||
<Storyboard x:Key="Pulse" RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="BlurRadius" Storyboard.TargetName="ShadowEffect">
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="25"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="10"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="25"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
|
||||
<BeginStoryboard Storyboard="{StaticResource Pulse}"/>
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid Width="Auto" Height="Auto">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Preview Background="#FF232323" -->
|
||||
<Label Grid.Column="0" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Preview" />
|
||||
<Border Grid.Column="0" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
|
||||
BorderThickness="3" Width="800" Height="400">
|
||||
<Border>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect x:Name="ShadowEffect" ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1" />
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardImage}"
|
||||
Margin="50" />
|
||||
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardPreview}"
|
||||
Opacity="0.8"
|
||||
Width="{Binding Path=PreviewSettings.Width}"
|
||||
Height="{Binding Path=PreviewSettings.Height}"
|
||||
Margin="{Binding Path=PreviewSettings.Margin}"
|
||||
Stretch="Fill" Cursor="{Binding Path=KeyboardPreviewCursor}"
|
||||
cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
|
||||
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
|
||||
[Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
<!-- Profile management -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="2">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||
<Label Content="Active profile" />
|
||||
<ComboBox Width="220" VerticalAlignment="Top" x:Name="ProfileNames" Margin="5,0,0,0" />
|
||||
<Button x:Name="AddProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Add profile">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="RenameProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="DuplicateProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0"
|
||||
ToolTip="Duplicate profile"
|
||||
IsEnabled="{Binding Path=ProfileSelected, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="DeleteProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<TextBlock VerticalAlignment="Top" Foreground="{DynamicResource HighlightBrush}" HorizontalAlignment="Left"
|
||||
Margin="5,5,0,0" Text="Note: To edit a default profile, duplicate it first." FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Right">
|
||||
<Button x:Name="ImportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" ToolTip="Import profile">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_cabinet_in}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">import profile</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="ExportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" IsEnabled="{Binding ProfileSelected}">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_cabinet_out}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">export profile</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="EditLua" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Import profile"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12" Margin="3,0">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_code_xml}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="2,0,2,0">edit lua</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Layer list -->
|
||||
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
|
||||
<Label FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
|
||||
<Label HorizontalAlignment="Right" ToolTip="Show all layers instead of just the one you have selected"
|
||||
Content="Show all" Margin="88,0,0,0" VerticalAlignment="Center" />
|
||||
<ToggleButton x:Name="ShowAll" ToolTip="Show all layers instead of just the one you have selected"
|
||||
Margin="0 3 0 0" Width="25" Height="25"
|
||||
IsChecked="{Binding Path=ShowAll, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" HorizontalAlignment="Right" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
|
||||
BorderThickness="3" Margin="10,0,0,0" Height="400" Width="233">
|
||||
<TreeView x:Name="ProfileTree"
|
||||
dragDrop:DragDrop.IsDragSource="True"
|
||||
dragDrop:DragDrop.IsDropTarget="True"
|
||||
dragDrop:DragDrop.DropHandler="{Binding}"
|
||||
ItemsSource="{Binding Path=Layers, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}"
|
||||
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
cal:Message.Attach="[Event MouseDoubleClick] = [Action EditLayerFromDoubleClick]">
|
||||
<i:Interaction.Behaviors>
|
||||
<itemBehaviours:BindableSelectedItemBehavior
|
||||
SelectedItem="{Binding SelectedLayer, Mode=TwoWay}" />
|
||||
</i:Interaction.Behaviors>
|
||||
<TreeView.Resources>
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate
|
||||
ItemsSource="{Binding Children, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}">
|
||||
<StackPanel Orientation="Horizontal" Tag="{Binding DataContext, ElementName=ProfileTree}">
|
||||
<StackPanel.ContextMenu>
|
||||
<ContextMenu
|
||||
cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Rename" cal:Message.Attach="RenameLayer($datacontext)" />
|
||||
<MenuItem Header="Duplicate" cal:Message.Attach="CloneLayer($datacontext)" />
|
||||
<MenuItem Header="Delete" cal:Message.Attach="RemoveLayer($datacontext)" />
|
||||
<MenuItem Header="Properties" cal:Message.Attach="EditLayer($datacontext)" />
|
||||
</ContextMenu>
|
||||
</StackPanel.ContextMenu>
|
||||
<CheckBox VerticalAlignment="Center" ToolTip="Layer enabled" IsChecked="{Binding Enabled}" />
|
||||
<Image Height="18" Width="18" Source="{Binding LayerImage}" />
|
||||
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">
|
||||
<Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="10,5,0,0" HorizontalAlignment="Right">
|
||||
<Button x:Name="AddLayer" VerticalAlignment="Top"
|
||||
Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
Width="26" Height="26" ToolTip="Add layer" HorizontalAlignment="Left">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="AddFolder" VerticalAlignment="Top"
|
||||
Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"
|
||||
Width="26" Height="26" ToolTip="Add folder" HorizontalAlignment="Left" Margin="10,0,0,0">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_folder}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="EditLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Edit layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="CloneLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="RemoveLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
|
||||
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete layer"
|
||||
IsEnabled="{Binding Path=LayerSelected}">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="12" Height="12">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Views.Profiles
|
||||
namespace Artemis.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ProfileEditorView.xaml
|
||||
Loading…
x
Reference in New Issue
Block a user