Пример #1
0
        public PickUnitsPointsViewModel(Bitmap bitmap, IWhiskerPoint point1 = null, IWhiskerPoint point2 = null)
        {
            Image = bitmap;

            IGenericPoint genericPoint1 = ModelResolver.Resolve <IGenericPoint>();
            IGenericPoint genericPoint2 = ModelResolver.Resolve <IGenericPoint>();

            genericPoint1.PointId = 1;
            genericPoint2.PointId = 2;

            GenericPointViewModel viewModel1 = new GenericPointViewModel(genericPoint1);
            GenericPointViewModel viewModel2 = new GenericPointViewModel(genericPoint2);

            //IWhisker whisker = ModelResolver.Resolve<IWhisker>();
            //whisker.WhiskerId = 1;

            //IWhiskerPoint whiskerPoint1 = point1 ?? ModelResolver.Resolve<IWhiskerPoint>();
            //whiskerPoint1.Parent = whisker;
            ////whiskerPoint1.WhiskerId = 0;

            //IWhiskerPoint whiskerPoint2 = point2 ?? ModelResolver.Resolve<IWhiskerPoint>();
            //whiskerPoint2.Parent = whisker;
            ////whiskerPoint2.WhiskerId = 1;
            //whisker.WhiskerPoints = new IWhiskerPoint[] { whiskerPoint1, whiskerPoint2 };

            //WhiskerViewModel whiskerViewModel = new WhiskerViewModel(whisker);
            //WhiskerPointViewModel viewModel1 = new WhiskerPointViewModel(whiskerPoint1, whiskerViewModel);
            //WhiskerPointViewModel viewModel2 = new WhiskerPointViewModel(whiskerPoint2, whiskerViewModel);

            CanvasChildren.Add(viewModel1);
            CanvasChildren.Add(viewModel2);
        }
Пример #2
0
        public double GetDistance()
        {
            GenericPointViewModel genericPoint1 = CanvasChildren[0];
            GenericPointViewModel genericPoint2 = CanvasChildren[1];

            PointF relativePoint1 = new PointF((float)genericPoint1.XRatio * Image.Width, (float)genericPoint1.YRatio * Image.Height);
            PointF relativePoint2 = new PointF((float)genericPoint2.XRatio * Image.Width, (float)genericPoint2.YRatio * Image.Height);

            double dist = relativePoint1.Distance(relativePoint2);

            return(dist);
        }
Пример #3
0
        public void MouseClicked(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Controls.Image image = (System.Windows.Controls.Image)sender;

            Point point = e.GetPosition(image);

            double xRatio = point.X / image.ActualWidth;
            double yRatio = point.Y / image.ActualHeight;

            GenericPointViewModel currentPoint = CanvasChildren[CurrentPoint - 1];

            currentPoint.XRatio = xRatio;
            currentPoint.YRatio = yRatio;

            if (CurrentPoint == 1)
            {
                CurrentPoint++;
            }

            OkCommand.RaiseCanExecuteChangedNotification();
        }