From 0655ecb1f60920ec1acbbe252829a4fffd5fd645 Mon Sep 17 00:00:00 2001 From: Charles Lechasseur Date: Tue, 31 Dec 2019 21:16:21 -0500 Subject: [PATCH] #7 : Edit option to copy true .lnk paths in Settings app --- PathCopyCopySettings/Core/UserSettings.cs | 19 +++++++++++++ .../UI/Forms/MainForm.Designer.cs | 27 ++++++++++++++----- PathCopyCopySettings/UI/Forms/MainForm.cs | 4 +++ PathCopyCopySettings/UI/Forms/MainForm.resx | 21 +++++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/PathCopyCopySettings/Core/UserSettings.cs b/PathCopyCopySettings/Core/UserSettings.cs index 6330929..9c15bb9 100644 --- a/PathCopyCopySettings/Core/UserSettings.cs +++ b/PathCopyCopySettings/Core/UserSettings.cs @@ -116,6 +116,9 @@ public enum StringEncodeParam /// Name of registry value specifying the separator to use between multiple copied paths. private const string PathsSeparatorValueName = "PathsSeparator"; + /// Name of registry value specifying whether to copy paths to the .lnk files themselves. + private const string TrueLnkPathsValueName = "TrueLnkPaths"; + /// Name of registry value containing the ID of the plugin to activate when Ctrl key is held down. private const string CtrlKeyPluginValueName = "CtrlKeyPlugin"; @@ -226,6 +229,9 @@ public enum StringEncodeParam /// Default value of the "paths separator" setting. private const string PathsSeparatorDefaultValue = ""; + /// Default value of the "true .lnk paths" setting. + private const int TrueLnkPathsDefaultValue = 0; + /// Default value of the "disable software update" setting. private const int DisableSoftwareUpdateDefaultValue = 0; @@ -463,6 +469,19 @@ public string PathsSeparator } } + /// + /// Whether to copy the paths of .lnk files themselves. + /// + public bool TrueLnkPaths + { + get { + return ((int) GetUserOrGlobalValue(TrueLnkPathsValueName, TrueLnkPathsDefaultValue)) != 0; + } + set { + userKey.SetValue(TrueLnkPathsValueName, value ? 1 : 0); + } + } + /// /// Whether software updates are disabled. /// diff --git a/PathCopyCopySettings/UI/Forms/MainForm.Designer.cs b/PathCopyCopySettings/UI/Forms/MainForm.Designer.cs index b0478cf..27c5d77 100644 --- a/PathCopyCopySettings/UI/Forms/MainForm.Designer.cs +++ b/PathCopyCopySettings/UI/Forms/MainForm.Designer.cs @@ -87,6 +87,7 @@ private void InitializeComponent() this.ExportUserSettingsSaveDlg = new System.Windows.Forms.SaveFileDialog(); this.ExportUserSettingsBtn = new System.Windows.Forms.Button(); this.MainToolTip = new System.Windows.Forms.ToolTip(this.components); + this.TrueLnkPathsChk = new System.Windows.Forms.CheckBox(); this.MainTabCtrl.SuspendLayout(); this.PluginsPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PluginsDataGrid)).BeginInit(); @@ -391,6 +392,7 @@ private void InitializeComponent() // // MiscOptionsPage // + this.MiscOptionsPage.Controls.Add(this.TrueLnkPathsChk); this.MiscOptionsPage.Controls.Add(this.UsePreviewModeInMainMenuChk); this.MiscOptionsPage.Controls.Add(this.AppendSepForDirChk); this.MiscOptionsPage.Controls.Add(this.UseFQDNChk); @@ -472,10 +474,10 @@ private void InitializeComponent() this.CtrlKeyPluginCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CtrlKeyPluginCombo.Enabled = false; this.CtrlKeyPluginCombo.FormattingEnabled = true; - this.CtrlKeyPluginCombo.Location = new System.Drawing.Point(25, 351); + this.CtrlKeyPluginCombo.Location = new System.Drawing.Point(25, 374); this.CtrlKeyPluginCombo.Name = "CtrlKeyPluginCombo"; this.CtrlKeyPluginCombo.Size = new System.Drawing.Size(399, 21); - this.CtrlKeyPluginCombo.TabIndex = 15; + this.CtrlKeyPluginCombo.TabIndex = 16; this.MainToolTip.SetToolTip(this.CtrlKeyPluginCombo, "Command to use automatically when user holds down the Ctrl key when Explorer\'s co" + "ntextual menu is shown"); this.CtrlKeyPluginCombo.ValueMember = "Plugin"; @@ -484,10 +486,10 @@ private void InitializeComponent() // CtrlKeyPluginChk // this.CtrlKeyPluginChk.AutoSize = true; - this.CtrlKeyPluginChk.Location = new System.Drawing.Point(6, 328); + this.CtrlKeyPluginChk.Location = new System.Drawing.Point(6, 351); this.CtrlKeyPluginChk.Name = "CtrlKeyPluginChk"; this.CtrlKeyPluginChk.Size = new System.Drawing.Size(418, 17); - this.CtrlKeyPluginChk.TabIndex = 14; + this.CtrlKeyPluginChk.TabIndex = 15; this.CtrlKeyPluginChk.Text = "When user holds down Ctrl &key when opening contextual menu, use this command:"; this.MainToolTip.SetToolTip(this.CtrlKeyPluginChk, "Choose a command to use automatically when user holds down the Ctrl key when Expl" + "orer\'s contextual menu is shown"); @@ -581,10 +583,10 @@ private void InitializeComponent() // EnableSoftwareUpdateChk // this.EnableSoftwareUpdateChk.AutoSize = true; - this.EnableSoftwareUpdateChk.Location = new System.Drawing.Point(6, 378); + this.EnableSoftwareUpdateChk.Location = new System.Drawing.Point(6, 401); this.EnableSoftwareUpdateChk.Name = "EnableSoftwareUpdateChk"; this.EnableSoftwareUpdateChk.Size = new System.Drawing.Size(177, 17); - this.EnableSoftwareUpdateChk.TabIndex = 16; + this.EnableSoftwareUpdateChk.TabIndex = 17; this.EnableSoftwareUpdateChk.Text = "Check for &updates automatically"; this.MainToolTip.SetToolTip(this.EnableSoftwareUpdateChk, "Automatically check for new versions of Path Copy Copy and offer them when they a" + "re released"); @@ -800,6 +802,18 @@ private void InitializeComponent() this.ExportUserSettingsBtn.UseVisualStyleBackColor = true; this.ExportUserSettingsBtn.Click += new System.EventHandler(this.ExportUserSettingsBtn_Click); // + // TrueLnkPathsChk + // + this.TrueLnkPathsChk.AutoSize = true; + this.TrueLnkPathsChk.Location = new System.Drawing.Point(6, 328); + this.TrueLnkPathsChk.Name = "TrueLnkPathsChk"; + this.TrueLnkPathsChk.Size = new System.Drawing.Size(235, 17); + this.TrueLnkPathsChk.TabIndex = 14; + this.TrueLnkPathsChk.Text = "Copy paths of sh&ortcut (.lnk) files themselves"; + this.MainToolTip.SetToolTip(this.TrueLnkPathsChk, "When copying path of a shortcut (.lnk) file, copy the path of the shortcut file i" + + "tself instead of the path of its target"); + this.TrueLnkPathsChk.UseVisualStyleBackColor = true; + // // MainForm // this.AcceptButton = this.OKBtn; @@ -901,6 +915,7 @@ private void InitializeComponent() private System.Windows.Forms.BindingSource PluginsDataGridBindingSource; private System.Windows.Forms.BindingSource CtrlKeyPluginComboBindingSource; private UserControls.PluginPreviewUserControl PreviewCtrl; + private System.Windows.Forms.CheckBox TrueLnkPathsChk; } } diff --git a/PathCopyCopySettings/UI/Forms/MainForm.cs b/PathCopyCopySettings/UI/Forms/MainForm.cs index e10d6be..c351235 100644 --- a/PathCopyCopySettings/UI/Forms/MainForm.cs +++ b/PathCopyCopySettings/UI/Forms/MainForm.cs @@ -269,6 +269,7 @@ private void LoadUserSettings() UsePreviewModeInMainMenuChk.Checked = settings.UsePreviewModeInMainMenu; } DropRedundantWordsChk.Checked = settings.DropRedundantWords; + TrueLnkPathsChk.Checked = settings.TrueLnkPaths; EnableSoftwareUpdateChk.Checked = !settings.DisableSoftwareUpdate; // Set binding list as data source for the combo box used to pick ctrl key plugin. @@ -427,6 +428,9 @@ private void SaveUserSettings() if (DropRedundantWordsChk.Checked != settings.DropRedundantWords) { settings.DropRedundantWords = DropRedundantWordsChk.Checked; } + if (TrueLnkPathsChk.Checked != settings.TrueLnkPaths) { + settings.TrueLnkPaths = TrueLnkPathsChk.Checked; + } if (EnableSoftwareUpdateChk.Checked != (!settings.DisableSoftwareUpdate)) { settings.DisableSoftwareUpdate = !EnableSoftwareUpdateChk.Checked; } diff --git a/PathCopyCopySettings/UI/Forms/MainForm.resx b/PathCopyCopySettings/UI/Forms/MainForm.resx index cf96ca2..5ed6edf 100644 --- a/PathCopyCopySettings/UI/Forms/MainForm.resx +++ b/PathCopyCopySettings/UI/Forms/MainForm.resx @@ -120,6 +120,27 @@ 769, 18 + + 769, 18 + + + 209, 40 + + + True + + + True + + + True + + + True + + + 15, 39 + True