void AddSignElement(SignContentType e) { SignElementUI se = new SignElementUI(); se.ContentType = e; se.Content = SignContentFactory.Create(e); try { se.ContentControl = SignContentFactory.CreateControl(e); se.ContentControl.BindToContent(se.Content); se.ContentControl.ContentChange += ContentControl_ContentChange; } catch { se.ContentControl = null; // If there are errors, don't use the UI. (allow controls without UI) } ISignContent[] newElements; lock (Elements) { Elements.Add(se); listBox1.Items.Add(se.Content.Summary); newElements = Elements.Select(i => i.Content).ToArray(); } Animate.SetContent(newElements); }
public static ISignContent Create(SignContentType t) { object o = Assembly.GetCallingAssembly().CreateInstance(t.ContentClassType.FullName); if (o is ISignContent) { return((ISignContent)o); } throw new Exception("Mislabeled Sign content type: " + t.ContentClassType.FullName); }
public static ISignContentControl CreateControl(SignContentType t) { object o = Assembly.GetCallingAssembly().CreateInstance(t.ContentClassType.FullName + "Control"); if (o is ISignContentControl) { return((ISignContentControl)o); } throw new Exception("No content control available for type: " + t.ContentClassType.FullName); }
public static IEnumerable <SignContentType> EnumerateContentTypes() { if (Types == null) { List <SignContentType> generateTypes = new List <SignContentType>(); TypeMap = new Dictionary <string, SignContentType>(); Assembly a = Assembly.GetCallingAssembly(); foreach (Type t in a.GetTypes()) { SignContentAttribute sc = t.GetCustomAttribute <SignContentAttribute>(false); if (sc != null) { SignContentType sct = new SignContentType(); sct.Name = sc.ContentName; sct.ContentClassType = t; generateTypes.Add(sct); TypeMap.Add(sct.Name, sct); } } Types = generateTypes.ToArray(); } return(Types); }
void AddSignElement(SignContentType e) { SignElementUI se = new SignElementUI(); se.ContentType = e; se.Content = SignContentFactory.Create(e); try { se.ContentControl = SignContentFactory.CreateControl(e); se.ContentControl.BindToContent(se.Content); se.ContentControl.ContentChange += ContentControl_ContentChange; } catch { se.ContentControl = null; // If there are errors, don't use the UI. (allow controls without UI) } ISignContent[] newElements; lock(Elements) { Elements.Add(se); listBox1.Items.Add(se.Content.Summary); newElements = Elements.Select(i => i.Content).ToArray(); } Animate.SetContent(newElements); }
public static ISignContent Create(SignContentType t) { object o = Assembly.GetCallingAssembly().CreateInstance(t.ContentClassType.FullName); if(o is ISignContent) { return (ISignContent)o; } throw new Exception("Mislabeled Sign content type: " + t.ContentClassType.FullName); }
public static IEnumerable<SignContentType> EnumerateContentTypes() { if(Types == null) { List<SignContentType> generateTypes = new List<SignContentType>(); TypeMap = new Dictionary<string, SignContentType>(); Assembly a = Assembly.GetCallingAssembly(); foreach(Type t in a.GetTypes()) { SignContentAttribute sc = t.GetCustomAttribute<SignContentAttribute>(false); if(sc != null) { SignContentType sct = new SignContentType(); sct.Name = sc.ContentName; sct.ContentClassType = t; generateTypes.Add(sct); TypeMap.Add(sct.Name, sct); } } Types = generateTypes.ToArray(); } return Types; }
public static ISignContentControl CreateControl(SignContentType t) { object o = Assembly.GetCallingAssembly().CreateInstance(t.ContentClassType.FullName + "Control"); if(o is ISignContentControl) { return (ISignContentControl)o; } throw new Exception("No content control available for type: " + t.ContentClassType.FullName); }