void ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Ellipse ellipse = (Ellipse)sender; if (ellipse.Tag == null) { //Point p1 = ViewportRectPanel.GetPoint1(ellipse); //Point p2 = ViewportRectPanel.GetPoint2(ellipse); //Rect bounds = new Rect(p1, p2); //Point center = bounds.GetCenter(); //DraggablePoint pt = new DraggablePoint(center); //pt.PositionChanged += pt_PositionChanged; //pt.Tag = ellipse; //ellipse.Tag = pt; //plotter.Children.Add(pt); } else { DraggablePoint pt = (DraggablePoint)ellipse.Tag; pt.Tag = null; ellipse.Tag = null; pt.PositionChanged -= pt_PositionChanged; plotter.Children.Remove(pt); } }
private void UpdateUI() { foreach (var point in points) { point.PositionChanged -= OnPoint_PositionChanged; pointsPool.Put(point); plotter.Children.Remove(point); } points.Clear(); int i = 0; foreach (var point3D in Pattern.GeneratePoints()) { DraggablePoint draggablePoint = pointsPool.GetOrCreate(); var position = project(point3D); outPattern.Points.Add(point3D); draggablePoint.Position = position; draggablePoint.PositionChanged += OnPoint_PositionChanged; SetIndex(draggablePoint, i); plotter.Children.Add(draggablePoint); points.Add(draggablePoint); i++; } }
protected override void OnPoint_PositionChanged(object sender, PositionChangedEventArgs e) { DraggablePoint marker = (DraggablePoint)sender; // adjusting position to fit inside allowed region var region = AllowedRegion; var position = e.Position; if (position.X < region.XMin) { position.X = region.XMin; } if (position.Y < region.YMin) { position.Y = region.YMin; } if (position.X > region.XMax) { position.X = region.XMax; } if (position.Y > region.YMax) { position.Y = region.YMax; } marker.Position = position; marker.DataContext = position; var index = DevMarkerChart.GetIndex(marker); if (0 <= index && index < Points.Count && !ProtectedPoints.Changing) { Points[index] = position; } }
protected void OnPoint_PositionChanged(object sender, PositionChangedEventArgs e) { DraggablePoint source = (DraggablePoint)sender; int index = GetIndex(source); var point = source.Position; var point3D = outProject(point); outPattern.Points[index] = point3D; }
void pt_PositionChanged(object sender, PositionChangedEventArgs e) { DraggablePoint pt = (DraggablePoint)sender; Ellipse ellipse = (Ellipse)pt.Tag; Rect bounds = RectExtensions.FromCenterSize(e.Position, xSize, ySize); //ViewportRectPanel.SetPoint1(ellipse, bounds.TopLeft); //ViewportRectPanel.SetPoint2(ellipse, bounds.BottomRight); }
public static void SetAnchor(this HorizontalLine line, DraggablePoint draggablePoint) { var b = new Binding() { Path = new PropertyPath("Position.Y"), Source = draggablePoint }; line.SetBinding(HorizontalLine.ValueProperty, b); line.SetBinding(HorizontalLine.ToolTipProperty, b); }
public static void SetAnchor(this VerticalLine line, DraggablePoint draggablePoint) { var b = new Binding() { Path = new PropertyPath("Position.X"), Source = draggablePoint }; line.SetBinding(VerticalLine.ValueProperty, b); line.SetBinding(VerticalLine.ToolTipProperty, b); var b2 = new Binding() { Path = new PropertyPath(VerticalLine.VisibilityProperty), Source = line }; draggablePoint.SetBinding(DraggablePoint.VisibilityProperty, b2); }
private void AddPointToList(double x, double y, bool endOfList) { //check if point is not allready in the chart if (_points.Any(q => Math.Abs(q.Position.X - x) < .2)) { return; } var p = new DraggablePoint(new Point(x, y)); p.PositionChanged += PPositionChanged; if (endOfList) { _points.Add(p); } else { _points.Insert(0, p); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //plotter.DataTransform = new Log10Transform(); // Create first source sourcecurrent = new ObservableDataSource <Tuple <double, double> >(); sourcecurrent.SetXYMapping(z => { Point p = new Point(z.Item1, z.Item2); return(p); }); //plotter.DataTransform = new Log10Transform(); //HorizontalAxis xAxis = new HorizontalAxis //{ // TicksProvider = new NumericTicksProvider(), // LabelProvider = new ExponentialLabelProvider() //}; //plotter.MainHorizontalAxis = xAxis; //VerticalAxis yAxis = new VerticalAxis //{ // //TicksProvider = new LogarithmNumericTicksProvider(10), // TicksProvider = new NumericTicksProvider(), // LabelProvider = new ExponentialLabelProvider() //}; //plotter.MainVerticalAxis = yAxis; HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis; //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0")); axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick)); VerticalAxis axisv = (VerticalAxis)plotter.MainVerticalAxis; //String.Format(new TelephoneFormatter(), "{0}", 0) axisv.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0")); sourcevoltage = new ObservableDataSource <Tuple <double, double> >(); sourcevoltage.SetXYMapping(z => { Point p = new Point(z.Item1, z.Item2); return(p); }); //otherPlotter.DataTransform = new Log10Transform(); //xAxis = new HorizontalAxis //{ // TicksProvider = new LogarithmNumericTicksProvider(10), // LabelProvider = new UnroundingLabelProvider() //}; //otherPlotter.MainHorizontalAxis = xAxis; //yAxis = new VerticalAxis //{ // TicksProvider = new LogarithmNumericTicksProvider(10), // LabelProvider = new UnroundingLabelProvider() //}; //otherPlotter.MainVerticalAxis = yAxis; //List<Point> list = new List<Point>(); Random rnd = new Random(); for (int i = 10; i < 300; i++) { sourcecurrent.Collection.Add(new Tuple <double, double>(i, 20000 + rnd.Next(10000))); sourcevoltage.Collection.Add(new Tuple <double, double>(i, 30 + rnd.Next(20))); //list.Add(new Point(i, rnd.Next(50))); } //plotter1.VerticalAxis.LabelProvider = new ExponentialLabelProvider(); //LineGraph line = new LineGraph(source1); //line.AddToPlotter(plotter); // plotter.Children.Add(line); //otherPlotter.MainVerticalAxis. linegraph.DataSource = sourcevoltage; linephase.DataSource = sourcecurrent; //axis = new VerticalAxisTitle(); //linegraph = new Microsoft.Research.DynamicDataDisplay.LineGraph( // Creating the new DraggablePoint if (false) { int x1 = 10, y1 = 10; Point q = new Point(x1, y1); var globalPoint = new DraggablePoint(q); globalPoint.PositionChanged += (s, r) => { globalPoint.Position = q; }; plotter.Children.Add(globalPoint); } // Set the point on the map }