private DrawElement putGridToPosition(Point Position, DrawElement drawElement) { double x = Position.X * ((double)305 / 152.5); double y = Position.Y * ((double)548 / (double)274); double left = x - (drawElement.g.Width / 2); double top = y - (drawElement.g.Height / 2); drawElement.g.Margin = new Thickness(left, top, 0, 0); return(drawElement); }
public void OnNewStrokes() { DrawnStrokes.Clear(); foreach (Stroke s in Strokes) { Application.Current.Dispatcher.Invoke(() => { DrawElement dE = createDrawElement(Visibility.Hidden); dE.text = s.Number.ToString(); s.StrokePlacementChanged += S_StrokePlacementChanged; if (s.Placement != null && s.Placement.WX >= 0 && s.Placement.WY >= 0) { dE.g.Visibility = Visibility.Visible; putGridToPosition(new Point(s.Placement.WX, s.Placement.WY), dE); } DrawnStrokes.Add(dE); }); } }
private void OnStrokePositionCalculated(object source, StrokePositionCalculatedEventArgs args) { if (!CurrentStroke.Course.Equals("Net/Out")) { if (CurrentStroke.Number > DrawnStrokes.Count) { while (CurrentStroke.Number > DrawnStrokes.Count) { DrawnStrokes.Add(createDrawElement(Visibility.Hidden)); } } DrawElement dE = DrawnStrokes[CurrentStroke.Number - 1]; dE.text = CurrentStroke.Number.ToString(); putGridToPosition(args.Position, dE); dE.g.Visibility = Visibility.Visible; showCorrectStrokes(); } }
private DrawElement createDrawElement(Visibility visibility) { Ellipse e = new Ellipse(); e.Stroke = System.Windows.Media.Brushes.Black; e.Fill = System.Windows.Media.Brushes.Transparent; e.StrokeThickness = 5; Grid g = new Grid(); g.Height = 40; g.Width = 40; g.IsHitTestVisible = true; g.Background = System.Windows.Media.Brushes.Transparent; g.Visibility = visibility; DrawElement ele = new DrawElement(); ele.e = e; ele.g = g; return(ele); }