mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 03:59:15 +08:00
Merge pull request #125 from CoenraadS/master
Control Panel Split Logic
This commit is contained in:
commit
a62b225fe0
@ -51,9 +51,9 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
foreach (ControlPanelItem item in controlPanelItems)
|
foreach (ControlPanelItem item in controlPanelItems)
|
||||||
{
|
{
|
||||||
if (!File.Exists(iconFolder + item.LocalizedString + fileType) && item.Icon != null)
|
if (!File.Exists(iconFolder + item.GUID + fileType) && item.Icon != null)
|
||||||
{
|
{
|
||||||
item.Icon.ToBitmap().Save(iconFolder + item.LocalizedString + fileType);
|
item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
Title = item.LocalizedString,
|
Title = item.LocalizedString,
|
||||||
SubTitle = item.InfoTip,
|
SubTitle = item.InfoTip,
|
||||||
Score = item.Score,
|
Score = item.Score,
|
||||||
IcoPath = "Images\\ControlPanelIcons\\" + item.LocalizedString + fileType,
|
IcoPath = "Images\\ControlPanelIcons\\" + item.GUID + fileType,
|
||||||
Action = e =>
|
Action = e =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -8,16 +8,18 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
{
|
{
|
||||||
public string LocalizedString { get; private set; }
|
public string LocalizedString { get; private set; }
|
||||||
public string InfoTip { get; private set; }
|
public string InfoTip { get; private set; }
|
||||||
|
public string GUID { get; private set; }
|
||||||
public ProcessStartInfo ExecutablePath { get; private set; }
|
public ProcessStartInfo ExecutablePath { get; private set; }
|
||||||
public Icon Icon { get; private set; }
|
public Icon Icon { get; private set; }
|
||||||
public int Score { get; set; }
|
public int Score { get; set; }
|
||||||
|
|
||||||
public ControlPanelItem(string newLocalizedString, string newInfoTip, ProcessStartInfo newExecutablePath, Icon newIcon)
|
public ControlPanelItem(string newLocalizedString, string newInfoTip, string newGUID, ProcessStartInfo newExecutablePath, Icon newIcon)
|
||||||
{
|
{
|
||||||
LocalizedString = newLocalizedString;
|
LocalizedString = newLocalizedString;
|
||||||
InfoTip = newInfoTip;
|
InfoTip = newInfoTip;
|
||||||
ExecutablePath = newExecutablePath;
|
ExecutablePath = newExecutablePath;
|
||||||
Icon = newIcon;
|
Icon = newIcon;
|
||||||
|
GUID = newGUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
myIcon = getIcon(currentKey, size);
|
myIcon = getIcon(currentKey, size);
|
||||||
|
|
||||||
controlPanelItems.Add(new ControlPanelItem(localizedString, infoTip, executablePath, myIcon));
|
controlPanelItems.Add(new ControlPanelItem(localizedString, infoTip, key, executablePath, myIcon));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,20 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
else if (currentKey.OpenSubKey("Shell\\Open\\Command") != null && currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null) != null)
|
else if (currentKey.OpenSubKey("Shell\\Open\\Command") != null && currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null) != null)
|
||||||
{
|
{
|
||||||
//Other files (usually third party items)
|
//Other files (usually third party items)
|
||||||
executablePath.FileName = Environment.ExpandEnvironmentVariables(currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null).ToString());
|
string value = Environment.ExpandEnvironmentVariables(currentKey.OpenSubKey("Shell\\Open\\Command").GetValue(null).ToString());
|
||||||
|
|
||||||
|
if (value[0] == '"')
|
||||||
|
{
|
||||||
|
for (int x = 1; x < value.Length && value[x] != '"'; x++)
|
||||||
|
{
|
||||||
|
executablePath.FileName += value[x];
|
||||||
|
}
|
||||||
|
executablePath.Arguments = value.Remove(0, executablePath.FileName.Length + 2).Trim();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
executablePath.FileName = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -121,7 +134,7 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
if (currentKey.GetValue("LocalizedString") != null)
|
if (currentKey.GetValue("LocalizedString") != null)
|
||||||
{
|
{
|
||||||
localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new char[] { ',' }, 2);
|
localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new string[] { ",-" }, StringSplitOptions.None);
|
||||||
|
|
||||||
if (localizedStringRaw.Length > 1)
|
if (localizedStringRaw.Length > 1)
|
||||||
{
|
{
|
||||||
@ -142,9 +155,7 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
localizedString = resource.ToString();
|
localizedString = resource.ToString();
|
||||||
|
|
||||||
/*This shouldn't be necessary, but some apps (e.g. Bootcamp)
|
//Some apps don't return a string, although they do have a stringIndex. Use Default value.
|
||||||
* don't follow Microsoft's standard. Have to make a choice whether
|
|
||||||
* empty string == failure, or use default name. I'm using default name */
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(localizedString))
|
if (String.IsNullOrEmpty(localizedString))
|
||||||
{
|
{
|
||||||
@ -184,7 +195,7 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
if (currentKey.GetValue("InfoTip") != null)
|
if (currentKey.GetValue("InfoTip") != null)
|
||||||
{
|
{
|
||||||
infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new char[] { ',' }, 2);
|
infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new string[] { ",-" }, StringSplitOptions.None);
|
||||||
|
|
||||||
if (infoTipRaw.Length == 2)
|
if (infoTipRaw.Length == 2)
|
||||||
{
|
{
|
||||||
@ -204,6 +215,10 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
infoTip = resource.ToString();
|
infoTip = resource.ToString();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoTip = currentKey.GetValue("InfoTip").ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -241,31 +256,32 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
|
|
||||||
iconIndex = (IntPtr)sanitizeUint(iconString[1]);
|
iconIndex = (IntPtr)sanitizeUint(iconString[1]);
|
||||||
|
|
||||||
if (iconIndex == IntPtr.Zero)
|
iconPtr = LoadImage(dataFilePointer, iconIndex, 1, iconSize, iconSize, 0);
|
||||||
|
|
||||||
|
if (iconPtr == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
iconQueue = new Queue<IntPtr>();
|
iconQueue = new Queue<IntPtr>();
|
||||||
EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources.
|
EnumResourceNamesWithID(dataFilePointer, 3, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources.
|
||||||
|
|
||||||
while (iconPtr == IntPtr.Zero && iconQueue.Count > 0)
|
while (iconPtr == IntPtr.Zero && iconQueue.Count > 0)
|
||||||
{
|
{
|
||||||
iconPtr = LoadImage(dataFilePointer, iconQueue.Dequeue(), 1, iconSize, iconSize, 0);
|
iconPtr = LoadImage(dataFilePointer, iconQueue.Dequeue(), 1, iconSize, iconSize, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
iconPtr = LoadImage(dataFilePointer, iconIndex, 1, iconSize, iconSize, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeLibrary(dataFilePointer);
|
FreeLibrary(dataFilePointer);
|
||||||
|
|
||||||
try
|
if (iconPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
myIcon = Icon.FromHandle(iconPtr);
|
try
|
||||||
myIcon = (Icon)myIcon.Clone(); //Remove pointer dependancy.
|
{
|
||||||
}
|
myIcon = Icon.FromHandle(iconPtr);
|
||||||
catch
|
myIcon = (Icon)myIcon.Clone(); //Remove pointer dependancy.
|
||||||
{
|
}
|
||||||
//Silently fail for now..
|
catch
|
||||||
|
{
|
||||||
|
//Silently fail for now.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,12 +314,10 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
|
|||||||
args = args.Remove(x);
|
args = args.Remove(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint size;
|
/*If the logic is correct, this should never through an exception.
|
||||||
if (uint.TryParse(args, out size))
|
* If there is an exception, then need to analyze what the input is.
|
||||||
{
|
* Returning the wrong number will cause more errors */
|
||||||
return size;
|
return Convert.ToUInt32(args);
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IS_INTRESOURCE(IntPtr value)
|
private static bool IS_INTRESOURCE(IntPtr value)
|
||||||
|
Loading…
Reference in New Issue
Block a user