/// <summary> /// Throws exception if endpoints of two arrows do not coincide /// </summary> /// <param name="x">First arrow</param> /// <param name="y">Second arrow</param> static public void ThrowEndpointsException(ICategoryArrow x, ICategoryArrow y) { if ((x.Source != y.Source) | (x.Target != y.Target)) { throw new CategoryException(EndpointsOfTwoArrowsError); } }
/// <summary> /// The on mouse down event handler /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event arguments</param> private void onMouseDownMoveEventHandler(object sender, MouseEventArgs e) { if (!e.IsArrowClick()) { return; } IObjectLabel lab = Label; if (lab == null) { return; } PanelDesktop desktop = Parent as PanelDesktop; PaletteButton active = desktop.Tools.Active; if (active != null) { if (active.IsArrow & !(active.ReflectionType == null)) { try { ICategoryArrow arrow = desktop.Tools.Factory.CreateArrow(active); arrow.Source = lab.Object; desktop.ActiveArrow = arrow; desktop.ActiveObjectLabel = lab; return; } catch (Exception ex) { ex.ShowError(10); } } } }
/// <summary> /// Checks connection between first and next arrow /// </summary> /// <param name="first">The first arrow</param> /// <param name="next">The next arrow</param> static public void CheckArrowConnection(this ICategoryArrow first, ICategoryArrow next) { if (first.Source != next.Target) { throw new CategoryException(TargetSourceArrow); } }
/// <summary> /// Creates a form for component properties editor /// </summary> /// <param name="comp">The component</param> /// <returns>The result form</returns> public override object CreateForm(INamedComponent comp) { if (comp is IObjectLabel) { IObjectLabel lab = comp as IObjectLabel; // The object of component ICategoryObject obj = lab.Object; if (obj is Motion6D.SerializablePosition) { Motion6D.Interfaces.IPosition p = obj as Motion6D.Interfaces.IPosition; object o = p.Parameters; if (o != null) { if (o is Motion6D.PhysicalFieldBase) { return(new Motion6D.UI.Forms.FormField3D(lab, o as Motion6D.PhysicalField3D)); } if (o is PhysicalField.SphericalFieldWrapper) { return(new Motion6D.UI.FormSphericalMagnnetic(lab, o as PhysicalField.SphericalFieldWrapper)); } if (o is Motion6D.InertialSensorData) { return(new Motion6D.UI.FormInertialSystem(lab, o as Motion6D.InertialSensorData)); } } } if (obj is Motion6D.InertialReferenceFrame) { return(new Motion6D.UI.FormInertia(lab)); } if (obj is Motion6D.ReferenceFrameData) { return(new Motion6D.UI.Forms.FormFrameData(lab)); } if (obj is Motion6D.RigidReferenceFrame) { return(new Motion6D.UI.Forms.FormRigidFrame(lab)); } if (obj is Motion6D.AcceleratedPosition) { return(new Motion6D.UI.FormAcceleratedPoint(lab)); } if (obj is Motion6D.PositionCollectionData) { return(new FormPointsCollection(lab)); } } if (comp is IArrowLabel) { IArrowLabel l = comp as IArrowLabel; ICategoryArrow arrow = l.Arrow; if (arrow is MechanicalAggregateLink) { return(new FormAggregateLink(l)); } } return(null); }
/// <summary> /// Sets labels /// </summary> /// <param name="c">Collection of arrows</param> static public void SetLabels(IEnumerable <IArrowLabel> c) { foreach (IArrowLabel l in c) { ICategoryArrow a = l.Arrow; a.SetAssociatedObject(l); } }
/// <summary> /// Constructor /// </summary> /// <param name="button">Associated button</param> /// <param name="arrow">Associated arrow</param> /// <param name="source">Associated source</param> /// <param name="target">Associated target</param> public ArrowLabel(IPaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target) : base(button) { this.arrow = arrow; this.source = source; this.target = target; Initialize(); }
void Load() { byte[] bytesOut; Assembly ass = LibraryObjectWrapper.Load(bytes, out bytesOut); IArrowFactory f = GetFactory(ass); theArrow = f[name]; ICategoryArrow arr = this; theArrow.SetAssociatedObject(arr.Object); }
/// <summary> /// Crerates arrow label from arrow /// </summary> /// <param name="arr">The arrow</param> /// <returns>The label</returns> public virtual IArrowLabelUI CreateLabel(ICategoryArrow arr) { foreach (IUIFactory f in factories) { IArrowLabelUI a = f.CreateLabel(arr); if (a != null) { return(a); } } return(null); }
/// <summary> /// Gets button from arrow /// </summary> /// <param name="arrow">The arrow</param> /// <returns>The arrow</returns> public virtual IPaletteButton GetArrowButton(ICategoryArrow arrow) { foreach (IUIFactory f in factories) { IPaletteButton b = f.GetArrowButton(arrow); if (b != null) { return(b); } } return(null); }
/// <summary> /// Creates desktop from Xml documet /// </summary> /// <param name="document">The document</param> /// <param name="create">The create function</param> /// <returns>The desktop</returns> public static PureDesktopPeer LoadFromXml(this XmlDocument document, Func <XmlElement, object> create) { PureDesktopPeer desktop = new PureDesktopPeer(); Dictionary <string, IObjectLabel> dictionary = new Dictionary <string, IObjectLabel>(); XmlElement objs = document.GetElementsByTagName("Objects")[0] as XmlElement; foreach (XmlElement e in objs.ChildNodes) { string name = e.GetAttribute("Name"); object o = create(e); if (o == null) { continue; } string t = o.GetType() + ""; string k = ""; if (t.Equals("DataPerformer.DataLink") | t.Equals("DataPerformer.VectorFormulaConsumer")) { k = "Mv"; } PureObjectLabelPeer l = new PureObjectLabelPeer(name, k, t, 0, 0); dictionary[name] = l; desktop.AddObjectLabel(l, o as ICategoryObject, true); l.Desktop = desktop; } XmlElement arrs = document.GetElementsByTagName("Arrows")[0] as XmlElement; foreach (XmlElement e in arrs.ChildNodes) { string name = e.GetAttribute("Name"); ICategoryArrow a = create(e) as ICategoryArrow; if (a == null) { continue; } string s = e.GetAttribute("Source"); string t = e.GetAttribute("Target"); if (!dictionary.ContainsKey(s) | !dictionary.ContainsKey(t)) { continue; } try { desktop.AddArrowWithExistingLabels(a, dictionary[s], dictionary[t], name, ""); } catch (Exception) { } } return(desktop); }
/// <summary> /// Creates arrow label /// </summary> /// <param name="button">Corresponding button</param> /// <param name="arrow">Corresponding arrow</param> /// <param name="source">Soource label</param> /// <param name="target">Target label</param> /// <returns>The arrow label</returns> public virtual IArrowLabelUI CreateArrowLabel(IPaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target) { foreach (IUIFactory f in factories) { IArrowLabelUI a = f.CreateArrowLabel(button, arrow, source, target); if (a != null) { return(a); } } if (defaultValue) { return(factory.CreateArrowLabel(button, arrow, source, target)); } return(null); }
private void MouseDown(object sender, MouseEventArgs e) { if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { label.Selected = !label.Selected; return; } if (e.Button == MouseButtons.Right) { if (label is IShowForm) { IShowForm sf = label as IShowForm; sf.Show(); return; } } /* if (EditorRectangle.Contains(e.X, e.Y)) * { * return; * }*/ PaletteButton active = pDesktop.Tools.Active; if (active != null) { if (active.IsArrow & (active.ReflectionType != null)) { try { ICategoryArrow arrow = pDesktop.Tools.Factory.CreateArrow(active); arrow.Source = label.Object; pDesktop.ActiveArrow = arrow; pDesktop.ActiveObjectLabel = label; return; } catch (Exception ex) { ex.ShowError(10); return; } } } IsMoved = true; pDesktop.SetBlocking(true); mouseX = e.X; mouseY = e.Y; }
/// <summary> /// Adds arrow with existing source and target /// </summary> /// <param name="arrow">Arrow</param> /// <param name="source">Source</param> /// <param name="target">Target</param> /// <param name="name">Arrow name</param> /// <param name="kind">Arrow kind</param> /// <returns>Added arrow</returns> public IArrowLabel AddArrowWithExistingLabels(ICategoryArrow arrow, IObjectLabel source, IObjectLabel target, string name, string kind) { source.Object.Object = source; target.Object.Object = target; IArrowLabel arrowLabel = new PureArrowLabelPeer(name, kind, arrow.GetType().FullName, 0, 0); arrowLabel.Desktop = this; arrowLabel.Arrow = arrow; arrow.Object = arrowLabel; arrowLabel.Source = source; arrowLabel.Target = target; arrowLabel.Arrow = arrow; arrow.Source = source.Object; arrow.Target = target.Object; arrows.Add(arrowLabel); return(arrowLabel); }
public override object CreateForm(INamedComponent component) { if (component is IArrowLabel) { IArrowLabel lab = component as IArrowLabel; ICategoryArrow arrow = lab.Arrow; } if (component is IObjectLabel) { IObjectLabel lab = component as IObjectLabel; // The object of component ICategoryObject obj = lab.Object; if (obj is Services.MeteoService) { return(new Forms.FormMeteo(obj)); } } return(null); }
public override object CreateForm(INamedComponent comp) { if (comp is IArrowLabel) { IArrowLabel lab = comp as IArrowLabel; ICategoryArrow arrow = lab.Arrow; } if (comp is IObjectLabel) { IObjectLabel lab = comp as IObjectLabel; // The object of component ICategoryObject obj = lab.Object; if (obj is ControlSystems.Data.RationalTransformControlSystemData) { return(CreateControlSystemForm(lab)); } } return(null); }
/// <summary> /// The on mouse down event handler /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event arguments</param> protected void onMouseDownMoveEventHandler(object sender, MouseEventArgs e) { if ((ModifierKeys & Keys.Shift) == Keys.Shift) { return; } if (!StaticExtensionDiagramUIForms.IsArrowClick(e)) { return; } if (EditorRectangle.Contains(e.X, e.Y)) { return; } PaletteButton active = Desktop.Tools.Active; if (active != null) { if (active.IsArrow & active.ReflectionType != null) { try { ICategoryArrow arrow = Desktop.Tools.Factory.CreateArrow(active); arrow.Source = Object; Desktop.ActiveArrow = arrow; Desktop.ActiveObjectLabel = this; return; } catch (Exception ex) { ex.ShowError(10); return; } } } isMoved = true; Desktop.IsMoved = true; Desktop.SetBlocking(true); mouseX = e.X; mouseY = e.Y; }
/// <summary> /// Removes itself /// </summary> /// <param name="removeForm">The "should remove properties editor" flag</param> public void Remove(bool removeForm) { if (Desktop == null) { return; } Desktop.Tools.RemoveArrowNode(this); RemoveFromComponent(); pair.Remove(this); pair.Refresh(); if (removeForm) { RemoveForm(); } if (Arrow is IRemovableObject) { IRemovableObject obj = Arrow as IRemovableObject; obj.RemoveObject(); } arrow = null; GC.Collect(); }
public override void CheckOrder(IDesktop desktop) { Control desk = desktop as Control; foreach (Control c in desk.Controls) { if (!(c is ArrowLabel)) { continue; } ArrowLabel l = c as ArrowLabel; ICategoryArrow a = l.Arrow; if (!(a is DataLink)) { continue; } if (l.Source.Root.Ord < l.Target.Root.Ord) { a.Throw(new Exception(DataLink.SetProviderBefore)); } } }
private void buttonUpdate_Click(object sender, System.EventArgs e) { try { if (component is IObjectLabel) { IObjectLabel lab = component as IObjectLabel; ICategoryObject obj = lab.Object; if (obj is IUpdatableObject) { IUpdatableObject updatable = obj as IUpdatableObject; if (updatable.Update != null) { updatable.Update(); } } } else if (component is IArrowLabel) { IArrowLabel lab = component as IArrowLabel; ICategoryArrow arrow = lab.Arrow; if (arrow is IUpdatableObject) { IUpdatableObject updatable = arrow as IUpdatableObject; if (updatable.Update != null) { updatable.Update(); } } } } catch (Exception ex) { ex.ShowError(10); } }
/// <summary> /// Creates an arrow the corresponds to button /// </summary> /// <param name="button">The button</param> /// <returns>Created arrow</returns> public virtual ICategoryArrow CreateArrow(IPaletteButton button) { foreach (IUIFactory f in factories) { ICategoryArrow a = f.CreateArrow(button); if (a != null) { return(a); } } if (defaultValue) { Type t = button.ReflectionType; if (t != null) { ConstructorInfo cons = t.GetConstructor(new System.Type[0]); if (cons != null) { return(cons.Invoke(null) as ICategoryArrow); } } } return(null); }
/// <summary> /// Gets image of arrow /// </summary> /// <param name="arrow">The arrow</param> /// <returns>The image</returns> public static Image GetImage(ICategoryArrow arrow) { INamedComponent c = arrow.Object as INamedComponent; return(GetImage(c)); }
IArrowLabelUI IDefaultLabelFactory.CreateArrowLabel(IPaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target) { return(new ArrowLabel(button, arrow, source, target)); }
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> /// Creates arrow label /// </summary> /// <param name="button">Corresponding button</param> /// <param name="arrow">Corresponding arrow</param> /// <param name="source">Soource label</param> /// <param name="target">Target label</param> /// <returns>The arrow label</returns> public virtual IArrowLabelUI CreateArrowLabel(IPaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target) { return(null); }
/// <summary> /// Crerates arrow label from arrow /// </summary> /// <param name="arr">The arrow</param> /// <returns>The label</returns> public virtual IArrowLabelUI CreateLabel(ICategoryArrow arr) { return(null); }
/// <summary> /// Gets button from arrow /// </summary> /// <param name="arrow">The arrow</param> /// <returns>The arrow</returns> public virtual IPaletteButton GetArrowButton(ICategoryArrow arrow) { return(null); }
/// <summary> /// The on mouse up event handler /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event arguments</param> protected void onMouseUpMoveEventHandler(object sender, MouseEventArgs e) { isMoved = false; Desktop.IsMoved = false; Desktop.SetBlocking(false); ICategoryArrow arrow = Desktop.ActiveArrow; if (!e.IsArrowClick()) { return; } try { if (arrow == null) { Desktop.Redraw(); return; } int x = Left + e.X; int y = Top + e.Y; for (int i = 0; i < Desktop.Controls.Count; i++) { if (!(Desktop.Controls[i] is IChildObjectLabel) & !(Desktop.Controls[i] is IObjectLabel)) { 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 IObjectLabel) { 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); 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> /// The on mouse up event handler /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event arguments</param> protected void onMouseUpArrow(object sender, MouseEventArgs e) { //isMoved = false; PanelDesktop desktop = Parent as PanelDesktop; ICategoryArrow arrow = desktop.ActiveArrow; if (!StaticExtensionDiagramUIForms.IsArrowClick(e)) { return; } if (!(nc is IObjectLabel)) { return; } IObjectLabel ol = nc as IObjectLabel; ICategoryObject obj = ol.Object; try { if (arrow == null) { return; } int x = Left + e.X; int y = Top + e.Y; for (int i = 0; i < desktop.Controls.Count; i++) { if (!(desktop.Controls[i] is ChildObjectLabel) & !(desktop.Controls[i] is ObjectLabel)) { 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 IObjectLabel) { label = desktop.Controls[i] as IObjectLabel; } else { ChildObjectLabel child = desktop.Controls[i] as ChildObjectLabel; label = child.Label; } arrow.Target = label.Object; ArrowLabel lab = desktop.Tools.Factory.CreateArrowLabel(desktop.Tools.Active, arrow, ol, label) as ArrowLabel; lab.Arrow.Object = 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> /// Deserialization constructor /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Streaming context</param> public ArrowLabel(SerializationInfo info, StreamingContext context) : base(info, context) { arrow = (ICategoryArrow)info.GetValue("Arrow", typeof(object)); sourceNumber = (int)info.GetValue("SourceNumber", typeof(int)); targetNumber = (int)info.GetValue("TargetNumber", typeof(int)); }
/*public XmlElement CreateXml(XmlDocument doc) * { * XmlElement el = doc.CreateElement("SwitchLink"); * return el; * }*/ /// <summary> /// Composes this arrow "f" with next arrow "g" /// </summary> /// <param name="category"> The category of arrow</param> /// <param name="next"> The next arrow "g" </param> /// <returns>Composition "fg" </returns> public ICategoryArrow Compose(ICategory category, ICategoryArrow next) { return(null); }