Skip to content

Commit 5eb3cf9

Browse files
committed
Add ellipsis to explorer context menu entry
1 parent ee91bd7 commit 5eb3cf9

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

PasteIntoFile/Dialog.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,8 @@ private void ChkAutoSave_CheckedChanged(object sender, EventArgs e)
361361
{
362362
MessageBox.Show(Resources.str_autosave_infotext, Resources.str_autosave_checkbox, MessageBoxButtons.OK, MessageBoxIcon.Information);
363363
}
364-
365-
Settings.Default.autoSave = chkAutoSave.Checked;
366-
Settings.Default.Save();
364+
365+
Wizard.SetAutosaveMode(chkAutoSave.Checked);
367366

368367
}
369368

PasteIntoFile/Main.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static int RunCopy(ArgsCopy args)
200200
static int RunWizard(ArgsWizard args = null)
201201
{
202202
if (RegistryUtil.IsContextMenuEntryRegistered())
203-
RegistryUtil.RegisterContextMenuEntry(); // overwrites default entry with localized strings
203+
RegistryUtil.RegisterContextMenuEntry(!Settings.Default.autoSave); // overwrites default entry with localized strings
204204

205205
Application.Run(new Wizard());
206206
return 0;
@@ -273,7 +273,7 @@ static void ApplyCommonArgs(ArgsCommon args)
273273
if (args.ClearClipboard != null)
274274
Settings.Default.clrClipboard = (bool) args.ClearClipboard;
275275
if (args.Autosave != null)
276-
Settings.Default.autoSave = (bool) args.Autosave;
276+
Wizard.SetAutosaveMode((bool) args.Autosave);
277277

278278
Settings.Default.Save();
279279
}
@@ -289,7 +289,7 @@ static int RunConfig(ArgsConfig args)
289289
try
290290
{
291291
if (args.RegisterContextMenu)
292-
RegistryUtil.RegisterContextMenuEntry();
292+
RegistryUtil.RegisterContextMenuEntry(!Settings.Default.autoSave);
293293
if (args.UnregisterContextMenu)
294294
RegistryUtil.UnRegisterContextMenuEntry();
295295
if (args.RegisterAutostart)

PasteIntoFile/RegistryUtil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static void UnRegisterContextMenuEntry()
7474
/// <summary>
7575
/// Create context menu entry
7676
/// </summary>
77-
public static void RegisterContextMenuEntry(bool silent = false)
77+
public static void RegisterContextMenuEntry(bool hasDialog = false)
7878
{
7979
// Documentation:
8080
// https://docs.microsoft.com/en-us/windows/win32/shell/context
@@ -84,7 +84,7 @@ public static void RegisterContextMenuEntry(bool silent = false)
8484
foreach (var classKey in OpenClassKeys("Directory"))
8585
{
8686
var key = classKey.CreateSubKey(PRIMARY_KEY_NAME);
87-
key.SetValue("", Resources.str_contextentry);
87+
key.SetValue("", Resources.str_contextentry + (hasDialog ? "…" : ""));
8888
key.SetValue("Icon", "\"" + Application.ExecutablePath + "\",0");
8989
key = key.CreateSubKey("command");
9090
key.SetValue("", "\"" + Application.ExecutablePath + "\" paste \"%V\"");

PasteIntoFile/Wizard.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ public Wizard()
2727
autostartCheckBox.Checked = RegistryUtil.IsAutostartRegistered();
2828
}
2929

30-
private void ChkAutoSave_CheckedChanged(object sender, EventArgs e)
31-
{
32-
Settings.Default.autoSave = autoSaveCheckBox.Checked;
30+
public static void SetAutosaveMode(bool enabled) {
31+
Settings.Default.autoSave = enabled;
3332
Settings.Default.Save();
33+
// update context menu entry
34+
if (RegistryUtil.IsContextMenuEntryRegistered())
35+
RegistryUtil.RegisterContextMenuEntry(!Settings.Default.autoSave);
36+
}
3437

38+
private void ChkAutoSave_CheckedChanged(object sender, EventArgs e)
39+
{
40+
SetAutosaveMode(autoSaveCheckBox.Checked);
3541
}
3642

3743
private void ChkContextEntry_CheckedChanged(object sender, EventArgs e)
@@ -40,7 +46,7 @@ private void ChkContextEntry_CheckedChanged(object sender, EventArgs e)
4046
{
4147
if (contextEntryCheckBox.Checked && !RegistryUtil.IsContextMenuEntryRegistered())
4248
{
43-
RegistryUtil.RegisterContextMenuEntry();
49+
RegistryUtil.RegisterContextMenuEntry(!Settings.Default.autoSave);
4450
MessageBox.Show(Resources.str_message_register_context_menu_success, Resources.str_main_window_title, MessageBoxButtons.OK, MessageBoxIcon.Information);
4551
}
4652
else if (!contextEntryCheckBox.Checked && RegistryUtil.IsContextMenuEntryRegistered())

0 commit comments

Comments
 (0)