Exemple #1
0
        /// <summary>
        /// Sets measures to consumer
        /// </summary>
        /// <param name="consumer">The consumer</param>
        /// <param name="measures">Names of measures</param>
        /// <param name="measuresData">Measures</param>
        public static void SetMeasurements(IDataConsumer consumer, List <string> measures, List <IMeasurement> measuresData)
        {
            measuresData.Clear();
            IAssociatedObject ac = consumer as IAssociatedObject;

            foreach (string ms in measures)
            {
                for (int i = 0; i < consumer.Count; i++)
                {
                    IMeasurements     m  = consumer[i];
                    IAssociatedObject ao = m as IAssociatedObject;
                    string            on = ac.GetRelativeName(ao) + ".";

                    for (int j = 0; j < m.Count; j++)
                    {
                        IMeasurement mea = m[j];
                        string       s   = on + mea.Name;
                        if (s.Equals(ms))
                        {
                            measuresData.Add(mea);
                        }
                    }
                }
            }
        }
Exemple #2
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);
            }
        }
        /// <summary>
        /// Gets names of providers
        /// </summary>
        /// <param name="consumer">Consumer</param>
        /// <returns>Names of providers</returns>
        public static IEnumerable <string> GetProviders(this IBitmapConsumer consumer)
        {
            IAssociatedObject ao = consumer as IAssociatedObject;

            foreach (IBitmapProvider p in consumer.Providers)
            {
                yield return(ao.GetRelativeName(p as IAssociatedObject));
            }
        }
Exemple #4
0
 /// <summary>
 /// Gets names of events
 /// </summary>
 /// <param name="handler">Event handler</param>
 /// <returns>Names of events</returns>
 public static IEnumerable <string> GetEventNames(this IEventHandler handler)
 {
     if (handler is IAssociatedObject)
     {
         IAssociatedObject ao = handler as IAssociatedObject;
         foreach (IEvent ev in handler.Events)
         {
             if (ev is IAssociatedObject)
             {
                 yield return(ao.GetRelativeName(ev as IAssociatedObject));
             }
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Finds event
        /// </summary>
        /// <param name="handler">Event handler</param>
        /// <param name="name">The name of event</param>
        /// <returns>The event</returns>
        public static IEvent FindEvent(this IEventHandler handler, string name)
        {
            if (!(handler is IAssociatedObject))
            {
                return(null);
            }
            IAssociatedObject ao = handler as IAssociatedObject;

            foreach (IEvent ev in handler.Events)
            {
                if (ev is IAssociatedObject)
                {
                    string s = ao.GetRelativeName(ev as IAssociatedObject);
                    if (s == name)
                    {
                        return(ev);
                    }
                }
            }
            return(null);
        }
Exemple #6
0
        /// <summary>
        /// Modelled after CreateList meotod. Both methods have to be roofed by a single method, with and object of Object class rather than IEnumerable or IITerator
        /// </summary>
        /// <param name="consumer"></param>
        /// <param name="list"></param>
        /// <param name="components"></param>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        public static IIterator CreateIterator(this IDataConsumer consumer, IEnumerable <object> list, IComponentCollection components,
                                               out Dictionary <IReplacedMeasurementParameter, string> dictionary)
        {
            Dictionary <IReplacedMeasurementParameter, string> dict = new Dictionary <IReplacedMeasurementParameter, string>();
            List <object> ll = new List <object>();

            components.ForEach((IMeasurements m) =>
            {
                string name = consumer.GetMeasurementsName(m) + ".";
                for (int i = 0; i < m.Count; i++)
                {
                    IMeasurement me = m[i];
                    if (me is IReplacedMeasurementParameter)
                    {
                        dict[me as IReplacedMeasurementParameter] = name + me.Name;
                    }
                }
            });
            Dictionary <string, INativeReader> dnr = new Dictionary <string, INativeReader>();

            components.ForEach((INativeReader reader) =>
            {
                if (reader is IAssociatedObject)
                {
                    string name = (consumer as IAssociatedObject).GetRelativeName(
                        reader as IAssociatedObject);
                    dnr[name] = reader;
                }
            });
            Dictionary <string, INativeEvent> dna = new Dictionary <string, INativeEvent>();
            IAssociatedObject ao = consumer as IAssociatedObject;

            components.ForEach((INativeEvent ne) =>
            {
                dna[ao.GetRelativeName(ne as IAssociatedObject)] = ne;
            });
            dictionary = dict;

            return(null);
        }
        void fill()
        {
            if (field == null)
            {
                return;
            }
            if (field.Field == null)
            {
                return;
            }
            Image im = NamedComponent.GetImage(field.Field as ICategoryObject);

            pictureBoxGrav.Image = im;
            string name =
                data.GetRelativeName(field.Field as ICategoryObject);

            labelName.Text = name;
            int[] n = field.Numbers;
            foreach (int i in n)
            {
                comboBoxNum.Items.Add(i + "");
            }
            int k = field.Number;

            if (k < 0)
            {
                return;
            }
            string sk = k + "";

            for (int i = 0; i < comboBoxNum.Items.Count; i++)
            {
                string s = comboBoxNum.Items[i] + "";
                if (s.Equals(sk))
                {
                    comboBoxNum.SelectedIndex = i;
                    break;
                }
            }
        }
        /// <summary>
        /// Ges name of provider
        /// </summary>
        /// <param name="provider">Provider</param>
        /// <returns>Name</returns>
        protected string GetName(IBitmapProvider provider)
        {
            IAssociatedObject ao = provider as IAssociatedObject;

            return(th.GetRelativeName(ao));
        }