1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profile import/clone fixes

Fixed importing a default profile not setting the IsDefault flag to false
Fixed duplicating a profile not cloning the layers
This commit is contained in:
SpoinkyNL 2016-07-20 08:19:28 +02:00
parent 11035f7920
commit 20eca5e849
3 changed files with 9 additions and 19 deletions

View File

@ -50,13 +50,7 @@ namespace Artemis.Utilities
if (ReferenceEquals(source, null))
return default(T);
var deserializeSettings = new JsonSerializerSettings
{
ObjectCreationHandling = ObjectCreationHandling.Replace,
TypeNameHandling = TypeNameHandling.Auto
};
return (T) JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source), source.GetType(),
deserializeSettings);
return (T)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source), source.GetType());
}
public static object GetPropertyValue(object o, string path)

View File

@ -217,20 +217,17 @@ namespace Artemis.ViewModels.Profiles
foreach (var conditionViewModel in LayerConditionVms)
ProposedLayer.Properties.Conditions.Add(conditionViewModel.LayerConditionModel);
// Ignore children on the comparison
var currentNoChildren = GeneralHelpers.Clone(Layer);
currentNoChildren.Children.Clear();
// If not a keyboard, ignore size and position
if (ProposedLayer.LayerType.DrawType != DrawType.Keyboard)
{
ProposedLayer.Properties.Width = currentNoChildren.Properties.Width;
ProposedLayer.Properties.Height = currentNoChildren.Properties.Height;
ProposedLayer.Properties.X = currentNoChildren.Properties.X;
ProposedLayer.Properties.Y = currentNoChildren.Properties.Y;
ProposedLayer.Properties.Contain = currentNoChildren.Properties.Contain;
ProposedLayer.Properties.Width = Layer.Properties.Width;
ProposedLayer.Properties.Height = Layer.Properties.Height;
ProposedLayer.Properties.X = Layer.Properties.X;
ProposedLayer.Properties.Y = Layer.Properties.Y;
ProposedLayer.Properties.Contain = Layer.Properties.Contain;
}
var current = JsonConvert.SerializeObject(currentNoChildren, Formatting.Indented);
var current = JsonConvert.SerializeObject(Layer, Formatting.Indented);
var proposed = JsonConvert.SerializeObject(ProposedLayer, Formatting.Indented);
if (current.Equals(proposed))

View File

@ -414,8 +414,6 @@ namespace Artemis.ViewModels.Profiles
{
var clone = GeneralHelpers.Clone(layer);
layer.InsertAfter(clone);
foreach (var layerModel in layer.Children)
clone.Children.Add(GeneralHelpers.Clone(layerModel));
UpdateLayerList(clone);
}
@ -642,9 +640,10 @@ namespace Artemis.ViewModels.Profiles
profile.KeyboardSlug = deviceManager.ActiveKeyboard.Slug;
profile.Width = deviceManager.ActiveKeyboard.Width;
profile.Height = deviceManager.ActiveKeyboard.Height;
profile.IsDefault = false;
}
profile.IsDefault = false;
// Verify the name
while (ProfileProvider.GetAll().Contains(profile))
{