Skip to content

Commit

Permalink
更新。
Browse files Browse the repository at this point in the history
  • Loading branch information
nicengi committed Mar 30, 2020
1 parent d41a03d commit a32675e
Show file tree
Hide file tree
Showing 116 changed files with 18,534 additions and 1,800 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,5 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb
*.snk
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace MMEdit.Fx
namespace MMEdit
{
public class Annotation : ObjectFX
/// <summary>
/// 定义可编辑对象注解。
/// </summary>
public class Annotation : ObjectFX, INotifyPropertyChanged, IFormattable
{
#region Constructor
/// <summary>
/// 初始化 <see cref="Annotation"/> 类的新实例。
/// </summary>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="value"></param>
public Annotation(string type, string name, string value) : this()
public Annotation() : base(null)
{
Type = type;
Name = name;
Value = value;
Data.Add("Type", null);
Data.Add("Name", null);
Data.Add("Value", null);
}

/// <summary>
/// 初始化 <see cref="Annotation"/> 类的新实例。
/// <inheritdoc cref="Annotation()"/>
/// </summary>
public Annotation() : base(null)
/// <param name="type">类型。</param>
/// <param name="name">名称。</param>
/// <param name="value">值。</param>
public Annotation(string type, string name, object value) : this()
{
Data.Add("Type", null);
Data.Add("Name", null);
Data.Add("Value", null);
Type = type;
Name = name;
Value = value;
}
#endregion

Expand All @@ -43,6 +48,7 @@ public string Type
set
{
Data["Type"] = value;
OnPropertyChanged();
}
}

Expand All @@ -59,47 +65,63 @@ public string Name
set
{
Data["Name"] = value;
OnPropertyChanged();
}
}

/// <summary>
/// 获取或设置注解的值。
/// </summary>
public string Value
public virtual object Value
{
get
{
return (string)Data["Value"];
return Data["Value"];
}

set
{
Data["Value"] = value;
OnValueChanged();
OnPropertyChanged();
}
}
#endregion

#region Events
/// <summary>
/// 当 <see cref="Value"/> 属性的值改变时发生。
/// <inheritdoc cref="INotifyPropertyChanged.PropertyChanged"/>
/// </summary>
public event EventHandler ValueChanged;
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// 引发 <see cref="ValueChanged"/> 事件。
/// 引发 <see cref="PropertyChanged"/> 事件。
/// </summary>
protected void OnValueChanged()
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = "")
{
ValueChanged?.Invoke(this, EventArgs.Empty);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion

#region Methods
/// <summary>
/// <inheritdoc cref="object.ToString()"/>
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Name;
}

/// <summary>
/// <inheritdoc cref="IFormattable.ToString(string, IFormatProvider)"/>
/// </summary>
/// <param name="format"></param>
/// <param name="formatProvider"></param>
/// <returns></returns>
public virtual string ToString(string format, IFormatProvider formatProvider)
{
return ((ICustomFormatter)formatProvider.GetFormat(typeof(ICustomFormatter)))?.Format(format, this, formatProvider);
}
#endregion
}
}
62 changes: 62 additions & 0 deletions MMEdit.Framework/Configuration/CustomSettingsBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Collections.Generic;
using System.Windows.Forms;

namespace MMEdit.Configuration
{
/// <summary>
/// 定义自定义设置的基类。
/// </summary>
public abstract class CustomSettingsBase : ICustomSettings
{
#region Constructor
/// <summary>
/// 初始化 <see cref="CustomSettingsBase"/> 类的新实例。
/// </summary>
public CustomSettingsBase()
{
Settings = new List<ICustomSettings>();
}
#endregion

#region Properties
/// <summary>
/// 获取或设置标签文本。
/// </summary>
public string Text { get; protected set; }

/// <summary>
/// 获取子设置集合。
/// </summary>
public List<ICustomSettings> Settings { get; }

IList<ICustomSettings> ICustomSettings.Settings
{
get
{
return Settings;
}
}
#endregion

#region Methods
/// <summary>
/// 存储设置属性的当前值。
/// </summary>
public abstract void Save();

/// <summary>
/// <see cref="Settings"/> <inheritdoc cref="CustomSettingsBase.Save()"/>
/// </summary>
protected virtual void SaveSettings()
{
Settings.ForEach(s => s.Save());
}

/// <summary>
/// 创建控件。
/// </summary>
/// <returns></returns>
public abstract Control CreateControl();
#endregion
}
}
44 changes: 44 additions & 0 deletions MMEdit.Framework/Configuration/ExtensionRule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;

namespace MMEdit.Configuration
{
/// <summary>
/// 定义扩展名导入规则。
/// </summary>
[Serializable]
public class ExtensionRule
{
#region Constructor
/// <summary>
/// 初始化 <see cref="ExtensionRule"/> 类的新实例。
/// </summary>
public ExtensionRule()
{

}

/// <summary>
/// <inheritdoc cref="ExtensionRule.ExtensionRule()"/>
/// </summary>
/// <param name="extension"></param>
/// <param name="importerGuid"></param>
public ExtensionRule(string extension, Guid importerGuid)
{
Extension = extension;
ImporterGuid = importerGuid;
}
#endregion

#region Properties
/// <summary>
/// 获取或设置扩展名。
/// </summary>
public string Extension { get; set; }

/// <summary>
/// 获取或设置导入程序 GUID。
/// </summary>
public Guid ImporterGuid { get; set; }
#endregion
}
}
95 changes: 95 additions & 0 deletions MMEdit.Framework/Configuration/History.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Drawing;
using System.IO;

namespace MMEdit.Configuration
{
/// <summary>
/// 表示历史项目。
/// </summary>
[Serializable]
public class History
{
#region Constructor
/// <summary>
/// 初始化 <see cref=" History"/> 类的新实例。
/// </summary>
public History()
{
DateTime = DateTime.Now;
}

/// <summary>
/// <inheritdoc cref="History()"/>
/// </summary>
/// <param name="fileName">文件名。</param>
/// <param name="importerGuid">导入程序 GUID。</param>
public History(string fileName, Guid importerGuid) : this()
{
FullName = fileName;
ImporterGuid = importerGuid;
}

/// <summary>
/// <inheritdoc cref="History()"/>
/// </summary>
/// <param name="fileName">文件名。</param>
/// <param name="importerGuid">导入程序 GUID。</param>
/// <param name="image">图像。</param>
public History(string fileName, Guid importerGuid, Image image) : this(fileName, importerGuid)
{
Image = image;
}

/// <summary>
/// <inheritdoc cref="History()"/>
/// </summary>
/// <param name="fileName">文件名。</param>
/// <param name="importerGuid">导入程序 GUID。</param>
/// <param name="image">图像。</param>
/// <param name="dateTime">日期时间。</param>
public History(string fileName, Guid importerGuid, Image image, DateTime dateTime) : this(fileName, importerGuid, image)
{
DateTime = dateTime;
}
#endregion

#region Properties
/// <summary>
/// 获取文件的名称。
/// </summary>
public string Name
{
get
{
return Path.GetFileName(FullName);
}
}

/// <summary>
/// 获取或设置文件的完整名称。
/// </summary>
public string FullName { get; set; }

/// <summary>
/// 获取或设置导入程序 GUID。
/// </summary>
public Guid ImporterGuid { get; set; }

/// <summary>
/// 获取或设置图像。
/// </summary>
public Image Image { get; set; }

/// <summary>
/// 获取日期时间。
/// </summary>
public DateTime DateTime { get; set; }
#endregion

/// <summary>
/// 获取历史缓存文件的路径。
/// </summary>
public static string HistoryCachePath => Path.Combine(System.Windows.Forms.Application.UserAppDataPath, "Histories");
}
}
32 changes: 32 additions & 0 deletions MMEdit.Framework/Configuration/ICustomSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Windows.Forms;

namespace MMEdit.Configuration
{
/// <summary>
/// 定义自定义设置。
/// </summary>
public interface ICustomSettings
{
/// <summary>
/// 获取标签文本。
/// </summary>
string Text { get; }

/// <summary>
/// 获取子设置集合。
/// </summary>
IList<ICustomSettings> Settings { get; }

/// <summary>
/// 存储设置属性的当前值。
/// </summary>
void Save();

/// <summary>
/// 创建控件。
/// </summary>
/// <returns></returns>
Control CreateControl();
}
}
Loading

0 comments on commit a32675e

Please sign in to comment.