2014-07-26 07:12:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-09-12 10:19:01 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml.Serialization;
|
2014-08-12 13:33:13 +00:00
|
|
|
|
using RainmeterStudio.Core.Storage;
|
2014-08-31 11:41:24 +00:00
|
|
|
|
using RainmeterStudio.Core.Utils;
|
|
|
|
|
using Version = RainmeterStudio.Core.Utils.Version;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-08-12 13:33:13 +00:00
|
|
|
|
namespace RainmeterStudio.Core.Model
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines a Rainmeter Studio project
|
|
|
|
|
/// </summary>
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public class Project : INotifyPropertyChanged
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
2014-09-12 10:19:01 +00:00
|
|
|
|
private string _author;
|
|
|
|
|
private Reference _autoLoadFile;
|
|
|
|
|
private Version _version, _minimumWindows, _minimumRainmeter;
|
|
|
|
|
private Reference _root;
|
|
|
|
|
|
2014-08-16 14:09:08 +00:00
|
|
|
|
#region Properties
|
2014-07-27 13:21:06 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name of the project
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "name", Order = 1)]
|
2014-07-27 13:21:06 +00:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-31 11:41:24 +00:00
|
|
|
|
return Root.Name;
|
2014-07-27 13:21:06 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-31 11:41:24 +00:00
|
|
|
|
Root.Name = value;
|
2014-09-12 10:19:01 +00:00
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
|
2014-07-27 13:21:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the file path of this project
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlIgnore]
|
2014-07-27 13:21:06 +00:00
|
|
|
|
public string Path
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-31 11:41:24 +00:00
|
|
|
|
return Root.StoragePath;
|
2014-07-27 13:21:06 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-31 11:41:24 +00:00
|
|
|
|
Root.StoragePath = value;
|
2014-09-12 10:19:01 +00:00
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
|
2014-07-27 13:21:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the author of the project
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "author", Order = 2)]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public string Author
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _author;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_author = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Author"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the version of the project
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "version", Order = 3)]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public Version Version
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _version;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_version = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Version"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
/// Gets or sets the reference to the file that automatically loads at package installation
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlIgnore]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public Reference AutoLoadFile
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _autoLoadFile;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_autoLoadFile = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("AutoLoadFile"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-08-31 11:41:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the qualified name of the auto load file
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlElement(ElementName = "autoLoadFile", Order = 7)]
|
|
|
|
|
public string AutoLoadFileQualifiedName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return ((AutoLoadFile == null) ? null : AutoLoadFile.QualifiedName);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
AutoLoadFile = Root.GetReference(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the list of variable files
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlIgnore]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public ObservableCollection<Reference> VariableFiles { get; private set; }
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-08-31 11:41:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the list of variable files qualified names
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlArray(ElementName = "variableFiles", Order = 8)]
|
|
|
|
|
public string[] VariableFilesQualifiedNames
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return VariableFiles.Select(x => x.QualifiedName).ToArray();
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
VariableFiles.Clear();
|
2014-09-12 10:19:01 +00:00
|
|
|
|
value.Select(x => Root.GetReference(x)).ForEach(VariableFiles.Add);
|
2014-08-31 11:41:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the minimum rainmeter version
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "minimumRainmeter", Order = 4)]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public Version MinimumRainmeter
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _minimumRainmeter;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_minimumRainmeter = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("MinimumRainmeter"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the minimum Windows version
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "minimumWindows", Order = 5)]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public Version MinimumWindows
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _minimumWindows;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_minimumWindows = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("MinimumWindows"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the root node
|
|
|
|
|
/// </summary>
|
2014-08-31 11:41:24 +00:00
|
|
|
|
[XmlElement(ElementName = "root", Order = 6)]
|
2014-09-12 10:19:01 +00:00
|
|
|
|
public Reference Root
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _root;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_root = value;
|
|
|
|
|
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Root"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a project
|
|
|
|
|
/// </summary>
|
2014-07-26 07:12:56 +00:00
|
|
|
|
public Project()
|
|
|
|
|
{
|
2014-09-16 18:57:15 +00:00
|
|
|
|
Root = new Reference(String.Empty, ReferenceTargetKind.Project);
|
2014-09-12 10:19:01 +00:00
|
|
|
|
VariableFiles = new ObservableCollection<Reference>();
|
2014-07-26 07:12:56 +00:00
|
|
|
|
Version = new Version();
|
|
|
|
|
MinimumRainmeter = new Version("3.1");
|
|
|
|
|
MinimumWindows = new Version("5.1");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 13:21:06 +00:00
|
|
|
|
#endregion
|
2014-08-31 11:41:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Operations
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Looks for reference in project
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reference">Reference</param>
|
|
|
|
|
/// <returns>True if reference was found</returns>
|
|
|
|
|
public bool Contains(Reference reference)
|
|
|
|
|
{
|
|
|
|
|
return Root.TreeContains(reference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-09-12 10:19:01 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Triggered when a property changes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|