//既定のConfig private void OnCreateDefaultConfig(XmlConfigModel config) { //対象拡張子 config.AddXmlContentsItem("LibraryExplorer.setting:Common.TargetExtentions.Count", 3); config.AddXmlContentsItem("LibraryExplorer.setting:Common.TargetExtentions.1", ".bas"); config.AddXmlContentsItem("LibraryExplorer.setting:Common.TargetExtentions.2", ".frm"); config.AddXmlContentsItem("LibraryExplorer.setting:Common.TargetExtentions.3", ".cls"); config.AddXmlContentsItem("LibraryExplorer.setting:Common.HasOtherFilesExtentions.Count", 1); config.AddXmlContentsItem("LibraryExplorer.setting:Common.HasOtherFilesExtentions.1.Target", ".frm"); config.AddXmlContentsItem("LibraryExplorer.setting:Common.HasOtherFilesExtentions.1.Count", 1); config.AddXmlContentsItem("LibraryExplorer.setting:Common.HasOtherFilesExtentions.1.1", ".frx"); //Library関連 config.AddXmlContentsItem("LibraryExplorer.setting:Library.Header.Start", "MY_LIBRARY_HEADER_START"); config.AddXmlContentsItem("LibraryExplorer.setting:Library.Header.End", "MY_LIBRARY_HEADER_END"); //エディタ設定 config.AddXmlContentsItem("LibraryExplorer.setting:Editor.Path", ""); config.AddXmlContentsItem("LibraryExplorer.setting:Editor.Arguments", ""); //比較ツール設定 config.AddXmlContentsItem("LibraryExplorer.setting:DiffTool.Path", ""); config.AddXmlContentsItem("LibraryExplorer.setting:DiffTool.Arguments", ""); //スクリプト config.AddXmlContentsItem("LibraryExplorer.setting:Script.ExcelModuleExport", "ExcelModuleExport.vbs"); config.AddXmlContentsItem("LibraryExplorer.setting:Script.ExcelModuleImport", "ExcelModuleImport.vbs"); //MainWindowの位置とサイズ config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Size.Width", 400); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Size.Height", 300); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Location.Left", 50); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Location.Top", 50); }
/// <summary> /// ウインドウ領域 /// </summary> /// <param name="config"></param> private void OnReflectWindowBounds(XmlConfigModel config) { config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Size.Width", this.m_MainWindowWidth); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Size.Height", this.m_MainWindowHeight); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Location.Left", this.m_MainWindowLeft); config.AddXmlContentsItem("LibraryExplorer.setting:Window.MainWindow.Location.Top", this.m_MainWindowTop); }
/// <summary> /// configとして保存するデフォルト設定を作成します。 /// </summary> /// <returns></returns> public XmlConfigModel CreateDefaultConfig() { XmlConfigModel config = new XmlConfigModel(); this.OnCreateDefaultConfig(config); return(config); }
//既定のConfig private void OnCreateDefaultConfig(XmlConfigModel config) { config.AddXmlContentsItem("Kucl.setting:Common.Name", "SAMPLE_NAME"); config.AddXmlContentsItem("Kucl.setting:Common.Location.X", 10); config.AddXmlContentsItem("Kucl.setting:Common.Location.Y", 20); config.AddXmlContentsItem("Kucl.setting:Common.Settings.Detail.Enabled", false); config.AddXmlContentsItem("Kucl.setting:Special.Settings.UnManaged", false); }
/// <summary> /// 対象拡張子 /// </summary> /// <param name="config"></param> private void OnReflectTargetExtentions(XmlConfigModel config) { config.AddXmlContentsItem("LibraryExplorer.setting:Common.TargetExtentions.Count", this.m_TargetExtentions.Count); for (int i = 0; i < this.m_TargetExtentions.Count; i++) { config.AddXmlContentsItem($"LibraryExplorer.setting:Common.TargetExtentions.{i + 1}", this.m_TargetExtentions[i]); } }
private void button1_Click(object sender, EventArgs e) { XmlContentsModelViewer viewer = new XmlContentsModelViewer(); XmlConfigModel model = new XmlConfigModel(); AppMain.g_AppMain.UseConfigObjects.Cast <IUseConfig>().ToList().ForEach(x => x.ReflectConfig(model)); viewer.TargetModel = model; viewer.ShowDialog(); }
//Configの更新 private void OnReflectConfig(XmlConfigModel config) { config.AddXmlContentsItem("Kucl.setting:Common.Name", this.m_Name); config.AddXmlContentsItem("Kucl.setting:Common.Location.X", this.m_Location.X); config.AddXmlContentsItem("Kucl.setting:Common.Location.Y", this.m_Location.Y); config.AddXmlContentsItem("Kucl.setting:Common.Settings.Detail.Enabled", this.m_EnableDetailSettings); config.AddXmlContentsItem("Kucl.setting:Special.Settings.UnManaged", this.UnManagedMode); }
//Configの適用 private void OnApplyConfig(XmlConfigModel config) { this.m_Name = this.m_ConfigHelper.GetStringValue("Kucl.setting:Common.Name"); int x = this.m_ConfigHelper.GetIntValue("Kucl.setting:Common.Location.X"); int y = this.m_ConfigHelper.GetIntValue("Kucl.setting:Common.Location.Y"); this.m_Location = new System.Drawing.Point(x, y); this.m_EnableDetailSettings = this.m_ConfigHelper.GetBoolValue("Kucl.setting:Common.Settings.Detail.Enabled"); this.UnManagedMode = this.m_ConfigHelper.GetBoolValue("Kucl.setting:Special.Settings.UnManaged"); }
/// <summary> /// 複数ファイルで構成されるファイル /// </summary> /// <param name="config"></param> private void OnReflectHasOtherFilesExtentions(XmlConfigModel config) { config.AddXmlContentsItem("LibraryExplorer.setting:Common.HasOtherFilesExtentions.Count", this.m_HasOtherFilesExtentions.Count); for (int i = 0; i < this.m_HasOtherFilesExtentions.Keys.Count; i++) { string key = this.m_HasOtherFilesExtentions.Keys.ElementAt(i); config.AddXmlContentsItem($"LibraryExplorer.setting:Common.HasOtherFilesExtentions.{i + 1}.Target", key); List <string> list = this.m_HasOtherFilesExtentions[key]; config.AddXmlContentsItem($"LibraryExplorer.setting:Common.HasOtherFilesExtentions.{i + 1}.Count", list.Count); for (int j = 0; j < list.Count; j++) { config.AddXmlContentsItem($"LibraryExplorer.setting:Common.HasOtherFilesExtentions.{i + 1}.{j + 1}", list[j]); } } }
//Configの適用 private void OnApplyConfig(XmlConfigModel config) { //LibraryFolders this.m_Libraries.Clear(); int folder_count = this.m_ConfigHelper.GetIntValue("LibraryExplorer.project:Project.LibraryFolders.Count"); for (int i = 0; i < folder_count; i++) { string path = this.m_ConfigHelper.GetStringValue($"LibraryExplorer.project:Project.LibraryFolders.Folders.{i + 1}"); Library lib = Library.FromFolder(path); if (lib != null) { this.m_Libraries.Add(lib); } } //OfficeFiles this.m_ExcelFiles.Clear(); int file_count = this.m_ConfigHelper.GetIntValue("LibraryExplorer.project:Project.OfficeFiles.Count"); for (int i = 0; i < file_count; i++) { string path = this.m_ConfigHelper.GetStringValue($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.Path"); string exportPath = this.m_ConfigHelper.GetStringValue($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.ExportPath"); string dateString = this.m_ConfigHelper.GetStringValue($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.ExportDate"); DateTime?exportDate = (dateString != "" ? DateTime.Parse(dateString) : (DateTime?)null); OfficeFile file = new ExcelFile(path, exportPath) { ExportDate = exportDate }; int backupCount = this.m_ConfigHelper.GetIntValue($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.BackupCount", 0); for (int j = 0; j < backupCount; j++) { string backupPath = this.m_ConfigHelper.GetStringValue($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.Backup.{j + 1}", ""); file.BackupPathList.Add(backupPath); } this.m_ExcelFiles.Add(file); } }
//Configの適用 private void OnApplyConfig(XmlConfigModel config) { //対象拡張子 this.OnApplyTargetExtentions(); this.OnApplyHasOtherFilesExtentions(); //Library関連 this.OnApplyHeaderInfo(); //エディタ設定 this.OnApplyEditorInfo(); //比較ツール設定 this.OnApplyDiffToolInfo(); //スクリプト this.OnApplyScriptInfo(); //MainWindowの位置とサイズ this.OnApplyWindowBounds(); }
//Configの更新 private void OnReflectConfig(XmlConfigModel config) { //対象拡張子 this.OnReflectTargetExtentions(config); this.OnReflectHasOtherFilesExtentions(config); //Library関連 this.OnReflectHeaderInfo(config); //エディタ設定 this.OnReflectEditorInfo(config); //比較ツール設定 this.OnReflectDiffToolInfo(config); //スクリプト this.OnReflectScriptInfo(config); //MainWindowの位置とサイズ this.OnReflectWindowBounds(config); }
//Configの更新 private void OnReflectConfig(XmlConfigModel config) { //LibraryFolders config.AddXmlContentsItem("LibraryExplorer.project:Project.LibraryFolders.Count", this.m_Libraries.Count); for (int i = 0; i < this.m_Libraries.Count; i++) { config.AddXmlContentsItem($"LibraryExplorer.project:Project.LibraryFolders.Folders.{i + 1}", this.m_Libraries[i].TargetFolder); } //OfficeFiels config.AddXmlContentsItem("LibraryExplorer.project:Project.OfficeFiles.Count", this.m_ExcelFiles.Count); for (int i = 0; i < this.m_ExcelFiles.Count; i++) { OfficeFile file = this.m_ExcelFiles[i]; config.AddXmlContentsItem($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.Path", file.FileName); config.AddXmlContentsItem($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.ExportPath", file.WorkspaceFolder.Path); config.AddXmlContentsItem($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.ExportDate", file.ExportDate?.ToString() ?? ""); config.AddXmlContentsItem($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.BackupCount", file.BackupPathList.Count); for (int j = 0; j < file.BackupPathList.Count; j++) { config.AddXmlContentsItem($"LibraryExplorer.project:Project.OfficeFiles.{i + 1}.Backup.{j + 1}", file.BackupPathList[j]); } } }
/// <summary> /// ライブラリヘッダ /// </summary> /// <param name="config"></param> private void OnReflectHeaderInfo(XmlConfigModel config) { config.AddXmlContentsItem("LibraryExplorer.setting:Library.Header.Start", this.m_LibraryHeaderStart); config.AddXmlContentsItem("LibraryExplorer.setting:Library.Header.End", this.m_LibraryHeaderEnd); }
/// <summary> /// エディタ設定 /// </summary> /// <param name="config"></param> private void OnReflectEditorInfo(XmlConfigModel config) { Config.AddXmlContentsItem("LibraryExplorer.setting:Editor.Path", this.m_EditorPath); Config.AddXmlContentsItem("LibraryExplorer.setting:Editor.Arguments", this.m_EditorArguments); }
/// <summary> /// 比較ツール設定 /// </summary> /// <param name="config"></param> private void OnReflectDiffToolInfo(XmlConfigModel config) { Config.AddXmlContentsItem("LibraryExplorer.setting:DiffTool.Path", this.m_DiffToolPath); Config.AddXmlContentsItem("LibraryExplorer.setting:DiffTool.Arguments", this.m_DiffToolArguments); }
/// <summary> /// 現在の設定をconfigに反映します。 /// </summary> /// <param name="config"></param> public void ReflectConfig(XmlConfigModel config) { this.OnReflectConfig(config); }
/// <summary> /// configを読み込んで適用します。 /// </summary> /// <param name="value"></param> public void ApplyConfig(XmlConfigModel value) { this.m_ConfigHelper.Config = value; this.OnApplyConfig(value); }
/// <summary> /// スクリプト /// </summary> /// <param name="config"></param> private void OnReflectScriptInfo(XmlConfigModel config) { config.AddXmlContentsItem("LibraryExplorer.setting:Script.ExcelModuleExport", this.m_ExcelModuleExportScriptName); config.AddXmlContentsItem("LibraryExplorer.setting:Script.ExcelModuleImport", this.m_ExcelModuleImportScriptName); }
//既定のConfig private void OnCreateDefaultConfig(XmlConfigModel config) { //LibraryProject config.AddXmlContentsItem("LibraryExplorer.project:Project.LibraryFolders.Count", 0); config.AddXmlContentsItem("LibraryExplorer.project:Project.OfficeFiles.Count", 0); }