Beispiel #1
0
        public ChartInfo SetupChartAreaFor(string rootname, ChartTypes charttype, int refreshfrequency)
        {
            Chart c = null;

            c = this.GetDefaultChartIfNull(c);
            ChartInfo chartinfo = this.AddChartAreaAndLegend(c, rootname);

            switch (charttype)
            {
            case ChartTypes.Acceleration:
                this.ChartSeriesAndCustomization(c, chartinfo, SensorGrapherControl.SeriesXYZPostfix, SensorGrapherControl.DefaultXYZColor, SensorGrapherControl.DefaultAclLegendText, 45.0);
                break;

            case ChartTypes.Velocity:
                this.ChartSeriesAndCustomization(c, chartinfo, SensorGrapherControl.SeriesXYZPostfix, SensorGrapherControl.DefaultXYZColor, SensorGrapherControl.DefaultVelLegendText, 6.0);
                break;

            case ChartTypes.Position:
                this.ChartSeriesAndCustomization(c, chartinfo, SensorGrapherControl.SeriesXYZPostfix, SensorGrapherControl.DefaultXYZColor, SensorGrapherControl.DefaultPosLegendText, 4.0);
                break;
            }
            this.InitilizeRefreshCountAndFreq(chartinfo, refreshfrequency);
            this.ChartItemsList.Add(chartinfo);
            return(chartinfo);
        }
Beispiel #2
0
 public static ChartInfo AsCopy(this ChartInfo c)
 {
     return(new ChartInfo()
     {
         ChartAreaName = c.ChartAreaName, RootName = c.RootName, TitleName = c.TitleName, LegendName = c.LegendName, RefreshCounterName = c.RefreshCounterName, RefreshFrequencyName = c.RefreshFrequencyName, SeriesNames = new List <string>(c.SeriesNames.ToArray())
     });
 }
Beispiel #3
0
 public void UpdateGraph(ChartInfo chartinfo, double[] yvalues, long ticks)
 {
     if (this.RefreshDictionary[chartinfo.RefreshCounterName] >= this.RefreshDictionary[chartinfo.RefreshFrequencyName])
     {
         this.RefreshDictionary[chartinfo.RefreshCounterName] = 0;
         this.BeginInvoke((Action) delegate
         {
             try
             {
                 Chart c = this.SensorChart;
                 double min, max;
                 min = (new DateTime(ticks)).AddSeconds(-5).ToOADate();
                 max = (new DateTime(ticks)).ToOADate();
                 c.ChartAreas[chartinfo.ChartAreaName].AxisX.Minimum = min;
                 c.ChartAreas[chartinfo.ChartAreaName].AxisX.Maximum = max;
                 for (int i = 0; i < chartinfo.SeriesNames.Count; i++)
                 {
                     c.Series[chartinfo.SeriesNames[i]].Points.AddXY(max, yvalues[i]);
                     while (c.Series[chartinfo.SeriesNames[i]].Points[0].XValue < min)
                     {
                         c.Series[chartinfo.SeriesNames[i]].Points.RemoveAt(0);
                     }
                 }
             }
             catch (Exception)
             {
                 System.Diagnostics.Debug.WriteLine("Exception throw on: BeginInoke on UpdateGraph in SensorGrapherControl");
             }
         });
     }
     else
     {
         this.RefreshDictionary[chartinfo.RefreshCounterName]++;
     }
 }
Beispiel #4
0
 private ChartInfo InitilizeRefreshCountAndFreq(ChartInfo chartinfo, int frequency)
 {
     chartinfo.RefreshCounterName   = chartinfo.RootName + SensorGrapherControl.RefreshCountPostFix;
     chartinfo.RefreshFrequencyName = chartinfo.RootName + SensorGrapherControl.RefreshFreqPostFix;
     this.RefreshDictionary[chartinfo.RefreshCounterName]   = 0;
     this.RefreshDictionary[chartinfo.RefreshFrequencyName] = frequency;
     return(chartinfo);
 }
Beispiel #5
0
        public void RemoveChartViaChartInfo(ChartInfo chartinfo)
        {
            Chart c = null;

            c = this.GetDefaultChartIfNull(c);
            foreach (string s in chartinfo.SeriesNames)
            {
                c.Series.Remove(c.Series[s]);
            }
            c.Titles.Remove(c.Titles[chartinfo.TitleName]);
            c.Legends.Remove(c.Legends[chartinfo.LegendName]);
            c.ChartAreas.Remove(c.ChartAreas[chartinfo.ChartAreaName]);
        }
Beispiel #6
0
        public static List <ChartInfo> UpdateOrAdd(this List <ChartInfo> l, ChartInfo chartitemtoadd)
        {
            ChartInfo tci;

            if ((tci = l.FirstOrDefault(x => x.RootName == chartitemtoadd.RootName)) != null)
            {
                tci += chartitemtoadd;
            }
            else
            {
                l.Add(chartitemtoadd);
            }
            return(l);
        }
Beispiel #7
0
 private ChartInfo ChartSeriesAndCustomization(Chart c, ChartInfo info, string[] seriespostfixs, Color[] colors, string[] legendstexts, double axissize)
 {
     for (int i = 0; i < seriespostfixs.Length; i++)
     {
         info.SeriesNames.Add(info.RootName + seriespostfixs[i]);
         c.Series.Add(new Series()
         {
             Name = info.RootName + seriespostfixs[i], ChartArea = info.ChartAreaName, ChartType = SeriesChartType.FastLine, Color = colors[i], LegendText = legendstexts[i], Legend = info.LegendName
         });
     }
     c.ChartAreas[info.RootName].AxisY.Minimum = -axissize;
     c.ChartAreas[info.RootName].AxisY.Maximum = axissize;
     return(info);
 }
Beispiel #8
0
        public static ChartInfo operator+(ChartInfo l, ChartInfo r)
        {
            ChartInfo c = new ChartInfo();

            if (r.RootName != null)
            {
                c.RootName = r.RootName;
            }
            else
            {
                c.RootName = l.RootName;
            }

            if (r.ChartAreaName != null)
            {
                c.ChartAreaName = r.ChartAreaName;
            }
            else
            {
                c.ChartAreaName = l.ChartAreaName;
            }

            if (r.LegendName != null)
            {
                c.LegendName = r.LegendName;
            }
            else
            {
                c.LegendName = l.LegendName;
            }

            if (r.TitleName != null)
            {
                c.TitleName = r.TitleName;
            }
            else
            {
                c.TitleName = l.TitleName;
            }

            c.SeriesNames.AddRange(l.SeriesNames);
            c.SeriesNames.AddRange(r.SeriesNames);
            return(c);
        }
Beispiel #9
0
        private ChartInfo AddChartAreaAndLegend(Chart c, string rootname)
        {
            //c = this.GetDefaultChartIfNull(c);
            ChartInfo buildingchartinfo = new ChartInfo();

            buildingchartinfo.RootName      = rootname;
            buildingchartinfo.ChartAreaName = rootname;
            c.ChartAreas.Add(new ChartArea()
            {
                Name = buildingchartinfo.ChartAreaName, AxisX = this.GetDefaultXAxis()
            });

            buildingchartinfo.LegendName = rootname + SensorGrapherControl.LegendPostfix;
            c.Legends.Add(new Legend {
                Name = buildingchartinfo.LegendName, TableStyle = LegendTableStyle.Wide, Alignment = StringAlignment.Far, BackColor = System.Drawing.SystemColors.InactiveBorder, DockedToChartArea = buildingchartinfo.RootName, Docking = Docking.Left
            });
            buildingchartinfo.TitleName = buildingchartinfo.RootName + SensorGrapherControl.TitlePostfix;
            c.Titles.Add(new Title {
                BackColor = System.Drawing.SystemColors.ActiveCaption, Text = buildingchartinfo.RootName, Name = buildingchartinfo.RootName + SensorGrapherControl.TitlePostfix, DockedToChartArea = buildingchartinfo.ChartAreaName, IsDockedInsideChartArea = true
            });
            return(buildingchartinfo);
        }