i do have the following Code:
- private static void AddElements(Canvas canvas)
- {
- double canvasHeight = canvas.Height;
- double canvasWidth = canvas.Width;
- double y0 = canvasHeight / 2;
- double x0 = canvasWidth / 2;
-
-
- TranslateTransform tt = new TranslateTransform(x0, y0);
-
- Line line1 = new Line();
- line1.X1 = -350;
- line1.Y1 = 0;
- line1.X2 = 350;
- line1.Y2 = 0;
- line1.Stroke = Brushes.Black;
- line1.StrokeThickness = 2.0;
- line1.RenderTransform = tt;
- canvas.Children.Add(line1);
-
- Line line2 = new Line();
- line2.X1 = 0;
- line2.Y1 = -350;
- line2.X2 = 0;
- line2.Y2 = 350;
- line2.Stroke = Brushes.Black;
- line2.StrokeThickness = 2.0;
- line2.RenderTransform = tt;
- canvas.Children.Add(line2);
-
-
- Label lblN = new Label();
- lblN.Width = 50;
- lblN.Background = Brushes.Red;
- lblN.Margin = new System.Windows.Thickness(0, -300, 0, 0);
- lblN.Content = $"N";
- lblN.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
- lblN.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
- lblN.RenderTransform = tt;
- lblN.Padding = new System.Windows.Thickness(0);
- lblN.BorderBrush = Brushes.Black;
- lblN.BorderThickness = new System.Windows.Thickness(2.0);
- lblN.RenderTransform = tt;
- canvas.Children.Add(lblN);
-
- Label lblS = new Label();
- lblS.Width = 50;
- lblS.Background = Brushes.Red;
- lblS.Margin = new System.Windows.Thickness(0, 300, 0, 0);
- lblS.Content = $"S";
- lblS.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
- lblS.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
- lblS.RenderTransform = tt;
- lblS.Padding = new System.Windows.Thickness(0);
- lblS.BorderBrush = Brushes.Black;
- lblS.BorderThickness = new System.Windows.Thickness(2.0);
- lblS.RenderTransform = tt;
- canvas.Children.Add(lblS);
- }
this method is called on an Menu-Eventhandler and it shows an coordinate system with (0,0) in the mid of the canvas. It should show a label with "N" at the top and a label with "S" at the bottom.
But i shows the attached image