Beispiel #1
0
        /// <summary>
        /// Prepares itself
        /// </summary>
        protected virtual void Prepare()
        {
            ClearAll();
            prepareAll(collection);
            IEnumerable <object> comp = collection.AllComponents;

            foreach (object o in comp)
            {
                IUpdatableObject up = o.GetLabelObject <IUpdatableObject>();
                if (up == null)
                {
                    continue;
                }
                if (up is IDynamical)
                {
                    continue;
                }
                if (up.ShouldUpdate)
                {
                    if (up.SatisfiesReason(reason))
                    {
                        if (up.Update != null)
                        {
                            updatable.Add(up.Update);
                        }
                    }
                }
            }
            foreach (object obj in comp)
            {
                IDynamical dyn = obj.GetLabelObject <IDynamical>();
                if (dyn == null)
                {
                    continue;
                }
                dynamical.Add(dyn);
            }
            collection.ForEach <IMeasurements>(

                (IMeasurements m) => { measurements.Add(m); }
                );
            collection.ForEach <IStep>((IStep s) => { steps.Add(s); });
            if (updatable.Count == 0)
            {
                updateAll = UpdateMeasurements;
            }
            else
            {
                updateAll = () =>
                {
                    UpdateMeasurements();
                    foreach (Action up in updatable)
                    {
                        up();
                    }
                    UpdateMeasurements();
                };
            }
            measurements.SortMeasurements();
        }
Beispiel #2
0
 void Add(object o)
 {
     if (o == null)
     {
         return;
     }
     if (o is IDataConsumer)
     {
         IDataConsumer c = o as IDataConsumer;
         if (!consumers.Contains(c))
         {
             consumers.Add(c);
         }
     }
     if (o is IUpdatableObject)
     {
         IUpdatableObject u = o as IUpdatableObject;
         if (!upd.Contains(u))
         {
             upd.Add(u);
         }
     }
     if (o is IDynamical)
     {
         IDynamical d = o as IDynamical;
         if (!dyn.Contains(d))
         {
             dyn.Add(d);
         }
     }
     if (o is IStep)
     {
         IStep s = o as IStep;
         s.Step = 0;
         if (!steps.Contains(s))
         {
             steps.Add(s);
         }
     }
     if (o is IChildrenObject)
     {
         IChildrenObject     ch   = o as IChildrenObject;
         IAssociatedObject[] objs = ch.Children;
         foreach (object obj in objs)
         {
             Add(obj);
         }
     }
     if (o is MeasurementsWrapper)
     {
         MeasurementsWrapper mw = o as MeasurementsWrapper;
         int n = mw.Count;
         for (int i = 0; i < n; i++)
         {
             Add(mw[i]);
         }
     }
 }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 void IBitmapConsumer.Process()
 {
     if (provider != null)
     {
         if (provider is IUpdatableObject)
         {
             IUpdatableObject up = provider as IUpdatableObject;
             if (up.Update != null)
             {
                 up.Update();
             }
         }
         pBmp = provider.Bitmap;
         if (pBmp != null)
         {
             draw();
         }
     }
 }
Beispiel #5
0
        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;
            }
        }
Beispiel #6
0
 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>
        /// Prepares itself
        /// </summary>
        protected override void Prepare()
        {
            ClearAll();
            IComponentCollection cc = factory.CreateCollection(consumer, 0, null);
            IEnumerable <object> en = cc.AllComponents;

            foreach (object o in en)
            {
                if (o is IRuntimeUpdate)
                {
                    runtimeUpdate.Add(o as IRuntimeUpdate);
                }
                if (o is IDataConsumer)
                {
                    IDataConsumer dc = o as IDataConsumer;
                    for (int i = 0; i < dc.Count; i++)
                    {
                        IMeasurements m = dc[i];
                        if (m is RelativeMeasurements)
                        {
                            RelativeMeasurements rm = m as RelativeMeasurements;
                            AddFrameDependent(rm.Source);
                            AddFrameDependent(rm.Target);
                        }
                        if (m is IRuntimeUpdate)
                        {
                            IRuntimeUpdate st = m as IRuntimeUpdate;
                            if (!st.ShouldRuntimeUpdate)
                            {
                                if (!runtimeUpdate.Contains(st))
                                {
                                    runtimeUpdate.Add(st);
                                }
                            }
                        }
                    }
                }
                if (o is IPosition)
                {
                    frames.Add(o as IPosition);
                }
                if (o is IMeasurements)
                {
                    IMeasurements m = o as IMeasurements;
                    if (!measurements.Contains(m))
                    {
                        measurements.Add(m);
                    }
                }
                if (o is IStep)
                {
                    steps.Add(o as IStep);
                }
                if (o is IUpdatableObject)
                {
                    IUpdatableObject up = o as IUpdatableObject;
                    if (up == null)
                    {
                        continue;
                    }
                    if (up is IDynamical)
                    {
                        continue;
                    }
                    if (up.ShouldUpdate)
                    {
                        if (up.Update != null)
                        {
                            updatable.Add(up.Update);
                        }
                    }
                }
            }
            foreach (object obj in en)
            {
                if (obj is IDynamical)
                {
                    IDynamical dyn = obj as IDynamical;
                    if (dyn == null)
                    {
                        continue;
                    }
                    dynamical.Add(dyn);
                }
            }
            measurements.SortMeasurements();
            updateAll = null;
            Action um = UpdateMeasurements;
            Action uu = () =>
            {
                foreach (Action up in updatable)
                {
                    up();
                }
            };
            Action upd = null;

            if (updatable.Count > 0)
            {
                upd = () =>
                {
                    foreach (Action up in updatable)
                    {
                        up();
                    }
                };
            }
            frames.SortPositions();
            Action uf = null;

            if (frames != null)
            {
                if (frames.Count > 0)
                {
                    uf = () =>
                    {
                        frames.UpdateFrames();
                    };
                }
            }
            if (uf == null & upd == null)
            {
                updateAll = UpdateMeasurements;
            }
            else if (upd == null)
            {
                updateAll = UpdateMeasurements + uf;
            }
            else if (uf == null)
            {
                updateAll = UpdateMeasurements + upd + UpdateMeasurements;
            }
            else
            {
                updateAll = UpdateMeasurements + upd + uf + UpdateMeasurements + upd;
            }
        }
Beispiel #8
0
 public void DNURegisterUpdatableObject(IUpdatableObject obj)
 {
     updatableObjects.Add(obj);
 }
Beispiel #9
0
 public void DNUUnregisterUpdatableObject(IUpdatableObject obj)
 {
     updatableObjects.Remove(obj);
 }