private void canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Point            mouseClickPt = e.GetPosition(cameraIMG);
            CameraSpacePoint mouseCamSP   = GetCamSpacePtFromMouseClick(mouseClickPt, SpaceMode.Color);

            if (!mouseCamSP.Equals(default(CameraSpacePoint)))
            {
                if (threePtEllipses[threePtIdxCnt] != null)
                {
                    canvas.RemoveChild(threePtEllipses[threePtIdxCnt]);
                }

                threePoints[threePtIdxCnt]     = new Vector3(mouseCamSP.X, mouseCamSP.Y, mouseCamSP.Z);
                threePtEllipses[threePtIdxCnt] = new Ellipse
                {
                    Width  = 20,
                    Height = 20,
                    Fill   = Brushes.Red
                };
                canvas.SetLeftAndTopForShapeWrtCentre(threePtEllipses[threePtIdxCnt], mouseClickPt);
                canvas.AddChild(threePtEllipses[threePtIdxCnt]);

                threePtIdxCnt++;
                threePtIdxCnt %= 3;
            }
            else
            {
                UiHelper.NotifyUser("No depth info is captured for this point!");
            }
        }
Пример #2
0
        // https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-enabling-drag-and-drop-on-a-user-control
        private void canvas_Drop(object sender, DragEventArgs e)
        {
            // If an element in the panel has already handled in the drop,
            // the panel should not also handle it.
            if (!e.Handled && e.Data.GetDataPresent(MyRockShape.RockViewModelDataFormatName))
            {
                bool isAllowedDragMove = false;

                // Canvas inherits Panel
                Panel         _canvas      = sender as Panel;
                RockViewModel selectedRock = rocksOnWallViewModel.SelectedRock;

                if (_canvas != null && selectedRock != null)
                {
                    Point mousePt = e.GetPosition(cameraIMG);

                    // check rock overlaps
                    if (rocksOnWallViewModel.IsOverlapWithRocksOnWallOtherThanSelectedRock(
                            mousePt, selectedRock.SizeOnCanvas)
                        == false)
                    {
                        CameraSpacePoint csp = jcWall.GetCamSpacePointFromMousePoint(mousePt, _mode);
                        if (!csp.Equals(default(CameraSpacePoint)))
                        {
                            // note:
                            // use RocksOnWallViewModel.MoveSelectedRock()
                            // instead of RockViewModel.MoveBoulder()
                            // because RocksOnWallViewModel.MoveSelectedRock()
                            // will set the selected rock indicator as well
                            isAllowedDragMove = rocksOnWallViewModel.MoveSelectedRock(csp);

                            if (!isAllowedDragMove)
                            {
                                UiHelper.NotifyUser(DepthInfoMissingWarningMsg);
                            }
                        }
                        else
                        {
                            UiHelper.NotifyUser(DepthInfoMissingWarningMsg);
                        }
                    }
                    else
                    {
                        UiHelper.NotifyUser(RockOverlapsWarningMsg);
                    }
                }

                if (isAllowedDragMove)
                {
                    e.Effects = supportedDragDropEffects;
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }
            }
        }
Пример #3
0
        private void canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isSnapShotTaken)
            {
                //Debug.WriteLine("canvas_MouseDown");

                Point mouseClickPt = e.GetPosition(cameraIMG);

                RockViewModel rockCorrespondsToCanvasPt =
                    rocksOnWallViewModel.GetRockInListByCanvasPoint(mouseClickPt);

                if (rockCorrespondsToCanvasPt == null)  // new rock
                {
                    Size newBoulderSizeOnCanvas = GetBoulderSizeOnCanvasFromSliders();

                    // check rock overlaps
                    if (rocksOnWallViewModel.IsOverlapWithRocksOnWall(
                            mouseClickPt, newBoulderSizeOnCanvas)
                        == false)
                    {
                        CameraSpacePoint csp = jcWall.GetCamSpacePointFromMousePoint(mouseClickPt, _mode);
                        if (!csp.Equals(default(CameraSpacePoint)))
                        {
                            rocksOnWallViewModel.AddRock(csp, newBoulderSizeOnCanvas);
                        }
                        else
                        {
                            UiHelper.NotifyUser(DepthInfoMissingWarningMsg);
                        }
                    }
                    else
                    {
                        UiHelper.NotifyUser(RockOverlapsWarningMsg);
                    }
                }
                else  // rock already in list
                {
                    rocksOnWallViewModel.SelectedRock = rockCorrespondsToCanvasPt;
                    boulderWidthSlider.Value          = rockCorrespondsToCanvasPt.RockShapeContainer.GetWidth();
                    boulderHeightSlider.Value         = rockCorrespondsToCanvasPt.RockShapeContainer.GetHeight();

                    // if rock already in list, enable drag drop!
                    rockCorrespondsToCanvasPt.RockShapeContainer.DoDragDrop();
                }
            }
            else
            {
                UiHelper.NotifyUser("Please take snap shot first.");
            }
        }
Пример #4
0
        private void canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isSnapShotTaken)
            {
                Point mouseClickPt = e.GetPosition(cameraIMG);
                //ColorSpacePoint _boulderCSP = new ColorSpacePoint { X = (float)mouseClickPt.X, Y = (float)mouseClickPt.Y };

                Boulder rockCorrespondsToCanvasPt =
                    rocksOnWallViewModel.GetRockInListByCanvasPoint(mouseClickPt);

                if (rockCorrespondsToCanvasPt == null)  // new rock
                {
                    double newBoulderWidthOnCanvas  = ConvertSliderValueToSizeOnCanvas(boulderWidthSlider.Value);
                    double newBoulderHeightOnCanvas = ConvertSliderValueToSizeOnCanvas(boulderHeightSlider.Value);

                    // check rock overlaps
                    if (rocksOnWallViewModel.IsOverlapWithRocksOnWall(
                            mouseClickPt, newBoulderWidthOnCanvas, newBoulderHeightOnCanvas)
                        == false)
                    {
                        CameraSpacePoint csp = jcWall.GetCamSpacePointFromMousePoint(mouseClickPt, _mode);
                        if (!csp.Equals(default(CameraSpacePoint)))
                        {
                            rocksOnWallViewModel.AddRock(csp, mouseClickPt, newBoulderWidthOnCanvas,
                                                         newBoulderHeightOnCanvas);
                        }
                        else
                        {
                            UiHelper.NotifyUser("No depth info is captured for this point!");
                        }
                    }
                    else
                    {
                        UiHelper.NotifyUser(RockOverlapsWarningMsg);
                    }
                }
                else  // rock already in list
                {
                    rocksOnWallViewModel.SelectedRock = rockCorrespondsToCanvasPt;
                    boulderWidthSlider.Value          = rockCorrespondsToCanvasPt.BCanvasWidth;
                    boulderHeightSlider.Value         = rockCorrespondsToCanvasPt.BCanvasHeight;
                }
            }
            else
            {
                UiHelper.NotifyUser("Please take snap shot first.");
            }
        }
Пример #5
0
        // https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-enabling-drag-and-drop-on-a-user-control
        private void canvas_DragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(MyRockShape.RockViewModelDataFormatName))
            {
                //Debug.WriteLine("canvas_DragOver");

                bool isAllowedDragMove = false;

                // Canvas inherits Panel
                Panel         _canvas      = sender as Panel;
                RockViewModel selectedRock = rocksOnWallViewModel.SelectedRock;

                if (_canvas != null && selectedRock != null)
                {
                    Point mousePt = e.GetPosition(cameraIMG);

                    // check rock overlaps
                    if (rocksOnWallViewModel.IsOverlapWithRocksOnWallOtherThanSelectedRock(
                            mousePt, selectedRock.SizeOnCanvas)
                        == false)
                    {
                        CameraSpacePoint csp = jcWall.GetCamSpacePointFromMousePoint(mousePt, _mode);
                        if (!csp.Equals(default(CameraSpacePoint)))
                        {
                            // note:
                            // use RocksOnWallViewModel.MoveSelectedRock()
                            // instead of RockViewModel.MoveBoulder()
                            // because RocksOnWallViewModel.MoveSelectedRock()
                            // will set the selected rock indicator as well
                            isAllowedDragMove = rocksOnWallViewModel.MoveSelectedRock(csp);
                        }
                    }
                }

                // These Effects values are used in the drag source's
                // GiveFeedback event handler to determine which cursor to display.
                if (isAllowedDragMove)
                {
                    e.Effects = supportedDragDropEffects;
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }
            }
        }
Пример #6
0
        public void getfloorPlane(Body body)
        {
            if (body.Joints[JointType.FootLeft] != null && body.Joints[JointType.FootRight] != null && theInnerCount == 0)
            {
                Joint leftFoot = body.Joints[JointType.FootLeft];
                Joint rightFoot = body.Joints[JointType.FootRight];
                leftFoot.Position.X += .5f;
                leftFoot.Position.Y += .5f;
                rightFoot.Position.X += .5f;
                rightFoot.Position.Y += .5f;

                floorPlanePoints[0] = leftFoot.Position;
                floorPlanePoints[1] = rightFoot.Position;
                startedTrackingState = theCount;
                theInnerCount++;
            }

            CameraSpacePoint leftFootPosState = body.Joints[JointType.FootLeft].Position;
            leftFootPosState.X += .5f;
            leftFootPosState.Y += .5f;
            if (leftFootPosState.Equals(floorPlanePoints[0]) == false)
            {
                Joint leftFoot2 = body.Joints[JointType.FootLeft];
                leftFoot2.Position.X += .5f;
                leftFoot2.Position.Y += .5f;
                floorPlanePoints[2] = leftFoot2.Position;
                floorPlane = new Plane(floorPlanePoints);
            }

            Joint head = body.Joints[JointType.Head];
            head.Position.X += .5f;
            head.Position.Y += .5f; //.5 sets positive axis' to bottom left corner

            if (floorPlane != null)
            {
                if (floorPlane.checkPoint(head.Position))
                {
                    Console.WriteLine("RED ALERT!");
                }
            }
        }