private void SetControl(object obj) { if (obj is Control) { Control c = obj as Control; c.Dock = DockStyle.Fill; panelCenter.Controls.Add(c); } if (obj is IObjectLabel) { child = obj as IObjectLabel; if (icon == null) { if (child is INonstandardLabel) { INonstandardLabel nl = child as INonstandardLabel; Image im = nl.Image as Image; if (im != null) { icon = im; pictureBoxIcon.Image = im; } } } properties = child; } }
/// <summary> /// Resize operation /// </summary> /// <param name="sender">Sender</param> /// <param name="args">Arguments</param> new protected virtual void Resize(object sender, EventArgs args) { if (child is INonstandardLabel) { INonstandardLabel l = child as INonstandardLabel; l.Resize(); } }
/// <summary> /// Post operation /// </summary> protected virtual void Post() { Init(); if (child is INonstandardLabel) { INonstandardLabel l = child as INonstandardLabel; l.Post(); } }
/// <summary> /// Creates form /// </summary> protected virtual void CreateForm() { if (form != null) { if (!form.IsDisposed) { return; } } if (child == null) { return; } if (!(child is INonstandardLabel)) { return; } INonstandardLabel l = child as INonstandardLabel; l.CreateForm(); form = l.Form as Form; Icon ico = Icon; if (form != null) { if (!form.IsDisposed) { if (ico != null) { form.Icon = ico; } Action <Form> act = StaticExtensionDiagramUIForms.PostFormLoad; if (act != null) { act(form); } form.FormClosing += (object sender, FormClosingEventArgs e) => { form.Prepare(); }; if (form is IUpdatableForm) { (form as IUpdatableForm).UpdateFormUI(); } } } }
/// <summary> /// Initialization /// </summary> public virtual void Init() { if (isInitialized) { return; } isInitialized = true; if (child is INonstandardLabel) { INonstandardLabel l = child as INonstandardLabel; l.Initialize(); } mainPanel = panelCenter; textBrush = new SolidBrush(Color.White); font = (Font)captionEditor.Font.Clone(); hLab = new NonstandardLabel(this, new Control[] { panelTop, pictureBoxIcon }, captionEditor, Post, Resize); panelTop.MouseDown += EditorMouseDown; panelTop.Paint += OnPaint; sel = new Panel[] { panelLeft, panelRight, panelBottom }; }
/// <summary> /// Creates Wrapper /// </summary> /// <param name="label">Wrapped label</param> /// <param name="icon">Icon</param> /// <param name="changeSize">The "change size" sign</param> /// <returns>Wrapper</returns> internal static UserControlLabel CreateLabel(IObjectLabel label, object icon, bool changeSize) { UserControlLabel l = new UserControlLabel(); if (changeSize) { if (label is Control) { Control c = label as Control; if (c.Width > l.panelCenter.Width) { l.Width += c.Width - l.panelCenter.Width; } if (c.Height > l.panelCenter.Height) { l.Height += c.Height - l.panelCenter.Height; } } } Image ic = icon as Image; if (ic == null) { if (label is INonstandardLabel) { INonstandardLabel nl = label as INonstandardLabel; ic = nl.Image as Image; } } l.icon = ic; l.pictureBoxIcon.Image = l.image; IProperties p = l; p.Properties = label; if (label is Control) { Control c = label as Control; c.Parent = l.panelCenter; } return(l); }