object IObjectCollection.this[string name] { get { foreach (object o in list) { if (o is IAssociatedObject) { string n = this.GetRelativeName(o as IAssociatedObject); if (n.Equals(name)) { if (o is ICategoryObject | o is ICategoryArrow) { return(o); } } } if (o is IObjectLabel) { IObjectLabel ol = o as IObjectLabel; return(ol.Object); } if (o is IArrowLabel) { IArrowLabel al = o as IArrowLabel; return(al.Arrow); } } return(null); } }
/// <summary> /// Constructor /// </summary> /// <param name="theLabel">The arrow label</param> public ArrowPanel(IArrowLabel theLabel) { PictureBox box = new PictureBox(); box.Left = 5; box.Top = y + 5; Image im = NamedComponent.GetImage(theLabel); box.Width = im.Width; box.Height = im.Height; box.Image = im; Controls.Add(box); Label label = new Label(); label.Top = box.Top; label.Left = box.Left + box.Width + 5; label.Text = theLabel.RootName; //NamedComponent.GetText(theLabel); Controls.Add(label); objects = new IObjectLabel[2]; objects[0] = theLabel.Source; objects[1] = theLabel.Target; y = box.Top + box.Height; Name = theLabel.RootName; //NamedComponent.GetText(theLabel) + ""; initialize(); }
/// <summary> /// Gets objects and arrows of associated object /// </summary> /// <param name="ao">The associated object</param> /// <param name="objects">Objects</param> /// <param name="arrows">Arrows</param> protected virtual void GetObjects(IAssociatedObject ao, IList <ICategoryObject> objects, IList <ICategoryArrow> arrows) { if (ao is IObjectContainer) { IObjectContainer oc = ao as IObjectContainer; IDesktop d = oc.Desktop; IEnumerable <object> c = d.AllComponents; foreach (object o in c) { if (o is IObjectLabel) { IObjectLabel ol = o as IObjectLabel; GetObjects(ol.Object, objects, arrows); } if (o is IArrowLabel) { IArrowLabel al = o as IArrowLabel; GetObjects(al.Arrow, objects, arrows); } } } else { GetObjectsPrivate(ao, objects, arrows); } }
/// <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> /// Composition of path arrows /// </summary> /// <param name="category">Category of arrows</param> /// <param name="path">The path</param> /// <returns>The composition</returns> static public IAdvancedCategoryArrow Composition(ICategory category, DigraphPath path) { IArrowLabel label = path[0].Object as IArrowLabel; IAdvancedCategoryArrow arrow = label.Arrow as IAdvancedCategoryArrow; for (int i = 1; i < path.Count; i++) { label = path[i].Object as IArrowLabel; arrow = (label.Arrow as IAdvancedCategoryArrow).Compose(category, arrow); } return(arrow); }
/// <summary> /// Updates form UI /// </summary> public void UpdateFormUI() { if (component == null) { return; } Text = component.RootName; //NamedComponent.GetText(component) + ""; if (!(component is IArrowLabel)) { return; } IArrowLabel label = component as IArrowLabel; this.labelSource.Text = label.Source.RootName; //NamedComponent.GetText(label.Source) + ""; this.labelTarget.Text = label.Target.RootName; //NamedComponent.GetText(label.Target) + ""; }
/// <summary> /// Default constructor /// </summary> /// <param name="component">Corresponding component</param> public DefaultForm(INamedComponent component) { InitializeComponent(); this.component = component; this.LoadControlResources(ControlUtilites.Resources); //, Resources); UpdateFormUI(); pictureBoxObject.Image = NamedComponent.GetImage(component); labelH.Text = NamedComponent.GetToolTip(component); object o = null; if (component is IObjectLabel) { IObjectLabel l = component as IObjectLabel; o = l.Object; } if (component is IArrowLabel) { IArrowLabel l = component as IArrowLabel; o = l.Arrow; } if (!(o is IUpdatableObject)) { checkBoxUpdatable.Visible = false; } else { IUpdatableObject upd = o as IUpdatableObject; if (upd.ShouldUpdate) { checkBoxUpdatable.Checked = true; } } if (!(component is IArrowLabel)) { this.labelSourceH.Visible = false; this.labelTargetH.Visible = false; return; } IArrowLabel label = component as IArrowLabel; pictureBoxSource.Image = NamedComponent.GetImage(label.Source); pictureBoxTarget.Image = NamedComponent.GetImage(label.Target); }
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> /// Constructor /// </summary> /// <param name="label">Arrow label</param> public FormAggregateLink(IArrowLabel label) : this() { this.label = label; UpdateFormUI(); link = label.Arrow as MechanicalAggregateLink; try { pictureBoxParent.Image = NamedComponent.GetImage(label.Target); pictureBoxChild.Image = NamedComponent.GetImage(label.Source); } catch (Exception ex) { ex.ShowError(10); } source = link.SourceObject; target = link.TargetObject; int nt = target.NumberOfConnections; int ns = source.NumberOfConnections; if (nt == 0) { numericUpDownChild.Enabled = false; } else { numericUpDownChild.Minimum = 1; numericUpDownChild.Maximum = source.NumberOfConnections; numericUpDownChild.Value = link.SourceConnection + 1; } if (nt == 0) { numericUpDownParent.Enabled = false; } else { numericUpDownParent.Minimum = 1; numericUpDownParent.Maximum = target.NumberOfConnections; numericUpDownParent.Value = link.TargetConnection + 1; } first = false; }
/// <summary> /// Gets full list of desktop components /// </summary> /// <param name="desktop">Desktop</param> /// <param name="objects">Objects</param> /// <param name="arrows">Arrows</param> static public void GetFullList(IDesktop desktop, out List <IObjectLabel> objects, out List <IArrowLabel> arrows) { objects = new List <IObjectLabel>(); arrows = new List <IArrowLabel>(); List <INamedComponent> list = new List <INamedComponent>(); foreach (INamedComponent c in list) { if (c is IObjectLabel) { IObjectLabel l = c as IObjectLabel; objects.Add(l); } if (c is IArrowLabel) { IArrowLabel l = c as IArrowLabel; arrows.Add(l); } } }
private void checkBoxUpdatable_CheckedChanged(object sender, System.EventArgs e) { object o = null; if (component is IObjectLabel) { IObjectLabel lab = component as IObjectLabel; o = lab.Object; } else if (component is IArrowLabel) { IArrowLabel lab = component as IArrowLabel; o = lab.Arrow; } if (o is IUpdatableObject) { IUpdatableObject updatable = o as IUpdatableObject; updatable.ShouldUpdate = checkBoxUpdatable.Checked; } }
/// <summary> /// Finds required button /// </summary> /// <param name="nc">Corresponding component</param> /// <returns>The button</returns> public IPaletteButton FindButton(INamedComponent nc) { string type = nc.Type; if (type == null) { type = ""; } if (type.Length == 0) { if (nc is IObjectLabel) { IObjectLabel l = nc as IObjectLabel; object o = l.Object; if (o != null) { type = o.GetType() + ""; } } } if (type.Length == 0) { if (nc is IArrowLabel) { IArrowLabel l = nc as IArrowLabel; object o = l.Arrow; if (o != null) { type = o.GetType() + ""; } } } if (type.Length == 0) { return(null); } return(FindButton(type, nc.Kind)); }
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); } }
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(); }
IComponentCollection CreateCollection(IEvent ev) { IComponentCollection cc = dCollection[ev]; List <IEventBlock> bl = new List <IEventBlock>(); cc.ForEach <IEventBlock>((IEventBlock block) => { if (block[ev]) { bl.Add(block); } }); if (bl.Count == 0) { return(cc); } IDesktop d = cc.Desktop; List <object> l = new List <object>(); foreach (object o in bl) { if (!l.Contains(bl)) { l.Add((o as IAssociatedObject).Object); } Func <ICategoryObject, bool> fca = (ICategoryObject cao) => { return(true); }; Func <ICategoryArrow, bool> fcar = (ICategoryArrow car) => { return(true); }; List <ICategoryObject> cl = (o as ICategoryObject).GetSourceObjects(fca, fcar, fcar); foreach (ICategoryObject co in cl) { object ob = co.Object; if (!l.Contains(ob)) { l.Add(ob); } } } IEnumerable <object> en = cc.AllComponents; List <object> ls = new List <object>(); foreach (object oo in en) { if (oo is IArrowLabel) { IArrowLabel al = oo as IArrowLabel; if (l.Contains(al.Source) | l.Contains(al.Target)) { continue; } } if (!l.Contains(oo)) { ls.Add(oo); } else { } } ComponentCollection ccl = new ComponentCollection(ls, d); dCollection[ev] = ccl; return(ccl); }
/// <summary> /// Checks whether arrow belongs to this pair /// </summary> /// <param name="l">The arrow label</param> /// <returns>True if belongs and false otherwise</returns> public bool Belongs(IArrowLabel l) { return(Belongs(l.Source) & Belongs(l.Target)); }
/// <summary> /// Creates property editor from of desktop component /// </summary> /// <param name="comp">The component</param> /// <returns>The property editor</returns> public override object CreateForm(INamedComponent comp) { // Checks whether component is an arrow if (comp is IArrowLabel) { IArrowLabel lab = comp as IArrowLabel; ICategoryArrow arrow = lab.Arrow; /*!!! FOR ARTICLE SAMPLE if (arrow is Motion6D.MechanicalAggregateLink) * { * return new Motion6D.UI.FormAggregateLink(lab); * }*/ } // The component is an object if (comp is IObjectLabel) { IObjectLabel lab = comp as IObjectLabel; // The object of component ICategoryObject obj = lab.Object; Form form = ToolsDiagram.CreateEditorForm(obj); if (form != null) { return(form); } // Creation of iterator property editor if (obj is Regression.IteratorGLM) { return(new FormIterateGLM(lab)); } // Creation of VectorFormulaConsumer property editor if (obj is VectorFormulaConsumer) { return(new DataPerformer.UI.Forms.FormVectorConsumer(lab)); } if (obj.GetType().Equals(typeof(DataPerformer.Series))) { object[] array = new object[] { (int)0, System.Drawing.Color.Red, new System.Collections.ICollection[0], true }; return(new DataPerformer.UI.Forms.FormSeries(lab, array)); } if (obj is Table3D) { return(new DataPerformer.UI.Forms.FormTable3D(lab)); } if (obj is DataPerformer.Helpers.DataPerformerCollectionStateTransformer) { return(new DataPerformer.UI.Forms.FormDataPerformerCollectionStateTransformer(lab)); } if (obj is MatrixAssembly) { return(new DataPerformer.UI.FormMatrixAssembly(lab)); } if (obj is VectorAssembly) { return(new FormVectorAssembly(lab)); } if (obj is ArrayDisassembly) { return(new FormArrayDisassembly(lab)); } if (obj is ArrayTransformer) { return(new DataPerformer.UI.Forms.FormArrayTransformer(lab)); } if (obj is DataPerformer.ObjectTransformer) { return(new DataPerformer.UI.Forms.FormObjectTransformer(lab)); } if (obj is Chart.Objects.DrawSeries) { return(new DataPerformer.UI.FormPointCollection(lab)); } if (obj is DataPerformer.Helpers.KalmanFilter) { return(new DataPerformer.UI.Forms.FormKalmanFilter(lab)); } if (obj is FunctionAccumulator) { return(new DataPerformer.UI.Forms.FormFuncAccumulator(lab)); } if (obj is Regression.CombinedSelection) { return(new FormCombinedSelection(lab)); } if (obj is FormulaFilterIterator) { return(new DataPerformer.UI.FormIteratorFilter(lab)); } if (obj is DifferentialEquationSolver) { return(new DataPerformer.UI.Forms.FormDiffEquation(lab)); } if (obj is Recursive) { return(new DataPerformer.UI.Forms.FormRecursive(lab)); } if (obj is Regression.XmlSelectionCollection) { return(new DataPerformer.UI.FormXmlSelection(lab)); } if (obj is Regression.AliasRegression) { return(new DataPerformer.UI.Forms.FormAliasRegression(lab)); } } 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(); }
private bool load(Stream stream, SerializationBinder binder, bool post) { stream.Position = 0; BinaryFormatter bformatter = new BinaryFormatter(); if (binder != null) { bformatter.Binder = binder; } try { objects = new List <IObjectLabel>(); arrows = new List <IArrowLabel>(); ArrayList objs = bformatter.Deserialize(stream) as ArrayList; ArrayList arrs = bformatter.Deserialize(stream) as ArrayList; if (objs != null) { objects = new List <IObjectLabel>(); foreach (IObjectLabel l in objs) { objects.Add(l); } } if (arrs != null) { arrows = new List <IArrowLabel>(); foreach (IArrowLabel l in arrs) { arrows.Add(l); } } foreach (object o in objects) { if (o is INamedComponent) { INamedComponent nc = o as INamedComponent; nc.Desktop = this; string n = nc.Name; if (!table.ContainsKey(n)) { table[n] = nc; } } if (o is IObjectLabel) { IObjectLabel l = o as IObjectLabel; object os = l.Object; if (os is IAssociatedObject) { IAssociatedObject ass = os as IAssociatedObject; ass.Object = l; PostSetObject(ass); } if (os is IObjectContainer) { IObjectContainer oc = os as IObjectContainer; bool lb = oc.Load(); if (!lb) { return(false); } } } } foreach (object o in arrows) { if (o is INamedComponent) { if (o is IArrowLabel) { IArrowLabel l = o as IArrowLabel; object os = l.Arrow; if (os is IAssociatedObject) { IAssociatedObject ass = os as IAssociatedObject; ass.Object = l; PostSetObject(ass); } } INamedComponent nc = o as INamedComponent; string n = nc.Name; if (!table.ContainsKey(n)) { table[n] = nc; } nc.Desktop = this; } } if (post) { bool b = PostLoad(); if (!b) { return(false); } return(PostDeserialize()); } return(true); } catch (Exception ex) { ex.ShowError(10); if (exceptions != null) { exceptions.Add(ex); } } return(false); }