From 2af06003d93803895a9fcdd668363cc43c820ed8 Mon Sep 17 00:00:00 2001 From: Nicengi Date: Thu, 6 Feb 2020 14:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IO.cs | 207 +++++++++ MMDUI.csproj | 164 ++++++++ MMDUI.sln | 25 ++ MMDUIObjectFX.cs | 21 + MMEdit.Framework.dll | Bin 0 -> 18944 bytes Menu.cs | 217 ++++++++++ Properties/AssemblyInfo.cs | 36 ++ Properties/Resources.Designer.cs | 243 +++++++++++ Properties/Resources.resx | 175 ++++++++ Properties/Settings.Designer.cs | 38 ++ Properties/Settings.settings | 9 + Resources/Images/color-adjustment-green.png | Bin 0 -> 605 bytes Resources/Images/color-adjustment-red.png | Bin 0 -> 600 bytes Resources/Images/color-adjustment.png | Bin 0 -> 572 bytes Resources/Images/color-swatch.png | Bin 0 -> 548 bytes Resources/Images/color-swatches.png | Bin 0 -> 613 bytes Resources/Images/color.png | Bin 0 -> 811 bytes Resources/Images/function.png | Bin 0 -> 372 bytes Resources/Images/ui-color-picker-default.png | Bin 0 -> 573 bytes .../Images/ui-color-picker-transparent.png | Bin 0 -> 591 bytes Resources/Images/ui-color-picker.png | Bin 0 -> 494 bytes Resources/Images/ui-label.png | Bin 0 -> 524 bytes Resources/Images/ui-slider-050.png | Bin 0 -> 478 bytes Resources/Images/ui-slider-100.png | Bin 0 -> 400 bytes Resources/Images/ui-slider-vertical-050.png | Bin 0 -> 458 bytes Resources/Images/ui-slider-vertical-100.png | Bin 0 -> 365 bytes Resources/Images/ui-slider-vertical.png | Bin 0 -> 371 bytes Resources/Images/ui-slider.png | Bin 0 -> 404 bytes Resources/Images/ui-spin.png | Bin 0 -> 330 bytes WidgetProvider.cs | 59 +++ Widgets/MMDUIWidgetBase.cs | 398 ++++++++++++++++++ Widgets/NumericWidget.Designer.cs | 156 +++++++ Widgets/NumericWidget.cs | 95 +++++ Widgets/NumericWidget.resx | 123 ++++++ Widgets/SliderWidget.Designer.cs | 209 +++++++++ Widgets/SliderWidget.cs | 157 +++++++ Widgets/SliderWidget.resx | 123 ++++++ Widgets/WidgetProxy.cs | 87 ++++ app.config | 15 + doc/ThirdPartyNotices.txt | 16 + 40 files changed, 2573 insertions(+) create mode 100644 IO.cs create mode 100644 MMDUI.csproj create mode 100644 MMDUI.sln create mode 100644 MMDUIObjectFX.cs create mode 100644 MMEdit.Framework.dll create mode 100644 Menu.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 Resources/Images/color-adjustment-green.png create mode 100644 Resources/Images/color-adjustment-red.png create mode 100644 Resources/Images/color-adjustment.png create mode 100644 Resources/Images/color-swatch.png create mode 100644 Resources/Images/color-swatches.png create mode 100644 Resources/Images/color.png create mode 100644 Resources/Images/function.png create mode 100644 Resources/Images/ui-color-picker-default.png create mode 100644 Resources/Images/ui-color-picker-transparent.png create mode 100644 Resources/Images/ui-color-picker.png create mode 100644 Resources/Images/ui-label.png create mode 100644 Resources/Images/ui-slider-050.png create mode 100644 Resources/Images/ui-slider-100.png create mode 100644 Resources/Images/ui-slider-vertical-050.png create mode 100644 Resources/Images/ui-slider-vertical-100.png create mode 100644 Resources/Images/ui-slider-vertical.png create mode 100644 Resources/Images/ui-slider.png create mode 100644 Resources/Images/ui-spin.png create mode 100644 WidgetProvider.cs create mode 100644 Widgets/MMDUIWidgetBase.cs create mode 100644 Widgets/NumericWidget.Designer.cs create mode 100644 Widgets/NumericWidget.cs create mode 100644 Widgets/NumericWidget.resx create mode 100644 Widgets/SliderWidget.Designer.cs create mode 100644 Widgets/SliderWidget.cs create mode 100644 Widgets/SliderWidget.resx create mode 100644 Widgets/WidgetProxy.cs create mode 100644 app.config create mode 100644 doc/ThirdPartyNotices.txt diff --git a/IO.cs b/IO.cs new file mode 100644 index 0000000..2d70cd3 --- /dev/null +++ b/IO.cs @@ -0,0 +1,207 @@ +using MMDUI.Properties; +using MMEdit; +using MMEdit.Fx; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; + +namespace MMDUI +{ + public class IO : PluginClass, IImportPlugin, IExportPlugin + { + #region Fields + public Encoding Encoding; + private Regex regex = new Regex(@"(?static\s+)?(?const\s+)?(?string|float|float2|float3|float4|int)\s+(?\w+)\s*<\s*(?(?\w+)\s+(?\w+)\s*=\s*(?[^;]+)\s*;\s*)+\s*>\s*=\s*(?[^;]+);", RegexOptions.Multiline); + #endregion + + #region Constructor + public IO() + { + Encoding = Encoding.GetEncoding(Settings.Default.Encoding); + Settings.Default.PropertyChanged += Default_PropertyChanged; + } + #endregion + + #region Properties + public override Guid Guid + { + get + { + return new Guid("{2461F59A-09EA-49B5-9A8E-37588AABDC9B}"); + } + } + + public override string Name + { + get + { + return "MMDUI Format Import/Export"; + } + } + + public override string Version + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + + public override string Description + { + get + { + return "提供 MMDUI 格式的 MME 文件的导入/导出程序。\r\n支持的类型:int / float / float2 / float3 / float4"; + } + } + + public string Caption + { + get + { + return "MMDUI File"; + } + } + + public string Pattern + { + get + { + return "*.fx"; + } + } + + public Image Image + { + get + { + return Resources.function; + } + } + #endregion + + #region Methods + public bool IsExportable(ObjectFX obj) + { + return obj is MMDUIObjectFX; + } + + public void Export(ObjectFX obj, string path) + { + MMDUIObjectFX fx = (MMDUIObjectFX)obj; + + string originalText = fx.OriginalText; + List indexList = new List(); + + foreach (ControlObject controlObject in fx.ControlObjects) + { + indexList.Add(controlObject._Index); + } + indexList.Sort(); + indexList.Reverse(); + + foreach (int index in indexList) + { + foreach (ControlObject controlObject in fx.ControlObjects) + { + int startIndex = controlObject._Index; + + if (startIndex == index) + { + int length = controlObject._Length; + + originalText = originalText.Remove(startIndex, length); + originalText = originalText.Insert(startIndex, Format(controlObject)); + + break; + } + } + } + + File.WriteAllText(path, originalText, Encoding); + } + + private string Format(ControlObject controlObject) + { + string data = + $"{(controlObject.IsStatic ? "static " : "")}" + + $"{(controlObject.IsConst ? "const " : "")}" + + $"{controlObject.Type} {controlObject.Name} <"; + + foreach (Annotation annotation in controlObject.Annotations) + { + data += Environment.NewLine + $"\t{annotation.Type} {annotation.Name} = {(annotation.Type == "string" ? $"\"{annotation.Value}\"" : annotation.Value)};"; + } + + data += $"{Environment.NewLine}> = {controlObject.Value};"; + + return data; + } + + public bool IsImportable(string path) + { + if (Path.GetExtension(path) == ".fx") + { + string data = File.ReadAllText(path, Encoding); + return regex.IsMatch(data); + } + return false; + } + + public ObjectFX Import(string path) + { + if (!IsImportable(path)) + throw new Exception($"{Name}:\r\n无法导入此文件,因为它不是 MMDUI 格式。"); + + MMDUIObjectFX fx = new MMDUIObjectFX + { + WidgetID = "MMDUI.Widgets.WidgetProxy", + OriginalText = File.ReadAllText(path, Encoding), + }; + + foreach (Match match in regex.Matches(fx.OriginalText)) + { + ControlObject controlObject = new ControlObject() + { + Type = match.Groups["type"].Value, + Name = match.Groups["name"].Value, + Value = match.Groups["value"].Value + }; + + for (int i = 0; i < match.Groups["a_type"].Captures.Count; i++) + { + Annotation annotation = new Annotation() + { + Type = match.Groups["a_type"].Captures[i].Value, + Name = match.Groups["a_name"].Captures[i].Value, + Value = match.Groups["a_value"].Captures[i].Value.Replace("\"", ""), + }; + + controlObject.Annotations.Add(annotation); + } + + controlObject.IsStatic = match.Groups["static"].Success; + controlObject.IsConst = match.Groups["const"].Success; + controlObject._Index = match.Index; + controlObject._Length = match.Length; + + fx.ControlObjects.Add(controlObject); + } + + return fx; + } + + private void Default_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == "Encoding") + { + Encoding = Encoding.GetEncoding(Settings.Default.Encoding); + } + } + #endregion + } +} diff --git a/MMDUI.csproj b/MMDUI.csproj new file mode 100644 index 0000000..c15b59f --- /dev/null +++ b/MMDUI.csproj @@ -0,0 +1,164 @@ + + + + + Debug + AnyCPU + {3771D3DB-C587-4994-B30A-B09A24C94C9E} + Library + Properties + MMDUI + MMDUI + v4.6 + 512 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + embedded + true + bin\Release\ + TRACE + prompt + 4 + true + + + + False + .\MMEdit.Framework.dll + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + True + True + Settings.settings + + + + UserControl + + + NumericWidget.cs + + + UserControl + + + SliderWidget.cs + + + UserControl + + + UserControl + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + NumericWidget.cs + + + SliderWidget.cs + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if not exist "..\..\..\..\MMEdit\MMEdit\$(OutDir)Plugins" md "..\..\..\..\MMEdit\MMEdit\$(OutDir)Plugins" +xcopy /y "$(TargetPath)" "..\..\..\..\MMEdit\MMEdit\$(OutDir)Plugins" +if exist "$(TargetDir)$(TargetName).pdb" xcopy /y "$(TargetDir)$(TargetName).pdb" "..\..\..\..\MMEdit\MMEdit\$(OutDir)Plugins" + + \ No newline at end of file diff --git a/MMDUI.sln b/MMDUI.sln new file mode 100644 index 0000000..95ba65c --- /dev/null +++ b/MMDUI.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMDUI", "MMDUI.csproj", "{3771D3DB-C587-4994-B30A-B09A24C94C9E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3771D3DB-C587-4994-B30A-B09A24C94C9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3771D3DB-C587-4994-B30A-B09A24C94C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3771D3DB-C587-4994-B30A-B09A24C94C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3771D3DB-C587-4994-B30A-B09A24C94C9E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4EE22029-6A7B-49D2-ABB6-58EFA14CC901} + EndGlobalSection +EndGlobal diff --git a/MMDUIObjectFX.cs b/MMDUIObjectFX.cs new file mode 100644 index 0000000..5159627 --- /dev/null +++ b/MMDUIObjectFX.cs @@ -0,0 +1,21 @@ +using MMEdit; +using MMEdit.Fx; +using System.Collections.Generic; + +namespace MMDUI +{ + public class MMDUIObjectFX : ObjectFX + { + #region Constructor + public MMDUIObjectFX() + { + ControlObjects = new List(); + } + #endregion + + #region Properties + public List ControlObjects { get; } + public string OriginalText { get; set; } + #endregion + } +} diff --git a/MMEdit.Framework.dll b/MMEdit.Framework.dll new file mode 100644 index 0000000000000000000000000000000000000000..8f81c692339549ab212ed2d55e14f25024a07e2b GIT binary patch literal 18944 zcmeHvcU)B0_U}Gt3d6u43}S=e*vE!oLG02*R1g8Nivx@}aSF@~3bvp|4H{#M#$2P( z7;iL*8cPxlCTgOfCbpQw6uZXQ5^F4p(f3{ZoEcDa@9)0%d4Igm=iNi*d)8We?X}ik zyPSQBNf|nyDHvl){2o7MY#YvW^yK*Op%ldd^*;$#X19J9e$WH(sshJ^kZ2Ad<#9HG-`8_TBC5*h0!DA7#6%4fvJf$5;nj1@dx_V0KDW14E^8t}cV@eyuwu^YUyC%}LowN;KA6h91%jf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B+WR&(BZVOxdGc zXVWJp-OmdAbG?6!ZSyRpk8Q7Nh7C|{zPrx1ZE8WQX}QB!zdhP%ZCa_1S+Z;MCfAUi z(=Qe-`0@OonKRobUJEN35Lvg~!H79Wm(@+4y(-PoDysKeEn4Q@Zv9}K>&EZN=Fj)m zeK)1-%dpR`#a-NOjoG>HO7f2dwwhmDYNG&}ZL*A3mb+WX!(_|dj@8|||@|EL@EN39d(Ys$Ad%H!U7@BW+L{bBj` z-pLU^MMv!&bnWh&55DXFU~QZG=Q5r@x5Uw-Z+ZWg@rxg&esW>b^q`LW7nsNPI`-$` zG11*uto^FowD#9+r`Ju~Z2sZm*ypCy+t}#ru+aAu-CQHA$NeVF`*vo-yT?L@zL9*d zB>VU8OH$eyyWQE5dp^HpdX0dHOT#yITBTdM?BhG-hsz)T-1XJm<(t0W^LWg0>)Wrr zv?66f@+(*G%-b-G)K6{So;k`*e8D zJtUTY3rF{9)sF-)0<43_RXy6?#e~;jOhrl&H zP+ovh0WrCuWr0@y-&oqkbt2Jj>90NBg&+s`sxb(4tv~z4@tn14O>@wK~tNo9o&Ur?pzN)qO_%O?xBo<_Di1z%uZP0;^}^f n;dNrsIu~zi4q8%z4E;~_Jh}L{=TY+iGlmBCe~ + { + if (e.Status == FileStatus.Opened) + menuItem_MMDUI.Visible = host.MainForm.Importer.Guid == new Guid("{2461F59A-09EA-49B5-9A8E-37588AABDC9B}"); + }; + + flag = true; + } + } + + private void MenuItem_MMDUI_About_Click(object sender, EventArgs e) + { + string text = $"{AssemblyProduct}\n{string.Format("版本 {0}", AssemblyVersion)}\n{AssemblyCopyright}\n\n{AssemblyDescription}"; + MessageBox.Show(text, "关于 MMDUI", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + #endregion + + #region 程序集特性访问器 + + public string AssemblyTitle + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) + { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != "") + { + return titleAttribute.Title; + } + } + return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + } + } + + public string AssemblyVersion + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + + public string AssemblyDescription + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyDescriptionAttribute)attributes[0]).Description; + } + } + + public string AssemblyProduct + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyProductAttribute)attributes[0]).Product; + } + } + + public string AssemblyCopyright + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + } + + public string AssemblyCompany + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCompanyAttribute)attributes[0]).Company; + } + } + #endregion + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a8358cf --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MMDUI 扩展插件")] +[assembly: AssemblyDescription("提供 MMDUI 格式的 MME 文件的导入、导出和小部件。")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Nicengi")] +[assembly: AssemblyProduct("MMDUI 扩展插件")] +[assembly: AssemblyCopyright("© 2020 Nicengi.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("3771d3db-c587-4994-b30a-b09a24c94c9e")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.1.0.0")] +[assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7847b05 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MMDUI.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MMDUI.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color { + get { + object obj = ResourceManager.GetObject("color", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color_adjustment { + get { + object obj = ResourceManager.GetObject("color_adjustment", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color_adjustment_green { + get { + object obj = ResourceManager.GetObject("color_adjustment_green", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color_adjustment_red { + get { + object obj = ResourceManager.GetObject("color_adjustment_red", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color_swatch { + get { + object obj = ResourceManager.GetObject("color_swatch", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap color_swatches { + get { + object obj = ResourceManager.GetObject("color_swatches", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap function { + get { + object obj = ResourceManager.GetObject("function", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_color_picker { + get { + object obj = ResourceManager.GetObject("ui_color_picker", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_color_picker_default { + get { + object obj = ResourceManager.GetObject("ui_color_picker_default", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_color_picker_transparent { + get { + object obj = ResourceManager.GetObject("ui_color_picker_transparent", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_label { + get { + object obj = ResourceManager.GetObject("ui_label", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider { + get { + object obj = ResourceManager.GetObject("ui_slider", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider_050 { + get { + object obj = ResourceManager.GetObject("ui_slider_050", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider_100 { + get { + object obj = ResourceManager.GetObject("ui_slider_100", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider_vertical { + get { + object obj = ResourceManager.GetObject("ui_slider_vertical", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider_vertical_050 { + get { + object obj = ResourceManager.GetObject("ui_slider_vertical_050", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_slider_vertical_100 { + get { + object obj = ResourceManager.GetObject("ui_slider_vertical_100", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ui_spin { + get { + object obj = ResourceManager.GetObject("ui_spin", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..476d57c --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Images\color.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\color-adjustment.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\color-adjustment-green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\color-adjustment-red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\color-swatch.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\color-swatches.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\images\function.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-color-picker.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-color-picker-default.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-color-picker-transparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-label.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider-050.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider-100.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider-vertical.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider-vertical-050.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-slider-vertical-100.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Images\ui-spin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..367b12f --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MMDUI.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("shift_jis")] + public string Encoding { + get { + return ((string)(this["Encoding"])); + } + set { + this["Encoding"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..dbb8306 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + shift_jis + + + \ No newline at end of file diff --git a/Resources/Images/color-adjustment-green.png b/Resources/Images/color-adjustment-green.png new file mode 100644 index 0000000000000000000000000000000000000000..c8bd99dee2365d812a2bc1596876cf9fb2c5e87d GIT binary patch literal 605 zcmV-j0;2tiP)`t~6R{ zZx8RT5bUmy6ruzn0XrK@JBt*8g1ucxAojKv3Kr=MBB+Hn%7LJT1gy?N<@An-mt^y2 z*1<&yXMo`5)tm$(v0Ae+tN{rD3e96Ukawefv& zh>xSsxc#LrM*5%6Q#^6PK@bGOLHo~3B*)-8{KCi>|97N#;)Fu2R=Yc$PE*^qPu(e= zI7@6vF}vx(4(7CKolJGYwyV?~5Z4Cz3dKASnt`ez!>+@jDI?*e>p0yNB6u z0zdM2cj1LD&K7r;av&T~QS4uQvvlu!KlU&f3~(vgMOCl&1M-&hUa-p z0<=q~(}87Ka9ww4O;uG8Cj@%E9+M;qxm<23s8Xq%Sd|n{9DQdrO}oh_c2<2%+~JYq rIBl{)TbsPgEAaG^M*QghUjYUHH4aU8dNRAv00000NkvXXu0mjfdD#jQ literal 0 HcmV?d00001 diff --git a/Resources/Images/color-adjustment-red.png b/Resources/Images/color-adjustment-red.png new file mode 100644 index 0000000000000000000000000000000000000000..c7f1808de32a16fd0d426f3e0c0e449f9cffca21 GIT binary patch literal 600 zcmV-e0;m0nP)`474>v9TbrcZ(7!e*`R*7&@UWs2y4s)Jhe~Lc~%rbO8b`s8I?y zv7NJ>-aC;L53R^ar|0v%@8`bn*(Wud%?$uW%s<>lqp_n#QB-QRS}*5S*X#9X6xBG6 zF_}!z?RNi5sD(c6tUm(j1b{InB}oEBQBbK=t`tsw4Un81BYwY!fCjh*J8Gy!U z{|(~rU%-w(!rXWarF4t0zhboW8kw~UnCl|P^GP>#00Lw(8F)wUaQ5m2%zF

h%zH zjxhSrnXS#`vWOPXC!GL{$7A6j*=?iW{{ipx6w+XDZKQnC&3Zr$DL#EJh>L$~zAjS! ztOrvE2dgWv@;Ruc3Dvft=4>cg6LK~S#n7SX24r2w`R5+)Zf##W2*XeS9LGk!cmtZ_ zKwnydTPVRdZ7f(OZZGFKki#ttKR=y_5=ch?dFnvdRc~rw z5Ro5%@wrgGneG9RsHT;-oz!<9A0G0i_TjDG2dmY<{@vvHQwQpBIF#s541yp9pi|oI zHVTCTeBV#)8HNGU34rUmsw~UUG%b}>tyZu6D=D9J^ekDH^@P7D&wH7;!*8DFZIcZ; m+Tl}~Lr*v9oR=P62rvMs8y#W(q{|Kf0000k}@P)BJ_A1T4fR`3Lz2b~gS3yO2QsgpFWfnJzZkDTvsZPAqH$^+XJQa7pfRcN=$B?&JzT zvM|i;?YuW{W@nXFt5pY3!1T**Hk(~N2!dj}-QJrP-Dos+$m?MkVltVa*X#WY=y?V< zH&;P8N#Ogw!a0YgX{b~xKLX$1C%C=kxVQ+hvB5z&Ngzsy31}T35ApaI;`-W0y`Dy~ zsL6e|JH*OL3byTo^9%?VDF6|qQYoCDJ2*Ia!TNd{_xD3wUIw_j8piv@#V^k}BL!b2 zjK^cC;OK~>-|yq;$-(QZ@~fwK!o@wHhHP&~H#z^Or}(%Bk%Dsh6xl38I;~@NR!1hI zV`fGZroyr`m?oKuySq2+@2`C;@H|fvg&_h9U*}U@%Z<5?$9#5Kxv*rz1+qi_D|MnPpiZoFuSqTUS*ThG8Uvs@3X` zQ%UiJqi=;Vwk3X)rhQC8;e+Eiha`hi=Y(lf;OQm3iPF7K0R{jPp&f7rvs^|10000< KMNUMnLSTaPk^K1p literal 0 HcmV?d00001 diff --git a/Resources/Images/color-swatch.png b/Resources/Images/color-swatch.png new file mode 100644 index 0000000000000000000000000000000000000000..2ba0a06f87e386043416c72a093df3f08a947b75 GIT binary patch literal 548 zcmV+<0^9wGP)MJ-)2RFO=27-=)YoSwVq1`0t;2_k|C(u#w0el4A6kFViv_o=})N^jqTkF;YlKgVd zIr+YGPmF%Qe*&O^&5ud1*LyOvEZZ9l26vlgce~vSzMFZTW3gD^?ePqOXQ{>d@d)qd z=LoEdN6b&ep5n%R3!JA4NGXk?DB#)xQRt|biUqOrmu=!uGv}!SWI+|kq=ZbR3fQ9R zisgS!6`AG6s^`)*$QSOye@4bEFr(Eez{s+Bz$hC_5-e_(l~ z=iz~YPKUVa!PS+yu7D+qZ2@Pu>On$myKus#=Wht=funmcT`8aj89a&d&%T%2lib#WtJ4Z01)hjhV@ei6qj7QzJQ@v~8@)lR9v{-!?@srsTOKN#ir mu)`C(K|cRUQ?io$3NQc`X(2ANiww{J00005zmWwYilTgDr`zp*UKibJ zwT}5)7*r}1%;$40<2c53{}5Hj)IV?SeZlXeAE=s+)-TWALn&nx20VlikWwND0%N&c z!j=Lx*V22Ooh>A4ma8@IFBXf!V4rHBnK=u~vfd5`1Kf`t+)SkoNYntaHNgw@EIq7j zK<@u%-rap9FO@?0`W3Pu#!U^Fg_--;hj6MX^WGLS9}%;eF`wb$;vVPc|FrhJrz-X)G&3s|QopFekPL)2;8gg; zcbh#ROnE63o4sBxHS@uNpt4M}X4`=8`zr%>Jh}V>)2ZqoKE09n`SC9tGu2IE_B`+V za5(&x7nSPfYXfFs10ii#Zpx^X4=HT8C1%HQt|pVox6;MjX*_1pHBb>$sPtqc)?5>w zyidInG#ZUtipl3pXTU7n%BM|k(`jaIqIqf-y3Aa!*D)H6R*%nh-4E2pJL?_~F^?&e zue=V!kULSoV!q2KG@rBC8jrg??R>Dog8%~n5^o&eU9O#*00000NkvXXu0mjf4(S)A literal 0 HcmV?d00001 diff --git a/Resources/Images/color.png b/Resources/Images/color.png new file mode 100644 index 0000000000000000000000000000000000000000..3ed7f55890df78bfffe61dbf356924ad3bc06cf6 GIT binary patch literal 811 zcmV+`1JwM9P)F`GcoXb?vhdsD)-5fm;_(Sfd(&Krc+`1c<&WxPq?LG;mQ>di1Vlfg= zC8O#mavNn2br3@2q75}~0Q<6p?HtvlOYx?Fk%ohH9ld3{TgV^{2?}J^30aom za0I|OJt#9G@&`a(1PV2v%-e-^=)Dbrm;sxLBC;?+w?&~24=;cfMPwNw;{?|KLlTR@ zur&mzKJf)@t=;B!*mh7R4@YRV0>KTS}ZGS*{a7)sGcyK(j&*WdHlfA)5;t$R$Al>rXLW)!~WjMPlDq`q5C8!O+Y zP3zD20Db3CR0R{l;8d0*M SoXIT!0000b@?P)!mpAQ&gHX8~clOZXdIk;Rd&0xQ{91I4*>2&^Sk*(KjUICRVoDhRf zrvsujbi8-DTsrl9&JJWUnb+BDW`x6Gn-W$m7Wuc?Y#NuOTrNMc`FyU>P-xm#A!cf| z8Xs7<+vSy5C6~)_b{HF8Bt(M6S!^4Ldo)DUL zJRX0+7V^Db4^pX=?cL#UnC!6g%wDe-G))7+j+M5-U;vB7f@6XmVgYu$9WRL_7K?Ef zP&hl*0ISssqS2_y4lyVbD4fOWj>luzY&LvD6-9x5zt5GO^6#ADPVo>ZjEjO*1ih4s|kH_5{uo=BM00000 LNkvXXu0mjfoTc+z literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-color-picker-transparent.png b/Resources/Images/ui-color-picker-transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..3ec0719ddd5f0f3b02f69b857fac8dc297aafd5c GIT binary patch literal 591 zcmV-V0AMIr1Pb2 zu%(Bt4<^aHneUtL&Ajk-yZw=^H3}nQOPcqO6qF0+RtV)_$~o=*=+VYl}aUn0oLyUngIfm zuC3SWpQlRu;c%#(dM4p0PZ^obQ05@xBJITrR(l$K!IPQVAG=0aiL!fQJ2J-BoUX02BHtw7gxj+-coB5So;9}sLdn|>1c{u?pm z&{Wu9Fksbc)%Str$z<}&bUOWZF7JO9RONEHuRI!!-U@>7?vkI0`k>;xxZiJ{XZ?Z& d$xpuo7yvc?FPQ#%s?Goa002ovPDHLkV1iN<7y$qP literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-color-picker.png b/Resources/Images/ui-color-picker.png new file mode 100644 index 0000000000000000000000000000000000000000..e244c689ebe88d938e89e9c39234debee87155da GIT binary patch literal 494 zcmVuJ3|JkpZKt2f0_1>B8UAzk*LrsvW-|w#t9LM=i;QKzqOSCMDT-Uuo zkummb0H}e}YPD!E7*M<2mUn1btya69PN%nKy#E}eYBU-*tXM3b=W@B@U4AAphkInj k12|Bt+U6kg>PvtD0MWn5v|6plNF;K5N#TCKciZiDPoRTlv-uQUXkpE72b0M}6AcD~k9xh{;aeQX zdBwX_Dm57EcDpa-a`_H5Fonl>JQlw13){9kmSw%clgXsU;D{MV4lvXh4d(N?Td7nU zN~wN49v7)pN*^K-mdRxFd%0W!>xa3nAt11~+wE|R$Y!%5oldh*M+8zzT;@=&gIq&! zX!(5J#N0tN8Z~D`aFnkOf8=sGEoSHv9l#MYj+~P{fF%+M-THRBWk_-dgh>XG11&JJ zAsCHDTDVv&CP*AjhVEE{&1R!JU9Z=Atl@Adrqk&$0gFW&DLl_B(AYb&1L~DO5nP#cErGN#yi5bT3vkK zaGV7I1BKKBQrk-ip-#XE&qBJVE&#=!<%og0lWg(T$P*fZ4r2rvLYh{-NTpH*+@9llU#(UjqSHpB!F?u^ zfiMhz?4W=}7qwdLkv!o)U7^$I02aVr zF!2=sYAl^j-=MbyvE6QAG#V8*n+-2!j1j&<-k^I6!#W?G$MX67S*z80kX8HrKEDbH z(C{3`so1t%k#k(vz2hCAYS3&pZ{^^0I=w8FO4lSpFVgLHpHcKx&cQnVbWGE<7hTs6 zfh0*_GMVUjIu}q?mGGNsnr*`{4tY4(;~_>-1cSi<;yBi*5WfX3K$v)n9}Q7#eBXy& zueT=|OLDo~y@=sJ6Pm|xID~S!43=emFEE?U1bm`FO9##6JXt{b_n+xxflmPj0F3*_ UjW>OCWB>pF07*qoM6N<$g6FN-Bme*a literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-slider-100.png b/Resources/Images/ui-slider-100.png new file mode 100644 index 0000000000000000000000000000000000000000..3180ccc4545f739f6fd22316379de0f8c4d0a2d9 GIT binary patch literal 400 zcmV;B0dM|^P)1RCwCNlf7z$KoG~r&(1Q12WPJ=}jhM8gZ|J&Iw zW*7!oGgw$T7)4PaNs?bD=(;{mWEc=Ve)rZQFjF17ultr)kT=PK@ecbp^&@<3OJok+$t~}^70Jv@$nd%nV7KqmIavu3{d@l|NdFX%E~eT1JL5y zwQCF<92~YFDWEt={uz+HnE_1`7#9>27!(y1Wdarc|NHkZ1_p_PKCAmoHy%2H=MeADD24!I?8>ZbU>xQgHg4Rw_SLIb$Dm>#u3x`C4{I1e0V@zofv}jESo8Vw=l{pX#+Jjx zfS4CO4A7nQ8;G9)qwE5N0C8Zxe#`1drvLx|07*qoM6N<$f+ya# ABLDyZ literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-slider-vertical-100.png b/Resources/Images/ui-slider-vertical-100.png new file mode 100644 index 0000000000000000000000000000000000000000..9852320adc98c2fcc35ee2959bfcb4104372c2bb GIT binary patch literal 365 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+82LS2978H@CH?vT-=3Mnz}VPWf!WjZWI=XzcA%u>%;PyZ zIns%b-oAaS@oI)d0rO5yVKpDNnXT@;am*b|i`f(;6A}{-CZwmghZ|OfG&68-VzjZb z;pyt?;^7w8I}*U*!+oUEF)nVNqMeqUFScpZCY}Q!8HI0e znX>Wm@kLJ%36N3w&vWA5nTBPYJ=|PeAcKq=x&HtE`&*p3`H15ugRcfW=CxC#9$AO)Z zkuf&r;*ZbI&+}hjA3wkSG=soVt|N;oCLKy&@ay~uCI&_}hS2R3x}5~m`+?!d;OXk; Jvd$@?2>^Jui&_8x literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-slider-vertical.png b/Resources/Images/ui-slider-vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..65cc423017791f961e1dd6ac2e874666839a64e2 GIT binary patch literal 371 zcmV-(0gV2MP)gxfKQ)3Sx=ib zZOWG~U$ENF%*@R2;ll?ebaA-AnKNf@L_|d7{r&rw;n%NUSn<1e?=TEtggF=JL{@ou zc?SUj0bLOP=g*&xIXO8#8#iuT`|8!JV^FaV*RNlnhaNBtNPcDoVkr<76BBDbfByXc z*x1-|m>3ZA!qmesx|4nb@iQhSrf00Ite?ci#Ti6JML$MGMLh$F1Mz2^VE`9k!VqGR zlapfr8iF-&S@3B@H>9GXf`On5NCl$?;5Xn=K|w(-kbaKO07h&%j}!n9U;wH)fOX2# RVmAN)002ovPDHLkV1m>RmdyYF literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-slider.png b/Resources/Images/ui-slider.png new file mode 100644 index 0000000000000000000000000000000000000000..7c0d7f758b301866667208b32f4fa3b822fb1db7 GIT binary patch literal 404 zcmV;F0c-w=P)fR+KG}vIEx%A{=FT8kS2P;A_Foz3-jA= zK6lA546r5`SQ%uu+X2UM8@j%x-+R+EACoHEwtsDuBngrv85L}3(~W7GkC?Ik(+G84 z-&&TnZ`&3yV@*NeIL<`?wyG+E&3)ek!!Urg>$;Gp>E(c~>i{7v%R&@IcNE6sjB_Cf zLQK;$0vMEx05nh6^{uL^+oh8Y!?+(66h$#AKnNiOJkNXaegAa{Kox$DfU+z{4-kMJ zWLfqmisGK<`B?xp`};5Cd47eB^e&75tPh6+9FND#Obo;Dq$tY6v_Z!?p`suNK+`mk yWqBSzPkKUAf9!oti#U!K0p#Bw(`vw3fB^vNilPN3fI!ax0000aifC( literal 0 HcmV?d00001 diff --git a/Resources/Images/ui-spin.png b/Resources/Images/ui-spin.png new file mode 100644 index 0000000000000000000000000000000000000000..c0834d85b1f016d610cc2d4e676c3c39d8e66f57 GIT binary patch literal 330 zcmV-Q0k!^#P)`6pHRCwCdlQD{fKoCW%+Ex^04lm4q%!lD9iHS=Xw4qk|f!rl)y=)6i~O&_q|o} zD8n#RuIsYq{R320WtCDGfc89(1u#X!FdRL~AP5u}U^*y@!h#&ffu?Ct5I~y|IB5!( zWr4b`t=bWM-`CtfSl1O05xTCkN?u^wwpTJS2S9}%M^9_;Evfj+&^R&A^YNjL@`3Na cOiuv@07%+sF&o(fa{vGU07*qoM6N<$f new WidgetProxy(obj, Host)), + new WidgetClass("Color", obj => new SliderWidget(true) { ObjectFX = obj }), + new WidgetClass("Slider", obj => new SliderWidget { ObjectFX = obj }), + new WidgetClass("Numeric", obj => new NumericWidget { ObjectFX = obj }), + new WidgetClass("Spinner", obj => new NumericWidget { ObjectFX = obj }), + }; + } + #endregion + } +} diff --git a/Widgets/MMDUIWidgetBase.cs b/Widgets/MMDUIWidgetBase.cs new file mode 100644 index 0000000..a5aad84 --- /dev/null +++ b/Widgets/MMDUIWidgetBase.cs @@ -0,0 +1,398 @@ +using MMEdit; +using MMEdit.Fx; +using System; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace MMDUI.Widgets +{ + public class MMDUIWidgetBase : WidgetControl + { + #region Constructor + public MMDUIWidgetBase() + { + Dock = DockStyle.Top; + } + #endregion + + #region Properties + public override ObjectFX ObjectFX + { + get + { + return base.ObjectFX; + } + + set + { + base.ObjectFX = value; + + if (!(ObjectFX is ControlObject)) + throw new Exception($"{Name}:无法编辑此对象。"); + + ControlObject = (ControlObject)ObjectFX; + + string UIVisible = ControlObject.GetAnnotation("UIVisible")?.Value; + switch (UIVisible) + { + default: + case "true": + Visible = true; + break; + case "false": + Visible = false; + break; + } + + UpdateControlObject(); + } + } + + public virtual ControlObject ControlObject { get; protected set; } + #endregion + + #region Events + ///

+ /// 在 .Value 属性的值被改变时发生。 + /// + public event EventHandler ValueChanged; + + /// + /// 引发 事件。 + /// + protected virtual void OnValueChanged() + { + ValueChanged?.Invoke(this, EventArgs.Empty); + } + #endregion + + #region Methods + /// + /// 此方法在 的值改变时被调用。 + /// + protected virtual void UpdateControlObject() { } + #endregion + } + + /// + /// 提供编辑值类型(int,float,float2,float3,float4)的小部件基类。 + /// + public class MMDUIWidgetBaseN : MMDUIWidgetBase + { + #region Fields + private string _ValueX = "0"; + private string _ValueY = "0"; + private string _ValueZ = "0"; + private string _ValueA = "0"; + private string _UIMaxX = "10000"; + private string _UIMaxY = "10000"; + private string _UIMaxZ = "10000"; + private string _UIMaxA = "10000"; + private string _UIMinX = "0"; + private string _UIMinY = "0"; + private string _UIMinZ = "0"; + private string _UIMinA = "0"; + #endregion + + #region Properties + public string ValueX + { + get + { + return _ValueX; + } + + set + { + _ValueX = value; + UpdateValue(); + } + } + + public string ValueY + { + get + { + return _ValueY; + } + + set + { + _ValueY = value; + UpdateValue(); + } + } + + public string ValueZ + { + get + { + return _ValueZ; + } + + set + { + _ValueZ = value; + UpdateValue(); + } + } + + public string ValueA + { + get + { + return _ValueA; + } + + set + { + _ValueA = value; + UpdateValue(); + } + } + + public string UIMaxX + { + get + { + return _UIMaxX; + } + } + + public string UIMaxY + { + get + { + return _UIMaxY; + } + } + + public string UIMaxZ + { + get + { + return _UIMaxZ; + } + } + + public string UIMaxA + { + get + { + return _UIMaxA; + } + } + + public string UIMinX + { + get + { + return _UIMinX; + } + } + + public string UIMinY + { + get + { + return _UIMinY; + } + } + + public string UIMinZ + { + get + { + return _UIMinZ; + } + } + + public string UIMinA + { + get + { + return _UIMinA; + } + } + #endregion + + #region Methods + protected override void UpdateControlObject() + { + Annotation UIMax = ControlObject.GetAnnotation("UIMax"); + if (UIMax != null) + { + switch (UIMax.Type) + { + case "int": + case "float": + string[] value = parse(UIMax.Value); + if (value.Length >= 1) + { + _UIMaxX = value[0]; + _UIMaxY = value[0]; + _UIMaxZ = value[0]; + _UIMaxA = value[0]; + } + break; + case "float2": + string[] float2 = parse(UIMax.Value); + if (float2.Length >= 2) + { + _UIMaxX = float2[0]; + _UIMaxY = float2[1]; + } + break; + case "float3": + string[] float3 = parse(UIMax.Value); + if (float3.Length >= 3) + { + _UIMaxX = float3[0]; + _UIMaxY = float3[1]; + _UIMaxZ = float3[2]; + } + break; + case "float4": + string[] float4 = parse(UIMax.Value); + if (float4.Length >= 4) + { + _UIMaxX = float4[0]; + _UIMaxY = float4[1]; + _UIMaxZ = float4[2]; + _UIMaxA = float4[3]; + } + break; + } + } + + Annotation UIMin = ControlObject.GetAnnotation("UIMin"); + if (UIMin != null) + { + switch (UIMin.Type) + { + case "int": + case "float": + string[] value = parse(UIMin.Value); + if (value.Length >= 1) + { + _UIMinX = value[0]; + _UIMinY = value[0]; + _UIMinZ = value[0]; + _UIMinA = value[0]; + } + break; + case "float2": + string[] float2 = parse(UIMin.Value); + if (float2.Length >= 2) + { + _UIMinX = float2[0]; + _UIMinY = float2[1]; + } + break; + case "float3": + string[] float3 = parse(UIMin.Value); + if (float3.Length >= 3) + { + _UIMinX = float3[0]; + _UIMinY = float3[1]; + _UIMinZ = float3[2]; + } + break; + case "float4": + string[] float4 = parse(UIMin.Value); + if (float4.Length >= 4) + { + _UIMinX = float4[0]; + _UIMinY = float4[1]; + _UIMinZ = float4[2]; + _UIMinA = float4[3]; + } + break; + } + } + + switch (ControlObject.Type) + { + case "int": + case "float": + string[] value = parse(ControlObject.Value); + if (value.Length >= 1) + { + _ValueX = value[0]; + _ValueY = UIMinY; + _ValueZ = UIMinZ; + _ValueA = UIMinA; + } + break; + case "float2": + string[] float2 = parse(ControlObject.Value); + if (float2.Length >= 2) + { + _ValueX = float2[0]; + _ValueY = float2[1]; + _ValueZ = UIMinZ; + _ValueA = UIMinA; + } + break; + case "float3": + string[] float3 = parse(ControlObject.Value); + if (float3.Length >= 3) + { + _ValueX = float3[0]; + _ValueY = float3[1]; + _ValueZ = float3[2]; + _ValueA = UIMinA; + } + break; + case "float4": + string[] float4 = parse(ControlObject.Value); + if (float4.Length >= 4) + { + _ValueX = float4[0]; + _ValueY = float4[1]; + _ValueZ = float4[2]; + _ValueA = float4[3]; + } + break; + } + + string[] parse(string str) + { + Regex regex = new Regex(@"(float|float2|float3|float4|int)\((?.*?)\)"); + if (regex.IsMatch(str)) + { + return Regex.Replace(regex.Match(str).Groups["value"].Value, @"\s", "").Split(','); + } + + return new string[] { str, str, str, str }; //Length >= 4 + } + } + + /// + /// 更新 .Value 属性的值,并引发 事件。 + /// + protected void UpdateValue() + { + switch (ControlObject.Type) + { + default: + case "int": + case "float": + ControlObject.Value = ValueX; + break; + case "float2": + ControlObject.Value = $"float2({ValueX}, {ValueY})"; + break; + case "float3": + ControlObject.Value = $"float3({ValueX}, {ValueY}, {ValueZ})"; + break; + case "float4": + ControlObject.Value = $"float4({ValueX}, {ValueY}, {ValueZ}, {ValueA})"; + break; + } + + OnValueChanged(); + } + #endregion + } +} diff --git a/Widgets/NumericWidget.Designer.cs b/Widgets/NumericWidget.Designer.cs new file mode 100644 index 0000000..2b98202 --- /dev/null +++ b/Widgets/NumericWidget.Designer.cs @@ -0,0 +1,156 @@ +namespace MMDUI.Widgets +{ + partial class NumericWidget + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.labelUIName = new System.Windows.Forms.Label(); + this.numericX = new System.Windows.Forms.NumericUpDown(); + this.numericY = new System.Windows.Forms.NumericUpDown(); + this.numericZ = new System.Windows.Forms.NumericUpDown(); + this.numericA = new System.Windows.Forms.NumericUpDown(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.tableLayoutPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericA)).BeginInit(); + this.SuspendLayout(); + // + // tableLayoutPanel + // + this.tableLayoutPanel.AutoSize = true; + this.tableLayoutPanel.ColumnCount = 4; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel.Controls.Add(this.labelUIName, 0, 0); + this.tableLayoutPanel.Controls.Add(this.numericX, 0, 1); + this.tableLayoutPanel.Controls.Add(this.numericY, 1, 1); + this.tableLayoutPanel.Controls.Add(this.numericZ, 2, 1); + this.tableLayoutPanel.Controls.Add(this.numericA, 3, 1); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 2; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(1374, 46); + this.tableLayoutPanel.TabIndex = 0; + // + // labelUIName + // + this.labelUIName.BackColor = System.Drawing.SystemColors.ControlLight; + this.tableLayoutPanel.SetColumnSpan(this.labelUIName, 4); + this.labelUIName.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelUIName.Image = global::MMDUI.Properties.Resources.ui_spin; + this.labelUIName.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + this.labelUIName.Location = new System.Drawing.Point(3, 0); + this.labelUIName.Name = "labelUIName"; + this.labelUIName.Size = new System.Drawing.Size(1368, 20); + this.labelUIName.TabIndex = 1; + this.labelUIName.Text = "UIName"; + this.labelUIName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.labelUIName.Click += new System.EventHandler(this.labelUIName_Click); + // + // numericX + // + this.numericX.DecimalPlaces = 2; + this.numericX.Dock = System.Windows.Forms.DockStyle.Fill; + this.numericX.Location = new System.Drawing.Point(3, 23); + this.numericX.Name = "numericX"; + this.numericX.Size = new System.Drawing.Size(337, 21); + this.numericX.TabIndex = 2; + this.numericX.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericX.ValueChanged += new System.EventHandler(this.numericX_ValueChanged); + // + // numericY + // + this.numericY.DecimalPlaces = 2; + this.numericY.Dock = System.Windows.Forms.DockStyle.Fill; + this.numericY.Location = new System.Drawing.Point(346, 23); + this.numericY.Name = "numericY"; + this.numericY.Size = new System.Drawing.Size(337, 21); + this.numericY.TabIndex = 3; + this.numericY.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericY.ValueChanged += new System.EventHandler(this.numericY_ValueChanged); + // + // numericZ + // + this.numericZ.DecimalPlaces = 2; + this.numericZ.Dock = System.Windows.Forms.DockStyle.Fill; + this.numericZ.Location = new System.Drawing.Point(689, 23); + this.numericZ.Name = "numericZ"; + this.numericZ.Size = new System.Drawing.Size(337, 21); + this.numericZ.TabIndex = 4; + this.numericZ.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericZ.ValueChanged += new System.EventHandler(this.numericZ_ValueChanged); + // + // numericA + // + this.numericA.DecimalPlaces = 2; + this.numericA.Dock = System.Windows.Forms.DockStyle.Fill; + this.numericA.Location = new System.Drawing.Point(1032, 23); + this.numericA.Name = "numericA"; + this.numericA.Size = new System.Drawing.Size(339, 21); + this.numericA.TabIndex = 5; + this.numericA.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericA.ValueChanged += new System.EventHandler(this.numericA_ValueChanged); + // + // NumericWidget + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.Controls.Add(this.tableLayoutPanel); + this.Name = "NumericWidget"; + this.Padding = new System.Windows.Forms.Padding(0, 0, 0, 6); + this.Size = new System.Drawing.Size(1374, 52); + this.tableLayoutPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericA)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.Label labelUIName; + private System.Windows.Forms.NumericUpDown numericX; + private System.Windows.Forms.NumericUpDown numericY; + private System.Windows.Forms.NumericUpDown numericZ; + private System.Windows.Forms.NumericUpDown numericA; + private System.Windows.Forms.ToolTip toolTip; + } +} diff --git a/Widgets/NumericWidget.cs b/Widgets/NumericWidget.cs new file mode 100644 index 0000000..f21162d --- /dev/null +++ b/Widgets/NumericWidget.cs @@ -0,0 +1,95 @@ +using System; + +namespace MMDUI.Widgets +{ + public partial class NumericWidget : MMDUIWidgetBaseN + { + #region Fields + private bool folded; + #endregion + + #region Constructor + public NumericWidget() + { + InitializeComponent(); + } + #endregion + + #region Methods + protected override void UpdateControlObject() + { + base.UpdateControlObject(); + + Fold(); + + numericY.Visible = ControlObject.Type == "float2" || ControlObject.Type == "float3" || ControlObject.Type == "float4"; + numericZ.Visible = ControlObject.Type == "float3" || ControlObject.Type == "float4"; + numericA.Visible = ControlObject.Type == "float4"; + + labelUIName.Text = ControlObject.GetAnnotation("UIName")?.Value ?? ControlObject.Name; + toolTip.SetToolTip(labelUIName, ControlObject.GetAnnotation("UIHelp")?.Value); + + numericX.Maximum = Convert.ToDecimal(UIMaxX); + numericY.Maximum = Convert.ToDecimal(UIMaxY); + numericZ.Maximum = Convert.ToDecimal(UIMaxZ); + numericA.Maximum = Convert.ToDecimal(UIMaxA); + + numericX.Minimum = Convert.ToDecimal(UIMinX); + numericY.Minimum = Convert.ToDecimal(UIMinY); + numericZ.Minimum = Convert.ToDecimal(UIMinZ); + numericA.Minimum = Convert.ToDecimal(UIMinA); + + numericX.Increment = numericX.Maximum * 0.005m >= 0.01m ? numericX.Maximum * 0.005m : 0.01m; + numericY.Increment = numericY.Maximum * 0.005m >= 0.01m ? numericY.Maximum * 0.005m : 0.01m; + numericZ.Increment = numericZ.Maximum * 0.005m >= 0.01m ? numericZ.Maximum * 0.005m : 0.01m; + numericA.Increment = numericA.Maximum * 0.005m >= 0.01m ? numericA.Maximum * 0.005m : 0.01m; + + numericX.Value = Convert.ToDecimal(ValueX); + numericY.Value = Convert.ToDecimal(ValueY); + numericZ.Value = Convert.ToDecimal(ValueZ); + numericA.Value = Convert.ToDecimal(ValueA); + } + + private void Fold() + { + SuspendLayout(); + if (folded) + { + tableLayoutPanel.RowStyles[1].Height = Font.Height * 2; + folded = false; + } + else + { + tableLayoutPanel.RowStyles[1].Height = 0; + folded = true; + } + ResumeLayout(); + } + + private void numericX_ValueChanged(object sender, EventArgs e) + { + ValueX = numericX.Value.ToString(); + } + + private void numericY_ValueChanged(object sender, EventArgs e) + { + ValueY = numericY.Value.ToString(); + } + + private void numericZ_ValueChanged(object sender, EventArgs e) + { + ValueZ = numericZ.Value.ToString(); + } + + private void numericA_ValueChanged(object sender, EventArgs e) + { + ValueA = numericA.Value.ToString(); + } + + private void labelUIName_Click(object sender, EventArgs e) + { + Fold(); + } + #endregion + } +} diff --git a/Widgets/NumericWidget.resx b/Widgets/NumericWidget.resx new file mode 100644 index 0000000..8766f29 --- /dev/null +++ b/Widgets/NumericWidget.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Widgets/SliderWidget.Designer.cs b/Widgets/SliderWidget.Designer.cs new file mode 100644 index 0000000..d64f86e --- /dev/null +++ b/Widgets/SliderWidget.Designer.cs @@ -0,0 +1,209 @@ +namespace MMDUI.Widgets +{ + partial class SliderWidget + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.textA = new System.Windows.Forms.TextBox(); + this.textZ = new System.Windows.Forms.TextBox(); + this.textY = new System.Windows.Forms.TextBox(); + this.trackY = new System.Windows.Forms.TrackBar(); + this.trackZ = new System.Windows.Forms.TrackBar(); + this.trackX = new System.Windows.Forms.TrackBar(); + this.textX = new System.Windows.Forms.TextBox(); + this.trackA = new System.Windows.Forms.TrackBar(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.labelUIName = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.trackY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackA)).BeginInit(); + this.tableLayoutPanel.SuspendLayout(); + this.SuspendLayout(); + // + // textA + // + this.textA.BackColor = System.Drawing.Color.White; + this.textA.Dock = System.Windows.Forms.DockStyle.Fill; + this.textA.Location = new System.Drawing.Point(1257, 101); + this.textA.Name = "textA"; + this.textA.ReadOnly = true; + this.textA.Size = new System.Drawing.Size(114, 21); + this.textA.TabIndex = 8; + this.textA.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // textZ + // + this.textZ.BackColor = System.Drawing.Color.White; + this.textZ.Dock = System.Windows.Forms.DockStyle.Fill; + this.textZ.Location = new System.Drawing.Point(1257, 75); + this.textZ.Name = "textZ"; + this.textZ.ReadOnly = true; + this.textZ.Size = new System.Drawing.Size(114, 21); + this.textZ.TabIndex = 6; + this.textZ.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // textY + // + this.textY.BackColor = System.Drawing.Color.White; + this.textY.Dock = System.Windows.Forms.DockStyle.Fill; + this.textY.Location = new System.Drawing.Point(1257, 49); + this.textY.Name = "textY"; + this.textY.ReadOnly = true; + this.textY.Size = new System.Drawing.Size(114, 21); + this.textY.TabIndex = 4; + this.textY.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // trackY + // + this.trackY.Dock = System.Windows.Forms.DockStyle.Fill; + this.trackY.Location = new System.Drawing.Point(3, 49); + this.trackY.Name = "trackY"; + this.trackY.Size = new System.Drawing.Size(1248, 20); + this.trackY.TabIndex = 3; + this.trackY.TickStyle = System.Windows.Forms.TickStyle.None; + this.trackY.Scroll += new System.EventHandler(this.trackY_Scroll); + // + // trackZ + // + this.trackZ.Dock = System.Windows.Forms.DockStyle.Fill; + this.trackZ.Location = new System.Drawing.Point(3, 75); + this.trackZ.Name = "trackZ"; + this.trackZ.Size = new System.Drawing.Size(1248, 20); + this.trackZ.TabIndex = 5; + this.trackZ.TickStyle = System.Windows.Forms.TickStyle.None; + this.trackZ.Scroll += new System.EventHandler(this.trackZ_Scroll); + // + // trackX + // + this.trackX.Dock = System.Windows.Forms.DockStyle.Fill; + this.trackX.Location = new System.Drawing.Point(3, 23); + this.trackX.Name = "trackX"; + this.trackX.Size = new System.Drawing.Size(1248, 20); + this.trackX.TabIndex = 1; + this.trackX.TickStyle = System.Windows.Forms.TickStyle.None; + this.trackX.Scroll += new System.EventHandler(this.trackX_Scroll); + // + // textX + // + this.textX.BackColor = System.Drawing.Color.White; + this.textX.Dock = System.Windows.Forms.DockStyle.Fill; + this.textX.Location = new System.Drawing.Point(1257, 23); + this.textX.Name = "textX"; + this.textX.ReadOnly = true; + this.textX.Size = new System.Drawing.Size(114, 21); + this.textX.TabIndex = 2; + this.textX.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // trackA + // + this.trackA.Dock = System.Windows.Forms.DockStyle.Fill; + this.trackA.Location = new System.Drawing.Point(3, 101); + this.trackA.Name = "trackA"; + this.trackA.Size = new System.Drawing.Size(1248, 20); + this.trackA.TabIndex = 7; + this.trackA.TickStyle = System.Windows.Forms.TickStyle.None; + this.trackA.Scroll += new System.EventHandler(this.trackA_Scroll); + // + // tableLayoutPanel + // + this.tableLayoutPanel.AutoSize = true; + this.tableLayoutPanel.ColumnCount = 2; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.Controls.Add(this.textA, 1, 4); + this.tableLayoutPanel.Controls.Add(this.trackA, 0, 4); + this.tableLayoutPanel.Controls.Add(this.textZ, 1, 3); + this.tableLayoutPanel.Controls.Add(this.trackZ, 0, 3); + this.tableLayoutPanel.Controls.Add(this.textY, 1, 2); + this.tableLayoutPanel.Controls.Add(this.trackY, 0, 2); + this.tableLayoutPanel.Controls.Add(this.textX, 1, 1); + this.tableLayoutPanel.Controls.Add(this.trackX, 0, 1); + this.tableLayoutPanel.Controls.Add(this.labelUIName, 0, 0); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 5; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(1374, 124); + this.tableLayoutPanel.TabIndex = 0; + // + // labelUIName + // + this.labelUIName.BackColor = System.Drawing.SystemColors.ControlLight; + this.tableLayoutPanel.SetColumnSpan(this.labelUIName, 2); + this.labelUIName.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelUIName.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + this.labelUIName.Location = new System.Drawing.Point(3, 0); + this.labelUIName.Name = "labelUIName"; + this.labelUIName.Size = new System.Drawing.Size(1368, 20); + this.labelUIName.TabIndex = 0; + this.labelUIName.Text = "UIName"; + this.labelUIName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.labelUIName.Click += new System.EventHandler(this.labelUIName_Click); + // + // SliderWidget + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.Controls.Add(this.tableLayoutPanel); + this.Name = "SliderWidget"; + this.Padding = new System.Windows.Forms.Padding(0, 0, 0, 6); + this.Size = new System.Drawing.Size(1374, 130); + ((System.ComponentModel.ISupportInitialize)(this.trackY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackA)).EndInit(); + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.TrackBar trackX; + private System.Windows.Forms.TextBox textX; + private System.Windows.Forms.TextBox textA; + private System.Windows.Forms.TextBox textZ; + private System.Windows.Forms.TextBox textY; + private System.Windows.Forms.TrackBar trackY; + private System.Windows.Forms.TrackBar trackZ; + private System.Windows.Forms.TrackBar trackA; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.Label labelUIName; + } +} diff --git a/Widgets/SliderWidget.cs b/Widgets/SliderWidget.cs new file mode 100644 index 0000000..bc39bd9 --- /dev/null +++ b/Widgets/SliderWidget.cs @@ -0,0 +1,157 @@ +using MMDUI.Properties; +using MMEdit.Fx; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace MMDUI.Widgets +{ + public partial class SliderWidget : MMDUIWidgetBaseN + { + #region Fields + private bool folded; + private List enabledRows = new List(); + #endregion + + #region Constructor + public SliderWidget() + { + InitializeComponent(); + } + + public SliderWidget(bool isColor) : this() + { + IsColor = isColor; + } + + #endregion + + #region Properties + public bool IsColor { get; } + #endregion + + #region Methods + protected override void UpdateControlObject() + { + base.UpdateControlObject(); + + if (ControlObject.Type == "float4") + { + enabledRows.Add(tableLayoutPanel.RowStyles[4]); + enabledRows.Add(tableLayoutPanel.RowStyles[3]); + enabledRows.Add(tableLayoutPanel.RowStyles[2]); + enabledRows.Add(tableLayoutPanel.RowStyles[1]); + } + else if (ControlObject.Type == "float3") + { + tableLayoutPanel.RowStyles[4].Height = 0; + + enabledRows.Add(tableLayoutPanel.RowStyles[3]); + enabledRows.Add(tableLayoutPanel.RowStyles[2]); + enabledRows.Add(tableLayoutPanel.RowStyles[1]); + } + else if (ControlObject.Type == "float2") + { + tableLayoutPanel.RowStyles[4].Height = 0; + tableLayoutPanel.RowStyles[3].Height = 0; + + enabledRows.Add(tableLayoutPanel.RowStyles[2]); + enabledRows.Add(tableLayoutPanel.RowStyles[1]); + + } + else if (ControlObject.Type == "float" || ControlObject.Type == "int") + { + tableLayoutPanel.RowStyles[4].Height = 0; + tableLayoutPanel.RowStyles[3].Height = 0; + tableLayoutPanel.RowStyles[2].Height = 0; + + enabledRows.Add(tableLayoutPanel.RowStyles[1]); + } + + Fold(); + + labelUIName.Image = IsColor ? Resources.color_swatches : Resources.ui_slider_050; + labelUIName.Text = $"{ControlObject.GetAnnotation("UIName")?.Value ?? ControlObject.Name}"; + labelUIName.Update(); + toolTip.SetToolTip(labelUIName, ControlObject.GetAnnotation("UIHelp")?.Value); + + trackX.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxX) * 100f); + trackY.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxY) * 100f); + trackZ.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxZ) * 100f); + trackA.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxA) * 100f); + + trackX.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinX) * 100f); + trackY.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinY) * 100f); + trackZ.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinZ) * 100f); + trackA.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinA) * 100f); + + trackX.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); + trackY.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); + trackZ.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); + trackA.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); + + trackX.Value = (int)(Convert.ToSingle(ValueX) * 100f); + trackY.Value = (int)(Convert.ToSingle(ValueY) * 100f); + trackZ.Value = (int)(Convert.ToSingle(ValueZ) * 100f); + trackA.Value = (int)(Convert.ToSingle(ValueA) * 100f); + + textX.Text = ValueX; + textY.Text = ValueY; + textZ.Text = ValueZ; + textA.Text = ValueA; + } + + private void Fold() + { + SuspendLayout(); + if (folded) + { + foreach (var rowStyle in enabledRows) + { + rowStyle.Height = Font.Height * 2; + } + folded = false; + } + else + { + foreach (var rowStyle in enabledRows) + { + rowStyle.Height = 0; + } + folded = true; + } + ResumeLayout(); + } + + private void trackX_Scroll(object sender, EventArgs e) + { + ValueX = + textX.Text = (trackX.Value / 100f).ToString(); + } + + private void trackY_Scroll(object sender, EventArgs e) + { + ValueY = + textY.Text = (trackY.Value / 100f).ToString(); + } + + private void trackZ_Scroll(object sender, EventArgs e) + { + ValueZ = + textZ.Text = (trackZ.Value / 100f).ToString(); + } + + private void trackA_Scroll(object sender, EventArgs e) + { + ValueA = + textA.Text = (trackA.Value / 100f).ToString(); + } + + private void labelUIName_Click(object sender, EventArgs e) + { + Fold(); + } + #endregion + } +} diff --git a/Widgets/SliderWidget.resx b/Widgets/SliderWidget.resx new file mode 100644 index 0000000..8766f29 --- /dev/null +++ b/Widgets/SliderWidget.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Widgets/WidgetProxy.cs b/Widgets/WidgetProxy.cs new file mode 100644 index 0000000..3031b44 --- /dev/null +++ b/Widgets/WidgetProxy.cs @@ -0,0 +1,87 @@ +using MMEdit; +using MMEdit.Fx; +using MMEdit.Widgets; +using System; +using System.Collections.Generic; +using System.Threading; + +namespace MMDUI.Widgets +{ + public class WidgetProxy : WidgetControl + { + #region Constructor + public WidgetProxy() + { + AutoScroll = true; + Dock = System.Windows.Forms.DockStyle.Fill; + Padding = new System.Windows.Forms.Padding(10); + } + public WidgetProxy(ObjectFX obj, IHost host) : this() + { + Host = host; + ObjectFX = obj; + } + #endregion + + #region Properties + public override ObjectFX ObjectFX + { + get + { + return base.ObjectFX; + } + + set + { + base.ObjectFX = value; + + if (!(ObjectFX is MMDUIObjectFX)) + throw new Exception($"Widget Proxy: 无法创建小部件,提供的对象不是“{nameof(MMDUIObjectFX)}”。"); + + List controlObjects = new List((ObjectFX as MMDUIObjectFX).ControlObjects); + controlObjects.Reverse(); + + new Thread(() => + { + Invoke(new Action(() => + { + SuspendLayout(); + foreach (ControlObject controlObject in controlObjects) + { + Annotation ann = controlObject.GetAnnotation("UIWidget"); + + if (ann != null) + { + WidgetControl widget; + try + { + widget = Host.CreateWidget(ann.Value, controlObject) ?? new MessageWidget($"{controlObject.Name}: 没有找到小部件“{ann.Value}”。"); + } + catch (Exception e) + { + widget = new MessageWidget($"{controlObject.Name}: {e.Message}"); + } + + if (widget is MMDUIWidgetBase widgetBase) + widgetBase.ValueChanged += Widget_ValueChanged; + + Controls.Add(widget); + } + } + ResumeLayout(); + })); + }).Start(); + } + } + + protected IHost Host { get; } + #endregion + + #region Methods + private void Widget_ValueChanged(object sender, EventArgs e) + { + Host.OnFileStatusChanged(new FileStatusEventArgs(FileStatus.Changed)); + } + #endregion + } +} diff --git a/app.config b/app.config new file mode 100644 index 0000000..1471b9f --- /dev/null +++ b/app.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + shift_jis + + + + \ No newline at end of file diff --git a/doc/ThirdPartyNotices.txt b/doc/ThirdPartyNotices.txt new file mode 100644 index 0000000..ffd3767 --- /dev/null +++ b/doc/ThirdPartyNotices.txt @@ -0,0 +1,16 @@ +Fugue Icons +------------------------------ + +(C) 2013 Yusuke Kamiyamane. All rights reserved. + +These icons are licensed under a Creative Commons +Attribution 3.0 License. + + +If you can't or don't want to provide attribution, please +purchase a royalty-free license. + + +I'm unavailable for custom icon design work. But your +suggestions are always welcome! + \ No newline at end of file