Esempio n. 1
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Prepering arrays with data

            const int  N = 200;
            DateTime[] x = new DateTime[N];
            double[]   y = new double[N];

            TimeSpan step = new TimeSpan(23, 11, 21, 31);

            x[0] = new DateTime(1990, 1, 1);
            y[0] = 0;

            for (int i = 1; i < N; i++)
            {
                x[i] = x[i - 1] + step;
                y[i] = (Int32)(y[i - 1] + Math.E) % 37;
            }
            #endregion

            //Here we replace default numeric axis with DateTime Axis
            dateAxis = new HorizontalDateTimeAxis();
            plotter.HorizontalAxis = dateAxis;

            //Now we should set xMapping using ConvertToDouble method
            var xDataSource = x.AsXDataSource();
            xDataSource.SetXMapping(d => dateAxis.ConvertToDouble(d));
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);
            LineGraph           line = new LineGraph(compositeDataSource, "Graph depends on DateTime");

//            plotter.Children.Add(line);
            plotter.FitToView();
        }
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Prepering arrays with data

            const int N = 200;
            DateTime[] x = new DateTime[N];
            double[] y = new double[N];

            TimeSpan step = new TimeSpan(11, 21, 31);

            x[0] = DateTime.Now;
            y[0] = 0;

            for (int i = 1; i < N; i++)
            {
                x[i] = x[i - 1] + step;
                y[i] = (Int32)(y[i - 1] + Math.E) % 37;
            }
            #endregion

            //Here we replace default numeric axis with DateTime Axis
            dateAxis = new HorizontalDateTimeAxis();
            plotter.HorizontalAxis =dateAxis;

            //Now we should set xMapping using ConvertToDouble method
            var xDataSource = x.AsXDataSource();
            xDataSource.SetXMapping(d => dateAxis.ConvertToDouble(d));
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);
            LineGraph line = new LineGraph(compositeDataSource,"Graph depends on DateTime");

            plotter.Children.Add(line);
            plotter.FitToView();
        }
Esempio n. 3
0
        private static ChartPlotter SamplePlot()
        {
            ChartPlotter           plotter  = new ChartPlotter();
            HorizontalDateTimeAxis dateAxis = new HorizontalDateTimeAxis();

            plotter.HorizontalAxis = dateAxis;

            // chart.Children.Add(plotter);

            int    size   = 15;
            Random random = new Random();

            DateTime[] dates   = new DateTime[size];
            int[]      values1 = new int[size];
            int[]      values2 = new int[size];

            for (int i = 0; i < size; ++i)
            {
                dates[i]   = DateTime.Today.AddDays(i);
                values1[i] = random.Next(0, 10);
                values2[i] = random.Next(5, 15);
            }

            var datesDataSource = new EnumerableDataSource <DateTime>(dates);

            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var numberOpenDataSource = new EnumerableDataSource <int>(values1);

            numberOpenDataSource.SetYMapping(y => y);

            var numberOpenDataSource2 = new EnumerableDataSource <int>(values2);

            numberOpenDataSource2.SetYMapping(y => y);

            var datesDataSource2 = new EnumerableDataSource <DateTime>(dates);

            datesDataSource2.SetXMapping(x => dateAxis.ConvertToDouble(((DateTime)x).AddDays(2)));

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);
            CompositeDataSource compositeDataSource2 = new CompositeDataSource(
                datesDataSource2,
                numberOpenDataSource2);
            LinearPalette pal = new LinearPalette(Colors.Crimson, Colors.DarkBlue);

            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.Blue, 2),
                                 new CirclePointMarker {
                Size = 10.0, Fill = Brushes.Red
            },
                                 new PenDescription("1n"));
            plotter.AddLineGraph(compositeDataSource2,
                                 new Pen(Brushes.Cyan, 1),
                                 new TrianglePointMarker {
                Size = 5.0
            },
                                 new PenDescription("2n"));

            return(plotter);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DateTimeSelector"/> class.
        /// </summary>
        public DateTimeSelector()
        {
            var axis = new HorizontalDateTimeAxis();

            MainHorizontalAxis = axis;
            ValueConversion    = axis;

            Range = new Range <DateTime>(DateTime.Now, DateTime.Now.AddHours(1));
        }
Esempio n. 5
0
        public void AddChartValues(DateTime x, double y)
        {
            HorizontalDateTimeAxis axis = multimeter.dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;

            minX = axis.ConvertToDouble(x.AddSeconds(-8 * multimeter.TimingInterval));
            maxX = axis.ConvertToDouble(x.AddSeconds(4 * multimeter.TimingInterval));
            maxY = 2 * y;

            loggedValues.AppendAsync(Application.Current.Dispatcher, new DatePoint(x, y));
            if (multimeter.GraphAutoScroll)
            {
                multimeter.dynamicChart.Viewport.Visible = new Microsoft.Research.DynamicDataDisplay.Common.DataRect(new Point(minX, 0), new Point(maxX, maxY));
            }

            multimeter.program.AddChartValues(x, y, multimeter.Index);
        }
Esempio n. 6
0
        public void SetHorizontalAxisMapping(Func <double, DateTime> fromDouble, Func <DateTime, double> toDouble)
        {
            if (fromDouble == null)
            {
                throw new ArgumentNullException("fromDouble");
            }
            if (toDouble == null)
            {
                throw new ArgumentNullException("toDouble");
            }


            HorizontalDateTimeAxis axis = (HorizontalDateTimeAxis)MainHorizontalAxis;

            axis.ConvertFromDouble = fromDouble;
            axis.ConvertToDouble   = toDouble;
        }
Esempio n. 7
0
        public void AddChartValues(DateTime x, double y, int index)
        {
            HorizontalDateTimeAxis axis = dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;

            maxX = axis.ConvertToDouble(x.AddSeconds(10));
            if (y > maxY)
            {
                maxY = y;
            }
            minX = axis.ConvertToDouble(x.AddSeconds(-50));

            points[index].AppendAsync(Application.Current.Dispatcher, new DatePoint(x, y));

            /*if (reference.GraphAutoScroll)
             * {*/
            dynamicChart.Viewport.Visible = new Microsoft.Research.DynamicDataDisplay.Common.DataRect(new Point(minX, 0), new Point(maxX, maxY * 2));
            //}
        }
Esempio n. 8
0
        public DataHandler(Multimeter refer)
        {
            s            = new Stopwatch();
            g            = new Stopwatch();
            multimeter   = refer;
            currentMeter = "DMM " + (multimeter.Index + 1).ToString();

            totalStopWatch = new Stopwatch();
            totalLogTimer  = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                multimeter.overview.ElapsedTimeDisplay.Text = String.Format("{0:hh\\:mm\\:ss}", totalStopWatch.Elapsed);
            }, Application.Current.Dispatcher);

            HorizontalDateTimeAxis axis = multimeter.dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;

            loggedValues = new ObservableDataSource <DatePoint>();
            loggedValues.SetXMapping(p => axis.ConvertToDouble(p.X));
            loggedValues.SetYMapping(p => p.Y);
            graph = multimeter.dynamicChart.AddLineGraph(loggedValues, Colors.Blue, 2, currentMeter);
        }
Esempio n. 9
0
        private void AddNewTab(int index = 1)
        {
            TabItem t = new TabItem();

            MultimeterTabs.Items.Insert(index, t);
            Multimeter multimeter = new Multimeter(this, t, MultimeterTabs, multimeters.Count);

            multimeters.Add(multimeter);
            t.Content = multimeter;
            MultimeterTabs.SelectedIndex = index;

            HorizontalDateTimeAxis           axis   = dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;
            ObservableDataSource <DatePoint> values = new ObservableDataSource <DatePoint>();

            values.SetYMapping(p => p.Y);
            values.SetXMapping(p => axis.ConvertToDouble(p.X));
            points.Add(values);
            graphs.Add(dynamicChart.AddLineGraph(values, 2, multimeter.handler.currentMeter));
            multimeter.graph = graphs.Last <LineGraph>();
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            const int count = 4;

            for (int i = 0; i < count; i++)
            {
                data.Add(CreateRandomRect());
            }

            chart.AddPropertyBinding <TimeSpan>(ViewportPanel.ViewportWidthProperty,
                                                duration =>
            {
                DateTime durationDT         = new DateTime(duration.Ticks);
                HorizontalDateTimeAxis axis = (HorizontalDateTimeAxis)plotter.MainHorizontalAxis;
                var result = axis.ConvertToDouble(durationDT);

                return(result);
            },
                                                "Duration");

            DataContext = data;
        }
Esempio n. 11
0
        public ltepopupModel()
        {
            PinCommand         = new DelegateCommand(new Action(OnPinCommandExecute));
            CloseWindowCommand = new DelegateCommand(new Action(OnCloseWindowCommandExecute));

            LTECollection  = new LTECollection();
            LTECollection2 = new LTECollection();
            DateTimeAxis1  = new HorizontalDateTimeAxis();
            DateTimeAxis2  = new HorizontalDateTimeAxis();

            var ds = new EnumerableDataSource <LTEData>(LTECollection);

            ds.SetXMapping(x => DateTimeAxis1.ConvertToDouble(x.Date));
            ds.SetYMapping(y => y.Data);

            RsrqGraph = ds;

            var ds2 = new EnumerableDataSource <LTEData>(LTECollection2);

            ds2.SetXMapping(x => DateTimeAxis1.ConvertToDouble(x.Date));
            ds2.SetYMapping(y => y.Data);

            RsrpGraph = ds2;
        }
Esempio n. 12
0
		public TimeChartPlotter()
		{
			HorizontalAxis = new HorizontalDateTimeAxis();
		}
		void LogYWindow_Loaded(object sender, RoutedEventArgs e)
		{
			//ChartPlotter plotter = new ChartPlotter();

			//plotter.Children.Add(new CursorCoordinateGraph());

			//plotter.DataTransform = new Log10YTransform();
			//VerticalAxis axis = new VerticalAxis
			//{
			//    TicksProvider = new LogarithmNumericTicksProvider(10),
			//    LabelProvider = new UnroundingLabelProvider()
			//};
			//plotter.MainVerticalAxis = axis;

			//plotter.AxisGrid.DrawVerticalMinorTicks = true;

			//const int count = 500;
			//double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
			//EnumerableDataSource<double> xDS = xs.AsXDataSource();

			//var pows = xs.Select(x => Math.Pow(10, x));
			//var linear = xs.Select(x => x);
			//var logXs = Enumerable.Range(101, count).Select(x => x * 0.01);
			//var logarithmic = logXs.Select(x => Math.Log10(x));

			//plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
			//plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
			//plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

			//Content = plotter;

			ChartPlotter plotter = new ChartPlotter();
			plotter.DataTransform = new Log10YTransform();
			VerticalAxis yAxis = new VerticalAxis
			{
				TicksProvider = new LogarithmNumericTicksProvider(10),
				LabelProvider = new UnroundingLabelProvider()
			};
			plotter.MainVerticalAxis = yAxis;
			plotter.AxisGrid.DrawVerticalMinorTicks = true;

			HorizontalDateTimeAxis xAxis = new HorizontalDateTimeAxis();
			plotter.MainHorizontalAxis = xAxis;

			EnumerableDataSource<TPoint> edsPow = new EnumerableDataSource<TPoint>(
				Enumerable.Range(1, 2000).Select(s =>
					new TPoint
					{
						X = DateTime.Now.AddYears(-20).AddDays(s),
						Y = Math.Pow(10, s / 5000.0)
					}
					).ToList());
			//edsPow.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
			edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
			edsPow.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
			edsPow.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

			EnumerableDataSource<TPoint> edsLinear = new EnumerableDataSource<TPoint>(
				Enumerable.Range(1, 2000).Select(s =>
					new TPoint
					{
						X = DateTime.Now.AddYears(-20).AddDays(s),
						Y = s / 2000.0
					}
					).ToList());
			//edsLinear.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
			edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
			edsLinear.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
			edsLinear.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

			edsLog10 = new EnumerableDataSource<TPoint>(
				Enumerable.Range(1, 2000).Select(s =>
					new TPoint
					{
						X = DateTime.Now.AddYears(-20).AddDays(s),
						Y = Math.Log10(s)
					}
					).Where(s => s.Y > 0).ToList());
			//edsLog10.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
			edsLog10.SetXMapping(s => xAxis.ConvertToDouble(s.X));
			edsLog10.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
			edsLog10.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

			SolidColorBrush brushPow = new SolidColorBrush(Colors.Green);
			Pen linePenPow = new Pen(brushPow, 2.0);
			CircleElementPointMarker markerPow = new CircleElementPointMarker
			{
				Size = 4,
				Brush = brushPow,
				Fill = brushPow
			};
			PenDescription descPow = new PenDescription("f(x) = 10 ^ x");
			//var chartPow = plotter.AddLineGraph(edsPow, linePenPow, (ShapeElementPointMarker)null/*markerPow*/, descPow);

			SolidColorBrush brushLinear = new SolidColorBrush(Colors.Blue);
			Pen linePenLinear = new Pen(brushLinear, 2.0);
			CircleElementPointMarker markerLinear = new CircleElementPointMarker
			{
				Size = 4,
				Brush = brushLinear,
				Fill = brushLinear
			};
			PenDescription descLinear = new PenDescription("f(x) = x");
			//var chartLinear = plotter.AddLineGraph(edsLinear, linePenLinear, (ShapeElementPointMarker)null/*markerLinear*/, descLinear);

			SolidColorBrush brushLog10 = new SolidColorBrush(Colors.Red);
			Pen linePenLog10 = new Pen(brushLog10, 2.0);
			CircleElementPointMarker markerLog10 = new CircleElementPointMarker
			{
				Size = 4,
				Brush = brushLog10,
				Fill = brushLog10
			};
			PenDescription descLog10 = new PenDescription("f(x) = log(x)");
			var chartLog10 = plotter.AddLineGraph(edsLog10, linePenLog10, (ShapeElementPointMarker)null/*markerLog10*/, descLog10);

			//plotter.Children.Add(new DataFollowChart(chartPow.LineGraph).WithProperty(c =>
			//{
			//    c.Marker.SetValue(Shape.FillProperty, brushPow);
			//    c.Marker.SetValue(Shape.StrokeProperty, brushPow.MakeDarker(0.2));
			//}));
			//plotter.Children.Add(new DataFollowChart(chartLinear.LineGraph).WithProperty(c =>
			//{
			//    c.Marker.SetValue(Shape.FillProperty, brushLinear);
			//    c.Marker.SetValue(Shape.StrokeProperty, brushLinear.MakeDarker(0.2));
			//}));

			plotter.Children.Add(new CursorCoordinateGraph());

			ValueStore store = new ValueStore();
			DataFollowChart dataFollowChart = new DataFollowChart(chartLog10.LineGraph);
			dataFollowChart.Marker.SetValue(Shape.FillProperty, brushLog10);
			dataFollowChart.Marker.SetValue(Shape.StrokeProperty, brushLog10.ChangeLightness(0.8));
			dataFollowChart.MarkerPositionChanged += new EventHandler(dataFollowChart_MarkerPositionChanged);
			//dataFollowChart.CustomDataContextCallback = () =>
			//    {
			//        if (dataFollowChart.ClosestPointIndex != -1)
			//        {
			//            var closestPoint = ((List<TPoint>)edsLog10.Data)[dataFollowChart.ClosestPointIndex];
			//            return store.SetValue("X", closestPoint.Y.ToString()).SetValue("Y", closestPoint.X.ToShortDateString());
			//        }
			//        else return null;
			//    };

#if true
			dataFollowChart.MarkerTemplate = (DataTemplate)FindResource("followMarkerTemplate");
#else
				dataFollowChart.MarkerAdjustCallback = marker =>
				{
				    Ellipse ellipse = (Ellipse)marker;
				    var markerPosition = c.MarkerPosition;
				    var date = xAxis.ConvertFromDouble(markerPosition.X);
				    var y = yAxis.ConvertFromDouble(markerPosition.Y);
				    ellipse.ToolTip = String.Format("Vol:{0}\r\nOn:{1}", y, date.ToShortDateString());
				};
#endif

			plotter.Children.Add(dataFollowChart);

			Content = plotter;
		}
Esempio n. 14
0
        private void ChartPlotter_Loaded(object sender, RoutedEventArgs e)
        {
         
            if (!alreadyLoaded)
            {
                VerticalAxis = new VerticalAxis();

                #region Different initialization
                if (settings.HorizontalAxisType == ChartPlotterSettings.AxisType.NumericAxis)
                {
                  var h = new HorizontalAxis();
                    HorizontalAxis =h;
                }
                else HorizontalAxis = new HorizontalDateTimeAxis();

                if (settings.IsButtonNavigationPresents)
                {
                    buttonsNavigation = new buttonsNavigation(this);
                    HoveringStackPanel.Children.Add(buttonsNavigation);
                }

                if (settings.IsLegendPresents)
                {
                    legend = new Legend(this);
                    ScrollWraper legendWraper = new ScrollWraper(legend);
                    legendWraper.Margin = new Thickness(5, 10, 10, 10);
                    HoveringStackPanel.Children.Add(legendWraper);
                }
                #endregion

                Children.Add(axisGrid);
              if (mouseNavigation!=null)
                Children.Add(mouseNavigation);

              
              
                MainCanvas.SizeChanged += new SizeChangedEventHandler(MainCanvas_SizeChanged);
                HoveringStackPanel.SizeChanged += new SizeChangedEventHandler(hoveringPanel_SizeChanged);
                Viewport.FitToView();
                alreadyLoaded = true;
            }
        }
Esempio n. 15
0
        public void SetHorizontalAxisMapping(double min, DateTime minDate, double max, DateTime maxDate)
        {
            HorizontalDateTimeAxis axis = (HorizontalDateTimeAxis)MainHorizontalAxis;

            axis.SetConversion(min, minDate, max, maxDate);
        }
Esempio n. 16
0
        private void AddLineGraphs()
        {
            const int N = 10;
            const int M = 20;

            double[] x = new double[N];
            double[] y = new double[N];

            ////double[] x1 = new double[N];
            ////double[] y1 = new double[N];
            double[]   x1    = new double[M];
            double[]   y1    = new double[M];
            DateTime[] date1 = new DateTime[M];

            DateTime[] date = new DateTime[N];

            for (int i = 0; i < N * 2; i = i + 2)
            {
                x[i / 2] = i / 2 * 0.1;
                //x1[i/2] = i/2 * 0.2;
                y[i / 2] = Math.Sin(x[i / 2]);
                //y1[i/2] = Math.Cos(x1[i/2]) * this.factor;
                date[i / 2] = DateTime.Now.AddMinutes(-(N * 2) + i / 2);
            }

            for (int i = 0; i < M; i++)
            {
                x1[i]    = i * 0.2;
                y1[i]    = Math.Cos(x1[i]) * 2;
                date1[i] = DateTime.Now.AddMinutes(-M + i);
            }

            EnumerableDataSource <double> xs = new EnumerableDataSource <double>(y);

            xs.SetYMapping(_y => _y);
            EnumerableDataSource <DateTime> ys = new EnumerableDataSource <DateTime>(date);

            this.dateAxis = new HorizontalDateTimeAxis();
            ys.SetXMapping(dateAxis.ConvertToDouble);
            CompositeDataSource       ds = new CompositeDataSource(xs, ys);
            LinePerturbationViewModel lineGraphViewModel = new LinePerturbationViewModel(_container);

            lineGraphViewModel.PointDataSource = ds;
            this.editedDs                    = ds;
            lineGraphViewModel.Name          = string.Format("Test{0}", _pertCount++);
            lineGraphViewModel.Color         = Color.FromRgb(255, 0, 0);
            lineGraphViewModel.EntityId      = Guid.NewGuid();
            lineGraphViewModel.LineAndMarker = false;
            lineGraphViewModel.Thickness     = 1;
            this.LinePerturbations.Add(lineGraphViewModel);

            EnumerableDataSource <double> xs1 = new EnumerableDataSource <double>(y1);

            xs1.SetYMapping(_y1 => _y1 / 2);
            EnumerableDataSource <DateTime> ys1 = new EnumerableDataSource <DateTime>(date1);

            ys1.SetXMapping(dateAxis.ConvertToDouble);
            CompositeDataSource ds1 = new CompositeDataSource(xs1, ys1);

            lineGraphViewModel = new LinePerturbationViewModel(_container);
            lineGraphViewModel.PointDataSource = ds1;
            lineGraphViewModel.Name            = string.Format("Test{0}", _pertCount++);
            lineGraphViewModel.Color           = Color.FromRgb(0, 0, 255);
            lineGraphViewModel.EntityId        = Guid.NewGuid();
            lineGraphViewModel.LineAndMarker   = true;
            lineGraphViewModel.Thickness       = 1;
            this.LinePerturbations.Add(lineGraphViewModel);
        }
Esempio n. 17
0
        public AxisColoringSample()
        {
            InitializeComponent();

            // setting custom colors of background, axis text labels and axis ticks:
            {
                // background brush is for axis's background
                plotter.MainHorizontalAxis.Background = Brushes.Aqua.MakeTransparent(0.1);
                // foreground bruhs is for axis's labels foreground
                plotter.MainHorizontalAxis.Foreground = Brushes.DarkMagenta;

                plotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.LightBlue, 90);
                plotter.MainVerticalAxis.Foreground = Brushes.DarkGoldenrod;

                // stroke brush is
                // ------ /*to rule them all*/ ------
                // for ticks' fill
                ((NumericAxis)plotter.MainHorizontalAxis).AxisControl.TicksPath.Stroke = Brushes.OrangeRed;
            }

            // this will make the most left axis to display ticks as percents
            secondAxis.LabelProvider = new ToStringLabelProvider();
            secondAxis.LabelProvider.LabelStringFormat = "{0}%";
            secondAxis.LabelProvider.SetCustomFormatter(info => (info.Tick * 100).ToString());
            // percent values that can be divided by 50 without a remainder will be red and with bigger font size
            secondAxis.LabelProvider.SetCustomView((info, ui) =>
            {
                if (((int)Math.Round(info.Tick * 100)) % 50 == 0)
                {
                    TextBlock text  = (TextBlock)ui;
                    text.Foreground = Brushes.Red;
                    text.FontSize   = 20;
                }
            });

            // you can add new axes not only from XAML, but from C#, too:
            HorizontalDateTimeAxis thirdAxis = new HorizontalDateTimeAxis();

            thirdAxis.LabelProvider.SetCustomFormatter(info =>
            {
                DifferenceIn dateTimeDifference = (DifferenceIn)info.Info;
                if (dateTimeDifference == DifferenceIn.Minute)
                {
                    return(info.Tick.ToString("%m:ss"));
                }

                // null should be returned if you want to use default label text
                return(null);
            });

            // let's have major labels for hours in Spanish,
            // for other time periods your Thread.CurrentThread.CurrentCulture will be used to format date.
            // You can change this default thread culture and get desired look of labels.

            CultureInfo culture = new CultureInfo("es-ES");

            thirdAxis.MajorLabelProvider.SetCustomFormatter(info =>
            {
                MajorLabelsInfo mInfo = (MajorLabelsInfo)info.Info;
                if ((DifferenceIn)mInfo.Info == DifferenceIn.Hour)
                {
                    return(info.Tick.ToString("MMMM/dd %m:ss", culture));
                }
                return(null);
            });
            plotter.Children.Add(thirdAxis);

            SetupLocationalAxis();

            SetupPiAxis();

            SetupOneThirdAxis();
        }
Esempio n. 18
0
        void LogYWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //ChartPlotter plotter = new ChartPlotter();

            //plotter.Children.Add(new CursorCoordinateGraph());

            //plotter.DataTransform = new Log10YTransform();
            //VerticalAxis axis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //plotter.MainVerticalAxis = axis;

            //plotter.AxisGrid.DrawVerticalMinorTicks = true;

            //const int count = 500;
            //double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
            //EnumerableDataSource<double> xDS = xs.AsXDataSource();

            //var pows = xs.Select(x => Math.Pow(10, x));
            //var linear = xs.Select(x => x);
            //var logXs = Enumerable.Range(101, count).Select(x => x * 0.01);
            //var logarithmic = logXs.Select(x => Math.Log10(x));

            //plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
            //plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
            //plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

            //Content = plotter;

            ChartPlotter plotter = new ChartPlotter();

            plotter.DataTransform = new Log10YTransform();
            VerticalAxis yAxis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
            };

            plotter.MainVerticalAxis = yAxis;
            plotter.AxisGrid.DrawVerticalMinorTicks = true;

            HorizontalDateTimeAxis xAxis = new HorizontalDateTimeAxis();

            plotter.MainHorizontalAxis = xAxis;

            EnumerableDataSource <TPoint> edsPow = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Pow(10, s / 5000.0)
            }
                                                 ).ToList());

            //edsPow.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsPow.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsPow.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            EnumerableDataSource <TPoint> edsLinear = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = s / 2000.0
            }
                                                 ).ToList());

            //edsLinear.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLinear.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsLinear.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            edsLog10 = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Log10(s)
            }
                                                 ).Where(s => s.Y > 0).ToList());
            //edsLog10.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLog10.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLog10.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsLog10.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            SolidColorBrush          brushPow   = new SolidColorBrush(Colors.Green);
            Pen                      linePenPow = new Pen(brushPow, 2.0);
            CircleElementPointMarker markerPow  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushPow,
                Fill  = brushPow
            };
            PenDescription descPow = new PenDescription("f(x) = 10 ^ x");
            //var chartPow = plotter.AddLineGraph(edsPow, linePenPow, (ShapeElementPointMarker)null/*markerPow*/, descPow);

            SolidColorBrush          brushLinear   = new SolidColorBrush(Colors.Blue);
            Pen                      linePenLinear = new Pen(brushLinear, 2.0);
            CircleElementPointMarker markerLinear  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushLinear,
                Fill  = brushLinear
            };
            PenDescription descLinear = new PenDescription("f(x) = x");
            //var chartLinear = plotter.AddLineGraph(edsLinear, linePenLinear, (ShapeElementPointMarker)null/*markerLinear*/, descLinear);

            SolidColorBrush          brushLog10   = new SolidColorBrush(Colors.Red);
            Pen                      linePenLog10 = new Pen(brushLog10, 2.0);
            CircleElementPointMarker markerLog10  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushLog10,
                Fill  = brushLog10
            };
            PenDescription descLog10  = new PenDescription("f(x) = log(x)");
            var            chartLog10 = plotter.AddLineGraph(edsLog10, linePenLog10, (ShapeElementPointMarker)null /*markerLog10*/, descLog10);

            //plotter.Children.Add(new DataFollowChart(chartPow.LineGraph).WithProperty(c =>
            //{
            //    c.Marker.SetValue(Shape.FillProperty, brushPow);
            //    c.Marker.SetValue(Shape.StrokeProperty, brushPow.MakeDarker(0.2));
            //}));
            //plotter.Children.Add(new DataFollowChart(chartLinear.LineGraph).WithProperty(c =>
            //{
            //    c.Marker.SetValue(Shape.FillProperty, brushLinear);
            //    c.Marker.SetValue(Shape.StrokeProperty, brushLinear.MakeDarker(0.2));
            //}));

            plotter.Children.Add(new CursorCoordinateGraph());

            ValueStore      store           = new ValueStore();
            DataFollowChart dataFollowChart = new DataFollowChart(chartLog10.LineGraph);

            dataFollowChart.Marker.SetValue(Shape.FillProperty, brushLog10);
            dataFollowChart.Marker.SetValue(Shape.StrokeProperty, brushLog10.ChangeLightness(0.8));
            dataFollowChart.MarkerPositionChanged += new EventHandler(dataFollowChart_MarkerPositionChanged);
            //dataFollowChart.CustomDataContextCallback = () =>
            //    {
            //        if (dataFollowChart.ClosestPointIndex != -1)
            //        {
            //            var closestPoint = ((List<TPoint>)edsLog10.Data)[dataFollowChart.ClosestPointIndex];
            //            return store.SetValue("X", closestPoint.Y.ToString()).SetValue("Y", closestPoint.X.ToShortDateString());
            //        }
            //        else return null;
            //    };

#if true
            dataFollowChart.MarkerTemplate = (DataTemplate)FindResource("followMarkerTemplate");
#else
            dataFollowChart.MarkerAdjustCallback = marker =>
            {
                Ellipse ellipse        = (Ellipse)marker;
                var     markerPosition = c.MarkerPosition;
                var     date           = xAxis.ConvertFromDouble(markerPosition.X);
                var     y = yAxis.ConvertFromDouble(markerPosition.Y);
                ellipse.ToolTip = String.Format("Vol:{0}\r\nOn:{1}", y, date.ToShortDateString());
            };
#endif

            plotter.Children.Add(dataFollowChart);

            Content = plotter;
        }
Esempio n. 19
0
 public TimeChartPlotter()
 {
     MainHorizontalAxis = new HorizontalDateTimeAxis();
 }
Esempio n. 20
0
        public void InitChart()
        {
            xs = new EnumerableDataSource <double>(y);
            xs.SetYMapping(_y => _y);
            ys            = new EnumerableDataSource <double>(x);
            this.dateAxis = new HorizontalDateTimeAxis();
            ys.SetXMapping(t_y => t_y);
            CompositeDataSource ds = new CompositeDataSource(xs, ys);
            LineGraphViewModel  lineGraphViewModel = new LineGraphViewModel();

            lineGraphViewModel.PointDataSource = ds;
            this.editedDs                    = ds;
            lineGraphViewModel.Name          = "频谱曲线";
            lineGraphViewModel.Color         = Color.FromRgb(255, 0, 0);
            lineGraphViewModel.EntityId      = Guid.NewGuid();
            lineGraphViewModel.LineAndMarker = false;
            lineGraphViewModel.Thickness     = 1;

            this.LineGraphs.Add(lineGraphViewModel);

            _uiContext.Send(o =>
            {
                ThreadShowOperator = new Thread(new ThreadStart(() =>
                {
                    while (true)
                    {
                        lock (FreqLineDataItemBuffer)
                        {
                            if (FreqLineDataItemBuffer.Count > 0)
                            {
                                FreqLineDataItem item = FreqLineDataItemBuffer.Dequeue();
                                _uiContext.Post(MySendOrPostCallback, item);
                                Monitor.Pulse(FreqLineDataItemBuffer);
                            }
                            else
                            {
                                Monitor.Wait(FreqLineDataItemBuffer);
                            }
                        }
                    }
                }))
                {
                    IsBackground = true
                };
                ThreadShowOperator.Start();
            }, null);
            //BackgroundWorker backgroundWorker = new BackgroundWorker();
            //backgroundWorker.DoWork +=(o,ea)=>
            //{
            //    try{
            //        while (true)
            //        {
            //            lock (FreqLineDataItemBuffer)
            //            {
            //                if (FreqLineDataItemBuffer.Count > 0)
            //                {
            //                    FreqLineDataItem item = FreqLineDataItemBuffer.Dequeue();
            //                    //UpdateChartData(item);
            //                    _uiContext.Send(MySendOrPostCallback, item);
            //                    Monitor.Pulse(FreqLineDataItemBuffer);
            //                }
            //                else
            //                {
            //                    Monitor.Wait(FreqLineDataItemBuffer);
            //                }
            //            }
            //        }
            //    }
            //    catch(Exception e)
            //    {

            //    }
            //};

            //backgroundWorker.RunWorkerCompleted += (o, ea) =>
            //{

            //};

            //backgroundWorker.RunWorkerAsync();
            //ThreadPool.QueueUserWorkItem(
            //  o =>
            //  {
            //      while (true)
            //      {
            //          lock (FreqLineDataItemBuffer)
            //          {
            //              if (FreqLineDataItemBuffer.Count > 0)
            //              {
            //                  FreqLineDataItem item = FreqLineDataItemBuffer.Dequeue();
            //                  UpdateChartData(item);
            //                  Monitor.Pulse(FreqLineDataItemBuffer);
            //              }
            //              else
            //              {
            //                  Monitor.Wait(FreqLineDataItemBuffer);
            //              }
            //          }
            //      }
            //  });
        }
Esempio n. 21
0
		public Window1()
		{
			InitializeComponent();

			// setting custom colors of background, axis text labels and axis ticks:
			{
				// background brush is for axis's background
				plotter.MainHorizontalAxis.Background = Brushes.Aqua.MakeTransparent(0.1);
				// foreground bruhs is for axis's labels foreground
				plotter.MainHorizontalAxis.Foreground = Brushes.DarkMagenta;

				plotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.LightBlue, 90);
				plotter.MainVerticalAxis.Foreground = Brushes.DarkGoldenrod;

				// stroke brush is 
				// ------ /*to rule them all*/ ------
				// for ticks' fill
				((NumericAxis)plotter.MainHorizontalAxis).AxisControl.TicksPath.Stroke = Brushes.OrangeRed;
			}

			// this will make the most left axis to display ticks as percents
			secondAxis.LabelProvider = new ToStringLabelProvider();
			secondAxis.LabelProvider.LabelStringFormat = "{0}%";
			secondAxis.LabelProvider.SetCustomFormatter(info => (info.Tick * 100).ToString());
			// percent values that can be divided by 50 without a remainder will be red and with bigger font size
			secondAxis.LabelProvider.SetCustomView((info, ui) =>
			{
				if (((int)Math.Round(info.Tick * 100)) % 50 == 0)
				{
					TextBlock text = (TextBlock)ui;
					text.Foreground = Brushes.Red;
					text.FontSize = 20;

				}
			});

			// you can add new axes not only from XAML, but from C#, too:
			HorizontalDateTimeAxis thirdAxis = new HorizontalDateTimeAxis();
			thirdAxis.LabelProvider.SetCustomFormatter(info =>
			{
				DifferenceIn dateTimeDifference = (DifferenceIn)info.Info;
				if (dateTimeDifference == DifferenceIn.Minute)
				{
					return info.Tick.ToString("%m:ss");
				}

				// null should be returned if you want to use default label text
				return null;
			});

			// let's have major labels for hours in Spanish,
			// for other time periods your Thread.CurrentThread.CurrentCulture will be used to format date.
			// You can change this default thread culture and get desired look of labels.

			CultureInfo culture = new CultureInfo("es-ES");
			thirdAxis.MajorLabelProvider.SetCustomFormatter(info =>
			{
				MajorLabelsInfo mInfo = (MajorLabelsInfo)info.Info;
				if ((DifferenceIn)mInfo.Info == DifferenceIn.Hour)
				{
					return info.Tick.ToString("MMMM/dd %m:ss", culture);
				}
				return null;
			});
			plotter.Children.Add(thirdAxis);

			SetupLocationalAxis();

			SetupPiAxis();

			SetupOneThirdAxis();
		}
Esempio n. 22
0
        void BindingData()
        {
            if (!dtstart.Value.HasValue || !dtend.Value.HasValue)
            {
                return;
            }
            DateTime start = dtstart.Value.Value;
            DateTime end   = dtend.Value.Value;

            if ((end - start).Days > 7)
            {
                end         = start.AddDays(7);
                dtend.Value = end;
            }
            else if (start >= end)
            {
                end         = start.AddDays(1);
                dtend.Value = end;
            }
            HashSet <short> hash = new HashSet <short>();

            foreach (var item in sortlist)
            {
                item.Value.Collection.Clear();
                hash.Add(item.Key);
            }

            foreach (KeyValuePair <short, string> item in chklist.SelectedItems)
            {
                ObservableDataSource <HistoryData> source;
                if (!sortlist.TryGetValue(item.Key, out source))
                {
                    source = new ObservableDataSource <HistoryData>();
                    source.SetXMapping(X => hTimeSpanAxis.ConvertToDouble(X.TimeStamp));
                    source.SetSourceMapping(App.Server[item.Key]);
                    if (comodel.SelectedIndex == 0 ||
                        (comodel.SelectedIndex == 1 && sortlist.Count == 0))
                    //|| (comodel.SelectedIndex == 2 && (sortlist.Count == 0 || chklist.SelectedItems.Count == 1)))
                    {
                        plotterlist[item.Key] = chartPlotter1.AddLineGraph(source, 2, item.Value);
                    }
                    else
                    {
                        var innerPlotter = new InjectedPlotter()
                        {
                            SetViewportBinding = false
                        };
                        var axis = new HorizontalDateTimeAxis();
                        innerPlotter.Children.Add(axis);
                        innerPlotter.MainHorizontalAxis = axis;
                        innerPlotter.Children.Add(new VerticalAxis()
                        {
                            Placement = AxisPlacement.Right
                        });
                        innerPlotter.Children.Add(new VerticalAxisTitle()
                        {
                            Content = item.Value, Placement = AxisPlacement.Right
                        });
                        chartPlotter1.Children.Add(innerPlotter);
                        innerPlotter.AddLineGraph(source, 2, item.Value);
                        plotterlist.Add(item.Key, innerPlotter);
                    }
                    sortlist.Add(item.Key, source);
                }
                hash.Remove(item.Key);
                var data = App.Server.ReadRaw(start, end, item.Key);
                if (data != null)
                {
                    bool first = true;
                    var  temp  = new HistoryData(item.Key, QUALITIES.QUALITY_GOOD, Storage.Empty, start);
                    source.SuspendUpdate();
                    foreach (var p in data)
                    {
                        if (first)
                        {
                            temp.Value = p.Value;
                            source.Collection.Add(temp);
                            first = false;
                        }
                        source.Collection.Add(p);
                    }
                    if (source.Collection.Count == 0)
                    {
                        source.Collection.Add(temp);
                    }
                    temp           = source.Collection[source.Collection.Count - 1];
                    temp.TimeStamp = end;
                    source.Collection.Add(temp);
                    source.ResumeUpdate();
                }
                chartPlotter1.FitToView();
            }
            foreach (short id in hash)
            {
                sortlist.Remove(id);
                IPlotterElement plotter;
                if (plotterlist.TryGetValue(id, out plotter))
                {
                    var chart = plotter as Plotter;
                    if (chart != null)
                    {
                        for (int i = chart.Children.Count - 1; i >= 0; i--)
                        {
                            chart.Children[i].RemoveFromPlotter();
                        }
                    }
                    plotter.RemoveFromPlotter();
                    plotterlist.Remove(id);
                }
            }
        }
Esempio n. 23
0
 private void ConfigureXAxis(ChartPlotter plotter)
 {
     xAxis = new HorizontalDateTimeAxis();
     plotter.MainHorizontalAxis = xAxis;
 }
Esempio n. 24
0
        private UIElement GenerateResultLayout(int channel, string sampleNum, string sampleName)
        {
            Border border = new Border()
            {
                Width               = 600,
                Height              = 440,
                Margin              = new Thickness(2),
                BorderThickness     = new Thickness(5),
                BorderBrush         = _borderBrushNormal,
                CornerRadius        = new CornerRadius(10),
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Name = "border"
            };
            StackPanel stackPanel = new StackPanel()
            {
                Width  = 600,
                Height = 420,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Name = "stackPanel"
            };
            Grid grid = new Grid()
            {
                Width  = 600,
                Height = 40,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right
            };
            Label label = new Label()
            {
                FontSize            = 20,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                VerticalAlignment   = System.Windows.VerticalAlignment.Center,
                Content             = " 检测通道" + (channel + 1)
            };
            Canvas canvas = new Canvas()
            {
                Width      = 600,
                Height     = 400,
                Background = Brushes.Gray,
                Name       = "canvas"
            };

            plotter = new ChartPlotter()
            {
                Width  = 600,
                Height = 380,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch
            };
            plotter.MouseDoubleClick += new MouseButtonEventHandler(plotter_MouseDoubleClick);
            plotter.Name              = "chartPlotter";

            HorizontalAxis horizontalAxis = new HorizontalAxis()
            {
                Name = "horizontalAxis"
            };

            dateAxis = new HorizontalDateTimeAxis()
            {
                //dateAxis = new HorizontalIntegerAxis();
                Name = "dateAxis"
            };
            VerticalAxis verticalAxis = new VerticalAxis()
            {
                Name = "verticalAxis"
            };
            VerticalIntegerAxis countAxis = new VerticalIntegerAxis()
            {
                Name = "countAxis"
            };
            VerticalAxisTitle arialy = new VerticalAxisTitle()
            {
                Content = "y"
            };
            HorizontalAxisTitle arialx = new HorizontalAxisTitle()
            {
                Content = "x"
            };

            canvas.Children.Add(plotter);
            canvas.Children.Add(dateAxis);
            canvas.Children.Add(verticalAxis);
            canvas.Children.Add(countAxis);
            canvas.Children.Add(arialy);
            canvas.Children.Add(arialx);

            WrapPanel wrapPannelSampleNum = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelSampleNum = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 样品编号:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxSampleNum = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty + sampleNum,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true
            };
            WrapPanel wrapPannelSampleName = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelSampleName = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 样品名称:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxSampleName = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty + _item.Hole[channel].SampleName,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true
            };
            WrapPanel wrapPannelRGBValue = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelRGBValue = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 灰度值:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxRGBValue = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true,
                Name       = "textBoxRGBValue"
            };
            WrapPanel wrapPannelDetectResult = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelDetectResult = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 检测结果:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxDetectResult = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "0.00",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true,
                Name       = "textBoxDetectResult"
            };

            //判定结果
            WrapPanel wrapJudgemtn = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelJudgment = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 判定结果:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textJugmentResult = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "合格",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                Name = "textJugmentResult"
            };
            //判定标准值
            WrapPanel wrapStandValue = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelStandValue = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 标准值:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textStandValue = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "1.00",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                Name = "textStandValue"
            };

            wrapPannelSampleNum.Children.Add(labelSampleNum);
            wrapPannelSampleNum.Children.Add(textBoxSampleNum);
            wrapPannelSampleName.Children.Add(labelSampleName);
            wrapPannelSampleName.Children.Add(textBoxSampleName);
            wrapPannelDetectResult.Children.Add(labelDetectResult);
            wrapPannelDetectResult.Children.Add(textBoxDetectResult);
            wrapJudgemtn.Children.Add(labelJudgment);
            wrapJudgemtn.Children.Add(textJugmentResult);
            wrapStandValue.Children.Add(labelStandValue);
            wrapStandValue.Children.Add(textStandValue);

            grid.Children.Add(label);
            stackPanel.Children.Add(grid);
            stackPanel.Children.Add(canvas);
            //stackPanel.Children.Add(wrapPannelSampleNum);
            //stackPanel.Children.Add(wrapPannelSampleName);
            //stackPanel.Children.Add(wrapPannelDetectResult);
            //stackPanel.Children.Add(wrapJudgemtn);
            //stackPanel.Children.Add(wrapStandValue);
            border.Child = stackPanel;
            return(border);
        }