public static bool AddFactory(TsrFactory f) { if(f == null) { Debug.Assert(false); return false; } TsrFactory fEx = GetFactory(f.Uuid); if(fEx != null) return false; // Exists already TsrPool.Factories.Add(f); return true; }
private static void EnsureFactories() { if(g_lFacs != null) return; TsrFactory fKP = new KeePassTsrFactory(); TsrFactory f81 = new Win81TsrFactory(); TsrFactory f10 = new Win10TsrFactory(); TsrFactory fP = new ProExtTsrFactory(); TsrFactory fS; try { fS = new SystemTsrFactory(); } catch(Exception) { Debug.Assert(false); fS = fP; } // https://sourceforge.net/p/keepass/discussion/329220/thread/fab85f1d/ // http://keepass.info/help/kb/tsrstyles_survey.html TsrFactory[] vPref; if(WinUtil.IsAtLeastWindows10) vPref = new TsrFactory[] { f10, f81, fKP, fP, fS }; else if(WinUtil.IsAtLeastWindows8) vPref = new TsrFactory[] { f81, f10, fKP, fP, fS }; else if(NativeLib.IsUnix()) vPref = new TsrFactory[] { f81, f10, fKP, fP, fS }; else // Older Windows systems vPref = new TsrFactory[] { fKP, f10, f81, fP, fS }; List<TsrFactory> l = new List<TsrFactory>(vPref); #if DEBUG for(int i = 0; i < l.Count; ++i) { TsrFactory f1 = l[i]; if(f1 == null) { Debug.Assert(false); continue; } if(f1.Uuid == null) { Debug.Assert(false); continue; } for(int j = i + 1; j < l.Count; ++j) { TsrFactory f2 = l[j]; if(f2 == null) { Debug.Assert(false); continue; } if(f2.Uuid == null) { Debug.Assert(false); continue; } Debug.Assert(!f1.Uuid.Equals(f2.Uuid)); } } #endif g_lFacs = l; g_nStdFac = l.Count; }
public static bool AddFactory(TsrFactory f) { if (f == null) { Debug.Assert(false); return(false); } TsrFactory fEx = GetFactory(f.Uuid); if (fEx != null) { return(false); // Exists already } TsrPool.Factories.Add(f); return(true); }
internal static ToolStripRenderer GetBestRenderer(PwUuid u) { TsrFactory fPref = null; if ((u == null) || PwUuid.Zero.Equals(u)) { } else { fPref = GetFactory(u); } List <TsrFactory> lPref = new List <TsrFactory>(); if (fPref != null) { lPref.Add(fPref); } lPref.AddRange(TsrPool.Factories); foreach (TsrFactory fCand in lPref) { if ((fCand != null) && fCand.IsSupported()) { try { ToolStripRenderer tsr = fCand.CreateInstance(); if (tsr != null) { return(tsr); } } catch (Exception) { Debug.Assert(false); } } } return(null); }
private static void EnsureFactories() { if (g_lFacs != null) { return; } TsrFactory fKP = new KeePassTsrFactory(); TsrFactory f81 = new Win81TsrFactory(); TsrFactory f10 = new Win10TsrFactory(); TsrFactory fP = new ProExtTsrFactory(); TsrFactory fS; try { fS = new SystemTsrFactory(); } catch (Exception) { Debug.Assert(false); fS = fP; } // https://sourceforge.net/p/keepass/discussion/329220/thread/fab85f1d/ // https://keepass.info/help/kb/tsrstyles_survey.html TsrFactory[] vPref; if (WinUtil.IsAtLeastWindows10) { vPref = new TsrFactory[] { f10, f81, fKP, fP, fS } } ; else if (WinUtil.IsAtLeastWindows8) { vPref = new TsrFactory[] { f81, f10, fKP, fP, fS } } ; else if (NativeLib.IsUnix()) { vPref = new TsrFactory[] { f81, f10, fKP, fP, fS } } ; else // Older Windows systems { vPref = new TsrFactory[] { fKP, f10, f81, fP, fS } }; List <TsrFactory> l = new List <TsrFactory>(vPref); #if DEBUG for (int i = 0; i < l.Count; ++i) { TsrFactory f1 = l[i]; if (f1 == null) { Debug.Assert(false); continue; } if (f1.Uuid == null) { Debug.Assert(false); continue; } for (int j = i + 1; j < l.Count; ++j) { TsrFactory f2 = l[j]; if (f2 == null) { Debug.Assert(false); continue; } if (f2.Uuid == null) { Debug.Assert(false); continue; } Debug.Assert(!f1.Uuid.Equals(f2.Uuid)); } } #endif g_lFacs = l; g_nStdFac = l.Count; }