Esempio n. 1
0
        public void LeftClickOnImage(Canvas canvas)
        {
            if (canvas.Children.Count == 9)
            {
                canvas.Children.RemoveRange(1, 9);
                PointsToAdd.Clear();
            }

            if (Mouse.LeftButton == MouseButtonState.Pressed && PointsToAdd.Count < 4)
            {
                CurrentPoint = Mouse.GetPosition(canvas);
                PointsToAdd.Add(CurrentPoint);

                var ellipse = new Ellipse()
                {
                    Fill            = Brushes.Black,
                    Width           = 4,
                    Height          = 4,
                    StrokeThickness = 1
                };

                canvas.Children.Add(ellipse);

                Canvas.SetLeft(ellipse, CurrentPoint.X);
                Canvas.SetTop(ellipse, CurrentPoint.Y);

                if (PointsToAdd.Count > 1)
                {
                    MainWindowViewModel.i++;
                    var line = new Line()
                    {
                        Stroke = Brushes.Red,
                        X1     = PointsToAdd[MainWindowViewModel.i].X,
                        Y1     = PointsToAdd[MainWindowViewModel.i].Y,
                        X2     = PointsToAdd[PointsToAdd.Count - 1].X,
                        Y2     = PointsToAdd[PointsToAdd.Count - 1].Y
                    };
                    canvas.Children.Add(line);
                }

                if (PointsToAdd.Count == 4)
                {
                    var line = new Line()
                    {
                        Stroke = Brushes.Red,
                        X1     = PointsToAdd[PointsToAdd.Count - 1].X,
                        Y1     = PointsToAdd[PointsToAdd.Count - 1].Y,
                        X2     = PointsToAdd[0].X,
                        Y2     = PointsToAdd[0].Y
                    };

                    canvas.Children.Add(line);

                    // TODO: Zrobić żeby szerokość i wysokość tekstury same dopasowywały się do wycinanego obszaru
                    //var bitmap = CreateTexture.CropImage(CurrentPoint, ImagePath);
                    //bitmap.Save("C:/VISUAL STUDIO PROJECTS/Reconstruction3D/Reconstruction3D/Textures/Crate2.bmp");
                    MainWindowViewModel.i = -1;
                }
            }
        }
Esempio n. 2
0
        public void LeftClickOnImage(Canvas canvas)
        {
            if (canvas.Children.Count == 9)
            {
                canvas.Children.RemoveRange(1, 9);
                PointsToAdd.Clear();
            }

            if (Mouse.LeftButton == MouseButtonState.Pressed && PointsToAdd.Count < 4)
            {
                CurrentPoint = Mouse.GetPosition(canvas);
                thumb        = new Thumb();

                canvas.Children.Add(thumb);

                Canvas.SetLeft(thumb, CurrentPoint.X);
                Canvas.SetTop(thumb, CurrentPoint.Y);


                PointsToAdd.Add(CurrentPoint);

                thumb.DragDelta += Thumb_DragDelta;

                if (PointsToAdd.Count > 1)
                {
                    i++;
                    var line = new Line()
                    {
                        Stroke = Brushes.Red,
                        X1     = PointsToAdd[i].X,
                        Y1     = PointsToAdd[i].Y,
                        X2     = PointsToAdd[PointsToAdd.Count - 1].X,
                        Y2     = PointsToAdd[PointsToAdd.Count - 1].Y
                    };
                    canvas.Children.Add(line);
                }

                if (PointsToAdd.Count == 4)
                {
                    var line = new Line()
                    {
                        Stroke = Brushes.Red,
                        X1     = PointsToAdd[PointsToAdd.Count - 1].X,
                        Y1     = PointsToAdd[PointsToAdd.Count - 1].Y,
                        X2     = PointsToAdd[0].X,
                        Y2     = PointsToAdd[0].Y
                    };

                    canvas.Children.Add(line);

                    //var bitmap = CreateTexture.CropImage(CurrentPoint, ImagePath);
                    //bitmap.Save("C:/VISUAL STUDIO PROJECTS/Reconstruction3D/Reconstruction3D/Textures/Crate2.bmp");
                    i = -1;
                }
            }
        }