2017-02-26 19:23:31 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using HeliosDisplayManagement.Shared;
|
|
|
|
|
using HeliosDisplayManagement.ShellExtension.Resources;
|
|
|
|
|
using SharpShell.Attributes;
|
|
|
|
|
using SharpShell.SharpContextMenu;
|
|
|
|
|
|
|
|
|
|
namespace HeliosDisplayManagement.ShellExtension
|
|
|
|
|
{
|
|
|
|
|
[ComVisible(true)]
|
|
|
|
|
[COMServerAssociation(AssociationType.Class, @"DesktopBackground")]
|
|
|
|
|
internal class HeliosDesktopMenuExtension : SharpContextMenu
|
|
|
|
|
{
|
|
|
|
|
private static ToolStripMenuItem CreateProfileMenu(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
|
2017-08-10 14:09:41 +00:00
|
|
|
|
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Apply, Properties.Resources.Run_x16,
|
2017-02-26 19:23:31 +00:00
|
|
|
|
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile))
|
|
|
|
|
{
|
|
|
|
|
Enabled = profile.IsPossible && !profile.IsActive
|
|
|
|
|
});
|
|
|
|
|
profileMenu.DropDownItems.Add(new ToolStripSeparator());
|
2017-08-10 14:09:41 +00:00
|
|
|
|
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, Properties.Resources.Edit_x16,
|
2017-02-26 19:23:31 +00:00
|
|
|
|
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile)));
|
2017-08-10 14:21:45 +00:00
|
|
|
|
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut,
|
|
|
|
|
Properties.Resources.Shortcut_x16,
|
2017-02-26 19:23:31 +00:00
|
|
|
|
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile)));
|
|
|
|
|
return profileMenu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool CanShowMenu()
|
|
|
|
|
{
|
2017-08-10 14:05:43 +00:00
|
|
|
|
return Helios.IsInstalled;
|
2017-02-26 19:23:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override ContextMenuStrip CreateMenu()
|
|
|
|
|
{
|
|
|
|
|
var explorerMenu = new ContextMenuStrip();
|
2017-08-10 14:05:43 +00:00
|
|
|
|
if (Profile.GetAllProfiles().Any())
|
|
|
|
|
{
|
2018-10-20 00:22:48 +00:00
|
|
|
|
Profile.RefreshActiveStatus();
|
2017-08-10 14:05:43 +00:00
|
|
|
|
var extensionMenu = new ToolStripMenuItem(Language.Display_Profiles,
|
|
|
|
|
Properties.Resources.Icon_x16);
|
|
|
|
|
foreach (var profile in Profile.GetAllProfiles())
|
|
|
|
|
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
|
|
|
|
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
|
|
|
|
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
|
|
|
|
Properties.Resources.Icon_x16,
|
|
|
|
|
(sender, args) => { HeliosDisplayManagement.Open(); }));
|
|
|
|
|
explorerMenu.Items.Add(extensionMenu);
|
|
|
|
|
explorerMenu.Items.Add(new ToolStripSeparator());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var extensionMenu = new ToolStripMenuItem(Language.Manage_Profiles,
|
|
|
|
|
Properties.Resources.Icon_x16,
|
|
|
|
|
(sender, args) => { HeliosDisplayManagement.Open(); });
|
|
|
|
|
explorerMenu.Items.Add(extensionMenu);
|
|
|
|
|
explorerMenu.Items.Add(new ToolStripSeparator());
|
|
|
|
|
}
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return explorerMenu;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|