コード例 #1
0
        new internal void Load()
        {
            /*         userControlCommentsFont.AcceptComments += delegate(ICollection comm)
             *       {
             *           consumer.Comments = comm;
             *       };
             */
            PanelFormula.SetResize(panelFormula);
            fill();
            IList <string> a = consumer.AliasNames;

            numericUpDownOrder.Value = consumer.DerivationOrder;
            first = false;
            Diagram.UI.PropertyEditors.AliasTable.AddDicitionary(consumer, tempAliases);
            try
            {
                IAlias         alias = consumer;
                IList <string> al    = alias.AliasNames;
                propertyGridAlias.SetAlias(consumer);
                string str = consumer.AllVariables;
                foreach (char c in str)
                {
                    if (al.Contains(c + ""))
                    {
                        checkedListBoxP.Items.Add("" + c, CheckState.Checked);
                    }
                    else
                    {
                        checkedListBoxP.Items.Add("" + c, CheckState.Unchecked);
                    }
                }
                IMeasurements m = consumer;
                numericUpDownQuantity.Value = m.Count;
                fillFormulas();
                setComboboxes();
                userControlFeedBack.Reset();
                userControlFeedBack.Set(consumer.Feedback);
                userControlForward.Measurements = consumer;
                userControlForward.Items        = consumer.ForwardAliases;
                userControlForward.OnChange    += (Dictionary <int, string> d) =>
                {
                    consumer.ForwardAliases = userControlForward.Items;
                };
                IRuntimeUpdate start = consumer;

                checkBoxRuntimeUpdate.Checked            = start.ShouldRuntimeUpdate;
                checkBoxRuntimeUpdate.CheckStateChanged += (object o, EventArgs e) =>
                {
                    start.ShouldRuntimeUpdate = checkBoxRuntimeUpdate.Checked;
                };
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
            }
        }
コード例 #2
0
        /// <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;
            }
        }