private void ComboBoxMeasurement_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxMeasurement.Items.Count > 0) { DataModelMeasurement selectedMeasurement = (DataModelMeasurement)ComboBoxMeasurement.SelectedItem; if (selectedMeasurement != null) { m_signalID = selectedMeasurement.SignalID.ToString(); if (selectedMeasurement.SignalSuffix == "PA") { ChartPlotterDynamic.Visible = DataRect.Create(0, -180, m_numberOfPointsToPlot, 180); } else if (selectedMeasurement.SignalSuffix == "FQ") { double frequencyMin = Convert.ToDouble(IsolatedStorageManager.ReadFromIsolatedStorage("FrequencyRangeMin")); double frequencyMax = Convert.ToDouble(IsolatedStorageManager.ReadFromIsolatedStorage("FrequencyRangeMax")); ChartPlotterDynamic.Visible = DataRect.Create(0, Math.Min(frequencyMin, frequencyMax), m_numberOfPointsToPlot, Math.Max(frequencyMin, frequencyMax)); } } } else { m_signalID = string.Empty; } SubscribeUnsynchronizedData(); }
public void Contains_1() { var big = DataRect.Create(0, 0, 1, 1); var small = DataRect.Create(0.1, 0.1, 0.9, 0.9); Assert.IsTrue(big.Contains(small)); Assert.IsTrue(big.IntersectsWith(small)); Assert.IsTrue(small.IntersectsWith(big)); Assert.IsFalse(small.Contains(big)); }
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(); }
public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport) { DataRect parentVisible = parentViewport.Visible; double xmin = parentVisible.XMin * xScale + xShift; double xmax = parentVisible.XMax * xScale + xShift; double ymin = parentVisible.YMin * yScale + yShift; double ymax = parentVisible.YMax * yScale + yShift; return(DataRect.Create(xmin, ymin, xmax, ymax)); }
private void UpdateDomain() { double width = Math.Min(Viewport.Visible.Width / 2, domain.Max - domain.Min); double min = Domain.Min - width; double max = Domain.Max + width; leftHighlight.Bounds = DataRect.Create(min, -0.1, Domain.Min, 1.1); rightHighlight.Bounds = DataRect.Create(Domain.Max, -0.1, max, 1.1); Viewport.Domain = DataRect.Create(min, 0, max, 1); }
public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport) { DataRect borderRect = DataRect.Create(proposedDataRect.XMin, minSeconds, proposedDataRect.XMax, maxSeconds); if (proposedDataRect.IntersectsWith(borderRect)) { DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect); return croppedRect; } return previousDataRect; }
public void UniteWithEndlessRect() { DataRect endless = DataRect.Create(0, 0, Double.PositiveInfinity, 1); DataRect r = DataRect.Create(-1, -1, 2, 2); DataRect union = endless; union.Union(r); Assert.AreEqual(DataRect.Create(-1, -1, Double.PositiveInfinity, 2), union); }
protected override object ConvertCore(double value1, double value2, double value3, double value4, Type targetType, object parameter, CultureInfo culture) { double crownHeight = value1; double trunkHeight = value2; double crownWidth = value3; double x = value4; double halfWidth = crownWidth / 2; DataRect result = DataRect.Create(x - halfWidth, 0, x + halfWidth, trunkHeight + crownHeight); return(result); }
private void Window_Loaded(object sender, RoutedEventArgs e) { innerPlotter.ViewportBindingConverter = new InjectedPlotterVerticalSyncConverter(innerPlotter); plotter.Visible = DataRect.Create(0, -1.1, 10, 1.1); var xs = Enumerable.Range(0, 10000).Select(i => i * 0.01); var xds = xs.AsXDataSource(); var ys1 = xs.Select(x => Math.Sin(x)).AsYDataSource(); plotter.AddLineGraph(ys1.Join(xds), 2.0); var ys2 = xs.Select(x => Math.Cos(x)).AsYDataSource(); innerPlotter.AddLineGraph(ys2.Join(xds), 2.0); }
private void InitializeChart() { ((HorizontalAxis)ChartPlotterDynamic.MainHorizontalAxis).LabelProvider.LabelStringFormat = ""; //Remove legend on the right. Panel legendParent = (Panel)ChartPlotterDynamic.Legend.ContentGrid.Parent; if (legendParent != null) { legendParent.Children.Remove(ChartPlotterDynamic.Legend.ContentGrid); } ChartPlotterDynamic.NewLegendVisible = m_displayLegend; ChartPlotterDynamic.MainVerticalAxisVisibility = FrequencyAxisTitle.Visibility = m_displayFrequencyYAxis ? Visibility.Visible : Visibility.Collapsed; ChartPlotterDynamic.MainHorizontalAxisVisibility = m_displayXAxis ? Visibility.Visible : Visibility.Collapsed; PhaseAngleYAxis.Visibility = PhaseAngleAxisTitle.Visibility = m_displayPhaseAngleYAxis ? Visibility.Visible : Visibility.Collapsed; VoltageYAxis.Visibility = VoltageAxisTitle.Visibility = m_displayVoltageYAxis ? Visibility.Visible : Visibility.Collapsed; CurrentYAxis.Visibility = CurrentAxisTitle.Visibility = m_displayCurrentYAxis ? Visibility.Visible : Visibility.Collapsed; // This check was added as there was an error reported where it was infinity. if (m_frequencyRangeMin.IsInfinite() || m_frequencyRangeMin.IsNaN()) { m_frequencyRangeMin = 59.95; } if (m_frequencyRangeMax.IsInfinite() || m_frequencyRangeMax.IsNaN()) { m_frequencyRangeMax = 60.05; } ChartPlotterDynamic.Visible = DataRect.Create(0, m_frequencyRangeMin, m_numberOfDataPointsToPlot, m_frequencyRangeMax); PhaseAnglePlotter.Visible = DataRect.Create(0, -180, m_numberOfDataPointsToPlot, 180); TextBlockLeft.Visibility = TextBlockRight.Visibility = ChartPlotterDynamic.MainHorizontalAxisVisibility; for (int i = 0; i < m_numberOfDataPointsToPlot; i++) { m_xAxisDataCollection[i] = i; } m_xAxisBindingCollection = new EnumerableDataSource <int>(m_xAxisDataCollection); m_xAxisBindingCollection.SetXMapping(x => x); }
private void ComboBoxMeasurement_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxMeasurement.Items.Count > 0) { m_selectedMeasurement = (Measurement)ComboBoxMeasurement.SelectedItem; // Capture's the Selected index of measurement Combo Box if (Application.Current.Resources.Contains("SelectedMeasurement_Home")) { Application.Current.Resources.Remove("SelectedMeasurement_Home"); Application.Current.Resources.Add("SelectedMeasurement_Home", ComboBoxMeasurement.SelectedIndex); } else { Application.Current.Resources.Add("SelectedMeasurement_Home", ComboBoxMeasurement.SelectedIndex); } if (m_selectedMeasurement != null) { m_signalID = m_selectedMeasurement.SignalID.ToString(); if (m_selectedMeasurement.SignalSuffix == "PA") { ChartPlotterDynamic.Visible = DataRect.Create(0, -180, m_numberOfPointsToPlot, 180); } else if (m_selectedMeasurement.SignalSuffix == "FQ") { double frequencyMin = Convert.ToDouble(IsolatedStorageManager.ReadFromIsolatedStorage("FrequencyRangeMin")); double frequencyMax = Convert.ToDouble(IsolatedStorageManager.ReadFromIsolatedStorage("FrequencyRangeMax")); ChartPlotterDynamic.Visible = DataRect.Create(0, Math.Min(frequencyMin, frequencyMax), m_numberOfPointsToPlot, Math.Max(frequencyMin, frequencyMax)); } } } else { m_signalID = string.Empty; } SubscribeUnsynchronizedData(); }
public void Intersects_1() { var first = DataRect.Create(0, 0, 1, 1); var second = DataRect.Create(-0.5, -0.5, 0.5, 0.5); Assert.IsTrue(first.IntersectsWith(second)); Assert.IsTrue(second.IntersectsWith(first)); Assert.IsFalse(first.Contains(second)); Assert.IsFalse(second.Contains(first)); var intersection1 = first; intersection1.Intersect(second); var intersection2 = second; intersection2.Intersect(first); var expected = DataRect.Create(0, 0, 0.5, 0.5); Assert.AreEqual(expected, intersection1); Assert.AreEqual(expected, intersection2); }
public override void BeginLoadImage(TileIndex id) { DataRect firstLevel = DataRect.Create(-1.7, -1.3, 0.8, 1.2); double width = firstLevel.Width / MapTileProvider.GetSideTilesCount(id.Level); double xmin = firstLevel.XMin + (id.X + MapTileProvider.GetSideTilesCount(id.Level) / 2) * width; double height = firstLevel.Height / MapTileProvider.GetSideTilesCount(id.Level); double ymin = firstLevel.YMin + (MapTileProvider.GetSideTilesCount(id.Level) / 2 - id.Y - 1) * height; DataRect tileBounds = new DataRect(xmin, ymin, width, height); if (tasks.Count == 0) { CreateTask(id, tileBounds); } else { tasks.Push(new TaskInfo { ID = id, TileBounds = tileBounds }); } }
public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport) { return(DataRect.Create(proposedDataRect.XMin, 0, proposedDataRect.XMax, 1)); }
public override IEnumerable <TileIndex> GetTilesForRegion(DataRect region, double level) { var allTilesBounds = rect; if (xCycling) { allTilesBounds = DataRect.Create(-Double.MaxValue, -MaxLatitude, Double.MaxValue, MaxLatitude); } region.Intersect(allTilesBounds); //region.Intersect(new Rect(region.XMin, minY, region.Width, maxY - minY)); if (region.IsEmpty) { yield break; } checked { double tileWidth = TileWidth; double tileHeight = TileHeight; int minIx = (int)Math.Floor(region.XMin / tileWidth); int maxIx = (int)Math.Ceiling(region.XMax / tileWidth); int minIy = (int)Math.Floor(region.YMin / tileHeight); int maxIy = (int)Math.Ceiling(region.YMax / tileHeight); var maxSideCount = GetSideTilesCount(Level); int maxIndex = maxSideCount / 2; if (!xCycling) { if (maxIx > maxIndex) { maxIx = maxIndex; } if (minIx < -maxIndex) { minIx = -maxIndex; } } if (maxIy > maxIndex) { maxIy = maxIndex; } if (minIy < -maxIndex) { minIy = -maxIndex; } if (level != 0) { maxIx--; maxIy--; } for (int ix = minIx; ix <= maxIx; ix++) { for (int iy = minIy; iy <= maxIy; iy++) { yield return(new TileIndex(ix, iy, level)); } } } }
public void CreateInfiniteDataRect() { DataRect r = DataRect.Create(0, 0, 0, Double.PositiveInfinity); Assert.AreEqual(Double.PositiveInfinity, r.Height); }
public void CreateDataRectWithInfiniteMinAndMax() { DataRect r = DataRect.Create(Double.NegativeInfinity, 0, Double.PositiveInfinity, 0); Assert.AreEqual(Double.PositiveInfinity, r.Width); }