/// <summary> /// The on mouse move event handler /// Moves itself /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event arguments</param> protected void onMouseMoveEventHandler(object sender, MouseEventArgs e) { if (!isMoved) { return; } Left += e.X - mouseX; Top += e.Y - mouseY; if (Selected) { foreach (Control control in Desktop.Controls) { if (!(control is IObjectLabelUI)) { continue; } IObjectLabelUI comp = control as IObjectLabelUI; if (comp.Selected & comp != this) { comp.X += e.X - mouseX; comp.Y += e.Y - mouseY; } } } Desktop.Redraw(); }
private void addObjectNode(TreeNode parent, IObjectLabel label) { if (tree == null) { return; } NamedNode node = new NamedNode(label, false); if (label is IObjectLabelUI) { IObjectLabelUI lab = label as IObjectLabelUI; lab.Node = node; } parent.Nodes.Add(node); if (!(label.Object is IObjectContainer)) { return; } IObjectContainer cont = label.Object as IObjectContainer; IDesktop desk = cont.Desktop; Dictionary <string, object> t = cont.Interface; foreach (string str in t.Keys) { INamedComponent comp = desk[str]; NamedNode n = new NamedNode(comp, false); node.Nodes.Add(n); } }
/// <summary> /// Redraws all forms /// </summary> internal void Redraw() { foreach (Control c in desktop.Controls) { if (!(c is IObjectLabelUI)) { continue; } IObjectLabelUI label = c as IObjectLabelUI; Form f = null; if (label is IShowForm) { IShowForm sf = label as IShowForm; f = sf.Form as Form; } if (f == null) { Redraw(c); continue; } if (f.IsDisposed) { Redraw(c); continue; } if (!(f is IRedraw)) { continue; } IRedraw r = f as IRedraw; r.Redraw(); } }
/// <summary> /// Saves label /// </summary> /// <param name="label">The label</param> /// <param name="info">Serialization info</param> public static void Save(IObjectLabelUI label, SerializationInfo info) { info.AddValue("X", label.X, typeof(int)); info.AddValue("Y", label.Y, typeof(int)); Control c = label.Control as Control; info.AddValue("Width", c.Width, typeof(int)); info.AddValue("Height", c.Height, typeof(int)); }
/// <summary> /// Loads label /// </summary> /// <param name="label">The label</param> /// <param name="info">Serialization info</param> public static void Load(IObjectLabelUI label, SerializationInfo info) { label.X = (int)info.GetValue("X", typeof(int)); label.Y = (int)info.GetValue("Y", typeof(int)); Control c = label.Control as Control; c.Width = (int)info.GetValue("Width", typeof(int)); c.Height = (int)info.GetValue("Height", typeof(int)); }
/// <summary> /// Sets control of the object /// </summary> /// <param name="categoryObject">The object</param> /// <param name="control">The control</param> /// <returns>True in case of succces and false otherwise</returns> static public bool SetControl(this ICategoryObject categoryObject, Control control) { IUIFactory factory = StaticExtensionDiagramUIFactory.UIFactory; IObjectLabelUI label = factory.CreateLabel(categoryObject); if (label == null) { return(false); } label.SetControl(control); return(true); }
/// <summary> /// Creates object label /// </summary> /// <param name="button">Corresponding button</param> /// <returns>The object label</returns> public virtual IObjectLabelUI CreateObjectLabel(IPaletteButton button) { foreach (IUIFactory f in factories) { IObjectLabelUI o = f.CreateObjectLabel(button); if (o != null) { return(o); } } if (defaultValue) { return(factory.CreateObjectLabel(button)); } return(null); }
/// <summary> /// Removes object node /// </summary> /// <param name="label">The object label</param> public void RemoveObjectNode(IObjectLabelUI label) { if (tree == null) { return; } try { TreeNode n = label.Node as TreeNode; objectsNode.Nodes.Remove(n); } catch (Exception ex) { ex.ShowError(10); } }
/// <summary> /// Sets new name /// </summary> /// <param name="name">The name</param> public void SetName(string name) { if (component is NamedComponent) { NamedComponent comp = component as NamedComponent; comp.SetName(name); } else if (component is IObjectLabelUI) { IObjectLabelUI olui = component as IObjectLabelUI; olui.ComponentName = name; } else if (component is IArrowLabelUI) { IArrowLabelUI alui = component as IArrowLabelUI; alui.ComponentName = name; } }
private void MMouseMove(object sender, MouseEventArgs e) { Control caption = sender as Control; if (!pDesktop.Tools.IsMoved) { return; } if (!IsMoved) { return; } Control c = caption; int dx = e.X - mouseX; int dy = e.Y - mouseY; //c.Left += dx; //c.Top += dy; label.X += dx; label.Y += dy; PanelDesktop d = label.Desktop as PanelDesktop; if (label.Selected) { foreach (Control control in pDesktop.Controls) { if (control is IObjectLabelUI) { IObjectLabelUI olui = control as IObjectLabelUI; if (olui.Selected) { if (olui != label) { olui.X += dx; olui.Y += dy; } } } } } d.Redraw(); }
/// <summary> /// Creates object label from object /// </summary> /// <param name="obj">The object</param> /// <returns>The label</returns> public virtual IObjectLabelUI CreateLabel(ICategoryObject obj) { foreach (IUIFactory f in factories) { IObjectLabelUI o = f.CreateLabel(obj); if (o != null) { return(o); } } if (defaultValue) { IObjectLabelUI o = factory.CreateObjectLabel(obj); if (o != null) { return(o); } } return(null); }
/// <summary> /// Gets image of component /// </summary> /// <param name="component">The component</param> /// <returns>The image</returns> public static Image GetImage(INamedComponent component) { if (component is IObjectLabelUI) { IObjectLabelUI l = component as IObjectLabelUI; return(l.Image as Image); } if (component is IObjectLabel) { IObjectLabel l = component as IObjectLabel; object o = l.Object; if (o is MultiLibraryObject) { return(ResourceImage.MultiInterface.ToBitmap()); } } IPaletteButton button = GetButton(component); return(button.ButtonImage as Image); }
/// <summary> /// Constructor /// </summary> /// <param name="label">Associated label</param> /// <param name="caption">Caption control</param> /// <param name="captionEditor">Caption editor</param> /// <param name="post">The "Post" acion</param> /// <param name="resize">The Resize event handler</param> public NonstandardLabel(IObjectLabelUI label, Control[] caption, TextBox captionEditor, Action post, EventHandler resize) { this.label = label; this.caption = caption; this.captionEditor = captionEditor; this.post = post; this.resize = resize; x = label.X; y = label.Y; Control c = label.Control as Control; w = c.Width; h = c.Height; if (captionEditor != null) { captionEditor.KeyUp += KeyUp; } // box = new MovedBox(label); rbox = new ResizeBox(label); c.Paint += Paint; }
/// <summary> /// Sets control /// </summary> /// <param name="label">Label</param> /// <param name="control">Control</param> static public void SetControl(this IObjectLabelUI label, Control control) { UserControlBaseLabel bl = (label as Control).FindChild <UserControlBaseLabel>(); foreach (Control cc in bl.Controls) { string ccn = cc.Name; if (ccn.Equals("panelCenter")) { Control contr = null; foreach (Control ccc in cc.Controls) { contr = ccc; break; } cc.Controls.Remove(contr); contr.Dock = DockStyle.Fill; control.Controls.Add(contr); return; } } }
private void buttonOK_Click(object sender, System.EventArgs e) { int ord = label.Ord; try { int n = listBoxComponents.SelectedIndex; if (label is IObjectLabelUI) { IObjectLabelUI l = label as IObjectLabelUI; l.Ord = n; } if (label is IArrowLabelUI) { IArrowLabelUI l = label as IArrowLabelUI; l.Ord = n; } desktop.CheckOrder(); Dispose(); } catch (Exception ex) { ex.ShowError(10); if (label is IObjectLabelUI) { IObjectLabelUI l = label as IObjectLabelUI; l.Ord = ord; } if (label is IArrowLabelUI) { IArrowLabelUI l = label as IArrowLabelUI; l.Ord = ord; } this.ShowError(ex, Diagram.UI.Utils.ControlUtilites.Resources); } }
/// <summary> /// Removes itself /// </summary> /// <param name="removeForm">The "remove form" sign</param> public void Remove(bool removeForm) { Control cp = Parent; if (cp != null) { if (cp.Controls.Contains(rbox)) { cp.Controls.Remove(rbox); } } if (removeForm) { if (label is IShowForm) { IShowForm sf = label as IShowForm; Form form = sf.Form as Form; if (form is IRemovableObject) { IRemovableObject r = form as IRemovableObject; r.RemoveObject(); } sf.RemoveForm(); sf = null; } } if (isRemoved) { return; } isRemoved = true; if (label is IRemovableObject) { IRemovableObject r = label as IRemovableObject; r.RemoveObject(); } Control cont = label as Control; Control c = Parent; if (c != null) { PanelDesktop d = pDesktop; if (c.Controls.Contains(cont)) { d.Remove(label); if (c.Controls.Contains(cont)) { c.Controls.Remove(cont); } } } if (label.Object is IRemovableObject) { IRemovableObject obj = label.Object as IRemovableObject; obj.RemoveObject(); obj = null; } cont.Dispose(); label = null; cont = null; GC.Collect(); }
/// <summary> /// Constructor /// </summary> /// <param name="label">Associated label</param> public MovedBox(IObjectLabelUI label) : this() { this.label = label; }
private void MouseUp(object sender, MouseEventArgs e) { Control caption = sender as Control; IsMoved = false; pDesktop.SetBlocking(false); PanelDesktop Desktop = pDesktop; ICategoryArrow arrow = Desktop.ActiveArrow; if (!StaticExtensionDiagramUIForms.IsArrowClick(e)) { return; } try { if (arrow == null) { pDesktop.Redraw(); return; } int x = this.label.X + caption.Left + e.X; int y = this.label.Y + caption.Top + e.Y; for (int i = 0; i < Desktop.Controls.Count; i++) { if (!(Desktop.Controls[i] is IChildObjectLabel) & !(Desktop.Controls[i] is IObjectLabelUI)) { continue; } Control c = Desktop.Controls[i]; bool hor = x <c.Left | x> c.Left + c.Width; bool vert = y <c.Top | y> c.Top + c.Height; if (hor | vert) { continue; } IObjectLabel label = null; if (Desktop.Controls[i] is IObjectLabelUI) { label = Desktop.Controls[i] as IObjectLabel; } else { IChildObjectLabel child = Desktop.Controls[i] as IChildObjectLabel; label = child.Label; } arrow.Target = label.Object; IArrowLabel lab = Desktop.Tools.Factory.CreateArrowLabel(Desktop.Tools.Active, arrow, this.label, label); lab.Arrow.SetAssociatedObject(lab); Desktop.AddArrowLabel(lab); break; } } catch (Exception ex) { ex.ShowError(10); if (arrow != null) { if (arrow is IRemovableObject) { IRemovableObject rem = arrow as IRemovableObject; rem.RemoveObject(); } } ex.ShowError(1); } Desktop.ActiveArrow = null; Desktop.Redraw(); }
/// <summary> /// Constructor /// </summary> /// <param name="label">Associated label</param> public ResizeBox(IObjectLabelUI label) : this() { this.label = label; }