internal static VisualElement Create(string key, Type type, Codespace codespace, ElementType eltype) { try { // Simple method calling default ctor // create an object of the type //ICodespaceElement obj = (ICodespaceElement)Activator.CreateInstance(type); /*Another way is to use reflection: */ // Get public constructors //var ctors = type.GetConstructors(BindingFlags.Public); var ctr = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(String), typeof(Codespace) }, null); if (ctr != null) { var obj = (VisualElement)ctr.Invoke(new object[] { key, codespace }); obj.Type = eltype; return(obj); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(null); }
public CodespaceElement(string key, Codespace parent) : base() { Debug.Assert(!String.IsNullOrEmpty(key)); Key = key; _parent = parent; }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Create new Codespace _codespace1 = new Robots1("ROBOTS-1", this, 1000, 800); _codespace1.SetMode(Codespace.Mode.DesignTime); _codespace1.Layout(); //Runtime invoked fromUI }
/// <summary> /// Note: you must add one or more PathFigure to this collection /// </summary> internal static StaticPathElement StaticPathHelper(string key, Codespace codespace, Brush strokeBrush, int strokethickness, string imageSrc) { var sp = new StaticPathElement(key, codespace); sp.Init(strokeBrush, strokethickness, imageSrc); /* * <Path Stroke ="Black" StrokeThickness="2" Data="M100,50 L140,60 L150,100 L125,120 L90,110 L80,80 z M15,40 L70,15 L80,30 L65,70 L80,115 L10,80 z M160,40 L170,50 L180,90 L180,120 L140,150 L130,130 L160,100 z" > * <Path.Fill> * <ImageBrush ImageSource="" TileMode="None" Stretch="UniformToFill" /> * </Path.Fill> * * </Path> */ return(sp); }
public GraphicImageElement(string key, Codespace parent) : base(key, parent) { }
public StaticPathElement(string key, Codespace parent) : base(key, parent) { }
internal VirtualMachine(Codespace cs) { _codespace = cs; }
public VisualElement(string key, Codespace parent) : base(key, parent) { }
public DynamicElement(string key, Codespace parent) : base(key, parent) { MagneticState = Magnestism.None; }