Пример #1
0
 private static float OffsetToCoordinate(float yOffset, YPosition yPosition, int height)
 {
     switch (yPosition)
     {
         case YPosition.Top:     return yOffset;
         case YPosition.Bottom:  return height - yOffset;
         default: throw new ArgumentException($"Unknown YPosition {(int)yPosition}");
     }
 }
Пример #2
0
 private static StringAlignment PositionToAlignment(YPosition yPosition)
 {
     switch (yPosition)
     {
         case YPosition.Top:     return StringAlignment.Near;
         case YPosition.Bottom:  return StringAlignment.Far;
         default: throw new ArgumentException($"Unknown YPosition {(int)yPosition}");
     }
 }
Пример #3
0
        /// <summary>
        /// Steps the wave algorithm.  The wave algorithm does not run at the same speed as the physics simulator. It runs at its
        /// own frequency set by the Frequency property.
        /// </summary>
        public void Update(float dt)
        {
            if (_timePassed < Frequency)
            {
                _timePassed += dt;
                return;
            }
            _timePassed = 0;

            _aabbMin           = float.MaxValue;
            _aabb.LowerBound.Y = _aabbMin;
            for (int i = 1; i < NodeCount - 1; i++)
            {
                _resultWave[i] = (YPosition[i - 1] + YPosition[i + 1]) - PreviousWave[i];
                _resultWave[i] = _resultWave[i] * DampingCoefficient;

                //keep track of _aabb min Value
                if (_resultWave[i] + Position.Y < _aabbMin)
                {
                    _aabbMin = _resultWave[i] + Position.Y;
                }
            }
            _aabb.LowerBound.Y = _aabbMin;
            YPosition.CopyTo(PreviousWave, 0);
            _resultWave.CopyTo(YPosition, 0);

            if (_goingUp)
            {
                if (_waveGeneratorCount > WaveGeneratorMax)
                {
                    _goingUp = false;
                }
                else
                {
                    _waveGeneratorCount += WaveGeneratorStep;
                }
            }
            else
            {
                if (_waveGeneratorCount < WaveGeneratorMin)
                {
                    _goingUp = true;
                }
                else
                {
                    _waveGeneratorCount -= WaveGeneratorStep;
                }
            }
            YPosition[YPosition.Length - 1] = _waveGeneratorCount;
        }
        public DomainResult Validate()
        {
            var errors = new List <string>();

            // IsInSymmetricRange is an extension method
            if (!XPosition.IsInSymmetricRange(0, 999))
            {
                errors.Add("The X Position must be within the range of 0 - 999");
            }

            if (!YPosition.IsInSymmetricRange(0, 999))
            {
                errors.Add("The Y Position must be within the range of 0 - 999");
            }

            if (!Width.IsInSymmetricRange(1, 999))
            {
                errors.Add("The Width must be within the range of 1 - 999");
            }

            if (!Width.IsInCanvasBounds(XPosition, 1000))
            {
                errors.Add("The sum of the Width and X Position must not be greater than canvas size of 1000");
            }

            if (!Height.IsInSymmetricRange(0, 999))
            {
                errors.Add("The Height must be within the range of 1 - 999");
            }

            if (!Height.IsInCanvasBounds(YPosition, 1000))
            {
                errors.Add("The sum of the Height and X Position must not be greater than canvas size of 1000");
            }

            // ToValidationResult is an extension method
            var result = errors.ToValidationResult();

            return(result);
        }
Пример #5
0
        private Bitmap GeneratePartialBitmap(GeoPoint center, XPosition xPos, YPosition yPos)
        {
            double x = center.X, y = center.Y;

            switch (xPos)
            {
                case XPosition.Right:
                    x += _map.Envelope.Width;
                    break;
                case XPosition.Left:
                    x -= _map.Envelope.Width;
                    break;
            }

            switch (yPos)
            {
                case YPosition.Top:
                    y += _map.Envelope.Height;
                    break;
                case YPosition.Bottom:
                    y -= _map.Envelope.Height;
                    break;
            }

            _map.Center = new GeoPoint(x, y);
            return _map.GetMap() as Bitmap;
        }
Пример #6
0
        private Bitmap GeneratePartialBitmap(Geometries.Point center, XPosition xPos, YPosition yPos)
        {
            double x = center.X, y = center.Y;

            switch (xPos)
            {
            case XPosition.Right:
                x += m_Map.Envelope.Width;
                break;

            case XPosition.Left:
                x -= m_Map.Envelope.Width;
                break;
            }

            switch (yPos)
            {
            case YPosition.Top:
                y += m_Map.Envelope.Height;
                break;

            case YPosition.Bottom:
                y -= m_Map.Envelope.Height;
                break;
            }

            m_Map.Center = new Geometries.Point(x, y);
            return(m_Map.GetMap() as Bitmap);
        }
Пример #7
0
 /// <summary>
 /// Writes text on to an image using some default options.
 /// </summary>
 /// <param name="image">The image to be written on.</param>
 /// <param name="text">The text to be written.</param>
 /// <param name="xPosition">The vertical side of the image relative to which the text is written.</param>
 /// <param name="yPosition">The horizontal side of the image relative to which the text is written.</param>
 /// <param name="xOffset">The x offset relative to the vertical side.</param>
 /// <param name="yOffset">The y offset relative to the horizontal side.</param>
 /// <param name="emSize">The em size of the text to be written.</param>
 /// <param name="brush">A brush to be used for writing to specify the colour for example.</param>
 public static void WriteString(this Image image, string text, XPosition xPosition, YPosition yPosition, float xOffset, float yOffset, float emSize, Brush brush)
 {
     var graphic = Graphics.FromImage(image);
     graphic.WriteString(text, 
                         OffsetToCoordinate(xOffset, xPosition, image.Width),
                         OffsetToCoordinate(yOffset, yPosition, image.Height), 
                         emSize,
                         brush,
                         PositionToAlignment(xPosition),
                         PositionToAlignment(yPosition));
     graphic.Flush();
 }
Пример #8
0
        /// <summary>
        /// 设置选项卡位置
        /// </summary>
        /// <typeparam name="TComponent">组件类型</typeparam>
        /// <param name="component">组件实例</param>
        /// <param name="position">选项卡位置</param>
        public static TComponent HeaderPosition <TComponent>(this TComponent component, YPosition position) where TComponent : ITabGroup
        {
            var option = component as IOptionConfig;

            option?.Config <Config>(config => {
                config.SetAttribute(MaterialConst.HeaderPosition, position);
            });
            return(component);
        }
Пример #9
0
 public string Print()
 {
     return("Name: " + Name + " X: " + XPosition.ToString() + " Y: " + YPosition.ToString() + " Z: " + ZPosition.ToString());
 }