public static Image GetImage(Guid guid) { if (ItemImageDic.TryGetValue(guid, out Image image)) { return(image); } IconLocation location = GetIconLocation(guid); string iconPath = location.IconPath; int iconIndex = location.IconIndex; if (iconPath == null && iconIndex == 0) { image = AppImage.DllDefaultIcon; } else if (Path.GetFileName(iconPath).ToLower() == "shell32.dll" && iconIndex == 0) { image = AppImage.DllDefaultIcon; } else { image = ResourceIcon.GetIcon(iconPath, iconIndex)?.ToBitmap() ?? AppImage.DllDefaultIcon; } ItemImageDic.Add(guid, image); return(image); }
public void WriteProgIDTest() { const string sProgId = "My.Crazy.1"; const string testStr = "Testing123"; ShellRegistrar.UnregisterProgID(sProgId); using (var progid = ShellRegistrar.RegisterProgID(sProgId, "Testing Vanara ProgId")) using (var reg = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(sProgId)) { Assert.That(reg, Is.Not.Null); Assert.That(reg.GetValue(null).ToString(), Is.EqualTo(progid.FriendlyName)); Assert.That(progid.ID, Is.EqualTo(sProgId)); Assert.That(progid.ReadOnly, Is.False); progid.AllowSilentDefaultTakeOver = true; Assert.That(progid.AllowSilentDefaultTakeOver, Is.True); progid.AllowSilentDefaultTakeOver = false; Assert.That(progid.AllowSilentDefaultTakeOver, Is.False); progid.AppUserModelID = testStr; Assert.That(progid.AppUserModelID, Is.EqualTo(testStr)); progid.AppUserModelID = null; Assert.That(progid.AppUserModelID, Is.Null); var g = Guid.NewGuid(); progid.CLSID = g; Assert.That(progid.CLSID.Value, Is.EqualTo(g)); progid.CLSID = null; Assert.That(progid.CLSID, Is.Null); var i = new IconLocation(@"C:\Temp\dllexp.exe", -1); progid.DefaultIcon = i; Assert.That(progid.DefaultIcon.ToString(), Is.EqualTo(i.ToString())); progid.DefaultIcon = null; Assert.That(progid.DefaultIcon, Is.Null); var f = PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_NoEditIcon | PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_NoEdit; progid.EditFlags = f; Assert.That(progid.EditFlags, Is.EqualTo(f)); progid.EditFlags = 0; Assert.That(progid.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_None)); var fn = new IndirectString(@"C:\Temp\dllexp.exe", -1); progid.FriendlyTypeName = fn; Assert.That(progid.FriendlyTypeName.ToString(), Is.EqualTo(fn.ToString())); progid.FriendlyTypeName = null; Assert.That(progid.FriendlyTypeName, Is.Null); progid.InfoTip = fn; Assert.That(progid.InfoTip.ToString(), Is.EqualTo(fn.ToString())); progid.InfoTip = null; Assert.That(progid.InfoTip, Is.Null); var vopen = progid.Verbs.Add("Open", "&Open", "notepad.exe %1"); var vprint = progid.Verbs.Add("Print", "&Print", "notepad.exe %1"); var vend = progid.Verbs.Add("Terminate", "&End", "notepad.exe %1"); progid.Verbs.Order = new[] { vend, vprint }; } }
public override int GetHashCode() => IconLocation.GetHashCode() ^ TargetPath.GetHashCode() ^ Arguments.GetHashCode() ^ WorkingDirectory.GetHashCode() ^ WindowStyle.GetHashCode() ^ WindowStyle.GetHashCode() ^ Description.GetHashCode() ^ FullName.GetHashCode();
public void SetIconLocation(IconLocation iconLocation) { if (Application.isEditor) { return; } this.inputInterceptor.Call("setIconLocation", new object[] { (int)iconLocation }); this.LogInfo("<>SetIconLocation()"); }
public void ToStream(IO.IndentedTextWriter s) { var sg = s.Owner as BSaveGame; s.WriteLine("{1}\t{2}\t{3}\t{4}\t{5}\t{0}", sg.Database.ProtoPowers[ProtoPowerID], TimesUsed.ToString(), IconLocation.ToString(), IgnoreCost.ToString(), IgnoreTechPrereqs.ToString(), IgnorePop.ToString()); using (s.EnterIndentBookmark()) for (int x = 0; x < Items.Length; x++) { Items[x].ToStream(s); } }
public int CompareTo(BLeaderSupportPower other) { if (IconLocation != other.IconLocation) { IconLocation.CompareTo(other.IconLocation); } if (TechPrereqID != other.TechPrereqID) { TechPrereqID.CompareTo(other.TechPrereqID); } if (SupportPowerIDs.Count != other.SupportPowerIDs.Count) { SupportPowerIDs.Count.CompareTo(other.SupportPowerIDs.Count); } int a_hash = PhxUtil.CalculateHashCodeForDBIDs(SupportPowerIDs); int b_hash = PhxUtil.CalculateHashCodeForDBIDs(other.SupportPowerIDs); return(a_hash.CompareTo(b_hash)); }
public static IconLocation GetIconLocation(Guid guid) { IconLocation location = new IconLocation(); if (guid.Equals(Guid.Empty)) { return(location); } if (IconLocationDic.ContainsKey(guid)) { location = IconLocationDic[guid]; } else { if (TryGetValue(guid.ToString(), "Icon", out string value)) { value = GetAbsStr(guid, value, false); int index = value.LastIndexOf(','); if (int.TryParse(value.Substring(index + 1), out int iconIndex)) { location.IconPath = value.Substring(0, index); location.IconIndex = iconIndex; } else { location.IconPath = value; } } else { location.IconPath = GetFilePath(guid); } IconLocationDic.Add(guid, location); } return(location); }