Example #1
0
        private void CalculatePointItemBasemOnCalculatedPoints(IEnumerable <Point> points, PixelsCaclulator parametrizedPixelsCaclulator)
        {
            Coordinates GetCalculatedPixels(Point vs)
            {
                var coor = parametrizedPixelsCaclulator.CalculatePixel(vs.ListOfVariables[0], vs.ListOfVariables[1]);

                coor.X -= _calculatedPointSize / 2; // change the coordinates to put pixel in the center of the point
                coor.Y -= _calculatedPointSize / 2;
                return(coor);
            }

            void ConnectPointWithLine(PointItem A, PointItem B)
            {
                var CoorA = new Coordinates(A.Coordinates.X + _calculatedPointSize / 2, A.Coordinates.Y + _calculatedPointSize / 2);
                var CoorB = new Coordinates(B.Coordinates.X + _calculatedPointSize / 2, B.Coordinates.Y + _calculatedPointSize / 2);

                var lineItem = new LineItem(CoorA, CoorB);

                LinesConnectingPoints.Add(lineItem);
            }

            if (points == null || points.Count() == 0)
            {
                return;
            }

            var point = points.ElementAt(0);

            var coordinates = GetCalculatedPixels(point);

            var PointItem = new PointItem(coordinates, point, _calculatedPointSize);

            PointItems.Add(PointItem);

            for (int i = 1; i < points.Count(); i++)
            {
                point       = points.ElementAt(i);
                coordinates = GetCalculatedPixels(point);
                PointItem   = new PointItem(coordinates, point, _calculatedPointSize);
                PointItems.Add(PointItem);


                ConnectPointWithLine(PointItems.ElementAt(i - 1), PointItem);
            }
        }
Example #2
0
        public async void Create(double imageSize, double range, int step, double CentrumX = 0, double CentrumY = 0)
        {
            _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(true); // Counterine is Creatng
            BitmapSize = imageSize;
            var pixelsCaclulator = new PixelsCaclulator(imageSize, imageSize, range, step, CentrumX, CentrumY);

            PointItems.Clear();
            LinesConnectingPoints.Clear();

            var centralCoordinate = pixelsCaclulator.CalculatePixel(CentrumX, CentrumY);

            CentralPoint = new PointItem(centralCoordinate, new Point(CentrumX, CentrumY), _calculatedPointSize);
            var pixels = await GetPixelsTask(pixelsCaclulator);

            Bitmap = BitmapCreator.CreateBitmap(pixels);

            _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(false); // Counterine is not Creatng
            CalculatePointItemBasemOnCalculatedPoints(CalculatedPoints, pixelsCaclulator);
        }