From 60fdc435adb10ed73996dd227cf2d6126fa6f260 Mon Sep 17 00:00:00 2001 From: vletroye Date: Sun, 17 Sep 2023 19:46:49 +0200 Subject: [PATCH] Fixes --- Mods/App.config | 7 +- Mods/Data/Package.cs | 7 +- Mods/Data/PackageHelper.cs | 5 +- Mods/Forms/MainForm.cs | 20 +++-- Mods/Forms/Parameters.Designer.cs | 121 ++++++++++++++++++--------- Mods/Forms/Parameters.cs | 67 +++++++++++---- Mods/Helpers/Helper.cs | 8 +- Mods/Helpers/MainHelper.cs | 28 +++++-- Mods/OpenFolderDialog.cs | 3 +- Mods/Properties/Settings.Designer.cs | 20 ++++- Mods/Properties/Settings.settings | 5 +- 11 files changed, 210 insertions(+), 81 deletions(-) diff --git a/Mods/App.config b/Mods/App.config index ad00aac..5819656 100644 --- a/Mods/App.config +++ b/Mods/App.config @@ -23,10 +23,13 @@ - + - + + + + diff --git a/Mods/Data/Package.cs b/Mods/Data/Package.cs index dbdec25..50a16fb 100644 --- a/Mods/Data/Package.cs +++ b/Mods/Data/Package.cs @@ -34,7 +34,7 @@ public Package(string targetFolder, string spk, bool forceDeflate) else { //Check if a package is to be deflated - if (PackageHelper.DeflatePackageIfRequired(forceDeflate, ref dirInfo, fileInfo) == DialogResult.Cancel) + if (PackageHelper.DeflatePackageIfRequired(forceDeflate, ref dirInfo, ref fileInfo) == DialogResult.Cancel) IsLoaded = false; else { @@ -46,11 +46,16 @@ public Package(string targetFolder, string spk, bool forceDeflate) IsLoaded = false; } } + if (dirInfo != null) this.Folder = dirInfo.FullName; + if (fileInfo != null) this.SPK = fileInfo.FullName; } } public Package(string targetFolder, string spk) : this(targetFolder, spk, false) { } + public string Folder { get; set; } + public string SPK { get; set; } + public bool IsLoaded { get; set; } /// diff --git a/Mods/Data/PackageHelper.cs b/Mods/Data/PackageHelper.cs index f238713..ea79cd5 100644 --- a/Mods/Data/PackageHelper.cs +++ b/Mods/Data/PackageHelper.cs @@ -57,7 +57,7 @@ internal static bool SeemsDeflated(DirectoryInfo packageFolder) /// No if a Deflation was not done. /// If the spk is deflated into a temporary folder, this one is returned into targetFolder. /// - internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref DirectoryInfo targetFolder, FileInfo spk) + internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref DirectoryInfo targetFolder, ref FileInfo spk) { DialogResult answer = DialogResult.No; bool spkToBeDeflated = true; @@ -80,7 +80,7 @@ internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref Dir else if (!spk.Exists) throw new ArgumentException(String.Format("Application Error: The SPK {0} does not exist.", spk.FullName)); - // If not target folder to deflate, use the folder of the SPK + // If no target folder provided to deflate, use the folder of the SPK if (targetFolder == null || !targetFolder.Exists) if (SeemsDeflated(spk.Directory)) { @@ -316,6 +316,7 @@ internal static bool DeflatePackage(FileInfo spk) internal static void CopyPackagingBinaries(string path) { + if (File.Exists(Path.Combine(path, "7z.exe"))) File.Delete(Path.Combine(path, "7z.exe")); File.Copy(Path.Combine(Helper.ResourcesDirectory, "7z.exe"), Path.Combine(path, "7z.exe")); diff --git a/Mods/Forms/MainForm.cs b/Mods/Forms/MainForm.cs index c327c55..51af4cf 100644 --- a/Mods/Forms/MainForm.cs +++ b/Mods/Forms/MainForm.cs @@ -519,7 +519,7 @@ private void FillInfoScreen() if (groupBoxPackage.BackColor != Color.Salmon) { groupBoxPackage.BackColor = Color.Salmon; - HelperNew.PublishWarning("This package has has been opened from a temporary folder. Possibly move it into a target folder using the menu Package > Move."); + HelperNew.PublishWarning("This package has been opened from a temporary folder. Possibly move it into a target folder using the menu Package > Move."); } } else @@ -3640,7 +3640,7 @@ private void buttonAdvanced_Click(object sender, EventArgs e) ScriptInfo config = null; if (!string.IsNullOrWhiteSpace(CurrentPackage.INFO.DsmUiDir)) { - configName = CurrentPackage.Folder_UI; + configName = CurrentPackage.Path_Config; if (File.Exists(configName)) { content = File.ReadAllText(configName); @@ -3680,10 +3680,15 @@ private void menuOpenPackageFolder_Click(object sender, EventArgs e) } Process.Start(path); } - else if (!(string.IsNullOrEmpty(Properties.Settings.Default.PackageRoot)) && Directory.Exists(Properties.Settings.Default.PackageRoot)) + else { - var path = Properties.Settings.Default.PackageRoot; - Process.Start(path); + + // TODO: check here if creating a package DSM <= 6.x or >= 7.x + if (!(string.IsNullOrEmpty(Properties.Settings.Default.PackageRootDSM6x)) && Directory.Exists(Properties.Settings.Default.PackageRootDSM6x)) + { + var path = Properties.Settings.Default.PackageRootDSM6x; + Process.Start(path); + } } } @@ -3994,7 +3999,10 @@ private bool PromptToMovePackage(string path = null) { folderBrowserDialog4Mods.Title = "Pick a target Root folder to move the Package currently opened."; if (Properties.Settings.Default.DefaultPackageRoot) - folderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRoot; + { + // TODO: check here if creating a package DSM <= 6.x or >= 7.x + folderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRootDSM6x; + } else folderBrowserDialog4Mods.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); diff --git a/Mods/Forms/Parameters.Designer.cs b/Mods/Forms/Parameters.Designer.cs index 1e03661..c5c1a37 100644 --- a/Mods/Forms/Parameters.Designer.cs +++ b/Mods/Forms/Parameters.Designer.cs @@ -37,11 +37,12 @@ private void InitializeComponent() this.toolTipProperties = new System.Windows.Forms.ToolTip(this.components); this.labelDefaultPublishFolder = new System.Windows.Forms.Label(); this.checkBoxOpenWith = new System.Windows.Forms.CheckBox(); - this.labelDefaultPackageRoot = new System.Windows.Forms.Label(); + this.labelDefaultPackageRootDSM6x = new System.Windows.Forms.Label(); this.checkBoxDefaultPackageRoot = new System.Windows.Forms.CheckBox(); this.buttonEditDSMReleases = new System.Windows.Forms.Button(); this.checkBoxPromptExplorer = new System.Windows.Forms.CheckBox(); this.checkBoxCopyPackagePath = new System.Windows.Forms.CheckBox(); + this.buttonPhpExtensions = new System.Windows.Forms.Button(); this.buttonDefaultPackageRepo = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); @@ -49,15 +50,17 @@ private void InitializeComponent() this.buttonReset = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); - this.buttonPhpExtensions = new System.Windows.Forms.Button(); this.groupBoxTips = new System.Windows.Forms.GroupBox(); + this.labelDSM6x = new System.Windows.Forms.Label(); + this.labelDsm7x = new System.Windows.Forms.Label(); + this.labelDefaultPackageRootDSM7x = new System.Windows.Forms.Label(); this.groupBoxTips.SuspendLayout(); this.SuspendLayout(); // // buttonOk // this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonOk.Location = new System.Drawing.Point(12, 261); + this.buttonOk.Location = new System.Drawing.Point(12, 299); this.buttonOk.Name = "buttonOk"; this.buttonOk.Size = new System.Drawing.Size(75, 23); this.buttonOk.TabIndex = 0; @@ -69,7 +72,7 @@ private void InitializeComponent() // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(443, 261); + this.buttonCancel.Location = new System.Drawing.Point(443, 299); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.TabIndex = 1; @@ -123,25 +126,25 @@ private void InitializeComponent() this.checkBoxOpenWith.UseVisualStyleBackColor = true; this.checkBoxOpenWith.CheckedChanged += new System.EventHandler(this.checkBoxOpenWith_CheckedChanged); // - // labelDefaultPackageRoot + // labelDefaultPackageRootDSM6x // - this.labelDefaultPackageRoot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.labelDefaultPackageRootDSM6x.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.labelDefaultPackageRoot.Cursor = System.Windows.Forms.Cursors.Hand; - this.labelDefaultPackageRoot.Location = new System.Drawing.Point(94, 203); - this.labelDefaultPackageRoot.Name = "labelDefaultPackageRoot"; - this.labelDefaultPackageRoot.Size = new System.Drawing.Size(423, 19); - this.labelDefaultPackageRoot.TabIndex = 31; - this.labelDefaultPackageRoot.Text = "..."; - this.toolTipProperties.SetToolTip(this.labelDefaultPackageRoot, "Path of the repository where new packages will be created before being published." + + this.labelDefaultPackageRootDSM6x.Cursor = System.Windows.Forms.Cursors.Hand; + this.labelDefaultPackageRootDSM6x.Location = new System.Drawing.Point(165, 197); + this.labelDefaultPackageRootDSM6x.Name = "labelDefaultPackageRootDSM6x"; + this.labelDefaultPackageRootDSM6x.Size = new System.Drawing.Size(353, 19); + this.labelDefaultPackageRootDSM6x.TabIndex = 31; + this.labelDefaultPackageRootDSM6x.Text = "..."; + this.toolTipProperties.SetToolTip(this.labelDefaultPackageRootDSM6x, "Path of the repository where new packages will be created before being published." + " Click here to open that folder."); - this.labelDefaultPackageRoot.Click += new System.EventHandler(this.labelDefaultPackageRoot_Click); + this.labelDefaultPackageRootDSM6x.Click += new System.EventHandler(this.labelDefaultPackageRootDSM6x_Click); // // checkBoxDefaultPackageRoot // this.checkBoxDefaultPackageRoot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.checkBoxDefaultPackageRoot.AutoSize = true; - this.checkBoxDefaultPackageRoot.Location = new System.Drawing.Point(14, 180); + this.checkBoxDefaultPackageRoot.Location = new System.Drawing.Point(14, 174); this.checkBoxDefaultPackageRoot.Name = "checkBoxDefaultPackageRoot"; this.checkBoxDefaultPackageRoot.Size = new System.Drawing.Size(169, 17); this.checkBoxDefaultPackageRoot.TabIndex = 32; @@ -155,7 +158,7 @@ private void InitializeComponent() // buttonEditDSMReleases // this.buttonEditDSMReleases.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonEditDSMReleases.Location = new System.Drawing.Point(412, 228); + this.buttonEditDSMReleases.Location = new System.Drawing.Point(412, 266); this.buttonEditDSMReleases.Name = "buttonEditDSMReleases"; this.buttonEditDSMReleases.Size = new System.Drawing.Size(105, 23); this.buttonEditDSMReleases.TabIndex = 36; @@ -191,6 +194,18 @@ private void InitializeComponent() this.checkBoxCopyPackagePath.UseVisualStyleBackColor = true; this.checkBoxCopyPackagePath.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // + // buttonPhpExtensions + // + this.buttonPhpExtensions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonPhpExtensions.Location = new System.Drawing.Point(13, 267); + this.buttonPhpExtensions.Name = "buttonPhpExtensions"; + this.buttonPhpExtensions.Size = new System.Drawing.Size(112, 23); + this.buttonPhpExtensions.TabIndex = 39; + this.buttonPhpExtensions.Text = "Edit Php Extensions"; + this.toolTipProperties.SetToolTip(this.buttonPhpExtensions, "Edit the list of php Extensions."); + this.buttonPhpExtensions.UseVisualStyleBackColor = true; + this.buttonPhpExtensions.Click += new System.EventHandler(this.buttonPhpExtensions_Click); + // // buttonDefaultPackageRepo // this.buttonDefaultPackageRepo.Location = new System.Drawing.Point(12, 35); @@ -217,16 +232,16 @@ private void InitializeComponent() this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.label2.Location = new System.Drawing.Point(13, 170); + this.label2.Location = new System.Drawing.Point(12, 167); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(504, 2); this.label2.TabIndex = 30; // - // buttonDefaultPackageRoot + // buttonDefaultPackageRootDSM6x // this.buttonDefaultPackageRoot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonDefaultPackageRoot.Location = new System.Drawing.Point(13, 203); - this.buttonDefaultPackageRoot.Name = "buttonDefaultPackageRoot"; + this.buttonDefaultPackageRoot.Location = new System.Drawing.Point(13, 197); + this.buttonDefaultPackageRoot.Name = "buttonDefaultPackageRootDSM6x"; this.buttonDefaultPackageRoot.Size = new System.Drawing.Size(75, 19); this.buttonDefaultPackageRoot.TabIndex = 29; this.buttonDefaultPackageRoot.Text = "Select"; @@ -237,7 +252,7 @@ private void InitializeComponent() // buttonReset // this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonReset.Location = new System.Drawing.Point(362, 261); + this.buttonReset.Location = new System.Drawing.Point(362, 299); this.buttonReset.Name = "buttonReset"; this.buttonReset.Size = new System.Drawing.Size(75, 23); this.buttonReset.TabIndex = 33; @@ -250,7 +265,7 @@ private void InitializeComponent() this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.label3.Location = new System.Drawing.Point(12, 256); + this.label3.Location = new System.Drawing.Point(12, 294); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(506, 2); this.label3.TabIndex = 34; @@ -260,34 +275,55 @@ private void InitializeComponent() this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.label4.Location = new System.Drawing.Point(13, 224); + this.label4.Location = new System.Drawing.Point(13, 262); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(504, 2); this.label4.TabIndex = 35; // - // buttonPhpExtensions - // - this.buttonPhpExtensions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonPhpExtensions.Location = new System.Drawing.Point(13, 229); - this.buttonPhpExtensions.Name = "buttonPhpExtensions"; - this.buttonPhpExtensions.Size = new System.Drawing.Size(112, 23); - this.buttonPhpExtensions.TabIndex = 39; - this.buttonPhpExtensions.Text = "Edit Php Extensions"; - this.toolTipProperties.SetToolTip(this.buttonPhpExtensions, "Edit the list of php Extensions."); - this.buttonPhpExtensions.UseVisualStyleBackColor = true; - this.buttonPhpExtensions.Click += new System.EventHandler(this.buttonPhpExtensions_Click); - // // groupBoxTips // this.groupBoxTips.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxTips.Controls.Add(this.labelToolTip); - this.groupBoxTips.Location = new System.Drawing.Point(12, 291); + this.groupBoxTips.Location = new System.Drawing.Point(12, 329); this.groupBoxTips.Name = "groupBoxTips"; this.groupBoxTips.Size = new System.Drawing.Size(505, 85); this.groupBoxTips.TabIndex = 40; this.groupBoxTips.TabStop = false; this.groupBoxTips.Text = "TIPS"; + // + // labelDSM6x + // + this.labelDSM6x.AutoSize = true; + this.labelDSM6x.Location = new System.Drawing.Point(95, 200); + this.labelDSM6x.Name = "labelDSM6x"; + this.labelDSM6x.Size = new System.Drawing.Size(63, 13); + this.labelDSM6x.TabIndex = 41; + this.labelDSM6x.Text = "DSM <= 6.x"; + // + // labelDsm7x + // + this.labelDsm7x.AutoSize = true; + this.labelDsm7x.Location = new System.Drawing.Point(95, 224); + this.labelDsm7x.Name = "labelDsm7x"; + this.labelDsm7x.Size = new System.Drawing.Size(63, 13); + this.labelDsm7x.TabIndex = 44; + this.labelDsm7x.Text = "DSM >= 7.x"; + // + // labelDefaultPackageRootDSM7x + // + this.labelDefaultPackageRootDSM7x.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelDefaultPackageRootDSM7x.Cursor = System.Windows.Forms.Cursors.Hand; + this.labelDefaultPackageRootDSM7x.Location = new System.Drawing.Point(163, 221); + this.labelDefaultPackageRootDSM7x.Name = "labelDefaultPackageRootDSM7x"; + this.labelDefaultPackageRootDSM7x.Size = new System.Drawing.Size(353, 19); + this.labelDefaultPackageRootDSM7x.TabIndex = 43; + this.labelDefaultPackageRootDSM7x.Text = "..."; + this.toolTipProperties.SetToolTip(this.labelDefaultPackageRootDSM7x, "Path of the repository where new packages will be created before being published." + + " Click here to open that folder."); + this.labelDefaultPackageRootDSM7x.Click += new System.EventHandler(this.labelDefaultPackageRootDSM7x_Click); + // // Parameters // @@ -295,8 +331,11 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(530, 388); + this.ClientSize = new System.Drawing.Size(530, 426); this.ControlBox = false; + this.Controls.Add(this.labelDsm7x); + this.Controls.Add(this.labelDefaultPackageRootDSM7x); + this.Controls.Add(this.labelDSM6x); this.Controls.Add(this.groupBoxTips); this.Controls.Add(this.buttonPhpExtensions); this.Controls.Add(this.checkBoxCopyPackagePath); @@ -306,7 +345,7 @@ private void InitializeComponent() this.Controls.Add(this.label3); this.Controls.Add(this.buttonReset); this.Controls.Add(this.checkBoxDefaultPackageRoot); - this.Controls.Add(this.labelDefaultPackageRoot); + this.Controls.Add(this.labelDefaultPackageRootDSM6x); this.Controls.Add(this.label2); this.Controls.Add(this.buttonDefaultPackageRoot); this.Controls.Add(this.label1); @@ -321,6 +360,7 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Properties"; + this.Load += new System.EventHandler(this.Parameters_Load); this.groupBoxTips.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -340,7 +380,7 @@ private void InitializeComponent() private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button buttonDefaultPackageRoot; - private System.Windows.Forms.Label labelDefaultPackageRoot; + private System.Windows.Forms.Label labelDefaultPackageRootDSM6x; private System.Windows.Forms.CheckBox checkBoxDefaultPackageRoot; private System.Windows.Forms.Button buttonReset; private System.Windows.Forms.Label label3; @@ -350,5 +390,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkBoxCopyPackagePath; private System.Windows.Forms.Button buttonPhpExtensions; private System.Windows.Forms.GroupBox groupBoxTips; + private System.Windows.Forms.Label labelDSM6x; + private System.Windows.Forms.Label labelDsm7x; + private System.Windows.Forms.Label labelDefaultPackageRootDSM7x; } } \ No newline at end of file diff --git a/Mods/Forms/Parameters.cs b/Mods/Forms/Parameters.cs index 11c8606..4d38717 100644 --- a/Mods/Forms/Parameters.cs +++ b/Mods/Forms/Parameters.cs @@ -54,14 +54,17 @@ private void ShowParameters() checkBoxDefaultPackageRoot.Checked = Properties.Settings.Default.DefaultPackageRoot; checkBoxPromptExplorer.Checked = Properties.Settings.Default.PromptExplorer; checkBoxCopyPackagePath.Checked = Properties.Settings.Default.CopyPackagePath; - + buttonDefaultPackageRepo.Visible = checkBoxDefaultPackageRepo.Checked; labelDefaultPublishFolder.Visible = checkBoxDefaultPackageRepo.Checked; labelDefaultPublishFolder.Text = Properties.Settings.Default.PackageRepo; buttonDefaultPackageRoot.Visible = checkBoxDefaultPackageRoot.Checked; - labelDefaultPackageRoot.Visible = checkBoxDefaultPackageRoot.Checked; - labelDefaultPackageRoot.Text = Properties.Settings.Default.PackageRoot; + labelDefaultPackageRootDSM6x.Visible = checkBoxDefaultPackageRoot.Checked; + labelDefaultPackageRootDSM6x.Text = Properties.Settings.Default.PackageRootDSM6x; + labelDefaultPackageRootDSM7x.Visible = checkBoxDefaultPackageRoot.Checked; + labelDefaultPackageRootDSM7x.Text = Properties.Settings.Default.PackageRootDSM7x; + } private void OnMouseEnter(object sender, EventArgs e) @@ -114,16 +117,32 @@ private void PickPackageRepo() private void PickPackageRoot() { - var path = Properties.Settings.Default.PackageRoot; - BrowserDialog4Mods.Title = "Pick a folder to store all your Packages under creation."; - if (!string.IsNullOrEmpty(path)) - BrowserDialog4Mods.InitialDirectory = path; - else - BrowserDialog4Mods.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + var path = Properties.Settings.Default.PackageRootDSM6x; + BrowserDialog4Mods.Title = "Pick a folder to store all your Packages compatible with DSM <= 6.x"; + if (string.IsNullOrEmpty(path)) + path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + + BrowserDialog4Mods.InitialDirectory = path; + //BrowserDialog4Mods.FileName = ""; + if (BrowserDialog4Mods.ShowDialog(this.Handle)) + { + Properties.Settings.Default.PackageRootDSM6x = BrowserDialog4Mods.FileName; + } + + path = Properties.Settings.Default.PackageRootDSM7x; + BrowserDialog4Mods.Title = "Pick a folder to store all your Packages compatible with DSM >= 7.x"; + if (string.IsNullOrEmpty(path)) + { + path = Properties.Settings.Default.PackageRootDSM6x; + if (string.IsNullOrEmpty(path)) + path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + } + BrowserDialog4Mods.InitialDirectory = path; + //BrowserDialog4Mods.FileName = ""; if (BrowserDialog4Mods.ShowDialog(this.Handle)) { - Properties.Settings.Default.PackageRoot = BrowserDialog4Mods.FileName; + Properties.Settings.Default.PackageRootDSM7x = BrowserDialog4Mods.FileName; } ShowParameters(); } @@ -139,7 +158,10 @@ private void buttonOk_Click(object sender, EventArgs e) Properties.Settings.Default.PackageRepo = ""; if (!Properties.Settings.Default.DefaultPackageRoot) - Properties.Settings.Default.PackageRoot = ""; + { + Properties.Settings.Default.PackageRootDSM6x = ""; + Properties.Settings.Default.PackageRootDSM7x = ""; + } Properties.Settings.Default.Save(); this.Hide(); @@ -225,7 +247,7 @@ private void checkBoxDefaultPackageRoot_CheckedChanged(object sender, EventArgs Properties.Settings.Default.DefaultPackageRoot = checkBoxDefaultPackageRoot.Checked; if (checkBoxDefaultPackageRoot.Checked) { - if (string.IsNullOrEmpty(Properties.Settings.Default.PackageRoot)) + if (string.IsNullOrEmpty(Properties.Settings.Default.PackageRootDSM6x) || string.IsNullOrEmpty(Properties.Settings.Default.PackageRootDSM7x)) PickPackageRoot(); } ShowParameters(); @@ -237,9 +259,18 @@ private void checkBoxPromptExplorer_CheckedChanged(object sender, EventArgs e) ShowParameters(); } - private void labelDefaultPackageRoot_Click(object sender, EventArgs e) + private void labelDefaultPackageRootDSM6x_Click(object sender, EventArgs e) { - var path = Properties.Settings.Default.PackageRoot; + var path = Properties.Settings.Default.PackageRootDSM6x; + if (Directory.Exists(path)) + Process.Start(path); + else + MessageBoxEx.Show(this, "This folder does not exist anymore or cannot be accessed.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + + } + private void labelDefaultPackageRootDSM7x_Click(object sender, EventArgs e) + { + var path = Properties.Settings.Default.PackageRootDSM7x; if (Directory.Exists(path)) Process.Start(path); else @@ -252,7 +283,8 @@ private void buttonReset_Click(object sender, EventArgs e) if (MessageBoxEx.Show(this, "Are you sure that you want to reset all user settings?\r\n\r\nThis cannot be undone!", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3) == DialogResult.Yes) { Properties.Settings.Default.DefaultPackageRoot = false; - Properties.Settings.Default.PackageRoot = ""; + Properties.Settings.Default.PackageRootDSM6x = ""; + Properties.Settings.Default.PackageRootDSM7x = ""; Properties.Settings.Default.DefaultPackageRepo = false; Properties.Settings.Default.PackageRepo = ""; Properties.Settings.Default.PromptExplorer = true; @@ -298,5 +330,10 @@ private void buttonPhpExtensions_Click(object sender, EventArgs e) Helper.WriteAnsiFile(phpExtensions, phpExtension.Code); } } + + private void Parameters_Load(object sender, EventArgs e) + { + + } } } diff --git a/Mods/Helpers/Helper.cs b/Mods/Helpers/Helper.cs index f24de0d..03d29fe 100644 --- a/Mods/Helpers/Helper.cs +++ b/Mods/Helpers/Helper.cs @@ -768,7 +768,7 @@ internal static DialogResult ScriptEditor(ScriptInfo script1, ScriptInfo script2 editScript.StartPosition = FormStartPosition.CenterParent; var result = editScript.ShowDialog(Application.OpenForms[0]); - if ((script1 == null || (script1.Code == originalScript1)) && (script2 == null || (script2.Code == originalScript2))) + if ((script1 == null || (script1.Code == (originalScript1 ?? ""))) && (script2 == null || (script2.Code == (originalScript2 ?? "")))) result = DialogResult.Cancel; return result; @@ -1382,7 +1382,11 @@ public static void GrantAccess(string fullPath) DirectoryInfo dInfo = new DirectoryInfo(fullPath); DirectorySecurity dSecurity = dInfo.GetAccessControl(); dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow)); - dInfo.SetAccessControl(dSecurity); + try + { + dInfo.SetAccessControl(dSecurity); + } + catch (Exception e) { } } } } diff --git a/Mods/Helpers/MainHelper.cs b/Mods/Helpers/MainHelper.cs index 8c73bc4..ffd25cb 100644 --- a/Mods/Helpers/MainHelper.cs +++ b/Mods/Helpers/MainHelper.cs @@ -12,6 +12,7 @@ using System.DirectoryServices.AccountManagement; using System.Threading.Tasks; using Microsoft.VisualBasic.ApplicationServices; +using Org.BouncyCastle.Utilities.Zlib; namespace BeatificaBytes.Synology.Mods.Helpers { @@ -86,10 +87,12 @@ internal bool OpenNewPackage(string targetFolder = null) if (string.IsNullOrWhiteSpace(targetFolder)) { - if (Properties.Settings.Default.DefaultPackageRoot && Directory.Exists(Properties.Settings.Default.PackageRoot)) + if (Properties.Settings.Default.DefaultPackageRoot && Directory.Exists(Properties.Settings.Default.PackageRootDSM6x) && Directory.Exists(Properties.Settings.Default.PackageRootDSM7x)) { + // TODO: check here if creating a package DSM <= 6.x or >= 7.x + // Use a temporary folder in the "default Package Root Folder" defined within MODS' properties (don't use a GUID as name. This is used only for spk "imported", and trigger a "warning message") - targetFolder = Path.Combine(Properties.Settings.Default.PackageRoot, "NEW-" + Guid.NewGuid().ToString()); + targetFolder = Path.Combine(Properties.Settings.Default.PackageRootDSM6x, "NEW-" + Guid.NewGuid().ToString()); ready = DialogResult.No; } else @@ -181,7 +184,11 @@ internal bool OpenExistingPackage(string targetPackage = null, bool import = fal { FolderBrowserDialog4Mods.Title = "Pick a folder containing an existing Package or a spk file to deflated."; if (Properties.Settings.Default.DefaultPackageRoot) - FolderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRoot; + { + // TODO: check here if creating a package DSM <= 6.x or >= 7.x + + FolderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRootDSM6x; + } else FolderBrowserDialog4Mods.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); @@ -207,7 +214,12 @@ internal bool OpenExistingPackage(string targetPackage = null, bool import = fal { // Check if the SPK is in its own folder (alone or deflated) if (!PackageHelper.SeemsDeflated(new DirectoryInfo(targetPackage))) + { targetPackage = null; + //PackageHelper.DeflatePackageIfRequired(true, ref dirTargetPackage , spk); + //targetPackage = dirTargetPackage.FullName; + //ready = DialogResult.Yes; + } } } else @@ -239,10 +251,10 @@ internal bool OpenExistingPackage(string targetPackage = null, bool import = fal } else { - // The selected folder contains an existing empty => open it - if (Properties.Settings.Default.DefaultPackageRoot && Directory.Exists(Properties.Settings.Default.PackageRoot)) + // The selected folder contains an existing package => open it + if (Properties.Settings.Default.DefaultPackageRoot && Directory.Exists(Properties.Settings.Default.PackageRootDSM6x) && Directory.Exists(Properties.Settings.Default.PackageRootDSM7x)) { - if (!import && !targetPackage.StartsWith(Properties.Settings.Default.PackageRoot)) + if (!import && !targetPackage.StartsWith(Properties.Settings.Default.PackageRootDSM6x) && !targetPackage.StartsWith(Properties.Settings.Default.PackageRootDSM7x)) HelperNew.PublishWarning(string.Format("This package is not stored in the default Package Root Folder defined in your Parameters...\r\n\r\n[{0}]", targetPackage)); } @@ -252,8 +264,8 @@ internal bool OpenExistingPackage(string targetPackage = null, bool import = fal var package = new Package(targetPackage, targetSPK, true); DisplayPackage(package); - //Refresh the binairies - PackageHelper.CopyPackagingBinaries(targetPackage); + //Refresh the binaries + PackageHelper.CopyPackagingBinaries(package.Folder); } } } else if (ready == DialogResult.Cancel) diff --git a/Mods/OpenFolderDialog.cs b/Mods/OpenFolderDialog.cs index c32b416..1bb1406 100644 --- a/Mods/OpenFolderDialog.cs +++ b/Mods/OpenFolderDialog.cs @@ -40,7 +40,7 @@ public OpenFolderDialog() public string InitialDirectory { get { return ofd.InitialDirectory; } - set { ofd.InitialDirectory = value == null || value.Length == 0 ? Environment.CurrentDirectory : value; } + set { ofd.InitialDirectory = value == null || value.Length == 0 ? Environment.CurrentDirectory : value; FileName = ""; } } /// @@ -58,6 +58,7 @@ public string Title public string FileName { get { return ofd.FileName; } + set { ofd.FileName = value == null ? "" : value; } } #endregion diff --git a/Mods/Properties/Settings.Designer.cs b/Mods/Properties/Settings.Designer.cs index 216cdcc..00be11f 100644 --- a/Mods/Properties/Settings.Designer.cs +++ b/Mods/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BeatificaBytes.Synology.Mods.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -38,12 +38,24 @@ public string Packages { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] - public string PackageRoot { + public string PackageRootDSM6x { get { - return ((string)(this["PackageRoot"])); + return ((string)(this["PackageRootDSM6x"])); } set { - this["PackageRoot"] = value; + this["PackageRootDSM6x"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string PackageRootDSM7x { + get { + return ((string)(this["PackageRootDSM7x"])); + } + set { + this["PackageRootDSM7x"] = value; } } diff --git a/Mods/Properties/Settings.settings b/Mods/Properties/Settings.settings index bb60904..abbcb43 100644 --- a/Mods/Properties/Settings.settings +++ b/Mods/Properties/Settings.settings @@ -5,7 +5,10 @@ - + + + +