|
@@ -1,22 +1,23 @@
|
|
|
-using System.Collections.Generic;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
|
|
|
-namespace PixiEditor.Models.Tools.ToolSettings
|
|
|
+namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
|
|
|
{
|
|
|
public abstract class Toolbar
|
|
|
{
|
|
|
- private static readonly List<Setting> _sharedSettings = new List<Setting>();
|
|
|
+ private static readonly List<Setting> SharedSettings = new List<Setting>();
|
|
|
public ObservableCollection<Setting> Settings { get; set; } = new ObservableCollection<Setting>();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Gets setting in toolbar by name.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="name">Setting name, non case sensitive</param>
|
|
|
+ /// <returns></returns>
|
|
|
public virtual Setting GetSetting(string name)
|
|
|
{
|
|
|
- return Settings.FirstOrDefault(x => x.Name == name);
|
|
|
- }
|
|
|
-
|
|
|
- public virtual Setting[] GetSettings(string name)
|
|
|
- {
|
|
|
- return Settings.Where(x => x.Name == name).ToArray();
|
|
|
+ return Settings.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.CurrentCultureIgnoreCase));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -25,17 +26,20 @@ namespace PixiEditor.Models.Tools.ToolSettings
|
|
|
public void SaveToolbarSettings()
|
|
|
{
|
|
|
for (int i = 0; i < Settings.Count; i++)
|
|
|
- if (_sharedSettings.Any(x => x.Name == Settings[i].Name))
|
|
|
- _sharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
|
|
|
+ if (SharedSettings.Any(x => x.Name == Settings[i].Name))
|
|
|
+ SharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
|
|
|
else
|
|
|
- _sharedSettings.Add(Settings[i]);
|
|
|
+ SharedSettings.Add(Settings[i]);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Loads common settings saved from previous tools to current one.
|
|
|
+ /// </summary>
|
|
|
public void LoadSharedSettings()
|
|
|
{
|
|
|
- for (int i = 0; i < _sharedSettings.Count; i++)
|
|
|
- if (Settings.Any(x => x.Name == _sharedSettings[i].Name))
|
|
|
- Settings.First(x => x.Name == _sharedSettings[i].Name).Value = _sharedSettings[i].Value;
|
|
|
+ for (int i = 0; i < SharedSettings.Count; i++)
|
|
|
+ if (Settings.Any(x => x.Name == SharedSettings[i].Name))
|
|
|
+ Settings.First(x => x.Name == SharedSettings[i].Name).Value = SharedSettings[i].Value;
|
|
|
}
|
|
|
}
|
|
|
}
|