public page(Canvas canvas, string title) { init_page(canvas, title); }
public page(Canvas canvas) { init_page(canvas, null); }
/// <summary> /// Create a control somwehere on the canvas... /// </summary> /// <param name="t">Type of the control to create ( should be either a Control type... )</param> /// <param name="i">(IReflectorCanvas, IReflectorButton, null...</param> /// <param name="rectangle">rectangle in canvas corrdinates</param> /// <returns>The control tracker that represents this control</returns> public ControlTracker MakeControl(Type t, Type i, Rectangle rectangle) { object widget_object = null; object o = null; rect.Width = canvas.Width; rect.Height = canvas.Height; Rectangle where = //this.GetScaledBounds( new Rectangle(PARTX(rectangle.X), PARTY(rectangle.Y) , PARTW(rectangle.X, rectangle.Width), PARTH(rectangle.Y, rectangle.Height)) //((Form)this.Parent).AutoScaleDimensions, BoundsSpecified.Location //) ; { Type[] types = new Type[1]; { //Type new_t = osalot.OverloadControl( t ); types[0] = typeof(Canvas); ConstructorInfo m = t.GetConstructor(types); if (m != null) { object[] paramlist = new object[1]; paramlist[0] = canvas; o = Activator.CreateInstance(t, paramlist); } } if (o == null) { types[0] = typeof(PSI_Button); ConstructorInfo m = t.GetConstructor(types); if (m != null) { object[] paramlist = new object[1]; PSI_Button button = new PSI_Button(canvas); widget_object = paramlist[0] = button; o = Activator.CreateInstance(t, paramlist); button.click_hook = (o as IReflectorButton); } } } if (o == null) { Type[] types = new Type[5]; types[0] = typeof(Canvas); // parent window handle types[1] = typeof(int); // x, y, w, h... types[2] = typeof(int); // types[3] = typeof(int); // types[4] = typeof(int); // ConstructorInfo m = t.GetConstructor(types); if (m != null) { object[] paramlist = new object[5]; paramlist[0] = canvas; paramlist[1] = where.X; paramlist[2] = where.Y; paramlist[3] = where.Width; paramlist[4] = where.Height; o = Activator.CreateInstance(t, paramlist); } } if (o == null) { //Type real_type = osalot.OverloadControl( t ); //t = real_type; ConstructorInfo m = t.GetConstructor(System.Type.EmptyTypes); if (m != null) { try { o = Activator.CreateInstance(t); if (t.IsSubclassOf(typeof(IReflectorScale))) { IReflectorScale tmp = o as IReflectorScale; tmp.SetScale(canvas.font_scale_x, canvas.font_scale_y); } if (osalot.IsAControl(t)) { widget_object = o; } } catch (Exception e) { Log.log(e.Message + "\n" + e.StackTrace); } } } //c = new System.Windows.Forms.Button(); //System.Windows.Forms. //((ToolStrip)e.ClickedItem.Container) { Control created_object; if (o == null) { return(null); } bool real = false; if ((t != typeof(PSI_Button)) && (i == typeof(IReflectorButton))) { if (widget_object != null) { created_object = widget_object as Control; } else { created_object = new PSI_Button(canvas, o as IReflectorButton); } } else if ((t != typeof(Canvas)) && i == typeof(IReflectorCanvas)) { created_object = new Canvas(o as IReflectorCanvas); } else { created_object = o as Control; if (created_object == null) { if (i == typeof(IReflectorCreate)) { created_object = new Control(); } } } Form form = (created_object as Form); if (form != null) { form.TopLevel = false; } //osalot.CreateWidget( where, "Button(1)", where.Size, c, created_object.Location = where.Location; created_object.Size = where.Size; created_object.Name = o.GetType().ToString() + "(" + (canvas.Controls.Count + 1) + ")"; created_object.TabIndex = 0; try { // web browser, is a control, but overrides text to 'not supported' exception? if (created_object.Text == null || created_object.Text == "") { created_object.Text = "A Control"; } } catch { } canvas.Controls.Add(created_object); created_object.Parent = canvas; created_object.Visible = false; ControlTracker tracker; { Control c = o as Control; if (c != null) { c.Paint += new PaintEventHandler(c_Paint); } } Add(tracker = new ControlTracker(created_object, rectangle, i, t, o, real)); return(tracker); } }