コード例 #1
0
        private void Initialize()
        {
            //Init original ChartData
            ChartData original = ChartData.GetInstance();

            //Initialize mousemarkercontrol
            this.mouseMarkerControl1             = new MouseMarkerControl();
            this.mouseMarkerControl1.Dock        = DockStyle.Fill;
            this.mouseMarkerControl1.ContextMenu = this.contextMenu1;
            this.mouseMarkerControl1.PickPoints  = false;
            this.mouseMarkerControl1.TraceValues = false;
            this.mouseMarkerControl1.NewMarker  += new NextGenLab.Chart.MouseMarkerControl.NewMarkerHandler(mouseMarkerControl1_NewMarker);
            this.mouseMarkerControl1.ForeColor   = ForeColor;
            this.mouseMarkerControl1.BackColor   = BackColor;

            //	this.mouseMarkerControl1.ChartData = original;
            this.Controls.Add(this.mouseMarkerControl1);


            //Initialize printer
            cp = new ChartPrint(mouseMarkerControl1);

            //Init splitter
            Splitter sp = new Splitter();

            sp.Dock    = DockStyle.Bottom;
            sp.MinSize = 3;
            this.Controls.Add(sp);

            //Init markers window
            markers         = new Markers();
            markers.Visible = false;
            markers.Dock    = DockStyle.Bottom;
            markers.Size    = new Size(50, 100);
            this.Controls.Add(markers);

            MenuItem m;

            //Get ChartTypes
            string[] strs = Enum.GetNames(typeof(ChartType));
            foreach (string s in strs)
            {
                m = new MenuItem(s, new EventHandler(Click_ChartType));
                this.miChartType.MenuItems.Add(m);
            }

            //X-Axis
            //MenuItem mi = new MenuItem("Type");
            //miXaxis.MenuItems.Add(mi);
            strs = Enum.GetNames(typeof(AxisType));
            foreach (string s in strs)
            {
                m = new MenuItem(s, new EventHandler(Click_AxisTypeX));
                miXaxis.MenuItems.Add(m);
            }

            //Y-Axis
            //mi = new MenuItem("Type");
            //miYaxis.MenuItems.Add(mi);
            foreach (string s in strs)
            {
                m = new MenuItem(s, new EventHandler(Click_AxisTypeY));
                miYaxis.MenuItems.Add(m);
            }

            //Trace
            miTraceType         = new MenuItem("Type");
            miTraceType.Enabled = false;
            miTrace.MenuItems.Add(miTraceType);
            strs = Enum.GetNames(typeof(ChartTraceType));
            foreach (string s in strs)
            {
                m = new MenuItem(s, new EventHandler(Click_ChartTraceType));
                miTraceType.MenuItems.Add(m);
            }
        }
コード例 #2
0
        /// <summary>
        /// Reads Graph Xml from a string
        /// </summary>
        /// <param name="ResultXml">Graph Xml</param>
        /// <returns>Array of GraphDTO objects</returns>
        private ChartData[] ReadXmlv1(string ResultXml)
        {
            ArrayList   graphs = new ArrayList();
            ArrayList   yvals  = new ArrayList();
            XmlDocument doc    = new XmlDocument();

            doc.LoadXml(ResultXml);
            XmlNodeList graphList = doc.DocumentElement.GetElementsByTagName("GRAPH");

            Widths  = new int[graphList.Count];
            Heights = new int[graphList.Count];
            for (int j = 0; j < graphList.Count; j++)
            {
                XmlNode graph = graphList[j];
                try
                {
                    XmlDocument graph_doc = new XmlDocument();
                    graph_doc.LoadXml(graph.OuterXml);

                    ChartData cd = ChartData.GetInstance();

                    //Get YValues
                    yvals = new ArrayList();
                    XmlNodeList temp_node_list = graph_doc.DocumentElement.GetElementsByTagName("YVALUES");

                    cd.Y = new double[temp_node_list.Count][];
                    for (int i = 0; i < temp_node_list.Count; i++)
                    {
                        XmlNode TempNode = temp_node_list[i];
                        cd.Y[i] = ParseValueString(TempNode.InnerText);
                    }
                    //Get XValues
                    cd.X = ParseValueString(graph_doc.DocumentElement.GetElementsByTagName("XVALUES")[0].InnerText);

                    cd.Title      = graph_doc.DocumentElement.GetElementsByTagName("YLABEL")[0].InnerText;
                    cd.TitleX     = graph_doc.DocumentElement.GetElementsByTagName("XLABEL")[0].InnerText;
                    cd.TitlesY    = new string[] {};
                    cd.AxisLabelX = "[" + graph_doc.DocumentElement.GetElementsByTagName("XVAL")[0].InnerText + "]";
                    cd.AxisLabelY = "[" + graph_doc.DocumentElement.GetElementsByTagName("YVAL")[0].InnerText + "]";

                    cd.AxisTypeX = (AxisType)Enum.Parse(typeof(AxisType), graph_doc.DocumentElement.GetElementsByTagName("TYPE_X")[0].InnerText, false);
                    cd.AxisTypeY = (AxisType)Enum.Parse(typeof(AxisType), graph_doc.DocumentElement.GetElementsByTagName("TYPE_Y")[0].InnerText, false);

                    Heights[j] = Int32.Parse(graph_doc.DocumentElement.GetElementsByTagName("VSIZE")[0].InnerText);
                    Widths[j]  = Int32.Parse(graph_doc.DocumentElement.GetElementsByTagName("HSIZE")[0].InnerText);

                    switch (cd.AxisTypeX)
                    {
                    case AxisType.LOG:
                        cd.AxisRangeX = GraphMath.TransformNoScale(cd.X);
                        break;

                    case AxisType.LIN:
                        cd.AxisRangeX = GraphMath.Transform(cd.X);
                        break;
                    }

                    switch (cd.AxisTypeY)
                    {
                    case AxisType.LOG:
                        cd.AxisRangeY = GraphMath.TransformNoScale(cd.Y);
                        break;

                    case AxisType.LIN:
                        cd.AxisRangeY = GraphMath.Transform(cd.Y);
                        break;
                    }


                    cd.ShowZero = true;

                    graphs.Add(cd);
                }
                catch
                {
                    //Could not parse graph
                }
            }

            if (graphs.Count > 0)
            {
                return((ChartData[])graphs.ToArray(typeof(ChartData)));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        private ChartData[] ReadXmlv2(string xml)
        {
            NextGenLab.DataSets.NglXml1 nx = new NextGenLab.DataSets.NglXml1();
            nx.DataSetName = "NglXml1";
            nx.Locale      = new System.Globalization.CultureInfo("en-US");

            nx.ReadXml(new MemoryStream(Encoding.Unicode.GetBytes(xml)));

            if (nx.Results.Count > 1)
            {
                throw new Exception("To many results, can't handle more than one");
            }
            if (nx.Results.Count == 0)
            {
                throw new ArgumentException("Can't find any results!!");
            }

            NglXml1.Plot[] plots  = nx.Results[0].GetPlots();
            ChartData[]    charts = new ChartData[plots.Length];
            NglXml1.Plot   p;
            ChartData      cd;

            Widths  = new int[plots.Length];
            Heights = new int[plots.Length];
            for (int j = 0; j < plots.Length; j++)
            {
                p  = plots[j];
                cd = ChartData.GetInstance();

                NglXml1.YVal[] yv = p.GetYVals();
                cd.Y = new double[yv.Length][];
                for (int i = 0; i < yv.Length; i++)
                {
                    cd.Y[i] = ParseValueString(yv[i].Y);
                }

                cd.X          = ParseValueString(p.X);
                cd.Title      = p.YLabel;
                cd.TitleX     = p.XLabel;
                cd.AxisLabelX = "[" + p.XUnit + "]";
                cd.AxisLabelY = "[" + p.YUnit + "]";
                cd.AxisTypeX  = (AxisType)Enum.Parse(typeof(AxisType), p.XScale, true);
                cd.AxisTypeY  = (AxisType)Enum.Parse(typeof(AxisType), p.YScale, true);

                switch (cd.AxisTypeX)
                {
                case AxisType.LOG:
                    cd.AxisRangeX = GraphMath.TransformNoScale(cd.X);
                    break;

                case AxisType.LIN:
                    cd.AxisRangeX = GraphMath.Transform(cd.X);
                    break;
                }

                switch (cd.AxisTypeY)
                {
                case AxisType.LOG:
                    cd.AxisRangeY = GraphMath.TransformNoScale(cd.Y);
                    break;

                case AxisType.LIN:
                    cd.AxisRangeY = GraphMath.Transform(cd.Y);
                    break;
                }

                Widths[j]   = p.Width;
                Heights[j]  = p.Height;
                cd.ShowZero = true;
                charts[j]   = cd;
            }

            return(charts);
        }
コード例 #4
0
 public ChartData GetDefault()
 {
     return(ChartData.GetInstance());
 }