/// <summary>
        /// Sets parents of objects
        /// </summary>
        /// <param name="desktop">The desktop</param>
        public void SetParents(IDesktop desktop)
        {
            IEnumerable <IObjectLabel> objs = desktop.Objects;
            INamedComponent            comp = null;

            foreach (IObjectLabel ol in objs)
            {
                if (ol.Object == this)
                {
                    comp = ol;
                    break;
                }
            }
            IEnumerable <object> objects = this.desktop.Components;

            foreach (INamedComponent nc in objects)
            {
                if (nc is IObjectLabel)
                {
                    IObjectLabel l = nc as IObjectLabel;
                    if (l.Object is IObjectContainer)
                    {
                        IObjectContainer oc = l.Object as IObjectContainer;
                        oc.Desktop.SetParents();
                    }
                }
                nc.Parent = comp;
            }
        }
示例#2
0
        /// <summary>
        /// Creates a form for component properties editor
        /// </summary>
        /// <param name="comp">The component</param>
        /// <returns>The result form</returns>
        public virtual object CreateForm(INamedComponent comp)
        {
            foreach (IUIFactory f in factories)
            {
                object form = f.CreateForm(comp);
                if (form != null)
                {
                    return(form);
                }
            }
            if (defaultValue)
            {
                StaticExtensionDiagramUIFactory.Factory.CreateDefaultForm(comp);
            }
            object o = null;

            if (comp is IObjectLabel)
            {
                o = (comp as IObjectLabel).Object;
            }
            else if (comp is IArrowLabel)
            {
                o = (comp as IArrowLabel).Arrow;
            }
            if (o is IPropertiesEditor)
            {
                object ob = (o as IPropertiesEditor).Editor;
                if (ob is object[])
                {
                    return((o as object[])[0]);
                }
                return(ob);
            }
            return(null);
        }
示例#3
0
        /// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="info">Serialization info</param>
        /// <param name="context">Streaming context</param>
        protected UserControlLabel(SerializationInfo info, StreamingContext context)
        {
            InitializeComponent();
            nc = this;
            NonstandardLabel.Load(this, info);
            bytes = PureDesktopPeer.LoadProperties(info);
            IProperties p = this;

            SetControl(p.Properties);
            if (child != null)
            {
                if (child is Control)
                {
                    Control c = child as Control;
                    c.Parent = panelCenter;
                }
            }
            try
            {
                icon = info.Deserialize <Image>("Icon");
                if (icon != null)
                {
                    pictureBoxIcon.Image = image;
                }
            }
            catch (Exception ex)
            {
                ex.ShowError(-1);
            }
            captionEditor.KeyUp += KeyUp;
        }
示例#4
0
        private void panelDrawing_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int n = comboBoxInter.SelectedIndex;

            if (n < 0)
            {
                return;
            }
            INamedComponent o = selected[n] as INamedComponent;

            blackPanels();
            if (table.ContainsKey(o))
            {
                object[] ob = table[o] as object[];
                Panel    p  = ob[0] as Panel;
                p.Left = e.X;
                p.Top  = e.Y;
                ob[1]  = this.textBoxComment.Text;
                return;
            }
            Panel pan = new Panel();

            pan.Width     = wP;
            pan.Height    = hP;
            pan.BackColor = Color.Red;
            pan.Left      = e.X;
            pan.Top       = e.Y;
            ToolTip t = new ToolTip();

            t.ShowAlways = true;
            t.SetToolTip(pan, o.GetName(desktop) + " :: " + textBoxComment.Text);
            panelDrawing.Controls.Add(pan);
            table[o] = new object[] { pan, textBoxComment.Text };
        }
示例#5
0
        /// <summary>
        /// Consructor
        /// </summary>
        /// <param name="desktop">Desktop</param>
        public FormOrder(PanelDesktop desktop)
        {
            InitializeComponent();
            this.LoadControlResources(ControlUtilites.Resources);
            this.desktop = desktop;
            IList <IObjectLabel> objs;
            IList <IArrowLabel>  arrs;

            desktop.GetSelected(out objs, out arrs);
            if (objs.Count != 0 | arrs.Count != 0)
            {
                if (objs.Count == 0)
                {
                    return;
                }
                else
                {
                    label = objs[0] as INamedComponent;
                }
            }
            else
            {
                label = objs[0] as INamedComponent;
            }
            labelObject.Text = label.Name;
            foreach (Control c in desktop.Controls)
            {
                if (!(c is INamedComponent))
                {
                    continue;
                }
                INamedComponent nc = c as INamedComponent;
                listBoxComponents.Items.Add(nc.Name);
            }
        }
示例#6
0
 /// <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    ol     = comp as IObjectLabel;
         ICategoryObject obj    = ol.Object;
         Camera          camera = obj.GetSimpleObject <Camera>();
         if (camera != null)
         {
         }
         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.Interfaces.IVisible)
                 {
                     Motion6D.Interfaces.IVisible v = o as Motion6D.Interfaces.IVisible;
                     object ob = factory.CreateForm(p, v);
                     if (ob != null)
                     {
                         if (ob is Form)
                         {
                             Form f = ob as Form;
                             return(f);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
示例#7
0
        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);
            }
        }
示例#8
0
 protected void AddNamedComponent(INamedComponent component)
 {
     if (!this.componentDictionary.ContainsKey(component.Name))
     {
         this.componentDictionary.Add(component.Name, component);
     }
 }
示例#9
0
        /// <summary>
        /// Checks whether str has prefix of component name
        /// </summary>
        /// <param name="ao">Relative object</param>
        /// <param name="obj">Object</param>
        /// <param name="str">String to check</param>
        /// <returns>The component and null otherwise</returns>
        static public INamedComponent PrefixComponent(IAssociatedObject ao, object obj, string str)
        {
            if (!(obj is IAssociatedObject))
            {
                return(null);
            }
            IAssociatedObject ass = obj as IAssociatedObject;

            if (!(ass.Object is INamedComponent))
            {
                return(null);
            }
            INamedComponent c = ass.Object as INamedComponent;
            int             n = str.LastIndexOf(".");
            string          s = str.Substring(0, n);

            if (s.Equals(ao.GetRelativeName(ass)))
            {
                return(c);
            }
            else
            {
                return(null);
            }
        }
示例#10
0
 /// <summary>
 /// Accepts arguments
 /// </summary>
 private void AcceptArguments()
 {
     foreach (IMeasurements measurements in this.measurements)
     {
         IAssociatedObject cont = measurements as IAssociatedObject;
         INamedComponent   c    = cont.Object as INamedComponent;
         string            name = c.Name;
         for (int i = 0; i < measurements.Count; i++)
         {
             IMeasurement measure = measurements[i];
             string       p       = name + "." + measure.Name;
             for (int j = 0; j < 2; j++)
             {
                 if (arguments[j].Equals(p))
                 {
                     input[j] = measure;
                     break;
                 }
             }
         }
     }
     hasDerivation = true;
     for (int i = 0; i < input.Length; i++)
     {
         IDerivation der = input[i] as IDerivation;
         if (der == null)
         {
             hasDerivation = false;
             break;
         }
     }
 }
示例#11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="component">Linked component</param>
 /// <param name="fullName">The "show full" name sign</param>
 public NamedNode(INamedComponent component, bool fullName)
 {
     this.component = component;
     if (component is NamedComponent)
     {
         NamedComponent comp = component as NamedComponent;
         comp.AddNode(this);
         Text = component.Name;
     }
     else
     {
         INamedComponent nc   = component;
         IDesktop        root = component.Root.Desktop;
         if (fullName)
         {
             Text = component.RootName;
         }
         else
         {
             Text = component.GetName(nc.Desktop);
         }
     }
     ImageIndex         = NamedComponent.GetImageNumber(component);
     SelectedImageIndex = ImageIndex;
 }
示例#12
0
 /// <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);
 }
示例#13
0
        /// <summary>
        /// Full iteration with all updates
        /// </summary>
        public void FullIterate()
        {
            UpdateSelections();
            INamedComponent nc = Object as INamedComponent;

            Iterate();
            SetAliases();
        }
示例#14
0
 /// <summary>
 /// Gets root UI desktop of component
 /// </summary>
 /// <param name="component">The component</param>
 /// <returns>The desktop</returns>
 public static PanelDesktop GetDesktop(INamedComponent component)
 {
     if (component.Desktop is PanelDesktop)
     {
         return(component.Desktop as PanelDesktop);
     }
     return(GetDesktop(component.Parent));
 }
示例#15
0
        /// <summary>
        /// Gets all measurements of one dimension real array
        /// </summary>
        /// <param name="ao">Associated object</param>
        /// <returns>Names of measurements</returns>
        public static string[] GetOneDimensionRealArrays(this IAssociatedObject ao)
        {
            INamedComponent nc = null;

            if (ao is INamedComponent)
            {
                nc = ao as INamedComponent;
            }
            else
            {
                nc = ao.Object as INamedComponent;
            }
            IDesktop desktop = nc.Root.Desktop;

            if (desktop == null)
            {
                desktop = nc.Desktop;
            }
            if (desktop == null)
            {
                return(new string[0]);
            }
            List <string> l = new List <string>();

            desktop.ForEach <IMeasurements>((IMeasurements m) =>
            {
                IAssociatedObject aob = m as IAssociatedObject;
                INamedComponent ncm   = aob.Object as INamedComponent;
                string nm             = ncm.GetName(desktop);
                for (int i = 0; i < m.Count; i++)
                {
                    IMeasurement mea = m[i];
                    if (mea == null)
                    {
                        continue;
                    }
                    object t = mea.Type;
                    if (!(t is ArrayReturnType))
                    {
                        continue;
                    }
                    ArrayReturnType art = t as ArrayReturnType;
                    Double a            = 0;
                    if (!art.ElementType.Equals(a))
                    {
                        continue;
                    }
                    if (art.Dimension.Length != 1)
                    {
                        continue;
                    }
                    l.Add(nm + "." + mea.Name);
                }
            });
            return(l.ToArray());
        }
示例#16
0
        public T FindNamedComponentAs <T>(string name)
        {
            INamedComponent namedComponent = null;

            if (this.componentDictionary.TryGetValue(name, out namedComponent) && namedComponent is T)
            {
                return((T)((object)namedComponent));
            }
            return(default(T));
        }
示例#17
0
        /// <summary>
        /// Gets image number
        /// </summary>
        /// <param name="component">Component</param>
        /// <returns>The image number</returns>
        public static int GetImageNumber(INamedComponent component)
        {
            IPaletteButton button = GetButton(component);

            if (button == null)
            {
                return(0);
            }
            return(button.ImageNumber);
        }
示例#18
0
        /// <summary>
        /// Gets associated control
        /// </summary>
        /// <param name="obj">Prototype</param>
        /// <returns>The control</returns>
        public static Control GetControl(this IAssociatedObject obj)
        {
            INamedComponent nc = obj.GetNamedComponent();

            if (nc is Control)
            {
                return(nc as Control);
            }
            return(null);
        }
示例#19
0
        public INamedComponent FindNamedComponent(string name)
        {
            INamedComponent result = null;

            if (this.componentDictionary.TryGetValue(name, out result))
            {
                return(result);
            }
            return(null);
        }
示例#20
0
        /// <summary>
        /// Gets aliases of associated object
        /// </summary>
        /// <param name="baseObject">Base object</param>
        /// <param name="lab">Label</param>
        /// <param name="list">List</param>
        /// <param name="type">Type of object</param>
        static public void GetAliases(IAssociatedObject baseObject, IObjectLabel lab, List <string> list, object type)
        {
            object ob = baseObject.Object;

            if (ob == null)
            {
                return;
            }
            INamedComponent nc = baseObject.Object as INamedComponent;

            GetAllAliases(nc, lab.Object, lab, list, type);
        }
示例#21
0
 /// <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 l = comp as IObjectLabel;
         if (l.Object is ObjectContainer)
         {
             return(new Forms.FormContainer(l));
         }
     }
     return(null);
 }
示例#22
0
        /// <summary>
        /// Gets root of the component
        /// </summary>
        /// <param name="component">The component</param>
        /// <returns>The root</returns>
        static public INamedComponent GetRoot(INamedComponent component)
        {
            IDesktop d = component.Desktop;

            if (d == null)
            {
                return(component);
            }
            IDesktop desk = d.Root;

            return(GetRoot(component, desk));
        }
示例#23
0
 /// <summary>
 /// Gets root component
 /// </summary>
 /// <param name="comp">Prototype</param>
 /// <param name="desktop">Root's desktop</param>
 /// <returns>The root</returns>
 public static INamedComponent GetRoot(INamedComponent comp, IDesktop desktop)
 {
     if (comp.Desktop == desktop)
     {
         return(comp);
     }
     if (comp.Parent == null)
     {
         return(comp);
     }
     return(GetRoot(comp.Parent, desktop));
 }
示例#24
0
        /// <summary>
        /// Creates objects
        /// </summary>
        /// <param name="element">XmlElement</param>
        /// <param name="categoryObject">Object</param>
        public override void Create(XElement element, ref ICategoryObject categoryObject)
        {
            factory.Create(element, ref categoryObject);
            if (categoryObject == null)
            {
                return;
            }
            string              name = AbstractXmlCreateObjectFactory.GetName(factory, categoryObject);
            INamedComponent     nc   = categoryObject.Object as INamedComponent;
            PureObjectLabelPeer ol   = new PureObjectLabelPeer(name, nc.Kind, categoryObject.GetType().FullName, 0, 0);

            desktop.AddObjectLabel(ol, categoryObject, true);
        }
示例#25
0
 public override object CreateForm(INamedComponent comp)
 {
     if (comp is IObjectLabel)
     {
         IObjectLabel    lab = comp as IObjectLabel;
         ICategoryObject obj = lab.Object;
         if (obj is BitmapGraphSelection)
         {
             return(new Forms.FormBitmapGraphSelection(lab));
         }
     }
     return(null);
 }
示例#26
0
        IMeasurements IDataLinkFactory.GetMeasurements(ICategoryObject target)
        {
            IAssociatedObject ao = target;
            object            o  = ao.Object;

            if (o is INamedComponent)
            {
                IMeasurements   ml   = null;
                INamedComponent comp = o as INamedComponent;
                IDesktop        d    = null;
                INamedComponent r    = comp.Root;
                if (r != null)
                {
                    d = r.Desktop;
                }
                else
                {
                    d = comp.Desktop;
                }
                if (d != null)
                {
                    d.ForEach((DataLink dl) =>
                    {
                        if (ml != null)
                        {
                            return;
                        }
                        object dt = dl.Target;
                        if (dt is IAssociatedObject)
                        {
                            IAssociatedObject aot = dt as IAssociatedObject;
                            if (aot.Object == o & (!(aot is IChildrenObject)))
                            {
                                ml = dl.Target as IMeasurements;
                            }
                        }
                    });
                    if (ml != null)
                    {
                        return(ml);
                    }
                }
            }
            IMeasurements m = MeasurementsWrapper.Create(target);

            if (m == null)
            {
                CategoryException.ThrowIllegalTargetException();
            }
            return(m);
        }
示例#27
0
        static private void Check(DataPerformer.Portable.DataLink l)
        {
            object o = l.Object;

            if (o != null)
            {
                if (o is INamedComponent)
                {
                    INamedComponent nc = o as INamedComponent;
                    IDesktop        d  = nc.Desktop;
                    Check(d);
                }
            }
        }
示例#28
0
        IDataConsumer IDataLinkFactory.GetConsumer(ICategoryObject source)
        {
            /*   if (source is IChildrenObject)
             * {
             *     IDataConsumer dcc = (source as IChildrenObject).GetChildren<IDataConsumer>();
             *     if (dcc != null)
             *     {
             *         return dcc;
             *     }
             * }*/
            IAssociatedObject ao = source;
            object            o  = ao.Object;

            if (o is INamedComponent)
            {
                IDataConsumer   dcl     = null;
                INamedComponent comp    = o as INamedComponent;
                IDesktop        desktop = comp.Root.Desktop;
                desktop.ForEach <DataLink>((DataLink dl) =>
                {
                    if (dcl != null)
                    {
                        return;
                    }
                    object dt = dl.Source;
                    if (dt is IAssociatedObject)
                    {
                        IAssociatedObject aot = dt as IAssociatedObject;
                        if (aot.Object == o)
                        {
                            dcl = dl.source as IDataConsumer;
                        }
                    }
                });

                if (dcl != null)
                {
                    return(dcl);
                }
            }

            IDataConsumer dc = DataConsumerWrapper.Create(source);

            if (dc == null)
            {
                CategoryException.ThrowIllegalTargetException();
            }
            return(dc);
        }
示例#29
0
        private void paintC(object c, PaintEventArgs e)
        {
            INamedComponent nc = this;
            PanelDesktop    d  = nc.Desktop as PanelDesktop;

            if (d.IsMoved)
            {
                return;
            }
            if (bmp == null)
            {
                return;
            }
            e.Graphics.DrawImage(bmp, 0, 0);
        }
示例#30
0
 /// <summary>
 /// Creates a form for component properties editor
 /// </summary>
 /// <param name="component">The component</param>
 /// <returns>The result form</returns>
 public override object CreateForm(INamedComponent component)
 {
     if (component is IObjectLabel)
     {
         IObjectLabel lab = component as IObjectLabel;
         // The object of component
         ICategoryObject obj = lab.Object;
         if (obj is ITimerEvent)
         {
             ITimerEvent timer = obj as ITimerEvent;
             return(new Forms.FormTimer(obj as ITimerEvent));
         }
     }
     return(null);
 }
 public NotifierViewModel(INamedComponent notifier, bool enabled)
 {
     Notifier = notifier;
     IsEnabled = enabled;
 }