Example #1
0
        protected internal Sprite(GridPointMatrix matrix, Frame frame)
        {
            id = Guid.NewGuid().ToString();
            parentGrid = matrix;
            animator = new Animator(this);
            movement = new Movement(this);
            pauseAnimation = false;
            pauseMovement = false;
            horizAlign = HorizontalAlignment.Center;
            vertAlign = VerticalAlignment.Bottom;
            nudgeX = 0;
            nudgeY = 0;
            CurrentFrame = frame;

            if ((Sprites.SizeNewSpritesToParentGrid) && (parentGrid != null))
                renderSize = new Size(parentGrid.GridPointWidth, parentGrid.GridPointHeight);
            else
                renderSize = CurrentFrame.Tilesheet.TileSize;

            zOrder = 1;

            if (parentGrid != null)
                parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);

            Sprites._spriteList.Add(this);
            CreateChildSprites();
        }
Example #2
0
		internal Style(Workbook wb, XfRecord xf) : base(wb)
		{	
			if(xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count)
    	        _font = wb.Fonts[xf.FontIdx - 1];
		    _format = wb.Formats[xf.FormatIdx];
			_typeAndProtection = xf.TypeAndProtection;
			if(_typeAndProtection.IsCell)
				_parentStyle = wb.Styles[xf.ParentIdx];
			_horizontalAlignment = xf.HorizontalAlignment;
			_wrapped = xf.Wrapped;
			_verticalAlignment = xf.VerticalAlignment;
			_rotation = xf.Rotation;
			_indentLevel = xf.IndentLevel;
			_shrinkContent = xf.ShrinkContent;
			_parentStyleAttributes = xf.ParentStyle;
			_leftLineStyle = xf.LeftLineStyle;
			_rightLineStyle = xf.RightLineStyle;
			_topLineStyle = xf.TopLineStyle;
			_bottomLineStyle = xf.BottomLineStyle;
			_leftLineColor = wb.Palette.GetColor(xf.LeftLineColor);
			_rightLineColor = wb.Palette.GetColor(xf.RightLineColor);
			_diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom;
			_diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight;
			_topLineColor = wb.Palette.GetColor(xf.TopLineColor);
			_bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor);
			_diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor);
			_diagonalLineStyle = xf.DiagonalLineStyle;
			_fillPattern = xf.FillPattern;
			_patternColor = wb.Palette.GetColor(xf.PatternColor);
			_patternBackground = wb.Palette.GetColor(xf.PatternBackground);
		}
Example #3
0
File: Font.cs Project: Tokter/TokED
        public void CreateSprite(SpriteBatch batch, int px, int py, string text, Color color, HorizontalAlignment horizontal, VerticalAlignment vertical)
        {
            int width = MeasureWidth(text);
            int height = MeasureHeight(text);
            int x = 0, y = 0;
            switch (horizontal)
            {
                case HorizontalAlignment.Left: x = px; break;
                case HorizontalAlignment.Center: x = px - width / 2; break;
                case HorizontalAlignment.Right: x = px - width; break;
            }
            switch (vertical)
            {
                case VerticalAlignment.Top: y = py; break;
                case VerticalAlignment.Center: y = py - height / 2 - 1; break;
                case VerticalAlignment.Bottom: y = py - height; break;
            }

            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
            for (int i = 0; i < bytes.Length; i++)
            {
                var b = bytes[i];
                if (b != 32)
                {
                    if (i > 0)
                    {
                        x -= _kerning[bytes[i - 1] * 256 + bytes[i]]-1;
                    }

                    batch.AddSprite(_material, new Vector2(x, y + _charInfo[b].YOffset), new Vector2(x + _charInfo[b].Width, y + _charInfo[b].YOffset + _charInfo[b].Height), _charInfo[b].U1, _charInfo[b].V1, _charInfo[b].U2, _charInfo[b].V2, color);
                }
                x += _charInfo[b].Width;
            }
        }
Example #4
0
        /// <summary>
        /// Private constructor used when calling the Clone() method on a Sprite.
        /// </summary>
        private Sprite(Sprite sprite)
        {
            id = Guid.NewGuid().ToString();
            animator = new Animator(this);
            movement = new Movement(this);
            Sprites._spriteList.Add(this);

            parentGrid = sprite.parentGrid;
            frame = sprite.frame;
            DetectCollision = sprite.collisionDetection;
            horizAlign = sprite.horizAlign;
            vertAlign = sprite.vertAlign;
            nudgeX = sprite.nudgeX;
            nudgeY = sprite.nudgeY;
            renderSize = sprite.renderSize;
            ZOrder = sprite.zOrder;
            visible = sprite.visible;
            gridCoordinates = sprite.gridCoordinates;
            AdjustCollisionArea = sprite.AdjustCollisionArea;

            if (parentGrid != null)
                parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);

            Sprites.SubscribeToSpriteEvents(this);

            CreateChildSprites();
        }
 public void RenderText(IRenderContext context, Vector2 position, string text, FontAsset font,
     HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
     VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
     Color? shadowColor = null)
 {
     throw new NotSupportedException();
 }
Example #6
0
		public MatrixViewModel(IReadOnlyList<BoxModel> boxes,
							   int columnCount,
							   int rowCount,
							   HorizontalAlignment defaultColumnAlignment = HorizontalAlignment.Center,
							   VerticalAlignment defaultRowAlignment = VerticalAlignment.Center,
							   VerticalAlignment defaultMatrixAlignment = VerticalAlignment.Center)
			: base(boxes, GetPositions(columnCount, rowCount))
		{

			Contract.Requires(columnCount >= 1);
			Contract.Requires(rowCount >= 1);
			Contract.Requires(boxes.Count == columnCount * rowCount);
			Contract.Requires(defaultColumnAlignment.IsValid());
			Contract.Requires(defaultRowAlignment.IsValid());

			columnAlignments = new List<HorizontalAlignment>();
			ColumnAlignments = new ReadOnlyCollection<HorizontalAlignment>(columnAlignments);
			rowAlignments = new List<VerticalAlignment>();
			RowAlignments = new ReadOnlyCollection<VerticalAlignment>(rowAlignments);
			VerticalInlineAlignment = defaultMatrixAlignment;
			AlignmentProtocols = new AlignmentProtocolCollection(this);

			for (int x = 0; x < columnCount; x++)
				this.columnAlignments.Add(defaultColumnAlignment);
			for (int y = 0; y < rowCount; y++)
				this.rowAlignments.Add(defaultRowAlignment);
		}
 public void RenderText(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix matrix,
     string text, FontAsset font, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
     VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
     Color? shadowColor = null)
 {
     throw new NotSupportedException();
 }
        /// <summary>
        /// Calculates the bounds with respect to rotation angle and horizontal/vertical alignment.
        /// </summary>
        /// <param name="bounds">The size of the object to calculate bounds for.</param>
        /// <param name="angle">The rotation angle (degrees).</param>
        /// <param name="horizontalAlignment">The horizontal alignment.</param>
        /// <param name="verticalAlignment">The vertical alignment.</param>
        /// <returns>A minimum bounding rectangle.</returns>
        public static OxyRect GetBounds(this OxySize bounds, double angle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var u = horizontalAlignment == HorizontalAlignment.Left ? 0 : horizontalAlignment == HorizontalAlignment.Center ? 0.5 : 1;
            var v = verticalAlignment == VerticalAlignment.Top ? 0 : verticalAlignment == VerticalAlignment.Middle ? 0.5 : 1;

            var origin = new ScreenVector(u * bounds.Width, v * bounds.Height);

            if (angle == 0)
            {
                return new OxyRect(-origin.X, -origin.Y, bounds.Width, bounds.Height);
            }

            // the corners of the rectangle
            var p0 = new ScreenVector(0, 0) - origin;
            var p1 = new ScreenVector(bounds.Width, 0) - origin;
            var p2 = new ScreenVector(bounds.Width, bounds.Height) - origin;
            var p3 = new ScreenVector(0, bounds.Height) - origin;

            var theta = angle * Math.PI / 180.0;
            var costh = Math.Cos(theta);
            var sinth = Math.Sin(theta);
            Func<ScreenVector, ScreenVector> rotate = p => new ScreenVector((costh * p.X) - (sinth * p.Y), (sinth * p.X) + (costh * p.Y));

            var q0 = rotate(p0);
            var q1 = rotate(p1);
            var q2 = rotate(p2);
            var q3 = rotate(p3);

            var x = Math.Min(Math.Min(q0.X, q1.X), Math.Min(q2.X, q3.X));
            var y = Math.Min(Math.Min(q0.Y, q1.Y), Math.Min(q2.Y, q3.Y));
            var w = Math.Max(Math.Max(q0.X - x, q1.X - x), Math.Max(q2.X - x, q3.X - x));
            var h = Math.Max(Math.Max(q0.Y - y, q1.Y - y), Math.Max(q2.Y - y, q3.Y - y));

            return new OxyRect(x, y, w, h);
        }
 protected override void DrawTextInternal(string value, Font font, Rectangle rectangle, Color color, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
 {
     System.Windows.Forms.TextFormatFlags flags = System.Windows.Forms.TextFormatFlags.Left;
     switch (horizontalAlignment)
     {
         case HorizontalAlignment.Center:
         {
             flags |= System.Windows.Forms.TextFormatFlags.HorizontalCenter;
             break;
         }
         case HorizontalAlignment.Right:
         {
             flags |= System.Windows.Forms.TextFormatFlags.Right;
             break;
         }
     }
     switch (verticalAlignment)
     {
         case VerticalAlignment.Bottom:
         {
             flags |= System.Windows.Forms.TextFormatFlags.Bottom;
             break;
         }
         case VerticalAlignment.Middle:
         {
             flags |= System.Windows.Forms.TextFormatFlags.VerticalCenter;
             break;
         }
     }
     System.Windows.Forms.TextRenderer.DrawText(mvarGraphics, value, FontToNativeFont(font), RectangleToNativeRectangle(rectangle), ColorToNativeColor(color), flags);
 }
Example #10
0
        public static void DrawGlyphRun(this DrawingContext drawingContext, Brush foreground, GlyphRun glyphRun,
            Point position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var boundingBox = glyphRun.ComputeInkBoundingBox();

            switch (horizontalAlignment)
            {
                case HorizontalAlignment.Center:
                    position.X -= boundingBox.Width / 2d;
                    break;
                case HorizontalAlignment.Right:
                    position.X -= boundingBox.Width;
                    break;
                default:
                    break;
            }

            switch (verticalAlignment)
            {
                case VerticalAlignment.Center:
                    position.Y -= boundingBox.Height / 2d;
                    break;
                case VerticalAlignment.Bottom:
                    position.Y -= boundingBox.Height;
                    break;
                default:
                    break;
            }

            drawingContext.PushTransform(new TranslateTransform(position.X - boundingBox.X, position.Y - boundingBox.Y));
            drawingContext.DrawGlyphRun(foreground, glyphRun);
            drawingContext.Pop();
        }
        /// <summary>
        /// Gets the polygon outline of the specified rotated and aligned box.
        /// </summary>
        /// <param name="size">The size of the  box.</param>
        /// <param name="origin">The origin of the box.</param>
        /// <param name="angle">The rotation angle of the box.</param>
        /// <param name="horizontalAlignment">The horizontal alignment of the box.</param>
        /// <param name="verticalAlignment">The vertical alignment of the box.</param>
        /// <returns>A sequence of points defining the polygon outline of the box.</returns>
        public static IEnumerable<ScreenPoint> GetPolygon(this OxySize size, ScreenPoint origin, double angle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var u = horizontalAlignment == HorizontalAlignment.Left ? 0 : horizontalAlignment == HorizontalAlignment.Center ? 0.5 : 1;
            var v = verticalAlignment == VerticalAlignment.Top ? 0 : verticalAlignment == VerticalAlignment.Middle ? 0.5 : 1;

            var offset = new ScreenVector(u * size.Width, v * size.Height);

            // the corners of the rectangle
            var p0 = new ScreenVector(0, 0) - offset;
            var p1 = new ScreenVector(size.Width, 0) - offset;
            var p2 = new ScreenVector(size.Width, size.Height) - offset;
            var p3 = new ScreenVector(0, size.Height) - offset;

            if (angle != 0)
            {
                var theta = angle * Math.PI / 180.0;
                var costh = Math.Cos(theta);
                var sinth = Math.Sin(theta);
                Func<ScreenVector, ScreenVector> rotate = p => new ScreenVector((costh * p.X) - (sinth * p.Y), (sinth * p.X) + (costh * p.Y));

                p0 = rotate(p0);
                p1 = rotate(p1);
                p2 = rotate(p2);
                p3 = rotate(p3);
            }

            yield return origin + p0;
            yield return origin + p1;
            yield return origin + p2;
            yield return origin + p3;
        }
        public Vector2 GetPositionInLayout(Rectangle layout, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var x = 0f;
            switch (horizontalAlignment)
            {
                case HorizontalAlignment.Left:
                    x = layout.X;
                    break;
                case HorizontalAlignment.Center:
                    x = layout.X + layout.Width / 2;
                    break;
                case HorizontalAlignment.Right:
                    x = layout.X + layout.Width;
                    break;
            }

            var y = 0f;
            switch (verticalAlignment)
            {
                case VerticalAlignment.Top:
                    y = layout.Y;
                    break;
                case VerticalAlignment.Center:
                    y = layout.Y + layout.Height / 2;
                    break;
                case VerticalAlignment.Bottom:
                    y = layout.Y + layout.Height;
                    break;
            }

            return new Vector2(x, y);
        }
 public static void drawStringCustom(SpriteBatch sprite, String text, String fontName, int size, Color color,
     Vector2 position, VerticalAlignment alignment, HorizontalAlignment horizontalAlignment, Matrix transform)
 {
     SpriteFont font = FontFactory.getInstance().getFont(fontName).getSize(size);
     switch (alignment)
     {
         case VerticalAlignment.LEFTALIGN:
             position = new Vector2(position.X - font.MeasureString(text).X, position.Y);
             break;
         case VerticalAlignment.RIGHTALIGN:
             break;
         case VerticalAlignment.CENTERED:
             position = new Vector2(position.X - (font.MeasureString(text).X / 2), position.Y);
             break;
     }
     switch (horizontalAlignment)
     {
         case HorizontalAlignment.ABOVE:
             position = new Vector2(position.X, position.Y - font.MeasureString(text).Y);
             break;
         case HorizontalAlignment.BELOW:
             break;
         case HorizontalAlignment.CENTERED:
             position = new Vector2(position.X, position.Y - font.MeasureString(text).Y / 2);
             break;
     }
     SpriteBatchWrapper.DrawStringCustom(font, text, new Vector2((int)position.X, (int)position.Y), color, transform);
 }
        /// <summary>
        /// Draws or measures text containing sub- and superscript.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="pt">The point.</param>
        /// <param name="text">The text.</param>
        /// <param name="textColor">Color of the text.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">The font size.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="angle">The angle.</param>
        /// <param name="ha">The horizontal alignment.</param>
        /// <param name="va">The vertical alignment.</param>
        /// <param name="maxsize">The maximum size of the text.</param>
        /// <param name="measure">Measure the size of the text if set to <c>true</c>.</param>
        /// <returns>The size of the text.</returns>
        /// <example>Subscript: H_{2}O
        /// Superscript: E=mc^{2}
        /// Both: A^{2}_{i,j}</example>
        public static OxySize DrawMathText(
            this IRenderContext rc,
            ScreenPoint pt,
            string text,
            OxyColor textColor,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double angle,
            HorizontalAlignment ha,
            VerticalAlignment va,
            OxySize? maxsize,
            bool measure)
        {
            if (string.IsNullOrEmpty(text))
            {
                return OxySize.Empty;
            }

            if (text.Contains("^{") || text.Contains("_{"))
            {
                double x = pt.X;
                double y = pt.Y;

                // Measure
                var size = InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, true, angle);

                switch (ha)
                {
                    case HorizontalAlignment.Right:
                        x -= size.Width;
                        break;
                    case HorizontalAlignment.Center:
                        x -= size.Width * 0.5;
                        break;
                }

                switch (va)
                {
                    case VerticalAlignment.Bottom:
                        y -= size.Height;
                        break;
                    case VerticalAlignment.Middle:
                        y -= size.Height * 0.5;
                        break;
                }

                InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, false, angle);
                return measure ? size : OxySize.Empty;
            }

            rc.DrawText(pt, text, textColor, fontFamily, fontSize, fontWeight, angle, ha, va, maxsize);
            if (measure)
            {
                return rc.MeasureText(text, fontFamily, fontSize, fontWeight);
            }

            return OxySize.Empty;
        }
Example #15
0
        public void RenderLineTo( Bitmap bm, string text, Rectangle bounds, HorizontalAlignment halign, VerticalAlignment valign )
        {
            if ( bounds.Width <= 0 || bounds.Height <= 0 ) return;

            var bits = bm.LockBits( bounds, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
            RenderLineTo( bits, text, new Rectangle(0,0,bounds.Width,bounds.Height), halign, valign );
            bm.UnlockBits(bits);
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnInfo"/> struct.
 /// </summary>
 /// <param name="width">The width of the column in (fixed-width) characters.</param>
 /// <param name="content">The content of this column.</param>
 /// <param name="alignment">The alignment to use for this column.</param>
 /// <param name="verticalAlignment">The vertical alignment to use for this column</param>        
 /// <param name="method">The word wrapping method to use for this column</param>
 public ColumnInfo(int width, string content, Alignment alignment, VerticalAlignment verticalAlignment, WordWrappingMethod method)
 {
    m_width = width;
    m_content = content;
    m_alignment = alignment;
    m_verticalAlignment = verticalAlignment;
    m_workdWrappingMethod = method;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnInfo"/> struct.
 /// </summary>
 /// <param name="width">The width of the column in (fixed-width) characters.</param>
 /// <param name="content">The content of this column.</param>
 /// <param name="alignment">The alignment to use for this column.</param>
 /// <param name="verticalAlignment">The vertical alignment to use for this column</param>        
 /// <param name="method">The word wrapping method to use for this column</param>
 public ColumnInfo(int width, string content, Alignment alignment, VerticalAlignment verticalAlignment, WordWrappingMethod method)
 {
     mWidth = width;
     mContent = content;
     mAlignment = alignment;
     mVerticalAlignment = verticalAlignment;
     mWordWrappingMethod = method;
 }
Example #18
0
 public GridHeaderItem(HorizontalAlignment hAlign, VerticalAlignment vAlign, Brush foreBrush,
     Font font, String text, SortOrder defaultSortOrder, int width, int minwidth, Brush hotbrush)
     : base(text, hAlign, vAlign, false, false, foreBrush, font, hotbrush, font)
 {
     this.defaultSortOrder = defaultSortOrder;
     this.width = width;
     MinimumWidth = minwidth;
 }
Example #19
0
 public Text Create(string fontName, int fontSize, string content, Vector2I size, Color color, 
     HorizontalAlignment horizontalAligment, VerticalAlignment verticalAlignment, Padding padding)
 {
     string fontKey = fontName + "-" + size;
     if (!_fontDictionary.ContainsKey(fontKey))
         _fontDictionary.Add(fontKey, new Font(_context, fontName, fontSize));
     return new Text(_context, content, _fontDictionary[fontKey], size, color, horizontalAligment, verticalAlignment, padding);
 }
Example #20
0
        public void SetAlignment(HorizontalAlignment h, VerticalAlignment v)
        {
            if (!IsRunning) return;

            Log.WriteLine($"Aligning notifications: {h}, {v}");
            _overlay.StackNotifications.HorizontalAlignment = h;
            _overlay.StackNotifications.VerticalAlignment = v;
        }
 public HierarchyLayout() :
     base()
 {
     this.LayoutStyle = LayoutStyle.Hierarchy;
     this.ConnectorStyle = ConnectorStyle.OrganizationChart;
     this.HorizontalAlignment = HorizontalAlignment.Center;
     this.VerticalAlignment = VerticalAlignment.Middle;
 }
        internal static void AddTextBlockExternal(int col, int row, string text, Grid grid, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var textBlock = new TextBlock();

            AddTextBlockAux(col, row, text, textBlock, horizontalAlignment, verticalAlignment);

            grid.Children.Add(textBlock);
        }
Example #23
0
        public int Text(string text, Vector2 position, VerticalAlignment verticalAlignment,
            HorizontalAlignment horizontalAlignment, float opacity = 1.0f, string fontface = null, int? fontSize = null, Color4? colour = null)
        {
            TextFormat drawTextFormat;
            var localOffset = new Vector2();

            switch (horizontalAlignment)
            {
                case HorizontalAlignment.LeftWithMargin:
                    drawTextFormat = TextFormat.Left;
                    localOffset = new Vector2(Dimensions.ContentMargin, 0);
                    break;
                case HorizontalAlignment.LeftAbsolute:
                    drawTextFormat = TextFormat.Left;
                    localOffset = new Vector2(0, 0);
                    break;
                case HorizontalAlignment.Centre:
                    drawTextFormat = TextFormat.Center;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("horizontalAlignment");
            }

            switch (verticalAlignment)
            {
                case VerticalAlignment.Top:
                    drawTextFormat = drawTextFormat | TextFormat.Top;
                    break;
                case VerticalAlignment.Middle:
                    drawTextFormat = drawTextFormat | TextFormat.VerticalCenter;
                    break;
                case VerticalAlignment.Bottom:
                    drawTextFormat = drawTextFormat | TextFormat.Bottom;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("verticalAlignment");
            }

            var font = _font;

            if (!string.IsNullOrEmpty(fontface)&& fontSize != null)
            {
                font = _graphicsContext.GetFont(fontface, fontSize.Value);
            }

            var extents = font.MeasureString(text, drawTextFormat);

            if (!colour.HasValue)
                colour = ColourScheme.TextColour.MakeTransparent(opacity);

            font.DrawString(
                text,
                (int)(_offset.X + extents.Left + position.X + localOffset.X),
                (int)(_offset.Y + extents.Top + position.Y + localOffset.Y),
                colour.Value);

            return extents.Width;
        }
Example #24
0
 private GridImageItem(Object rankObject, Image image, ImageDelegate imageDelegate, HorizontalAlignment hAlign, VerticalAlignment vAlign, bool clickSelectsRow, EventHandler onDoubleClickDelegate)
     : base(false, 1, clickSelectsRow, null, onDoubleClickDelegate)
 {
     this.rankObject = rankObject;
     this.imageDelegate = imageDelegate;
     this.image = image;
     this.vAlign = vAlign;
     this.hAlign = hAlign;
 }
Example #25
0
 /// <param name="viewport">The viewport to draw on, or null.</param>
 protected OverlayComponent(AWViewport viewport, HorizontalAlignment horizontal, VerticalAlignment vertical)
 {
     HorizontalAlignment = horizontal;
     VerticalAlignment = vertical;
     CustomAlignment = () => Vector2.Zero;
     Visible = true;
     Viewport = viewport;
     LoadContent();
 }
Example #26
0
        public LabelStyle(StyleFont font,
						  StyleBrush foreground,
						  StyleBrush background,
						  Point2D offset,
						  Size2D collisionBuffer,
						  HorizontalAlignment horizontalAlignment,
						  VerticalAlignment verticalAlignment)
            : base(font, foreground, background, offset, collisionBuffer, horizontalAlignment, verticalAlignment)
        {}
Example #27
0
        public void RenderLineTo( Graphics fx, string text, Rectangle bounds, HorizontalAlignment halign, VerticalAlignment valign )
        {
            if ( bounds.Width <= 0 || bounds.Height <= 0 ) return;

            using ( var bitmap = new Bitmap( bounds.Width, bounds.Height ) ) {
                using ( var fx2 = Graphics.FromImage(bitmap) ) fx2.Clear( Color.Transparent );
                RenderLineTo( bitmap, text, new Rectangle(0,0,bounds.Width,bounds.Height), halign, valign );
                fx.DrawImage( bitmap, bounds.X, bounds.Y );
            }
        }
Example #28
0
 public PositionLayout(UiComponent parent, UniScalar width, UniScalar height, HorizontalAlignment horizontalAlignment,
     VerticalAlignment verticalAlignment, Padding padding = null)
     : base(parent)
 {
     _width = width;
     _height = height;
     _horizontalAlignment = horizontalAlignment;
     _verticalAlignment = verticalAlignment;
     _padding = padding ?? new Padding(0);
 }
Example #29
0
 public void CheckPolygonCalculation(double x, double y, double angle, HorizontalAlignment ha, VerticalAlignment va, double expectedX0, double expectedY0, double expectedX2, double expectedY2)
 {
     const double Delta = 1;
     var size = new OxySize(40, 50);
     var p = size.GetPolygon(new ScreenPoint(x, y), angle, ha, va).ToArray();
     Assert.That(p[0].X, Is.EqualTo(expectedX0).Within(Delta));
     Assert.That(p[0].Y, Is.EqualTo(expectedY0).Within(Delta));
     Assert.That(p[2].X, Is.EqualTo(expectedX2).Within(Delta));
     Assert.That(p[2].Y, Is.EqualTo(expectedY2).Within(Delta));
 }
Example #30
0
        protected UIElement()
        {
            EnsureClassHandlers();

            _flags = Flags.NeverMeasured | Flags.NeverArranged | Flags.Enabled;

            _visibility = Visibility.Visible;

            _verticalAlignment = VerticalAlignment.Stretch;
            _horizontalAlignment = HorizontalAlignment.Stretch;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SoundAnnotation" /> class.
 /// </summary>
 /// <param name="Links">Link to the document..</param>
 /// <param name="Color">Color of the annotation..</param>
 /// <param name="Contents">Get the annotation content..</param>
 /// <param name="Modified">The date and time when the annotation was last modified..</param>
 /// <param name="Id">Gets ID of the annotation..</param>
 /// <param name="Flags">Gets Flags of the annotation..</param>
 /// <param name="Name">Gets Name of the annotation..</param>
 /// <param name="Rect">Gets Rect of the annotation. (required).</param>
 /// <param name="PageIndex">Gets PageIndex of the annotation..</param>
 /// <param name="ZIndex">Gets ZIndex of the annotation..</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation..</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation..</param>
 /// <param name="CreationDate">The date and time when the annotation was created..</param>
 /// <param name="Subject">Get the annotation subject..</param>
 /// <param name="Title">Get the annotation title..</param>
 /// <param name="RichText">Get the annotation RichText..</param>
 /// <param name="FilePath">A sound file path defining the sound to be played when the annotation is activated. (required).</param>
 /// <param name="Icon">Gets or sets an icon to be used in displaying the annotation..</param>
 /// <param name="Rate">Gets or sets the sampling rate, in samples per second..</param>
 /// <param name="Channels">Gets or sets the number of sound channels..</param>
 /// <param name="Bits">Gets or sets the number of bits per sample value per channel..</param>
 /// <param name="Encoding">Gets or sets the encoding format for the sample data..</param>
 public SoundAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), string FilePath = default(string), SoundIcon Icon = default(SoundIcon), int?Rate = default(int?), int?Channels = default(int?), int?Bits = default(int?), SoundEncoding Encoding = default(SoundEncoding))
 {
     // to ensure "Rect" is required (not null)
     if (Rect == null)
     {
         throw new InvalidDataException("Rect is a required property for SoundAnnotation and cannot be null");
     }
     else
     {
         this.Rect = Rect;
     }
     // to ensure "FilePath" is required (not null)
     if (FilePath == null)
     {
         throw new InvalidDataException("FilePath is a required property for SoundAnnotation and cannot be null");
     }
     else
     {
         this.FilePath = FilePath;
     }
     this.Links               = Links;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Modified            = Modified;
     this.Id                  = Id;
     this.Flags               = Flags;
     this.Name                = Name;
     this.PageIndex           = PageIndex;
     this.ZIndex              = ZIndex;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.CreationDate        = CreationDate;
     this.Subject             = Subject;
     this.Title               = Title;
     this.RichText            = RichText;
     this.Icon                = Icon;
     this.Rate                = Rate;
     this.Channels            = Channels;
     this.Bits                = Bits;
     this.Encoding            = Encoding;
 }
Example #32
0
        private void DrawGraphText(Canvas can, string text, Point location, double font_size, HorizontalAlignment halign, VerticalAlignment valign)
        {
            // Make the label.
            Label label = new Label();

            label.Content  = text;
            label.FontSize = font_size;
            can.Children.Add(label);

            // Position the label.
            label.Measure(new Size(double.MaxValue, double.MaxValue));

            double x = location.X;

            if (halign == HorizontalAlignment.Center)
            {
                x -= label.DesiredSize.Width / 2;
            }
            else if (halign == HorizontalAlignment.Right)
            {
                x -= label.DesiredSize.Width;
            }
            Canvas.SetLeft(label, x);

            double y = location.Y;

            if (valign == VerticalAlignment.Center)
            {
                y -= label.DesiredSize.Height / 2;
            }
            else if (valign == VerticalAlignment.Bottom)
            {
                y -= label.DesiredSize.Height;
            }
            Canvas.SetTop(label, y);
        }
Example #33
0
 public static void SetColumnVerticalContentAlignment(DependencyObject obj, VerticalAlignment value)
 {
     obj.SetValue(ColumnVerticalContentAlignmentProperty, value);
 }
Example #34
0
        public static void Draw(Image <Rgba32> img, Font font, VerticalAlignment vert, HorizontalAlignment horiz, float wrappingWidth)
        {
            Vector2 location = Vector2.Zero;

            switch (vert)
            {
            case VerticalAlignment.Top:
                location.Y = 0;
                break;

            case VerticalAlignment.Center:
                location.Y = img.Height / 2;
                break;

            case VerticalAlignment.Bottom:
                location.Y = img.Height;
                break;

            default:
                break;
            }
            switch (horiz)
            {
            case HorizontalAlignment.Left:

                location.X = 0;
                break;

            case HorizontalAlignment.Right:
                location.X = img.Width - wrappingWidth;
                break;

            case HorizontalAlignment.Center:
                location.X = (img.Width - wrappingWidth) / 2;
                break;

            default:
                break;
            }

            var glyphBuilder = new GlyphBuilder();

            var renderer = new TextRenderer(glyphBuilder);

            var style = new RendererOptions(font, 72, location)
            {
                ApplyKerning        = true,
                TabWidth            = 4,
                WrappingWidth       = wrappingWidth,
                HorizontalAlignment = horiz,
                VerticalAlignment   = vert
            };

            string text = $"    {horiz}     {vert}         {horiz}     {vert}         {horiz}     {vert}     ";

            renderer.RenderText(text, style);

            System.Collections.Generic.IEnumerable <SixLabors.Shapes.IPath> shapesToDraw = glyphBuilder.Paths;
            img.Mutate(x => x.Fill(Rgba32.Black, glyphBuilder.Paths));

            Rgba32 f = Rgba32.Fuchsia;

            f.A = 128;
            img.Mutate(x => x.Fill(Rgba32.Black, glyphBuilder.Paths));
            img.Mutate(x => x.Draw(f, 1, glyphBuilder.Boxes));

            img.Mutate(x => x.Draw(Rgba32.Lime, 1, glyphBuilder.TextBox));
        }
Example #35
0
        private void LayoutTextAboveOrBelowImage(Rectangle totalArea, bool textFirst, Size textSize, Size imageSize, out Rectangle textRect, out Rectangle imageRect)
        {
            int element_spacing = 0;    // Spacing between the Text and the Image
            int total_height    = textSize.Height + element_spacing + imageSize.Height;

            if (textFirst)
            {
                element_spacing += 2;
            }

            if (textSize.Width > totalArea.Width)
            {
                textSize.Width = totalArea.Width;
            }

            // If the there isn't enough room and we're text first, cut out the image
            if (total_height > totalArea.Height && textFirst)
            {
                imageSize    = Size.Empty;
                total_height = totalArea.Height;
            }

            int excess_height = totalArea.Height - total_height;
            int offset        = 0;

            Rectangle final_text_rect;
            Rectangle final_image_rect;

            VerticalAlignment v_text  = GetVerticalAlignment(TextAlign);
            VerticalAlignment v_image = GetVerticalAlignment(ImageAlign);

            if (v_image == VerticalAlignment.Top)
            {
                offset = 0;
            }
            else if (v_image == VerticalAlignment.Bottom && v_text == VerticalAlignment.Bottom)
            {
                offset = excess_height;
            }
            else if (v_image == VerticalAlignment.Center && (v_text == VerticalAlignment.Top || v_text == VerticalAlignment.Center))
            {
                offset += excess_height / 3;
            }
            else
            {
                offset += 2 * (excess_height / 3);
            }

            if (textFirst)
            {
                final_text_rect  = new Rectangle(AlignInRectangle(totalArea, textSize, TextAlign).Left, totalArea.Top + offset, textSize.Width, textSize.Height);
                final_image_rect = new Rectangle(AlignInRectangle(totalArea, imageSize, ImageAlign).Left, final_text_rect.Bottom + element_spacing, imageSize.Width, imageSize.Height);
            }
            else
            {
                final_image_rect = new Rectangle(AlignInRectangle(totalArea, imageSize, ImageAlign).Left, totalArea.Top + offset, imageSize.Width, imageSize.Height);
                final_text_rect  = new Rectangle(AlignInRectangle(totalArea, textSize, TextAlign).Left, final_image_rect.Bottom + element_spacing, textSize.Width, textSize.Height);

                if (final_text_rect.Bottom > totalArea.Bottom)
                {
                    final_text_rect.Y = totalArea.Top;
                }
            }

            textRect  = final_text_rect;
            imageRect = final_image_rect;
        }
 public static void SetPathVerticalAlignment(DependencyObject obj, VerticalAlignment value)
 {
     obj.SetValue(PathVerticalAlignmentProperty, value);
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextAnnotation" /> class.
 /// </summary>
 /// <param name="Links">Link to the document.</param>
 /// <param name="Color">Color of the annotation.</param>
 /// <param name="Contents">Get the annotation content.</param>
 /// <param name="Modified">The date and time when the annotation was last modified.</param>
 /// <param name="Id">Gets ID of the annotation.</param>
 /// <param name="Flags">Gets Flags of the annotation.</param>
 /// <param name="Name">Gets Name of the annotation.</param>
 /// <param name="Rect">Gets Rect of the annotation. (required)</param>
 /// <param name="PageIndex">Gets PageIndex of the annotation.</param>
 /// <param name="ZIndex">Gets ZIndex of the annotation.</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation.</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation.</param>
 /// <param name="CreationDate">The date and time when the annotation was created.</param>
 /// <param name="Subject">Get the annotation subject.</param>
 /// <param name="Title">Get the annotation title.</param>
 /// <param name="RichText">Get the annotation RichText.</param>
 /// <param name="State">Gets or sets the state to which the original annotation should be set.</param>
 /// <param name="Open">Gets or sets is the annotation open.</param>
 /// <param name="Icon">Gets or sets an icon to be used in displaying the annotation.</param>
 public TextAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), AnnotationState State = default(AnnotationState), bool?Open = default(bool?), TextIcon Icon = default(TextIcon))
 {
     // to ensure "Rect" is required (not null)
     if (Rect == null)
     {
         throw new InvalidDataException("Rect is a required property for TextAnnotation and cannot be null");
     }
     else
     {
         this.Rect = Rect;
     }
     this.Links               = Links;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Modified            = Modified;
     this.Id                  = Id;
     this.Flags               = Flags;
     this.Name                = Name;
     this.PageIndex           = PageIndex;
     this.ZIndex              = ZIndex;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.CreationDate        = CreationDate;
     this.Subject             = Subject;
     this.Title               = Title;
     this.RichText            = RichText;
     this.State               = State;
     this.Open                = Open;
     this.Icon                = Icon;
 }
Example #38
0
        public static async Task ScrollToItem2(this ListViewBase listViewBase, object item, VerticalAlignment alignment, bool highlight, double?pixel = null)
        {
            var scrollViewer = listViewBase.GetScrollViewer();

            if (scrollViewer == null)
            {
                return;
            }

            //listViewBase.SelectionMode = ListViewSelectionMode.Single;
            //listViewBase.SelectedItem = item;

            var selectorItem = listViewBase.ContainerFromItem(item) as SelectorItem;

            if (selectorItem == null)
            {
                // call task-based ScrollIntoViewAsync to realize the item
                await listViewBase.ScrollIntoViewAsync(item, ScrollIntoViewAlignment.Leading, true);

                // this time the item shouldn't be null again
                selectorItem = (SelectorItem)listViewBase.ContainerFromItem(item);
            }

            if (selectorItem == null)
            {
                return;
            }

            // calculate the position object in order to know how much to scroll to
            var transform = selectorItem.TransformToVisual((UIElement)scrollViewer.Content);
            var position  = transform.TransformPoint(new Point(0, 0));

            if (alignment == VerticalAlignment.Top)
            {
                if (pixel is double adjust)
                {
                    position.Y -= adjust;
                }
            }
            else if (alignment == VerticalAlignment.Center)
            {
                position.Y -= (listViewBase.ActualHeight - selectorItem.ActualHeight) / 2d;
            }
            else if (alignment == VerticalAlignment.Bottom)
            {
                position.Y -= listViewBase.ActualHeight - selectorItem.ActualHeight;

                if (pixel is double adjust)
                {
                    position.Y += adjust;
                }
            }

            // scroll to desired position with animation!
            scrollViewer.ChangeView(position.X, position.Y, null, alignment != VerticalAlignment.Center);

            if (highlight)
            {
                var bubble = selectorItem.Descendants <MessageBubble>().FirstOrDefault();
                if (bubble == null)
                {
                    return;
                }

                bubble.Highlight();
            }
        }
Example #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileAttachmentAnnotation" /> class.
 /// </summary>
 /// <param name="Links">Link to the document..</param>
 /// <param name="Color">Color of the annotation..</param>
 /// <param name="Contents">Get the annotation content..</param>
 /// <param name="Modified">The date and time when the annotation was last modified..</param>
 /// <param name="Id">Gets ID of the annotation..</param>
 /// <param name="Flags">Gets Flags of the annotation..</param>
 /// <param name="Name">Gets Name of the annotation..</param>
 /// <param name="Rect">Gets Rect of the annotation. (required).</param>
 /// <param name="PageIndex">Gets PageIndex of the annotation..</param>
 /// <param name="ZIndex">Gets ZIndex of the annotation..</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation..</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation..</param>
 /// <param name="CreationDate">The date and time when the annotation was created..</param>
 /// <param name="Subject">Get the annotation subject..</param>
 /// <param name="Title">Get the annotation title..</param>
 /// <param name="RichText">Get the annotation RichText..</param>
 /// <param name="Icon">Gets or sets icon that shall be used in displaying annotation..</param>
 /// <param name="Opacity">Gets or sets icon&#39;s opacity from 0 to 1: 0 - completely transparant, 1 - completely opaque..</param>
 /// <param name="FileDescription">Gets or sets text associated with the file specification. .</param>
 /// <param name="FileName">Gets or sets file specification name. .</param>
 /// <param name="FilePath">Sets content file path. .</param>
 public FileAttachmentAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), FileIcon Icon = default(FileIcon), double?Opacity = default(double?), string FileDescription = default(string), string FileName = default(string), string FilePath = default(string))
 {
     // to ensure "Rect" is required (not null)
     if (Rect == null)
     {
         throw new InvalidDataException("Rect is a required property for FileAttachmentAnnotation and cannot be null");
     }
     else
     {
         this.Rect = Rect;
     }
     this.Links               = Links;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Modified            = Modified;
     this.Id                  = Id;
     this.Flags               = Flags;
     this.Name                = Name;
     this.PageIndex           = PageIndex;
     this.ZIndex              = ZIndex;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.CreationDate        = CreationDate;
     this.Subject             = Subject;
     this.Title               = Title;
     this.RichText            = RichText;
     this.Icon                = Icon;
     this.Opacity             = Opacity;
     this.FileDescription     = FileDescription;
     this.FileName            = FileName;
     this.FilePath            = FilePath;
 }
Example #40
0
        /// <summary>
        /// Writes text.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="fill">
        /// The text color.
        /// </param>
        /// <param name="fontFamily">
        /// The font family.
        /// </param>
        /// <param name="fontSize">
        /// The font size.
        /// </param>
        /// <param name="fontWeight">
        /// The font weight.
        /// </param>
        /// <param name="rotate">
        /// The rotation angle.
        /// </param>
        /// <param name="halign">
        /// The horizontal alignment.
        /// </param>
        /// <param name="valign">
        /// The vertical alignment.
        /// </param>
        public void WriteText(
            ScreenPoint position,
            string text,
            OxyColor fill,
            string fontFamily          = null,
            double fontSize            = 10,
            double fontWeight          = FontWeights.Normal,
            double rotate              = 0,
            HorizontalAlignment halign = HorizontalAlignment.Left,
            VerticalAlignment valign   = VerticalAlignment.Top)
        {
            // http://www.w3.org/TR/SVG/text.html
            this.WriteStartElement("text");

            // WriteAttributeString("x", position.X);
            // WriteAttributeString("y", position.Y);
            string baselineAlignment = "hanging";

            if (valign == VerticalAlignment.Middle)
            {
                baselineAlignment = "middle";
            }

            if (valign == VerticalAlignment.Bottom)
            {
                baselineAlignment = "baseline";
            }

            this.WriteAttributeString("dominant-baseline", baselineAlignment);

            string textAnchor = "start";

            if (halign == HorizontalAlignment.Center)
            {
                textAnchor = "middle";
            }

            if (halign == HorizontalAlignment.Right)
            {
                textAnchor = "end";
            }

            this.WriteAttributeString("text-anchor", textAnchor);

            string fmt       = "translate({0:" + this.NumberFormat + "},{1:" + this.NumberFormat + "})";
            string transform = string.Format(CultureInfo.InvariantCulture, fmt, position.X, position.Y);

            if (Math.Abs(rotate) > 0)
            {
                transform += string.Format(CultureInfo.InvariantCulture, " rotate({0})", rotate);
            }

            this.WriteAttributeString("transform", transform);

            if (fontFamily != null)
            {
                this.WriteAttributeString("font-family", fontFamily);
            }

            if (fontSize > 0)
            {
                this.WriteAttributeString("font-size", fontSize);
            }

            if (fontWeight > 0)
            {
                this.WriteAttributeString("font-weight", fontWeight);
            }

            this.WriteAttributeString("fill", this.ColorToString(fill));

            // WriteAttributeString("style", style);
            this.WriteString(text);
            this.WriteEndElement();
        }
Example #41
0
 public static void SetVerticalPivot(this RectTransform rectTransform, VerticalAlignment alignment)
 {
     rectTransform.pivot = new Vector2(rectTransform.pivot.x, GetPivotPosition(alignment));
 }
Example #42
0
 /**
  * Take a cell, and vertically align it.
  *
  * This is superior to cell.getCellStyle().setVerticalAlignment(align) because
  * this method will not modify the CellStyle object that may be referenced
  * by multiple cells. Instead, this method will search for existing CellStyles
  * that match the desired CellStyle, creating a new CellStyle with the desired
  * style if no match exists.
  *
  * @param cell the cell to set the alignment for
  * @param align the vertical alignment to use.
  *
  * @see VerticalAlignment for alignment options
  * @since POI 3.15 beta 3
  */
 public static void SetVerticalAlignment(ICell cell, VerticalAlignment align)
 {
     SetCellStyleProperty(cell, VERTICAL_ALIGNMENT, align);
 }
 /// <summary>
 /// 设置垂直对齐
 /// </summary>
 /// <param name="cellStyle">单元格样式</param>
 /// <param name="verticalAlignment">垂直对齐</param>
 /// <returns></returns>
 public static ICellStyle SetVerticalAlignment(this ICellStyle cellStyle, VerticalAlignment verticalAlignment)
 {
     cellStyle.VerticalAlignment = verticalAlignment;
     return(cellStyle);
 }
Example #44
0
        /// <summary>
        /// Converts a <see cref="HorizontalAlignment"/> value and a <see cref="VerticalAlignment"/> value
        /// to the corresponding <see cref="TextFlags"/> value.
        /// </summary>
        /// <param name="horizontal">The <see cref="HorizontalAlignment"/> value to convert.</param>
        /// <param name="vertical">The <see cref="VerticalAlignment"/> value to convert.</param>
        /// <returns>The <see cref="TextFlags"/> value that corresponds to the specified set of alignments.</returns>
        public static TextFlags ConvertAlignmentsToTextFlags(HorizontalAlignment horizontal, VerticalAlignment vertical)
        {
            var flags = (TextFlags)0;

            switch (horizontal)
            {
            case HorizontalAlignment.Left:
            case HorizontalAlignment.Stretch:
                flags |= TextFlags.AlignLeft;
                break;

            case HorizontalAlignment.Right:
                flags |= TextFlags.AlignRight;
                break;

            case HorizontalAlignment.Center:
                flags |= TextFlags.AlignCenter;
                break;
            }

            switch (vertical)
            {
            case VerticalAlignment.Top:
            case VerticalAlignment.Stretch:
                flags |= TextFlags.AlignTop;
                break;

            case VerticalAlignment.Bottom:
                flags |= TextFlags.AlignBottom;
                break;

            case VerticalAlignment.Center:
                flags |= TextFlags.AlignMiddle;
                break;
            }

            return(flags);
        }
Example #45
0
 public AlignmentPanel(Control content, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) : this(horizontalAlignment, verticalAlignment)
 {
     Content = content;
 }
        public SizeF GetStringSize(
            string value,
            string fontName,
            float fontSize,
            HorizontalAlignment horizontalAlignment,
            VerticalAlignment verticalAlignment)
        {
            float factor = 1;

            while (fontSize > 10)
            {
                fontSize /= 10;
                factor   *= 10;
            }

            var path = new CGPath();

            path.AddRect(new Drawing.RectangleF(0, 0, 512, 512));
            path.CloseSubpath();

            var attributedString = new NSMutableAttributedString(value);

            var attributes = new CTStringAttributes();

            // Load the font
            var font = NativeFontService.Instance.LoadFont(fontName ?? SystemFontName, fontSize);

            attributes.Font = font;

            // Set the horizontal alignment
            var paragraphSettings = new CTParagraphStyleSettings();

            switch (horizontalAlignment)
            {
            case HorizontalAlignment.Left:
                paragraphSettings.Alignment = CTTextAlignment.Left;
                break;

            case HorizontalAlignment.Center:
                paragraphSettings.Alignment = CTTextAlignment.Center;
                break;

            case HorizontalAlignment.Right:
                paragraphSettings.Alignment = CTTextAlignment.Right;
                break;

            case HorizontalAlignment.Justified:
                paragraphSettings.Alignment = CTTextAlignment.Justified;
                break;
            }

            var paragraphStyle = new CTParagraphStyle(paragraphSettings);

            attributes.ParagraphStyle = paragraphStyle;

            // Set the attributes for the complete length of the string
            attributedString.SetAttributes(attributes, new NSRange(0, value.Length));

            // Create the frame setter with the attributed string.
            var frameSetter = new CTFramesetter(attributedString);

            var textBounds = GetTextSize(frameSetter, path);

            //Logger.Debug("{0} {1}",vSize,aString);

            frameSetter.Dispose();
            attributedString.Dispose();
            paragraphStyle.Dispose();
            //font.Dispose();
            path.Dispose();

            textBounds.Width  *= factor;
            textBounds.Height *= factor;

            //size.Width = Math.Ceiling(vSize.Width);
            //size.Height = Math.Ceiling(vSize.Height);

            return(textBounds.Size);
        }
        public bool Layout(object handle, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov, Rectangle boundingBox, Padding padding, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
        {
            var paddedBbox = boundingBox.PadIn(control.Margin);

            var size = Measure((ISpriteManager)handle, control, systemContainer, playerFov, paddedBbox, padding, horizontalAlignment, verticalAlignment);

            control.Position = new Rectangle(paddedBbox.Location, size);

            ApplyHorizontalAlignment(horizontalAlignment, control, paddedBbox, size);
            ApplyVerticalAlignment(verticalAlignment, control, paddedBbox, size);

            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Billboard" /> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="horizontalAlignment">The horizontal alignment.</param>
        /// <param name="verticalAlignment">The vertical alignment.</param>
        /// <param name="depthOffset">The depth offset.</param>
        /// <param name="worldDepthOffset">The depth offset in world coordinates.</param>
        public Billboard(Point3D position, double width = 1.0, double height = 1.0, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center, VerticalAlignment verticalAlignment = VerticalAlignment.Center, double depthOffset = 0.0, double worldDepthOffset = 0)
        {
            // Set horizontal alignment factor
            var xa = -0.5;

            if (horizontalAlignment == HorizontalAlignment.Left)
            {
                xa = 0;
            }

            if (horizontalAlignment == HorizontalAlignment.Right)
            {
                xa = -1;
            }

            // Set vertical alignment factor
            var ya = -0.5;

            if (verticalAlignment == VerticalAlignment.Top)
            {
                ya = 0;
            }

            if (verticalAlignment == VerticalAlignment.Bottom)
            {
                ya = -1;
            }

            double left = xa * width;
            double top  = ya * height;

            this.Position         = position;
            this.Left             = left;
            this.Right            = left + width;
            this.Top              = top;
            this.Bottom           = top + height;
            this.DepthOffset      = depthOffset;
            this.WorldDepthOffset = worldDepthOffset;
        }
        public static Stream CenterCrop(Stream imageStream, int width, int height, ImageFormat format, HorizontalAlignment cha, VerticalAlignment cva)
        {
            var bitmap = new System.Drawing.Bitmap(imageStream);

            if (bitmap.Width == width && bitmap.Height == height)
            {
                return(imageStream);
            }
            var cropWidth  = width < bitmap.Width && width != 0 ? width : bitmap.Width;
            var cropHeight = height < bitmap.Height && height != 0 ? height : bitmap.Height;

            var x = 0;

            if (cha == HorizontalAlignment.Center)
            {
                x = cropWidth == bitmap.Width ? 0 : (bitmap.Width / 2) - (cropWidth / 2);
            }
            else if (cha == HorizontalAlignment.Left)
            {
                x = 0;
            }
            else if (cha == HorizontalAlignment.Right)
            {
                x = cropWidth == bitmap.Width ? 0 : (bitmap.Width - cropWidth);
            }

            var y = 0;

            if (cva == VerticalAlignment.Middle)
            {
                y = cropHeight == bitmap.Width ? 0 : (bitmap.Height / 2) - (cropHeight / 2);
            }
            else if (cva == VerticalAlignment.Top)
            {
                y = 0;
            }
            else if (cva == VerticalAlignment.Bottom)
            {
                y = cropHeight == bitmap.Height ? 0 : (bitmap.Height - cropHeight);
            }

            var croppedBitmap = CropImage(bitmap, x, y, cropWidth, cropHeight);
            var memoryStream  = new MemoryStream();

            croppedBitmap.Save(memoryStream, format);
            return(memoryStream);
        }
Example #50
0
        internal void MakeCellAlignment(int row, int column, HorizontalAlignment horizontal, VerticalAlignment vertical)
        {
            AlignmentOptionsBase ao = sheet[column - 1, row - 1].Alignment as AlignmentOptionsBase;

            ao.Horizontal = horizontal;
            ao.Vertical   = vertical;
        }
Example #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScreenAnnotation" /> class.
 /// </summary>
 /// <param name="Links">Link to the document..</param>
 /// <param name="Color">Color of the annotation..</param>
 /// <param name="Contents">Get the annotation content..</param>
 /// <param name="Modified">The date and time when the annotation was last modified..</param>
 /// <param name="Id">Gets ID of the annotation..</param>
 /// <param name="Flags">Gets Flags of the annotation..</param>
 /// <param name="Name">Gets Name of the annotation..</param>
 /// <param name="Rect">Gets Rect of the annotation. (required).</param>
 /// <param name="PageIndex">Gets PageIndex of the annotation..</param>
 /// <param name="ZIndex">Gets ZIndex of the annotation..</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation..</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation..</param>
 /// <param name="Title">Get the annotation title..</param>
 /// <param name="FilePath">Sets content file path. .</param>
 public ScreenAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string Title = default(string), string FilePath = default(string))
 {
     // to ensure "Rect" is required (not null)
     if (Rect == null)
     {
         throw new InvalidDataException("Rect is a required property for ScreenAnnotation and cannot be null");
     }
     else
     {
         this.Rect = Rect;
     }
     this.Links               = Links;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Modified            = Modified;
     this.Id                  = Id;
     this.Flags               = Flags;
     this.Name                = Name;
     this.PageIndex           = PageIndex;
     this.ZIndex              = ZIndex;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.Title               = Title;
     this.FilePath            = FilePath;
 }
Example #52
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text.</param>
        public override void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            HorizontalAlignment halign,
            VerticalAlignment valign,
            OxySize?maxSize)
        {
            var fw = fontWeight >= 700 ? FontWeight.Bold : FontWeight.Normal;

            this.g.Save();
            this.g.SetFontSize(fontSize * FontsizeFactor);
            this.g.SelectFontFace(fontFamily, FontSlant.Normal, fw);

            // using (var sf = new StringFormat { Alignment = StringAlignment.Near })
            var size = this.g.TextExtents(text);

            if (maxSize != null)
            {
                size.Width  = Math.Min(size.Width, maxSize.Value.Width);
                size.Height = Math.Min(size.Height, maxSize.Value.Height);
            }

            double dx = 0;

            if (halign == HorizontalAlignment.Center)
            {
                dx = -size.Width / 2;
            }

            if (halign == HorizontalAlignment.Right)
            {
                dx = -size.Width;
            }

            double dy = 0;

            if (valign == VerticalAlignment.Middle)
            {
                dy = -size.Height / 2;
            }

            if (valign == VerticalAlignment.Bottom)
            {
                dy = -size.Height;
            }

            this.g.Translate(p.X, p.Y);
            if (Math.Abs(rotate) > double.Epsilon)
            {
                this.g.Rotate(rotate * Math.PI / 180.0);
            }

            this.g.Translate(dx, dy);

            // g.Rectangle(0, 0, size.Width + 0.1f, size.Height + 0.1f);
            this.g.MoveTo(0, size.Height + 0.1f);
            this.g.SetSourceColor(fill);
            this.g.ShowText(text);

            this.g.Restore();
        }
Example #53
0
 public static Point OffsetPoint(Rectangle root, Rectangle p, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center, VerticalAlignment verticalAlignment = VerticalAlignment.Center)
 {
     return(Point.Zero);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LineAnnotation" /> class.
 /// </summary>
 /// <param name="Links">Link to the document.</param>
 /// <param name="Color">Color of the annotation.</param>
 /// <param name="Contents">Get the annotation content.</param>
 /// <param name="Modified">The date and time when the annotation was last modified.</param>
 /// <param name="Id">Gets ID of the annotation.</param>
 /// <param name="Flags">Gets Flags of the annotation.</param>
 /// <param name="Name">Gets Name of the annotation.</param>
 /// <param name="Rect">Gets Rect of the annotation. (required)</param>
 /// <param name="PageIndex">Gets PageIndex of the annotation.</param>
 /// <param name="ZIndex">Gets ZIndex of the annotation.</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation.</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation.</param>
 /// <param name="CreationDate">The date and time when the annotation was created.</param>
 /// <param name="Subject">Get the annotation subject.</param>
 /// <param name="Title">Get the annotation title.</param>
 /// <param name="RichText">Get the annotation RichText.</param>
 /// <param name="Starting">Gets or sets starting point of line. (required)</param>
 /// <param name="StartingStyle">Gets or sets line ending style for line starting point.</param>
 /// <param name="Ending">Gets or sets ending point of line. (required)</param>
 /// <param name="EndingStyle">Gets or sets ending style for end point of line.</param>
 /// <param name="InteriorColor">Gets or sets interior color of the annotation.</param>
 /// <param name="LeaderLine">Gets or sets leader line length.</param>
 /// <param name="LeaderLineExtension">Gets or sets length of leader line extension.</param>
 /// <param name="LeaderLineOffset">Gets or sets leader line offset.</param>
 /// <param name="ShowCaption">Gets or sets boolean flag which determinies is contents must be shown as caption.</param>
 /// <param name="CaptionOffset">Gets or sets caption text offset from its normal position.</param>
 /// <param name="CaptionPosition">Gets or sets annotation caption position.</param>
 /// <param name="Intent">Gets or sets the intent of the line annotation.</param>
 public LineAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), Point Starting = default(Point), LineEnding StartingStyle = default(LineEnding), Point Ending = default(Point), LineEnding EndingStyle = default(LineEnding), Color InteriorColor = default(Color), double?LeaderLine = default(double?), double?LeaderLineExtension = default(double?), double?LeaderLineOffset = default(double?), bool?ShowCaption = default(bool?), Point CaptionOffset = default(Point), CaptionPosition CaptionPosition = default(CaptionPosition), LineIntent Intent = default(LineIntent))
 {
     // to ensure "Rect" is required (not null)
     if (Rect == null)
     {
         throw new InvalidDataException("Rect is a required property for LineAnnotation and cannot be null");
     }
     else
     {
         this.Rect = Rect;
     }
     // to ensure "Starting" is required (not null)
     if (Starting == null)
     {
         throw new InvalidDataException("Starting is a required property for LineAnnotation and cannot be null");
     }
     else
     {
         this.Starting = Starting;
     }
     // to ensure "Ending" is required (not null)
     if (Ending == null)
     {
         throw new InvalidDataException("Ending is a required property for LineAnnotation and cannot be null");
     }
     else
     {
         this.Ending = Ending;
     }
     this.Links               = Links;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Modified            = Modified;
     this.Id                  = Id;
     this.Flags               = Flags;
     this.Name                = Name;
     this.PageIndex           = PageIndex;
     this.ZIndex              = ZIndex;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.CreationDate        = CreationDate;
     this.Subject             = Subject;
     this.Title               = Title;
     this.RichText            = RichText;
     this.StartingStyle       = StartingStyle;
     this.EndingStyle         = EndingStyle;
     this.InteriorColor       = InteriorColor;
     this.LeaderLine          = LeaderLine;
     this.LeaderLineExtension = LeaderLineExtension;
     this.LeaderLineOffset    = LeaderLineOffset;
     this.ShowCaption         = ShowCaption;
     this.CaptionOffset       = CaptionOffset;
     this.CaptionPosition     = CaptionPosition;
     this.Intent              = Intent;
 }
Example #55
0
        /// <summary>
        /// Create a border geometry with a 'pointer'.
        /// </summary>
        /// <param name="ha">The horizontal alignment.</param>
        /// <param name="va">The vertical alignment.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="margin">The margin.</param>
        /// <returns>The border geometry.</returns>
        private Geometry CreatePointerBorderGeometry(
            HorizontalAlignment ha, VerticalAlignment va, double width, double height, out Thickness margin)
        {
            Point[] points = null;
            var     m      = Distance;

            margin = new Thickness();

            if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Bottom)
            {
                double x0 = 0;
                var    x1 = width;
                var    x2 = (x0 + x1) / 2;
                double y0 = 0;
                var    y1 = height;
                margin = new Thickness(0, 0, 0, m);
                points = new[]
                {
                    new Point(x0, y0), new Point(x1, y0), new Point(x1, y1), new Point(x2 + (m / 2), y1),
                    new Point(x2, y1 + m), new Point(x2 - (m / 2), y1), new Point(x0, y1)
                };
            }

            if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Top)
            {
                double x0 = 0;
                var    x1 = width;
                var    x2 = (x0 + x1) / 2;
                var    y0 = m;
                var    y1 = m + height;
                margin = new Thickness(0, m, 0, 0);
                points = new[]
                {
                    new Point(x0, y0), new Point(x2 - (m / 2), y0), new Point(x2, 0), new Point(x2 + (m / 2), y0),
                    new Point(x1, y0), new Point(x1, y1), new Point(x0, y1)
                };
            }

            if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Center)
            {
                var    x0 = m;
                var    x1 = m + width;
                double y0 = 0;
                var    y1 = height;
                var    y2 = (y0 + y1) / 2;
                margin = new Thickness(m, 0, 0, 0);
                points = new[]
                {
                    new Point(0, y2), new Point(x0, y2 - (m / 2)), new Point(x0, y0), new Point(x1, y0),
                    new Point(x1, y1), new Point(x0, y1), new Point(x0, y2 + (m / 2))
                };
            }

            if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Center)
            {
                double x0 = 0;
                var    x1 = width;
                double y0 = 0;
                var    y1 = height;
                var    y2 = (y0 + y1) / 2;
                margin = new Thickness(0, 0, m, 0);
                points = new[]
                {
                    new Point(x1 + m, y2), new Point(x1, y2 + (m / 2)), new Point(x1, y1), new Point(x0, y1),
                    new Point(x0, y0), new Point(x1, y0), new Point(x1, y2 - (m / 2))
                };
            }

            if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Top)
            {
                m *= 0.67;
                var x0 = m;
                var x1 = m + width;
                var y0 = m;
                var y1 = m + height;
                margin = new Thickness(m, m, 0, 0);
                points = new[]
                {
                    new Point(0, 0), new Point(m * 2, y0), new Point(x1, y0), new Point(x1, y1), new Point(x0, y1),
                    new Point(x0, m * 2)
                };
            }

            if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Top)
            {
                m *= 0.67;
                double x0 = 0;
                var    x1 = width;
                var    y0 = m;
                var    y1 = m + height;
                margin = new Thickness(0, m, m, 0);
                points = new[]
                {
                    new Point(x1 + m, 0), new Point(x1, y0 + m), new Point(x1, y1), new Point(x0, y1),
                    new Point(x0, y0), new Point(x1 - m, y0)
                };
            }

            if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Bottom)
            {
                m *= 0.67;
                var    x0 = m;
                var    x1 = m + width;
                double y0 = 0;
                var    y1 = height;
                margin = new Thickness(m, 0, 0, m);
                points = new[]
                {
                    new Point(0, y1 + m), new Point(x0, y1 - m), new Point(x0, y0), new Point(x1, y0),
                    new Point(x1, y1), new Point(x0 + m, y1)
                };
            }

            if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Bottom)
            {
                m *= 0.67;
                double x0 = 0;
                var    x1 = width;
                double y0 = 0;
                var    y1 = height;
                margin = new Thickness(0, 0, m, m);
                points = new[]
                {
                    new Point(x1 + m, y1 + m), new Point(x1 - m, y1), new Point(x0, y1), new Point(x0, y0),
                    new Point(x1, y0), new Point(x1, y1 - m)
                };
            }

            if (points == null)
            {
                return(null);
            }

            var pc = new List <Point>(points.Length);

            foreach (var p in points)
            {
                pc.Add(p);
            }
            var segments = new PathSegments();

            segments.AddRange(pc.Select(p => new LineSegment {
                Point = p
            }));
            var pf = new PathFigure {
                StartPoint = points[0], Segments = segments, IsClosed = true
            };

            return(new PathGeometry {
                Figures = new PathFigures {
                    pf
                }
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnInfo"/> struct.
 /// </summary>
 /// <param name="width">The width of the column in (fixed-width) characters.</param>
 /// <param name="content">The content of this column.</param>
 /// <param name="alignment">The alignment to use for this column.</param>
 /// <param name="verticalAlignment">The vertical alignment to use for this column</param>
 public ColumnInfo(int width, string content, Alignment alignment, VerticalAlignment verticalAlignment)
     : this(width, content, alignment, verticalAlignment, WordWrappingMethod.Optimal)
 {
 }
Example #57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Stamp" /> class.
 /// </summary>
 /// <param name="Type">Gets the stamp type. (required).</param>
 /// <param name="Background">Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top..</param>
 /// <param name="BottomMargin">Gets or sets bottom margin of stamp..</param>
 /// <param name="HorizontalAlignment">Gets or sets Horizontal alignment of stamp on the page. .</param>
 /// <param name="LeftMargin">Gets or sets left margin of stamp..</param>
 /// <param name="Opacity">Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0..</param>
 /// <param name="RightMargin">Gets or sets right margin of stamp..</param>
 /// <param name="Rotate">Sets or gets the rotation of stamp content according Rotation values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property.  If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None..</param>
 /// <param name="RotateAngle">Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle. .</param>
 /// <param name="TopMargin">Gets or sets top margin of stamp..</param>
 /// <param name="VerticalAlignment">Gets or sets vertical alignment of stamp on page..</param>
 /// <param name="XIndent">Horizontal stamp coordinate, starting from the left..</param>
 /// <param name="YIndent">Vertical stamp coordinate, starting from the bottom..</param>
 /// <param name="Zoom">Zooming factor of the stamp. Allows to scale stamp..</param>
 /// <param name="TextAlignment">Alignment of the text inside the stamp..</param>
 /// <param name="Value">Gets or sets string value which is used as stamp on the page..</param>
 /// <param name="TextState">Gets text properties of the stamp. See TextState for details..</param>
 /// <param name="FileName">Gets or sets the file name..</param>
 /// <param name="Width">Gets or sets image width. Setting this property allos to scal image horizontally..</param>
 /// <param name="Height">Gets or sets image height. Setting this image allows to scale image vertically..</param>
 /// <param name="PageIndex">Gets or sets the index of the page..</param>
 /// <param name="StartingNumber">Gets or sets value of the number of starting page. Other pages will be numbered starting from this value..</param>
 public Stamp(StampType Type = default(StampType), bool?Background = default(bool?), double?BottomMargin = default(double?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), double?LeftMargin = default(double?), double?Opacity = default(double?), double?RightMargin = default(double?), Rotation Rotate = default(Rotation), double?RotateAngle = default(double?), double?TopMargin = default(double?), VerticalAlignment VerticalAlignment = default(VerticalAlignment), double?XIndent = default(double?), double?YIndent = default(double?), double?Zoom = default(double?), HorizontalAlignment TextAlignment = default(HorizontalAlignment), string Value = default(string), TextState TextState = default(TextState), string FileName = default(string), double?Width = default(double?), double?Height = default(double?), int?PageIndex = default(int?), int?StartingNumber = default(int?))
 {
     // to ensure "Type" is required (not null)
     if (Type == null)
     {
         throw new InvalidDataException("Type is a required property for Stamp and cannot be null");
     }
     else
     {
         this.Type = Type;
     }
     this.Background          = Background;
     this.BottomMargin        = BottomMargin;
     this.HorizontalAlignment = HorizontalAlignment;
     this.LeftMargin          = LeftMargin;
     this.Opacity             = Opacity;
     this.RightMargin         = RightMargin;
     this.Rotate            = Rotate;
     this.RotateAngle       = RotateAngle;
     this.TopMargin         = TopMargin;
     this.VerticalAlignment = VerticalAlignment;
     this.XIndent           = XIndent;
     this.YIndent           = YIndent;
     this.Zoom           = Zoom;
     this.TextAlignment  = TextAlignment;
     this.Value          = Value;
     this.TextState      = TextState;
     this.FileName       = FileName;
     this.Width          = Width;
     this.Height         = Height;
     this.PageIndex      = PageIndex;
     this.StartingNumber = StartingNumber;
 }
Example #58
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text.</param>
        public override void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            HorizontalAlignment halign,
            VerticalAlignment valign,
            OxySize?maxSize)
        {
            if (text == null)
            {
                return;
            }

            var fontStyle = fontWeight < 700 ? FontStyle.Regular : FontStyle.Bold;

            using (var font = CreateFont(fontFamily, fontSize, fontStyle))
            {
                var size = this.g.MeasureString(text, font, int.MaxValue);
                if (maxSize != null)
                {
                    if (size.Width > maxSize.Value.Width)
                    {
                        size.Width = (float)maxSize.Value.Width;
                    }

                    if (size.Height > maxSize.Value.Height)
                    {
                        size.Height = (float)maxSize.Value.Height;
                    }
                }

                float dx = 0;
                if (halign == HorizontalAlignment.Center)
                {
                    dx = -size.Width / 2;
                }

                if (halign == HorizontalAlignment.Right)
                {
                    dx = -size.Width;
                }

                float dy = 0;
                if (valign == VerticalAlignment.Middle)
                {
                    dy = -size.Height / 2;
                }

                if (valign == VerticalAlignment.Bottom)
                {
                    dy = -size.Height;
                }

                var graphicsState = this.g.Save();

                this.g.TranslateTransform((float)p.X, (float)p.Y);

                var layoutRectangle = new RectangleF(0, 0, size.Width, size.Height);
                if (Math.Abs(rotate) > double.Epsilon)
                {
                    this.g.RotateTransform((float)rotate);

                    layoutRectangle.Height += (float)(fontSize / 18.0);
                }

                this.g.TranslateTransform(dx, dy);

                this.g.DrawString(text, font, fill.ToBrush(), layoutRectangle);

                this.g.Restore(graphicsState);
            }
        }
 protected abstract Size Measure(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov, Rectangle boundingBox, Padding padding, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment);
Example #60
0
        internal void MakeRangeAlignment(int row_start, int column_start, int row_end, int column_end, HorizontalAlignment horizontal, VerticalAlignment vertical)
        {
            AlignmentOptionsBase ao = new Range(sheet[column_start - 1, row_start - 1], sheet[column_end - 1, row_end - 1]).Alignment as AlignmentOptionsBase;

            ao.Horizontal = horizontal;
            ao.Vertical   = vertical;
        }