public void TestAddingToPlotter()
        {
            HorizontalLine line = new HorizontalLine {
                Value = 0.2
            };
            ChartPlotter plotter = new ChartPlotter();

            plotter.Children.Add(line);

            VerticalLine line2 = new VerticalLine {
                Value = 0.1
            };

            plotter.Children.Add(line2);

            VerticalRange range = new VerticalRange {
                Value1 = 0.1, Value2 = 0.3
            };

            plotter.Children.Add(range);

            RectangleHighlight rect = new RectangleHighlight {
                Bounds = new Rect(0, 0, 1, 1)
            };

            plotter.Children.Add(rect);
        }
Exemplo n.º 2
0
        private void addRect(double value, double width)
        {
            RectangleHighlight rh = new RectangleHighlight();

            rh.Bounds          = new Rect(new Point(value - width, 0), new Point(value, 0));
            rh.Stroke          = new SolidColorBrush(Colors.OrangeRed);
            rh.StrokeThickness = 2;
            this.chart.Children.Add(rh);
        }
Exemplo n.º 3
0
        public void AddTruthRect(int start, int end, Brush color, double height = 1)
        {
            RectangleHighlight rec = new RectangleHighlight();

            rec.Bounds  = new System.Windows.Rect(start, 0, end - start, height);
            rec.Fill    = color;
            rec.Opacity = 0.5;
            _rectList.Add(rec);
            //  _chartPlotter.Children.Add(rec);
        }
        public SelectorPlotter()
        {
            Viewport.Restrictions.Add(new FixedXRestriction());
            Viewport.Domain = DataRect.Create(0, 0, 1, 1);

            Children.Remove(MainHorizontalAxis);
            Children.Remove(MainVerticalAxis);
            Children.Remove(HorizontalAxisNavigation);
            Children.Remove(VerticalAxisNavigation);
            Children.Remove(AxisGrid);
            Children.Remove(DefaultContextMenu);
            Children.Remove(MouseNavigation);
            Children.Remove(Legend);
            Children.Remove(NewLegend);

            leftHighlight = new RectangleHighlight {
                Fill = highlightFill, Stroke = Brushes.DarkGray, Name = "Left_Highlight"
            };
            Children.Add(leftHighlight);
            rightHighlight = new RectangleHighlight {
                Fill = highlightFill, Stroke = Brushes.DarkGray, Name = "Right_Highlight"
            };
            Children.Add(rightHighlight);

            ResourceDictionary dict = new ResourceDictionary
            {
                Source = new Uri("/DynamicDataDisplay.Controls;component/Themes/Generic.xaml", UriKind.Relative)
            };

            Style plotterStyle = (Style)dict[typeof(SelectorPlotter)];

            Style    = plotterStyle;
            Template = (ControlTemplate)(((Setter)plotterStyle.Setters[1]).Value);
            ApplyTemplate();

            Style draggablePointstyle = (Style)dict[typeof(TemplateableDraggablePoint)];

            marker.Style = draggablePointstyle;

            Panel content = (Panel)Content;

            content.MouseLeftButtonDown += CentralGrid_MouseLeftButtonDown;
            content.MouseLeftButtonUp   += CentralGrid_MouseLeftButtonUp;

            selectorNavigation.MouseLeftButtonClick += new MouseButtonEventHandler(selectorNavigation_MouseLeftButtonClick);
            Children.Add(selectorNavigation);

            marker.PositionChanged += marker_PositionChanged;
            marker.PositionCoerceCallbacks.Add(CoerceMarkerPosition);
            marker.InvalidateProperty(PositionalViewportUIContainer.PositionProperty);
            Children.Add(marker);

            Viewport.PropertyChanged += Viewport_PropertyChanged;
            UpdateDomain();
        }
        //管理端绘制图形用oracle数据
        private void DrawChartByOraData(FreqNavBar fnr)
        {
            List <AnalysisResult> analysisList = new List <AnalysisResult>();

            //fnr.FreqStart = "80";
            //fnr.FreqStop = "107";
            //fnr.PlaceGuid = "0638536e6c5d4a358b579f94d8f170b1";
            //测试 34,66,0638536e6c5d4a358b579f94d8f170b1
            //PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke<I_CO_IA.FreqPlan.I_CO_IA_FreqPlan>(channel =>
            //{
            //    analysisList = channel.GetAnalysisResultList(Convert.ToDouble(fnr.FreqStart), Convert.ToDouble(fnr.FreqStop), fnr.PlaceGuid);
            //});

            analysisList = PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.FreqStation.I_CO_IA_FreqStation, List <AnalysisResult> >(channel =>
            {
                return(channel.GetAnalysisResultList(Convert.ToDouble(fnr.FreqStart), Convert.ToDouble(fnr.FreqStop), fnr.PlaceGuid));
            });

            if (analysisList.Count > 0)
            {
                freqList = new ObservableCollection <AnalysisResult>(analysisList);
                initDataSource(freqList);
                removeBar();
                foreach (AnalysisResult ar in analysisList)
                {
                    if (ar.Occupy == 0)
                    {
                        continue;
                    }
                    RectangleHighlight rh = new RectangleHighlight();
                    rh.Bounds          = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(ar.Frequency, 0, 0, ar.Occupy));
                    rh.Stroke          = Brushes.Yellow;
                    rh.StrokeThickness = 10;
                    rh.ToolTip         = ar.Frequency.ToString("0.0000") + "MHz";
                    BarPlotter.Children.Add(rh);
                }
                BarPlotter.MainHorizontalAxis.Background = Brushes.White;
                BarPlotter.MainVerticalAxis.Background   = Brushes.White;
                BarPlotter.MainHorizontalAxis.Foreground = Brushes.Orange;
                BarPlotter.MainVerticalAxis.Foreground   = Brushes.Orange;
                BarPlotter.Visible = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(Convert.ToDouble(fnr.FreqStart), 0, Convert.ToDouble(fnr.FreqStop) - Convert.ToDouble(fnr.FreqStart), 100));
            }
            else
            {
                MessageBox.Show("未查询到分析结果数据!");
            }
        }
        //绘制占用度和谱图
        private void setFreqStatDataSouce(Dictionary <double, FreqStatModel> dicFreqStatModel, ChartSeriesPoints chartSeriesPoints)
        {
            ObservableDataSource <Point> maxDataSource = new ObservableDataSource <Point>();
            ObservableDataSource <Point> midDataSource = new ObservableDataSource <Point>();

            if (dicFreqStatModel != null)
            {
                double tempFreq;
                foreach (KeyValuePair <double, FreqStatModel> kvp in dicFreqStatModel)
                {
                    Point dpMax = new Point();
                    Point dpMid = new Point();
                    tempFreq = kvp.Key;
                    int    overSignalLimit = kvp.Value.DicAmplitudeCount.Where(x => x.Key > chartSeriesPoints.SignalLimit).Select(x => x.Value).Sum();
                    int    sum             = kvp.Value.DicAmplitudeCount.Values.Sum();
                    double occpy           = (double)overSignalLimit / (double)sum;
                    if (occpy > 0.9)
                    {
                    }
                    double maxValue = kvp.Value.DicAmplitudeCount.Keys.Max();
                    dpMax.X = tempFreq / 1000;
                    dpMax.Y = Convert.ToInt16(maxValue);

                    maxDataSource.AppendAsync(plotter.Dispatcher, dpMax);

                    double AverageValue = kvp.Value.DicAmplitudeCount.Select(x => x.Key).Average();
                    dpMid.X = tempFreq / 1000;
                    dpMid.Y = Convert.ToInt16(AverageValue);
                    midDataSource.AppendAsync(plotter.Dispatcher, dpMid);
                }
            }
            plotter.Dispatcher.Invoke(
                new Action(
                    delegate
            {
                List <LineGraph> temp = new List <LineGraph>();
                foreach (var obj in plotter.Children)
                {
                    if (typeof(LineGraph).IsAssignableFrom(obj.GetType()))
                    {
                        temp.Add((LineGraph)obj);
                    }
                }
                if (temp.Count > 0)
                {
                    foreach (LineGraph rh in temp)
                    {
                        plotter.Children.Remove(rh);
                    }
                }
                plotter.AddLineGraph(maxDataSource, Colors.Red, 1, "最大值");
                plotter.AddLineGraph(midDataSource, Colors.LightBlue, 1, "中值");
                plotter.Visible = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(chartSeriesPoints.MinFreq, 0, chartSeriesPoints.MaxFreq - chartSeriesPoints.MinFreq, 100));
                //linegraphMax.DataSource = maxDataSource;
            }
                    )
                );
            // linegraphMid.Dispatcher.Invoke(
            //    new Action(
            //        delegate
            //        {
            //            linegraphMid.DataSource = midDataSource;
            //            plotter.Visible = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(chartSeriesPoints.MinFreq, 0, chartSeriesPoints.MaxFreq - chartSeriesPoints.MinFreq, 100));
            //        }
            //    )
            //);
            BarPlotter.Dispatcher.Invoke(
                new Action(
                    delegate
            {
                List <RectangleHighlight> temp = new List <RectangleHighlight>();
                foreach (var obj in BarPlotter.Children)
                {
                    if (typeof(RectangleHighlight).IsAssignableFrom(obj.GetType()))
                    {
                        temp.Add((RectangleHighlight)obj);
                    }
                }
                if (temp.Count > 0)
                {
                    foreach (RectangleHighlight rh in temp)
                    {
                        BarPlotter.Children.Remove(rh);
                    }
                }
                foreach (PointPair pp in chartSeriesPoints.OccupyPointPairList)
                {
                    if (pp.Y >= chartSeriesPoints.OccuDegreeLimit)
                    {
                        RectangleHighlight rh = new RectangleHighlight();
                        rh.Bounds             = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(pp.X, 0, 0, pp.Y));
                        rh.Stroke             = Brushes.Yellow;
                        rh.StrokeThickness    = 10;
                        rh.ToolTip            = pp.X.ToString("0.0000") + "MHz";
                        BarPlotter.Children.Add(rh);
                    }
                }
                BarPlotter.Visible = new Microsoft.Research.DynamicDataDisplay.DataRect(new Rect(chartSeriesPoints.MinFreq, 0, chartSeriesPoints.MaxFreq - chartSeriesPoints.MinFreq, 100));
                //ObservableDataSource<Point> standDataSource = new ObservableDataSource<Point>();
                //standDataSource.AppendAsync(BarPlotter.Dispatcher, new Point(chartSeriesPoints.MinFreq, 0));
                //standDataSource.AppendAsync(BarPlotter.Dispatcher, new Point(chartSeriesPoints.MinFreq, 100));
                //standDataSource.AppendAsync(BarPlotter.Dispatcher, new Point(chartSeriesPoints.MaxFreq, 100));
                //standDataSource.AppendAsync(BarPlotter.Dispatcher, new Point(chartSeriesPoints.MaxFreq, 0));
                //linegraphStand.DataSource = standDataSource;
            }
                    )
                );

            //this.freqDataSeries.Dispatcher.Invoke(
            //    new Action(
            //       delegate
            //       {
            //           freqDataSeries.DataPoints.Clear();
            //           if (dicFreqStatModel != null)
            //           {
            //               double tempFreq;
            //               foreach (KeyValuePair<double, FreqStatModel> kvp in dicFreqStatModel)
            //               {
            //                   Visifire.Charts.DataPoint dpMax = new Visifire.Charts.DataPoint();

            //                   tempFreq = kvp.Key;
            //                   int overSignalLimit = kvp.Value.DicAmplitudeCount.Where(x => x.Key > 45).Select(x => x.Value).Sum();
            //                   int sum = kvp.Value.DicAmplitudeCount.Values.Sum();
            //                   double occpy = (double)overSignalLimit / (double)sum;
            //                   if (occpy > 0.9)
            //                   {
            //                   }
            //                   double maxValue = kvp.Value.DicAmplitudeCount.Keys.Max();
            //                   //AmplitudeMaxValue.Add(Convert.ToInt16(maxValue));
            //                   dpMax.XValue = tempFreq / 1000;
            //                   dpMax.YValue = Convert.ToInt16(maxValue);

            //                   //spMax.X = tempFreq / 1000;
            //                   //spMax.Y = Convert.ToInt16(maxValue);
            //                   //maxValues.Add(spMax);
            //                    freqDataSeries.DataPoints.Add(dpMax);
            //                   double AverageValue = kvp.Value.DicAmplitudeCount.Select(x => x.Key).Average();
            //               }
            //           }
            //       }
            //    )
            //);
        }