Exemplo n.º 1
0
        private void DrawCircle_Clicked(object sender, RoutedEventArgs e)
        {
            var window = new EditPosition() { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner };
            var vm = new EditPositionVm();
            window.DataContext = vm;

            window.ShowDialog();

            if (window.DialogResult == true)
            {
                var ellipse = new Ellipse() { Width = 100, Height = 100, Stroke = new SolidColorBrush(Colors.Gold), StrokeThickness = 2 , Fill = new SolidColorBrush(Colors.Green)};
                Canvas.SetLeft(ellipse, vm.Left);
                Canvas.SetTop(ellipse, vm.Top);
                this.DrawCanvas.Children.Add(ellipse);

                //Add drag drop behavior
                ellipse.SetValue(DragDropBehavior.PlacementTarget, this.DrawCanvas);

            }
        }
Exemplo n.º 2
0
        private void DrawLine_Clicked(object sender, RoutedEventArgs e)
        {
            var window = new EditPosition() { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner };
            var vm = new EditPositionVm();
            window.DataContext = vm;

            window.ShowDialog();

            if (window.DialogResult == true)
            {
                var line = new Line() { X1 = 0, Y1 = 0, X2 = 150, Y2 = 320 ,Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 2};
                Canvas.SetLeft(line, vm.Left);
                Canvas.SetTop(line, vm.Top);
                this.DrawCanvas.Children.Add(line);

                //Add drag drop behavior
                line.SetValue(DragDropBehavior.PlacementTarget, this.DrawCanvas);
            }

            
        }