示例#1
0
        public void ApplyAllProperties(object target, PropFilter filter, APPLYDIRECTION direction)
        {
            System.Reflection.PropertyInfo[] props = this.GetType().GetProperties();
            foreach (var p in props)
            {
                if (p.CanWrite)
                {
                    string fullpropname = p.Name;
                    int    index        = fullpropname.IndexOf("_");
                    if (index < 0)
                    {
                        throw new System.ArgumentException("invalid Property name");
                    }
                    string        propType = fullpropname.Substring(0, index);
                    string        propname = fullpropname.Substring(index + 1);
                    List <String> path     = new List <String>();
                    path.Add(propname);


                    if ((target is Form) && (propType == "Form"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YDigitalDisplay) && (propType == "display"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }


                    if ((target is YAngularGauge) && (propType == "AngularGauge"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YSolidGauge) && (propType == "SolidGauge"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YGraph) && (propType == "Graph"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }
                }
            }
        }
示例#2
0
        //Direction :Settings To Target
        static public void copyProperty_STT(object rootTarget, object source, string propertySourceName, List <string> path, PropFilter filterAllow)
        {
            System.Reflection.PropertyInfo tinfo = null;
            System.Reflection.PropertyInfo sinfo = null;
            string ttype = "";
            string stype = "";
            object FinalTarget;
            object TerminalSource;


            computePropertyAccess(rootTarget, source, propertySourceName, path, out tinfo, out sinfo, out ttype, out stype, out FinalTarget, out TerminalSource);



            if (tinfo == null)
            {
                return;          // the property does not exists in the widget
            }
            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Color"))
            {
                Color c  = (Color)TerminalSource;
                Color C2 = Color.FromArgb(c.A, c.R, c.G, c.B);
                tinfo.SetValue(FinalTarget, C2, null);
            }
            else

            if ((stype == "YDataRendering.xAxisPosition") && (ttype == "System.Double"))
            {
                xAxisPosition v = (xAxisPosition)TerminalSource;
                tinfo.SetValue(FinalTarget, v.value, null);
            }
            else
            if ((stype == "YoctoVisualisation.doubleNan") && (ttype == "System.Double"))
            {
                doubleNan v = (doubleNan)TerminalSource;
                tinfo.SetValue(FinalTarget, v.value, null);
            }
            else
            if ((stype == "YoctoVisualisation.doubleNan") && (ttype.StartsWith("System.Nullable")))
            {
                if (Double.IsNaN(((doubleNan)TerminalSource).value))
                {
                    tinfo.SetValue(FinalTarget, null, null);
                }
                else
                {
                    tinfo.SetValue(FinalTarget, ((doubleNan)TerminalSource).value, null);
                }
            }


            else
            if ((stype == "System.String") && (ttype == "System.Windows.Media.FontFamily"))
            {
                string v = (string)TerminalSource;
                tinfo.SetValue(FinalTarget, new FontFamily(v), null);
            }


            else
            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Brush"))
            {
                Color c = (Color)TerminalSource;
                byte  a = c.A;
                if (propertySourceName == "Graph2_ScrollBarFill")
                {
                    a = 80;                                         // dirty hack to keep the navigator's cursor semi-transparent
                }
                Color      C2 = Color.FromArgb(a, c.R, c.G, c.B);
                SolidBrush b  = new SolidBrush(C2);
                tinfo.SetValue(FinalTarget, b, null);
            }
            else
            if ((stype == "YColors.YColor") && (ttype == "System.Drawing.Color"))
            {
                tinfo.SetValue(FinalTarget, ((YColor)TerminalSource).toColor(), null);
            }

            else
            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Brush"))
            {
                Color c = (Color)TerminalSource;
                byte  a = c.A;
                // if (propertySourceName == "Graph2_ScrollBarFill") a = 80; // dirty hack to keep the navigator's cursor semi-transparent
                Color      C2 = Color.FromArgb(a, c.R, c.G, c.B);
                SolidBrush b  = new SolidBrush(C2);
                tinfo.SetValue(FinalTarget, b, null);
            }
            else
            if ((stype == "YoctoVisualisation.DataTrackerDescription+DataPrecision") && (ttype == "YDataRendering.DataTracker+DataPrecision"))
            { // Mono doesn't like enums implicit conversions
                YoctoVisualisation.DataTrackerDescription.DataPrecision svalue = (YoctoVisualisation.DataTrackerDescription.DataPrecision)TerminalSource;
                int temp = (int)svalue;
                YDataRendering.DataTracker.DataPrecision tvalue = (YDataRendering.DataTracker.DataPrecision)(temp);
                tinfo.SetValue(FinalTarget, tvalue, null);
            }
            else
            {
                tinfo.SetValue(FinalTarget, TerminalSource, null);
            }
        }
示例#3
0
        // Direction : settings From Target
        static public void copyProperty_SFT(object rootTarget, object source, string propertySourceName, List <string> path, PropFilter filterAllow)
        {
            System.Reflection.PropertyInfo tinfo = null;
            System.Reflection.PropertyInfo sinfo = null;
            string ttype = "";
            string stype = "";
            object FinalTarget;
            object TerminalSource;

            computePropertyAccess_SFT(rootTarget, source, propertySourceName, path, out tinfo, out sinfo, out ttype, out stype, out FinalTarget, out TerminalSource);

            if (tinfo == null)
            {
                return;          // the property does not exists in the widget
            }
            if ((stype == "System.Drawing.Color") && (ttype == "YColors.YColor"))
            {
                tinfo.SetValue(FinalTarget, YColor.fromColor((Color)TerminalSource), null);
            }
            else if ((stype == "System.Double") && (ttype == "YoctoVisualisation.doubleNan"))
            {
                tinfo.SetValue(FinalTarget, new doubleNan((double)TerminalSource), null);
            }
            else
            if ((stype == "YDataRendering.DataTracker+DataPrecision") && (ttype == "YoctoVisualisation.DataTrackerDescription+DataPrecision"))
            { // Mono doesn't like enums implicit conversions
                YDataRendering.DataTracker.DataPrecision svalue = (YDataRendering.DataTracker.DataPrecision)TerminalSource;
                int temp = (int)svalue;
                YoctoVisualisation.DataTrackerDescription.DataPrecision tvalue = (YoctoVisualisation.DataTrackerDescription.DataPrecision)(temp);
                tinfo.SetValue(FinalTarget, tvalue, null);
            }

            else
            {
                tinfo.SetValue(FinalTarget, TerminalSource, null);
            }
        }
示例#4
0
        static public object newGetProperty(object rootTarget, object source, string propertySourceName, List <string> path, PropFilter filterAllow)
        {
            System.Reflection.PropertyInfo tinfo = null;
            System.Reflection.PropertyInfo sinfo = null;

            string ttype = "";
            string stype = "";
            object FinalTarget;
            object TerminalSource;

            computePropertyAccess(rootTarget, source, propertySourceName, path, out tinfo, out sinfo, out ttype, out stype, out FinalTarget, out TerminalSource);
            if (tinfo == null)
            {
                return(null);         // the property does not exists in the widget
            }
            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Color"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "YoctoVisualisation.doubleNan") && (ttype == "System.Double"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "YoctoVisualisation.doubleNan") && (ttype == "System.Double"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "YoctoVisualisation.xAxisPosition") && (ttype.StartsWith("System.Nullable")))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "System.String") && (ttype == "System.Windows.Media.FontFamily"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Brush"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "YColors.YColor") && (ttype == "System.Drawing.Color"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "System.Drawing.Color") && (ttype == "System.Windows.Media.Brush"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            if ((stype == "YoctoVisualisation.DataTrackerDescription+DataPrecision") && (ttype == "YDataRendering.DataTracker+DataPrecision"))
            {
                return(tinfo.GetValue(FinalTarget, null));
            }

            return(tinfo.GetValue(FinalTarget, null));
        }