Пример #1
0
        public static ConfigurationTargetLine Deserialize(XElement elm)
        {
            ConfigurationTargetLine line = new ConfigurationTargetLine();

            line.LineColor       = SerializeToXml.LoadColor(elm, "LineColor").Value;
            line.EnableFlag      = SerializeToXml.LoadBool(elm, "EnableFlag").Value;
            line.FlagColor       = SerializeToXml.LoadColor(elm, "FlagColor").Value;
            line.FlagBorderColor = SerializeToXml.LoadColor(elm, "FlagBorderColor").Value;
            line.FlagTextColor   = SerializeToXml.LoadColor(elm, "FlagTextColor").Value;
            line.YValue          = SerializeToXml.LoadDouble(elm, "YValue").Value;
            line.YValueRange     = SerializeToXml.LoadDouble(elm, "YRange").Value;
            line.Enabled         = SerializeToXml.LoadBool(elm, "Enabled").Value;
            line.LineType        = lineTypeFromString(SerializeToXml.LoadText(elm, "LineType"));
            line.FlagTextColor   = SerializeToXml.LoadColor(elm, "FlagTextColor").Value;
            line.Note            = SerializeToXml.LoadText(elm, "Note");

            Color?clr = SerializeToXml.LoadColor(elm, "NoteColor");

            if (clr.HasValue)
            {
                line.NoteColor = clr.Value;
            }

            return(line);
        }
Пример #2
0
        public static ConfigurationFrame Deserialize(XElement elm)
        {
            ConfigurationFrame frame = new ConfigurationFrame();

            frame.m_nDataIndex               = SerializeToXml.LoadInt(elm, "DataIndex").Value;
            frame.m_nFrameHeight             = SerializeToXml.LoadInt(elm, "FrameHeight").Value;
            frame.m_clrTitle                 = SerializeToXml.LoadColor(elm, "TitleColor").Value;
            frame.m_fontTitle                = SerializeToXml.LoadFont(elm, "TitleFont");
            frame.Name                       = SerializeToXml.LoadText(elm, "Name");
            frame.Visible                    = SerializeToXml.LoadBool(elm, "Visible").Value;
            frame.MinMaxTarget               = (PlotCollection.MINMAX_TARGET)SerializeToXml.LoadInt(elm, "MinMaxTarget");
            frame.ScaleToVisibleWhenRelative = SerializeToXml.LoadBool(elm, "ScaleToVisible").Value;
            frame.m_rgPlots                  = ConfigurationPlot.Deserialize(elm.Descendants());
            frame.m_rgLines                  = ConfigurationTargetLine.Deserialize(elm.Descendants());
            frame.m_configPlotArea           = ConfigurationPlotArea.Deserialize(elm);
            frame.m_configXAxis              = ConfigurationAxis.Deserialize(elm, "X");
            frame.m_configYAxis              = ConfigurationAxis.Deserialize(elm, "Y");

            double?dfVal = SerializeToXml.LoadDouble(elm, "MinYRange");

            if (dfVal.HasValue)
            {
                frame.MinimumYRange = dfVal.Value;
            }

            return(frame);
        }
Пример #3
0
        public bool Compare(ConfigurationTargetLine c)
        {
            if (m_clrLine != c.m_clrLine)
            {
                return(false);
            }

            if (m_bEnabled != c.m_bEnabled)
            {
                return(false);
            }

            if (m_clrFlag != c.m_clrFlag)
            {
                return(false);
            }

            if (m_clrFlagBorder != c.m_clrFlagBorder)
            {
                return(false);
            }

            if (m_clrFlagText != c.m_clrFlagText)
            {
                return(false);
            }

            if (m_bEnabled != c.m_bEnabled)
            {
                return(false);
            }

            if (m_lineType != c.m_lineType)
            {
                return(false);
            }

            if (m_dfYValue != c.m_dfYValue)
            {
                return(false);
            }

            if (m_dfYRange != c.m_dfYRange)
            {
                return(false);
            }

            if (m_strNote != c.m_strNote)
            {
                return(false);
            }

            if (m_clrNote != c.m_clrNote)
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
        private void drawFlag(Graphics g, ConfigurationTargetLine line)
        {
            if (!line.Enabled)
            {
                return;
            }

            drawFlag(g, line.YValue, line.EnableFlag, line.FlagColor, line.FlagTextColor, line.FlagBorderColor);
        }
Пример #5
0
        public ConfigurationFrame(SerializationInfo info, StreamingContext context)
        {
            int nCount = info.GetInt32("plotCount");

            for (int i = 0; i < nCount; i++)
            {
                ConfigurationPlot plot = (ConfigurationPlot)info.GetValue("plot_" + i.ToString(), typeof(ConfigurationPlot));
                m_rgPlots.Add(plot);
            }

            nCount = info.GetInt32("targetLineCount");

            for (int i = 0; i < nCount; i++)
            {
                ConfigurationTargetLine line = (ConfigurationTargetLine)info.GetValue("targetline_" + i.ToString(), typeof(ConfigurationTargetLine));
                m_rgLines.Add(line);
            }

            m_configPlotArea = (ConfigurationPlotArea)info.GetValue("plotArea", typeof(ConfigurationPlotArea));
            m_configXAxis    = (ConfigurationAxis)info.GetValue("axisX", typeof(ConfigurationAxis));
            m_configYAxis    = (ConfigurationAxis)info.GetValue("axisY", typeof(ConfigurationAxis));
            m_nDataIndex     = info.GetInt32("plotCollectionIdx");
            m_nFrameHeight   = info.GetInt32("frameHeight");
            m_clrTitle       = (Color)info.GetValue("clrTitle", typeof(Color));
            m_fontTitle      = (Font)info.GetValue("fontTitle", typeof(Font));
            m_strName        = info.GetString("name");
            m_bVisible       = info.GetBoolean("visible");

            try
            {
                m_minmaxTarget = (PlotCollection.MINMAX_TARGET)info.GetInt32("minmax_target");
            }
            catch (Exception)
            {
            }

            try
            {
                m_bScaleToVisibleWhenRelative = info.GetBoolean("scale_to_visible");
            }
            catch (Exception)
            {
            }

            try
            {
                m_dfMinYRange = info.GetDouble("min_y_range");
            }
            catch (Exception)
            {
            }
        }
Пример #6
0
        public static List <ConfigurationTargetLine> Deserialize(IEnumerable <XElement> elms)
        {
            List <ConfigurationTargetLine> rgLines = new List <ConfigurationTargetLine>();
            List <XElement> rgElm = SerializeToXml.GetElements(elms, "TargetLine");

            foreach (XElement elm in rgElm)
            {
                ConfigurationTargetLine line = ConfigurationTargetLine.Deserialize(elm);
                rgLines.Add(line);
            }

            return(rgLines);
        }
Пример #7
0
        private void setBounds(ConfigurationFrame config, PlotCollectionSet data)
        {
            if (config.MinimumYRange != 0)
            {
                double dfAbsMinY;
                double dfAbsMaxY;

                if (!config.UseExistingDataMinMax)
                {
                    data.SetMinMax();
                }
                data.GetAbsMinMax(0, 0, out dfAbsMinY, out dfAbsMaxY);

                double dfRange = dfAbsMaxY - dfAbsMinY;

                if (dfRange < config.MinimumYRange)
                {
                    double dfMid = dfAbsMinY + dfRange / 2;
                    dfAbsMinY = dfMid - (config.MinimumYRange / 2);
                    dfAbsMaxY = dfMid + (config.MinimumYRange / 2);

                    ConfigurationTargetLine        minLine  = null;
                    ConfigurationTargetLine        maxLine  = null;
                    List <ConfigurationTargetLine> rgRemove = new List <ConfigurationTargetLine>();

                    foreach (ConfigurationTargetLine line in config.TargetLines)
                    {
                        if (line.Name == "bounds_min")
                        {
                            minLine = line;
                        }

                        if (line.Name == "bounds_max")
                        {
                            maxLine = line;
                        }

                        if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN || line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX)
                        {
                            rgRemove.Add(line);
                        }

                        if (minLine != null && maxLine != null)
                        {
                            break;
                        }
                    }

                    foreach (ConfigurationTargetLine line in rgRemove)
                    {
                        config.TargetLines.Remove(line);
                    }

                    if (minLine == null)
                    {
                        minLine      = new ConfigurationTargetLine(dfAbsMinY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE);
                        minLine.Name = "bounds_min";
                        config.TargetLines.Add(minLine);
                    }
                    else
                    {
                        minLine.YValue = dfAbsMinY;
                    }

                    if (maxLine == null)
                    {
                        maxLine      = new ConfigurationTargetLine(dfAbsMaxY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE);
                        maxLine.Name = "bounds_max";
                        config.TargetLines.Add(maxLine);
                    }
                    else
                    {
                        maxLine.YValue = dfAbsMaxY;
                    }
                }
            }
        }