public static bool Has(string name) { StandardWindowReference spot = Spot(name); StandardWindow instance; return(spot != null && spot.window.TryGetTarget(out instance) && instance != null); }
// parameters: nameof(class) internal static StandardWindowReference Spot(string name) { StandardWindowReference spot = null; lock (windows_lock) { foreach (var el in windows) { if (el.type == name) { spot = el; break; } } } return(spot); }
public static StandardWindow Create(string name, StandardWindowCreatorFunction maker) { StandardWindowReference spot = Spot(name); StandardWindow instance; if (spot != null && spot.window.TryGetTarget(out instance) && instance != null) { return(instance); } else { // got to create an instance (and store it!) instance = maker(); if (spot == null) { spot = new StandardWindowReference() { window = new WeakReference <StandardWindow>(instance), type = name }; lock (windows_lock) { windows.Add(spot); } } else { // update spot: lock (windows_lock) { spot.window.SetTarget(instance); } } return(instance); } }