Esempio n. 1
0
        void setChooser()
        {
            if (chooser != null)
            {
                Control c = chooser as Control;
                Control p = c.Parent;
                p.Controls.Remove(c);
            }
            IPointFactory f = draw.Factory;

            if (f == null)
            {
                return;
            }
            chooser              = PointCollectionChooserFactory.Factory[f];
            chooser.Consumer     = draw;
            chooser.Measurements = draw.Measurements;
            Control control = chooser as Control;

            splitContainerMain.Panel2.Controls.Add(control);
            control.LoadResources();
            if (performer.Count > 0)
            {
                performer.Remove(draw);
            }
            ISeriesPainter painter = f.GetPainter(performer);

            performer.AddSeries(draw, painter);
            performer.Resize();
            performer.RefreshAll();
        }
Esempio n. 2
0
        protected static TPoint ReadPointCore <TPoint>(BinaryReader reader,
                                                       Ordinates ordinates,
                                                       IPointFactory <TPoint> pointBuilder)
        {
            switch (ordinates)
            {
            case Ordinates.Xy:
                return(pointBuilder.CreatePointXy(reader.ReadDouble(),
                                                  reader.ReadDouble()));

            case Ordinates.Xyz:
                return(pointBuilder.CreatePointXyz(reader.ReadDouble(),
                                                   reader.ReadDouble(),
                                                   reader.ReadDouble()));

            case Ordinates.Xym:
                return(pointBuilder.CreatePointXym(reader.ReadDouble(),
                                                   reader.ReadDouble(),
                                                   reader.ReadDouble()));

            case Ordinates.Xyzm:
                return(pointBuilder.CreatePointXyzm(reader.ReadDouble(),
                                                    reader.ReadDouble(),
                                                    reader.ReadDouble(),
                                                    reader.ReadDouble()));

            default: throw new NotSupportedException(ordinates.ToString());
            }
        }
Esempio n. 3
0
        void setChooser()
        {
            if (chooser != null)
            {
                Control c = chooser as Control;
                Control p = c.Parent;
                p.Controls.Remove(c);
            }
            IPointFactory f = series.Factory;

            if (f == null)
            {
                return;
            }
            chooser              = PointCollectionChooserFactory.Factory[f];
            chooser.Consumer     = series;
            chooser.Measurements = series.Measurements;
            Control control = chooser as Control;

            this.LoadResources();
            panelParameters.Controls.Add(control);
            if (performer.Count > 0)
            {
                performer.Remove(series);
            }
            ISeriesPainter painter = f.GetPainter(performer);

            performer.AddSeries(series, painter);
            performer.Resize();
            performer.RefreshAll();
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a rectangle using a string of points and a point factory
        /// </summary>
        /// <param name="pointFactory">A factory that creates points</param>
        /// <param name="pointsAsString">The points of the rectangle in the form "bottomLeftX bottomLeftY topRightX topRightY"</param>
        /// <returns>A rectangle with the corners as given</returns>
        public Rectangle CreateRectangle(IPointFactory pointFactory, string pointsAsString)
        {
            _logger.Debug($"Entering {nameof(CreateRectangle)} with {nameof(pointsAsString)} = \"{pointsAsString}\"");

            if (pointFactory == null)
            {
                var exception = new ArgumentNullException(nameof(pointFactory));
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            if (string.IsNullOrEmpty(pointsAsString))
            {
                var exception = new ArgumentException("The string passed in cannot be null or empty.", nameof(pointsAsString));
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            var points = pointsAsString.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            if (points.Length != 4)
            {
                var exception = new ArgumentException(string.Format("The number of points passed in must be four, not {0}", points.Length), nameof(pointsAsString));
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            var bottomLeft = pointFactory.CreatePoint(points[0], points[1]);
            var topRight   = pointFactory.CreatePoint(points[2], points[3]);

            return(new Rectangle(bottomLeft, topRight));
        }
Esempio n. 5
0
 static Program()
 {
     _marbleFactory = new MarbleFactory();
     _holeFactory   = new HoleFactory();
     _wallFactory   = new WallFactory();
     _pointFactory  = new PointFactory();
     _helper        = new Helper();
 }
Esempio n. 6
0
 private static IEnumerable <P> ReadPointsCore <P>([NotNull] BinaryReader reader,
                                                   Ordinates ordinates,
                                                   [NotNull] IPointFactory <P> builder,
                                                   int pointCount)
 {
     for (int i = 0; i < pointCount; i++)
     {
         yield return(ReadPointCore(reader, ordinates, builder));
     }
 }
Esempio n. 7
0
        private static L ReadLinestringCore <L, P>(BinaryReader reader, Ordinates ordinates,
                                                   GeometryBuilderBase <L, P> geometryBuilder)
        {
            int pointCount = checked ((int)reader.ReadUInt32());

            IPointFactory <P> builder = geometryBuilder.GetPointFactory(ordinates);

            return(geometryBuilder.CreateLinestring(
                       ReadPointsCore(reader, ordinates, builder, pointCount), pointCount));
        }
Esempio n. 8
0
 /// <summary>
 /// Gets points collection chooser by point factory
 /// </summary>
 /// <param name="factory">The point factory</param>
 /// <returns>The chooser</returns>
 public override IPointCollecionChooser this[IPointFactory factory]
 {
     get
     {
         if (factory is CirclePointFactory)
         {
             return(new ColoredChooser());
         }
         return(null);
     }
 }
Esempio n. 9
0
        protected static TMultipoint ReadMultipointCore <TMultipoint, TLinestring, TPoint>(
            [NotNull] BinaryReader reader,
            Ordinates ordinates,
            int pointCount,
            [NotNull] GeometryBuilderBase <TMultipoint, TLinestring, TPoint> geometryBuilder)
        {
            IPointFactory <TPoint> builder = geometryBuilder.GetPointFactory(ordinates);

            const bool reReadPointTypes = true;

            IEnumerable <TPoint> readPointsCore =
                ReadPointsCore(reader, ordinates, builder, pointCount, reReadPointTypes);

            return(geometryBuilder.CreateMultipoint(readPointsCore, pointCount));
        }
Esempio n. 10
0
        /// <summary>
        /// Reads the specified number of points, optionally re-reads the type for each point.
        /// </summary>
        /// <typeparam name="TPoint"></typeparam>
        /// <param name="reader"></param>
        /// <param name="ordinates"></param>
        /// <param name="builder"></param>
        /// <param name="pointCount"></param>
        /// <param name="reReadTypeForEachPoint"></param>
        /// <returns></returns>
        private static IEnumerable <TPoint> ReadPointsCore <TPoint>(
            [NotNull] BinaryReader reader,
            Ordinates ordinates,
            [NotNull] IPointFactory <TPoint> builder,
            int pointCount,
            bool reReadTypeForEachPoint = false)
        {
            for (int i = 0; i < pointCount; i++)
            {
                if (reReadTypeForEachPoint)
                {
                    ReadWkbType(reader, false, out WkbGeometryType _, out Ordinates _);
                }

                yield return(ReadPointCore(reader, ordinates, builder));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a rectangle with the x and y length as given
        /// </summary>
        /// <param name="pointFactory">A factory that creates points</param>
        /// <param name="xLength">The length of the rectangle in the x direction</param>
        /// <param name="yLength">The length of the rectangle in the y direction</param>
        /// <returns>A rectangle with the size given with the bottom left corner located at (0, 0)</returns>
        public Rectangle CreateRectangle(IPointFactory pointFactory, int xLength, int yLength)
        {
            _logger.Debug($"Entering {nameof(CreateRectangle)} with {nameof(xLength)} = {xLength} and {nameof(yLength)} = {yLength}");

            if (xLength < 0)
            {
                var exception = new ArgumentOutOfRangeException(nameof(xLength), xLength, "The value of X must be greater than or equal to zero");
                _logger.Error(exception.Message, exception);
                throw exception;
            }
            if (yLength < 0)
            {
                var exception = new ArgumentOutOfRangeException(nameof(yLength), yLength, "The value of Y must be greater than or equal to zero");
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            var bottomLeft = pointFactory.CreatePoint(0, 0);
            var topRight   = pointFactory.CreatePoint(xLength, yLength);

            return(new Rectangle(bottomLeft, topRight));
        }
Esempio n. 12
0
 public NatsSubscriber(string subjectName)
 {
     SubjectName = subjectName;
     _factory    = Ninject.Ninject.Get <IPointFactory>();
 }
Esempio n. 13
0
 /// <summary>
 /// Gets points collection chooser by point factory
 /// </summary>
 /// <param name="factory">The point factory</param>
 /// <returns>The chooser</returns>
 public abstract IPointCollecionChooser this[IPointFactory factory]
 {
     get;
 }
Esempio n. 14
0
 public PointBuilder(IPointFactory pointFactory, IEquationCalculateStrategy simpleCalculateStrategy)
 {
     _pointFactory            = pointFactory;
     _simpleCalculateStrategy = simpleCalculateStrategy;
 }