zaaReloaded2/zaaReloaded2/Controller/Settings.cs

127 lines
3.6 KiB
C#
Raw Normal View History

/* Settings.cs
2015-07-04 10:09:39 +00:00
* part of zaaReloaded2
*
* Copyright 2015 Daniel Kraus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using zaaReloaded2.Formatter;
using zaaReloaded2.Controller.Elements;
2015-07-04 10:09:39 +00:00
namespace zaaReloaded2.Controller
2015-07-04 10:09:39 +00:00
{
2015-07-13 21:57:35 +00:00
/// <summary>
/// Holds settings related to controlling laboratory output.
2015-07-13 21:57:35 +00:00
/// </summary>
[Serializable]
public class Settings : ICloneable
2015-07-04 10:09:39 +00:00
{
#region Properties
2015-07-16 03:28:28 +00:00
/// <summary>
/// Gets or sets the name of these settings.
/// </summary>
public string Name { get; set; }
2015-07-04 10:09:39 +00:00
/// <summary>
/// Gets or sets the reference style.
2015-07-04 10:09:39 +00:00
/// </summary>
public ReferenceStyle ReferenceStyle { get; set; }
2015-07-13 21:57:35 +00:00
/// <summary>
/// Gets the list of controlling elements.
2015-07-13 21:57:35 +00:00
/// </summary>
public IList<ElementBase> Elements { get; private set; }
2015-08-02 05:19:12 +00:00
/// <summary>
/// Gets the unique ID of this Settings object. The unique
/// ID is not included in deep-copying (cloning).
/// </summary>
public Guid Uid { get; private set; }
#endregion
#region Constructors
public Settings()
: this(string.Empty, null)
{ }
public Settings(string name)
: this(name, null)
{ }
/// <summary>
/// Creates a new Settings object with an initial
/// set of elements.
/// </summary>
/// <param name="initialElements">Set of ElementBase
/// object (or derived ones).</param>
public Settings(IList<ElementBase> initialElements)
: this(String.Empty, initialElements)
{ }
/// <summary>
/// Creates a new Settings object with an initial
/// set of elements and a name.
/// </summary>
/// <param name="initialElements">Set of ElementBase
/// object (or derived ones).</param>
/// <param name="name">Name of these settings.</param>
public Settings(string name, IList<ElementBase> initialElements)
{
Uid = Guid.NewGuid();
Name = name;
Elements = initialElements;
2015-08-09 11:24:44 +00:00
ReferenceStyle = Properties.Settings.Default.ReferenceStyle;
if (Elements == null)
{
Elements = new List<ElementBase>();
}
}
#endregion
#region Public methods
/// <summary>
/// Adds an element to the list of Elements.
/// </summary>
/// <param name="element">Element to add.</param>
public void AddElement(ElementBase element)
{
Elements.Add(element);
}
#endregion
#region Implementation of ICloneable
public object Clone()
{
Settings clone = new Settings(
String.Format("Kopie von {0}", Name),
Elements.Select(e => e.Clone() as ElementBase).ToList()
);
clone.ReferenceStyle = ReferenceStyle;
return clone;
}
#endregion
2015-07-04 10:09:39 +00:00
}
}