/// <summary> /// Does command</summary> /// <param name="commandTag">Command</param> void ICommandClient.DoCommand(object commandTag) { if (CommandTag.VitaNeighborhood.Equals(commandTag)) { // Invoke "Edit Vita Target in Neighborhood" command merely launches the PSP2 Neighborhood app that comes with Vita SDK installer, // as if you double click "Neighborhood for PlayStation(R)Vita" on your desktop icon. // This is intended just for a convenience helper to allow users directly bring up the PSP2 app without a detour to desktop first, // as PSP2 Neighborhood app can reboot, power off, and do much more for the Vita kit. // {BA414141-28C6-7F3C-45FF-14C28C11EE88} is the registered Neighborhood for PlayStation(R)Vita Shell extension System.Diagnostics.Process.Start("Explorer.exe", @"/e,/root,::{BA414141-28C6-7F3C-45FF-14C28C11EE88}"); } else if (m_addTargetsCmdTags.Contains(commandTag)) { foreach (var targetProvider in TargetProviders) { string addCmdTag = AddNewString.Localize() + targetProvider.Name; if (addCmdTag.Equals(commandTag)) { targetProvider.AddTarget(targetProvider.CreateNew()); break; } } } else if (m_removeTargetsCmdTags.Contains(commandTag)) { foreach (var item in m_selectedTargets) { foreach (var provider in TargetProviders) { provider.Remove(item); } } } }
/// <summary> /// Tests if client can perform command</summary> /// <param name="commandTag">Command</param> /// <returns>True iff client can perform command</returns> bool ICommandClient.CanDoCommand(object commandTag) { if (m_targetProviders == null) { return(false); } if (CommandTag.VitaNeighborhood.Equals(commandTag)) { if (m_selectedTargets != null && m_selectedTargets.Any()) { return(m_selectedTargets.All(target => target.Protocol == Deci4pTargetInfo.ProtocolName)); } return(false); } // add target if (m_addTargetsCmdTags.Contains(commandTag)) { foreach (var targetProvider in TargetProviders) { string addCmdTag = AddNewString.Localize() + targetProvider.Name; if (addCmdTag.Equals(commandTag)) { return(true); } } return(false); } // remove target if (m_removeTargetsCmdTags.Contains(commandTag)) { foreach (var targetProvider in TargetProviders) { string remCmdTag = RemoveTargetString.Localize() + targetProvider.Name; if (remCmdTag.Equals(commandTag)) { if (m_selectedTargets != null && m_selectedTargets.Any()) { // whether all these selected targets are provided by this provider return(m_selectedTargets.All(target => targetProvider.GetTargets(m_targetConsumer).Contains(target))); } } } return(false); } return(false); }
void IInitializable.Initialize() { if (CommandService == null) { return; } if (Deci4pTargetProvider.SdkInstalled) { var cmdInfo = new CommandInfo( CommandTag.VitaNeighborhood, null, null, "Edit Vita Target in Neighborhood".Localize(), "Edit Vita Target in Neighborhood".Localize()); cmdInfo.ShortcutsEditable = false; CommandService.RegisterCommand(cmdInfo, this); } foreach (var targetProvider in TargetProviders) { if (targetProvider.CanCreateNew) { string addCmdTag = AddNewString.Localize() + targetProvider.Name; CommandService.RegisterCommand( new CommandInfo( addCmdTag, null, null, addCmdTag, "Creates a new target".Localize()), this); m_addTargetsCmdTags.Add(addCmdTag); string remCmdTag = "Remove ".Localize() + targetProvider.Name; CommandService.RegisterCommand( new CommandInfo( remCmdTag, null, null, remCmdTag, "Remove selected target".Localize()), this); m_removeTargetsCmdTags.Add(remCmdTag); } } }