예제 #1
0
        /// <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;
        }
예제 #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);
		}
예제 #3
0
파일: StyleInfo.cs 프로젝트: rsdn/janus
		public StyleInfo(Color BackColor, Color ForeColor, Font Font, HorizontalAlignment Alignment)
		{
			this.BackColor2 = this.BackColor = BackColor;
			this.ForeColor2 = this.ForeColor = ForeColor;
			this.Font = Font;
			this.Algnment = Alignment;
		}
예제 #4
0
 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);
 }
예제 #5
0
		///<summary>Creates a new ODGridcolumn with the given heading and width. Alignment left</summary>
		public ODGridColumn(string heading,int colWidth){
			this.heading=heading;
			this.colWidth=colWidth;
			this.textAlign=HorizontalAlignment.Left;
			imageList=null;
			sortingStrategy=GridSortingStrategy.StringCompare;
		}
예제 #6
0
        /// <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);
        }
예제 #7
0
                public CustomButton(string content, double width, double height, System.Windows.Thickness margin, System.Windows.Thickness padding, HorizontalAlignment hAlign)
                {
                        _block = new TextBlock();
                        _block.Text = content;

                        this.Width = width;
                        this.Height = height;
                        this.Margin = margin;
                        this.Background = ThemeSelector.GetButtonColor();
                        
                        
                        this.HorizontalAlignment = hAlign;

                        _block.Padding = padding;
                        _block.FontSize = Responsive.GetButtonTextSize();
                        _block.FontFamily = FontProvider._lato;
                        _block.Foreground = ThemeSelector.GetButtonContentColor();
                        _block.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;


                        this.Children.Add(_block);

                        this.MouseLeave += CustomButton_MouseLeave;
                        this.MouseEnter += CustomButton_MouseEnter;
                    

                        //this.SetColor();
                }
        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 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();
 }
        /// <summary> Constructor for a new instance of the CustomGrid_Style class </summary>
        /// <param name="Data_Source"> DataTable for which to atuomatically build the style for </param>
        public CustomGrid_Style( DataTable Data_Source )
        {
            // Declare collection of columns
            columns = new List<CustomGrid_ColumnStyle>();
            visibleColumns = new CustomGrid_VisibleColumns( columns );

            // Set some defaults
            default_columnWidth = 100;
            headerHeight = 23;
            rowHeight = 20;
            default_textAlignment = HorizontalAlignment.Center;
            default_backColor = System.Drawing.Color.White;
            default_foreColor = System.Drawing.Color.Black;
            alternating_print_backColor = System.Drawing.Color.Honeydew;
            gridLineColor = System.Drawing.Color.Black;
            headerForeColor = System.Drawing.SystemColors.WindowText;
            headerBackColor = System.Drawing.SystemColors.Control;
            rowSelectForeColor = System.Drawing.SystemColors.WindowText;
            rowSelectBackColor = System.Drawing.SystemColors.Control;
            noMatchesTextColor = System.Drawing.Color.MediumBlue;
            selectedColor = System.Drawing.Color.Yellow;
            sortable = true;
            column_resizable = true;
            primaryKey = -1;
            double_click_delay = 1000;

            // Set this data source
            this.Data_Source = Data_Source;
        }
예제 #11
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);
		}
예제 #12
0
 public DataGridCommonColumn()
     : base()
 {
     mTxtAlign = HorizontalAlignment.Left;
     mDrawTxt.Alignment = StringAlignment.Near;
     //this.ReadOnly = true;
 }
예제 #13
0
 public ListViewColumnItem(String Header, String Binding, long WidthPercent, HorizontalAlignment Alignment)
 {
     this.Header         = Header;
     this.Binding        = Binding;
     this.WidthPercent   = WidthPercent;
     this.Alignment      = Alignment;
 }
예제 #14
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();
        }
예제 #15
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();
        }
예제 #16
0
 public static void AppendAlign(StringBuilder style, HorizontalAlignment alignment)
 {
     switch (alignment)
     {
         case HorizontalAlignment.CENTER:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.CENTER_SELECTION:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.FILL:
             // XXX: shall we support fill?
             break;
         case HorizontalAlignment.GENERAL:
             break;
         case HorizontalAlignment.JUSTIFY:
             style.Append("text-align: justify; ");
             break;
         case HorizontalAlignment.LEFT:
             style.Append("text-align: left; ");
             break;
         case HorizontalAlignment.RIGHT:
             style.Append("text-align: right; ");
             break;
     }
 }
예제 #17
0
 public static void AppendAlign(StringBuilder style, HorizontalAlignment alignment)
 {
     switch (alignment)
     {
         case HorizontalAlignment.Center:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.CenterSelection:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.Fill:
             // XXX: shall we support fill?
             break;
         case HorizontalAlignment.General:
             break;
         case HorizontalAlignment.Justify:
             style.Append("text-align: justify; ");
             break;
         case HorizontalAlignment.Left:
             style.Append("text-align: left; ");
             break;
         case HorizontalAlignment.Right:
             style.Append("text-align: right; ");
             break;
     }
 }
 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();
 }
예제 #19
0
파일: TableCell.cs 프로젝트: dbrgn/pi-vote
 public TableCell(string text, XFont font, int columnSpan, HorizontalAlignment alignment)
 {
     Text = text;
       Font = font;
       Alignment = alignment;
       ColumnSpan = columnSpan;
 }
예제 #20
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();
        }
예제 #21
0
파일: Font.cs 프로젝트: 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;
            }
        }
 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);
 }
 private static void DrawText(FixedContentEditor editor, string text, double width = double.PositiveInfinity, HorizontalAlignment alignment = HorizontalAlignment.Left)
 {
     Block block = CreateBlock(editor);
     block.HorizontalAlignment = alignment;
     block.InsertText(text);
     editor.DrawBlock(block, new Size(width, double.PositiveInfinity));
 }
예제 #24
0
        public LabelAndImage(ImageSource ImageSource, string LabelContent,
            HorizontalAlignment ControlHorizontalAlignment = HorizontalAlignment.Left,
            double PanelHeight = 0, double PanelWidth = 0, double LabelFont = 0)
        {
            InitializeComponent();

            this.ImageSource = ImageSource;
            this.LabelContent = LabelContent;
            this.ControlHorizontalAlignment = ControlHorizontalAlignment;

            if (PanelHeight == 0)
            {
                this.PanelHeight = (double)Application.Current.Resources["SmallButtonHeight"];
            }
            else
            {
                this.PanelHeight = PanelHeight;
            }
            if (PanelWidth == 0)
            {
                this.PanelWidth = (double)Application.Current.Resources["SmallButtonWidth"];
            }
            else
            {
                this.PanelWidth = PanelWidth;
            }
            if (LabelFont == 0)
            {
                this.LabelFont = (double)Application.Current.Resources["SmallButtonFont"];
            }
            else
            {
                this.LabelFont = LabelFont;
            }
        }
예제 #25
0
        /// <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;
        }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageEventArgs"/> class.
 /// </summary>
 public ImageEventArgs(string originalSrc, string src, string alt, string title, HorizontalAlignment horizontalAlign = HorizontalAlignment.None)
 {
     OriginalSrc = originalSrc;
     Src = src;
     Alt = alt;
     Title = title;
     HorizontalAlign = horizontalAlign;
 }
예제 #27
0
		internal ColumnHeader (string key, string text, int width, HorizontalAlignment textAlign)
		{
			Name = key;
			Text = text;
			this.width = width;
			this.text_alignment = textAlign;
			CalcColumnHeader ();
		}
예제 #28
0
파일: TextManager.cs 프로젝트: ndech/Alpha
 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);
 }
 public AlternativeButton(string content, double width, double height, System.Windows.Thickness margin, System.Windows.Thickness padding, HorizontalAlignment hAlign)
         : base(content, width, height, margin, padding, hAlign)
 {
         this.MouseEnter += AlternativeButton_MouseEnter;
         this.MouseLeave += AlternativeButton_MouseLeave;
         this.Background = Palette2.GetColor(Palette2.ALTERNATIVE);
         _block.Foreground = Palette2.GetColor(Palette2.THIN_GRAY);
 }
예제 #30
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);
        }
예제 #31
0
 protected void DrawText(HorizontalAlignment a, Color c, int x)
 {
     DrawText(a, c, x, 0);
 }
예제 #32
0
 protected void DrawIcon(HorizontalAlignment a, int x)
 {
     DrawIcon(a, x, 0);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageFragment" /> class.
 /// </summary>
 /// <param name="ImageFile">Gets or sets full storage path of image. (required)</param>
 /// <param name="FixWidth">Gets or sets fix width of the image.</param>
 /// <param name="FixHeight">Gets or sets fix height of the image.</param>
 /// <param name="HorizontalAlignment">Gets or sets horizontal alignment of the image.</param>
 /// <param name="VerticalAlignment">Gets or sets vertical alignment of the image.</param>
 /// <param name="ImageScale">Gets or sets ImageScale of the image.</param>
 /// <param name="Margin">Gets or sets Margin of the image.</param>
 public ImageFragment(string ImageFile = default(string), double?FixWidth = default(double?), double?FixHeight = default(double?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), double?ImageScale = default(double?), MarginInfo Margin = default(MarginInfo))
 {
     // to ensure "ImageFile" is required (not null)
     if (ImageFile == null)
     {
         throw new InvalidDataException("ImageFile is a required property for ImageFragment and cannot be null");
     }
     else
     {
         this.ImageFile = ImageFile;
     }
     this.FixWidth            = FixWidth;
     this.FixHeight           = FixHeight;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.ImageScale          = ImageScale;
     this.Margin = Margin;
 }
예제 #34
0
        /// <summary>
        /// Occurs when the value of the <see cref="HorizontalContentAlignment"/> dependency property changes.
        /// </summary>
        private static void HandleHorizontalContentAlignmentChanged(DependencyObject dobj, HorizontalAlignment oldValue, HorizontalAlignment newValue)
        {
            var label = (TextBlockBase)dobj;

            label.OnHorizontalContentAlignmentChanged();
        }
예제 #35
0
        public void ListViewGroup_HeaderAlignment_SetInvalid_ThrowsInvalidEnumArgumentException(HorizontalAlignment value)
        {
            var group = new ListViewGroup();

            Assert.Throws <InvalidEnumArgumentException>("value", () => group.HeaderAlignment = value);
        }
예제 #36
0
        //public static Vector3 Gw2V3toMonogameV3(GW2NET.Common.Drawing.Vector3D gw2v3) {
        //    return new Vector3((float)gw2v3.X, (float)gw2v3.Z, (float)gw2v3.Y);
        //}

        public static void DrawAlignedText(SpriteBatch sb, SpriteFont sf, string text, Rectangle bounds, Color clr, HorizontalAlignment ha, VerticalAlignment va)
        {
            // Filter out any characters our font doesn't support
            text = string.Join("", text.ToCharArray().Where(c => sf.Characters.Contains(c)));

            var textSize = sf.MeasureString(text);

            int xPos = bounds.X;
            int yPos = bounds.Y;

            if (ha == HorizontalAlignment.Center)
            {
                xPos += bounds.Width / 2 - (int)textSize.X / 2;
            }
            if (ha == HorizontalAlignment.Right)
            {
                xPos += bounds.Width - (int)textSize.X;
            }

            if (va == VerticalAlignment.Middle)
            {
                yPos += bounds.Height / 2 - (int)textSize.Y / 2;
            }
            if (va == VerticalAlignment.Bottom)
            {
                yPos += bounds.Height - (int)textSize.Y;
            }

            sb.DrawString(sf, text, new Vector2(xPos, yPos), clr);
        }
예제 #37
0
 /// <include file='doc\ListViewGroup.uex' path='docs/doc[@for="ListViewGroup.ListViewGroup3"]/*' />
 /// <devdoc>
 ///     Creates a ListViewGroup.
 /// </devdoc>
 public ListViewGroup(string header, HorizontalAlignment headerAlignment) : this(header) {
     this.headerAlignment = headerAlignment;
 }
예제 #38
0
        /// <summary>
        ///  Sets all the properties for this panel.
        /// </summary>
        internal void Realize()
        {
            if (Created)
            {
                string text;
                string sendText;
                int    border = 0;

                if (this.text == null)
                {
                    text = string.Empty;
                }
                else
                {
                    text = this.text;
                }

                HorizontalAlignment align = alignment;
                // Translate the alignment for Rtl apps
                //
                if (parent.RightToLeft == RightToLeft.Yes)
                {
                    switch (align)
                    {
                    case HorizontalAlignment.Left:
                        align = HorizontalAlignment.Right;
                        break;

                    case HorizontalAlignment.Right:
                        align = HorizontalAlignment.Left;
                        break;
                    }
                }

                switch (align)
                {
                case HorizontalAlignment.Center:
                    sendText = "\t" + text;
                    break;

                case HorizontalAlignment.Right:
                    sendText = "\t\t" + text;
                    break;

                default:
                    sendText = text;
                    break;
                }
                switch (borderStyle)
                {
                case StatusBarPanelBorderStyle.None:
                    border |= NativeMethods.SBT_NOBORDERS;
                    break;

                case StatusBarPanelBorderStyle.Sunken:
                    break;

                case StatusBarPanelBorderStyle.Raised:
                    border |= NativeMethods.SBT_POPOUT;
                    break;
                }
                switch (style)
                {
                case StatusBarPanelStyle.Text:
                    break;

                case StatusBarPanelStyle.OwnerDraw:
                    border |= NativeMethods.SBT_OWNERDRAW;
                    break;
                }

                int wparam = GetIndex() | border;
                if (parent.RightToLeft == RightToLeft.Yes)
                {
                    wparam |= NativeMethods.SBT_RTLREADING;
                }

                int result = (int)UnsafeNativeMethods.SendMessage(new HandleRef(parent, parent.Handle), NativeMethods.SB_SETTEXT, (IntPtr)wparam, sendText);

                if (result == 0)
                {
                    throw new InvalidOperationException(SR.UnableToSetPanelText);
                }

                if (icon != null && style != StatusBarPanelStyle.OwnerDraw)
                {
                    parent.SendMessage(NativeMethods.SB_SETICON, (IntPtr)GetIndex(), icon.Handle);
                }
                else
                {
                    parent.SendMessage(NativeMethods.SB_SETICON, (IntPtr)GetIndex(), IntPtr.Zero);
                }

                if (style == StatusBarPanelStyle.OwnerDraw)
                {
                    RECT rect = new RECT();
                    result = (int)UnsafeNativeMethods.SendMessage(new HandleRef(parent, parent.Handle), NativeMethods.SB_GETRECT, (IntPtr)GetIndex(), ref rect);

                    if (result != 0)
                    {
                        parent.Invalidate(Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom));
                    }
                }
            }
        }
예제 #39
0
        public static void DrawAlignedText(SpriteBatch sb, BitmapFont sf, string text, Rectangle bounds, Color clr, HorizontalAlignment ha = HorizontalAlignment.Left, VerticalAlignment va = VerticalAlignment.Middle)
        {
            Vector2 textSize = sf.MeasureString(text);

            int xPos = bounds.X;
            int yPos = bounds.Y;

            if (ha == HorizontalAlignment.Center)
            {
                xPos += bounds.Width / 2 - (int)textSize.X / 2;
            }
            if (ha == HorizontalAlignment.Right)
            {
                xPos += bounds.Width - (int)textSize.X;
            }

            if (va == VerticalAlignment.Middle)
            {
                yPos += bounds.Height / 2 - (int)textSize.Y / 2;
            }
            if (va == VerticalAlignment.Bottom)
            {
                yPos += bounds.Height - (int)textSize.Y;
            }

            sb.DrawString(sf, text, new Vector2(xPos, yPos), clr);
        }
예제 #40
0
 public SmartGroup(SmartListView listView, string header, HorizontalAlignment headerAlignment)
     : this(listView, new ListViewGroup(header, headerAlignment))
 {
 }
 public static void SetHorizontalAlignment(DependencyObject element, HorizontalAlignment value)
 => element.SetValue(HorizontalAlignmentProperty, value);
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StampBase" /> class.
 /// </summary>
 /// <param name="Links">Link to the document..</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="HorizontalAlignment">Gets or sets Horizontal alignment of stamp on the page. .</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="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="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>
 public StampBase(List <Link> Links = default(List <Link>), bool?Background = default(bool?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), double?Opacity = default(double?), Rotation Rotate = default(Rotation), double?RotateAngle = default(double?), double?XIndent = default(double?), double?YIndent = default(double?), double?Zoom = default(double?))
 {
     this.Links               = Links;
     this.Background          = Background;
     this.HorizontalAlignment = HorizontalAlignment;
     this.Opacity             = Opacity;
     this.Rotate              = Rotate;
     this.RotateAngle         = RotateAngle;
     this.XIndent             = XIndent;
     this.YIndent             = YIndent;
     this.Zoom = Zoom;
 }
예제 #43
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 fs = XFontStyle.Regular;

            if (fontWeight > FontWeights.Normal)
            {
                fs = XFontStyle.Bold;
            }

            var font = CreateFont(fontFamily, fontSize, fs);

            var size = this.g.MeasureString(text, font);

            if (maxSize != null)
            {
                if (size.Width > maxSize.Value.Width)
                {
                    size.Width = Math.Max(maxSize.Value.Width, 0);
                }

                if (size.Height > maxSize.Value.Height)
                {
                    size.Height = Math.Max(maxSize.Value.Height, 0);
                }
            }

            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;
            }

            var state = this.g.Save();

            this.g.TranslateTransform(dx, dy);
            if (Math.Abs(rotate) > double.Epsilon)
            {
                this.g.RotateAtTransform((float)rotate, new XPoint((float)p.X - dx, (float)p.Y - dy));
            }

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

            var layoutRectangle = new XRect(0, 0, size.Width, size.Height);
            var sf = new XStringFormat {
                Alignment = XStringAlignment.Near, LineAlignment = XLineAlignment.Near
            };

            this.g.DrawString(text, font, ToBrush(fill), layoutRectangle, sf);
            this.g.Restore(state);
        }
예제 #44
0
        public void ListViewGroup_HeaderAlignment_SetWithListViewWithHandle_GetReturnsExpected(HorizontalAlignment value)
        {
            using var listView = new ListView();
            var group = new ListViewGroup();

            listView.Groups.Add(group);
            Assert.NotEqual(IntPtr.Zero, listView.Handle);
            int invalidatedCallCount = 0;

            listView.Invalidated += (sender, e) => invalidatedCallCount++;
            int styleChangedCallCount = 0;

            listView.StyleChanged += (sender, e) => styleChangedCallCount++;
            int createdCallCount = 0;

            listView.HandleCreated += (sender, e) => createdCallCount++;

            group.HeaderAlignment = value;
            Assert.Equal(value, group.HeaderAlignment);
            Assert.True(listView.IsHandleCreated);
            Assert.Equal(0, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);

            // Set same.
            group.HeaderAlignment = value;
            Assert.Equal(value, group.HeaderAlignment);
            Assert.True(listView.IsHandleCreated);
            Assert.Equal(0, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);
        }
예제 #45
0
 public void SetHorizontalAlignment(HorizontalAlignment align)
 {
     HorizontalAlignment = align;
 }
예제 #46
0
        public void ListViewGroup_HeaderAlignment_SetWithListViewGroup_GetReturnsExpected(HorizontalAlignment value)
        {
            using var listView = new ListView();
            var group = new ListViewGroup();

            listView.Groups.Add(group);

            group.HeaderAlignment = value;
            Assert.Equal(value, group.HeaderAlignment);
            Assert.False(listView.IsHandleCreated);

            // Set same.
            group.HeaderAlignment = value;
            Assert.Equal(value, group.HeaderAlignment);
            Assert.False(listView.IsHandleCreated);
        }
예제 #47
0
        private void UpdateUIState(bool bSetModified, bool bFocusText)
        {
            ++m_uBlockEvents;
            if (bSetModified)
            {
                m_bModified = true;
            }

            this.Text = (((m_strDataDesc.Length > 0) ? (m_strDataDesc +
                                                        (m_bModified ? "*" : string.Empty) + " - ") : string.Empty) +
                         PwDefs.ShortProductName + " " + KPRes.DataEditor);

            // m_menuViewFont.Enabled = (m_bdc == BinaryDataClass.Text);
            UIUtil.SetChecked(m_menuViewWordWrap, m_rtbText.WordWrap);

            m_tbFileSave.Image = (m_bModified ? Properties.Resources.B16x16_FileSave :
                                  Properties.Resources.B16x16_FileSave_Disabled);

            m_tbEditUndo.Enabled = m_rtbText.CanUndo;
            m_tbEditRedo.Enabled = m_rtbText.CanRedo;

            Font fSel = m_rtbText.SelectionFont;

            if (fSel != null)
            {
                m_tbFormatBold.Checked      = fSel.Bold;
                m_tbFormatItalic.Checked    = fSel.Italic;
                m_tbFormatUnderline.Checked = fSel.Underline;
                m_tbFormatStrikeout.Checked = fSel.Strikeout;

                string strFontName = fSel.Name;
                if (m_tbFontCombo.Items.IndexOf(strFontName) >= 0)
                {
                    m_tbFontCombo.SelectedItem = strFontName;
                }
                else
                {
                    m_tbFontCombo.Text = strFontName;
                }

                string strFontSize = fSel.SizeInPoints.ToString();
                if (m_tbFontSizeCombo.Items.IndexOf(strFontSize) >= 0)
                {
                    m_tbFontSizeCombo.SelectedItem = strFontSize;
                }
                else
                {
                    m_tbFontSizeCombo.Text = strFontSize;
                }
            }

            HorizontalAlignment ha = m_rtbText.SelectionAlignment;

            m_tbAlignLeft.Checked   = (ha == HorizontalAlignment.Left);
            m_tbAlignCenter.Checked = (ha == HorizontalAlignment.Center);
            m_tbAlignRight.Checked  = (ha == HorizontalAlignment.Right);

            --m_uBlockEvents;
            if (bFocusText)
            {
                UIUtil.SetFocus(m_rtbText, this);
            }
        }
예제 #48
0
        public void ListViewGroup_HeaderAlignment_SetWithoutListViewGroup_GetReturnsExpected(HorizontalAlignment value)
        {
            var group = new ListViewGroup
            {
                HeaderAlignment = value
            };

            Assert.Equal(value, group.HeaderAlignment);

            // Set same.
            group.HeaderAlignment = value;
            Assert.Equal(value, group.HeaderAlignment);
        }
예제 #49
0
        private CellStyle CellStyle(string fontName = "", short fontHeight = 0, bool bold = false, IEnumerable <string> cellBorders = null, HorizontalAlignment alignment = HorizontalAlignment.GENERAL)
        {
            var cellStyle = this.Workbook.CreateCellStyle();
            var labelFont = this.Workbook.CreateFont();

            if (bold)
            {
                labelFont.Boldweight = (short)FontBoldWeight.BOLD;
            }
            if (!string.IsNullOrEmpty(fontName))
            {
                labelFont.FontName = fontName;
            }
            if (fontHeight > 0)
            {
                labelFont.FontHeightInPoints = fontHeight;
            }

            if (cellBorders != null)
            {
                foreach (var cellBorderType in cellBorders)
                {
                    switch (cellBorderType)
                    {
                    case "top":
                        cellStyle.BorderTop = CellBorderType.THIN;
                        break;

                    case "bottom":
                        cellStyle.BorderBottom = CellBorderType.THIN;
                        break;

                    case "right":
                        cellStyle.BorderRight = CellBorderType.THIN;
                        break;

                    case "left":
                        cellStyle.BorderLeft = CellBorderType.THIN;
                        break;
                    }
                }
            }

            cellStyle.Alignment = alignment;

            cellStyle.SetFont(labelFont);
            return(cellStyle);
        }
예제 #50
0
        /// <summary>
        /// 行内单元格常用样式设置
        /// </summary>
        /// <param name="workbook">Excel文件对象</param>
        /// <param name="hAlignment">水平布局方式</param>
        /// <param name="vAlignment">垂直布局方式</param>
        /// <param name="fontHeightInPoints">字体大小</param>
        /// <param name="isAddBorder">是否需要边框</param>
        /// <param name="boldWeight">字体加粗 (None = 0,Normal = 400,Bold = 700</param>
        /// <param name="fontName">字体(仿宋,楷体,宋体,微软雅黑...与Excel主题字体相对应)</param>
        /// <param name="isAddBorderColor">是否增加边框颜色</param>
        /// <param name="isItalic">是否将文字变为斜体</param>
        /// <param name="isLineFeed">是否自动换行</param>
        /// <param name="isAddCellBackground">是否增加单元格背景颜色</param>
        /// <param name="fillPattern">填充图案样式(FineDots 细点,SolidForeground立体前景,isAddFillPattern=true时存在)</param>
        /// <param name="cellBackgroundColor">单元格背景颜色(当isAddCellBackground=true时存在)</param>
        /// <param name="fontColor">字体颜色</param>
        /// <param name="underlineStyle">下划线样式(无下划线[None],单下划线[Single],双下划线[Double],会计用单下划线[SingleAccounting],会计用双下划线[DoubleAccounting])</param>
        /// <param name="typeOffset">字体上标下标(普通默认值[None],上标[Sub],下标[Super]),即字体在单元格内的上下偏移量</param>
        /// <param name="isStrikeout">是否显示删除线</param>
        /// <returns></returns>
        public HSSFCellStyle CreateStyle(HSSFWorkbook workbook, HorizontalAlignment hAlignment, VerticalAlignment vAlignment, short fontHeightInPoints, bool isAddBorder, short boldWeight, string fontName = "宋体", bool isAddBorderColor = true, bool isItalic = false, bool isLineFeed = false, bool isAddCellBackground = false, FillPattern fillPattern = FillPattern.NoFill, short cellBackgroundColor = HSSFColor.Yellow.Index, short fontColor = HSSFColor.Black.Index, FontUnderlineType underlineStyle =
                                         FontUnderlineType.None, FontSuperScript typeOffset = FontSuperScript.None, bool isStrikeout = false)
        {
            HSSFCellStyle cellStyle = (HSSFCellStyle)workbook.CreateCellStyle(); //创建列头单元格实例样式

            cellStyle.Alignment         = hAlignment;                            //水平居中
            cellStyle.VerticalAlignment = vAlignment;                            //垂直居中
            cellStyle.WrapText          = isLineFeed;                            //自动换行

            //背景颜色,边框颜色,字体颜色都是使用 HSSFColor属性中的对应调色板索引,关于 HSSFColor 颜色索引对照表,详情参考:https://www.cnblogs.com/Brainpan/p/5804167.html

            //TODO:引用了NPOI后可通过ICellStyle 接口的 FillForegroundColor 属性实现 Excel 单元格的背景色设置,FillPattern 为单元格背景色的填充样式

            //TODO:十分注意,要设置单元格背景色必须是FillForegroundColor和FillPattern两个属性同时设置,否则是不会显示背景颜色
            if (isAddCellBackground)
            {
                cellStyle.FillForegroundColor = cellBackgroundColor; //单元格背景颜色
                cellStyle.FillPattern         = fillPattern;         //填充图案样式(FineDots 细点,SolidForeground立体前景)
            }


            //是否增加边框
            if (isAddBorder)
            {
                //常用的边框样式 None(没有),Thin(细边框,瘦的),Medium(中等),Dashed(虚线),Dotted(星罗棋布的),Thick(厚的),Double(双倍),Hair(头发)[上右下左顺序设置]
                cellStyle.BorderBottom = BorderStyle.Thin;
                cellStyle.BorderRight  = BorderStyle.Thin;
                cellStyle.BorderTop    = BorderStyle.Thin;
                cellStyle.BorderLeft   = BorderStyle.Thin;
            }

            //是否设置边框颜色
            if (isAddBorderColor)
            {
                //边框颜色[上右下左顺序设置]
                cellStyle.TopBorderColor    = HSSFColor.DarkGreen.Index;//DarkGreen(黑绿色)
                cellStyle.RightBorderColor  = HSSFColor.DarkGreen.Index;
                cellStyle.BottomBorderColor = HSSFColor.DarkGreen.Index;
                cellStyle.LeftBorderColor   = HSSFColor.DarkGreen.Index;
            }

            /**
             * 设置相关字体样式
             */
            var cellStyleFont = (HSSFFont)workbook.CreateFont(); //创建字体

            //假如字体大小只需要是粗体的话直接使用下面该属性即可
            //cellStyleFont.IsBold = true;

            //cellStyleFont.Boldweight = boldWeight; //字体加粗
            cellStyleFont.FontHeightInPoints = fontHeightInPoints; //字体大小
            cellStyleFont.FontName           = fontName;           //字体(仿宋,楷体,宋体 )
            cellStyleFont.Color       = fontColor;                 //设置字体颜色
            cellStyleFont.IsItalic    = isItalic;                  //是否将文字变为斜体
            cellStyleFont.Underline   = underlineStyle;            //字体下划线
            cellStyleFont.TypeOffset  = typeOffset;                //字体上标下标
            cellStyleFont.IsStrikeout = isStrikeout;               //是否有删除线

            cellStyle.SetFont(cellStyleFont);                      //将字体绑定到样式
            return(cellStyle);
        }
예제 #51
0
 public ListViewColumnItem(String Header, String Binding, long WidthPercent, HorizontalAlignment Alignment)
 {
     this.Header       = Header;
     this.Binding      = Binding;
     this.WidthPercent = WidthPercent;
     this.Alignment    = Alignment;
 }
        private void ReadControlPropertFromXaml()
        {
            SolidColorBrush newBrush;

            switch (_control.GetType().FullName.Replace("WebSiteArchitect.AdminApp.Controls.Layout.", "").ToLower())
            {
            case "button":
                _controlType = WebControlTypeEnum.button;
                _content     = ((_control.Content as Grid).Children[0] as Button);

                newBrush         = (SolidColorBrush)((_content as Button).Background);
                _backgroundColor = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as Button).Foreground);
                _fontColor       = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as Button).BorderBrush);
                _contentColor    = newBrush.Color;

                this.Value = (_content as Button).Content.ToString();

                _verticalAlign = (_content as Button).VerticalAlignment;
                _fontSize      = (_content as Button).FontSize;
                if ((_content as Button).ToolTip != null)
                {
                    _goTo = (_content as Button).ToolTip.ToString();
                }
                break;

            case "emptyspace":
                this._controlType = WebControlTypeEnum.emptySpace;
                _controlType      = WebControlTypeEnum.emptySpace;
                _content          = _control.Content;
                newBrush          = (SolidColorBrush)((_control.Content as Rectangle).Fill);
                _backgroundColor  = newBrush.Color;
                break;

            case "input":
                _controlType = WebControlTypeEnum.input;
                _content     = ((_control.Content as Grid).Children[0] as TextBox);

                newBrush         = (SolidColorBrush)((_content as TextBox).Background);
                _backgroundColor = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as TextBox).Foreground);
                _fontColor       = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as TextBox).BorderBrush);
                _backgroundColor = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as TextBox).Background);
                _contentColor    = newBrush.Color;
                this.Value       = (_content as TextBox).Text.ToString();

                _verticalAlign = (_content as TextBox).VerticalAlignment;
                _textAlign     = (_content as TextBox).TextAlignment;
                _fontSize      = (_content as TextBox).FontSize;
                break;

            case "label":
                _controlType = WebControlTypeEnum.label;
                _content     = ((_control.Content as Grid).Children[0] as Label).Content;

                newBrush         = (SolidColorBrush)((_control.Content as Grid).Background);
                _backgroundColor = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as AccessText).Foreground);
                _fontColor       = newBrush.Color;

                this.Value = (_content as AccessText).Text.ToString();

                _verticalAlign = (_content as AccessText).VerticalAlignment;
                _textAlign     = (_content as AccessText).TextAlignment;
                _fontSize      = (_content as AccessText).FontSize;
                break;

            case "panel":
                _controlType = WebControlTypeEnum.panel;
                break;

            case "select":
                _controlType = WebControlTypeEnum.select;
                _content     = ((_control.Content as Grid).Children[0] as ComboBox);

                newBrush         = (SolidColorBrush)((_content as ComboBox).Background);
                _backgroundColor = newBrush.Color;
                newBrush         = (SolidColorBrush)((_content as ComboBox).Foreground);
                _fontColor       = newBrush.Color;

                break;

            case "row":
                _controlType = WebControlTypeEnum.row;
                break;

            case "image":
                _controlType = WebControlTypeEnum.image;
                _content     = ((_control.Content as Grid).Children[0] as Image);

                newBrush = (SolidColorBrush)(_control.Background);
                if (newBrush != null)
                {
                    _backgroundColor = newBrush.Color;
                }

                _itemAlign     = (_content as Image).HorizontalAlignment;
                _verticalAlign = (_content as Image).VerticalAlignment;
                this.Value     = (_content as Image).Source.ToString();

                break;

            default:
                _controlType = WebControlTypeEnum.emptySpace;
                break;
            }

            _controlTypeName = _control.GetType().FullName.Replace("WebSiteArchitect.AdminApp.Controls.Layout.", "");

            _parentControl = _control.Parent as Grid;

            if (_parentControl != null)
            {
                _childIndex = _parentControl.Children.IndexOf(_control);
                _size       = Convert.ToInt32(_parentControl.ColumnDefinitions[_childIndex].Width.Value);
                _height     = _parentControl.ActualHeight;
            }
        }
예제 #53
0
 /// <summary>
 ///     Align
 /// </summary>
 /// <param name="alignment"></param>
 /// <returns></returns>
 public ExcelStyle Align(HorizontalAlignment alignment)
 {
     Style.Alignment = alignment;
     return(this);
 }
예제 #54
0
        Thumb GetResizeThumb(Cursor cur, HorizontalAlignment hor, VerticalAlignment ver)
        {
            var thumb = new Thumb()

            {
                Background = Brushes.Red,

                Width = THUMB_SIZE,

                Height = THUMB_SIZE,

                HorizontalAlignment = hor,

                VerticalAlignment = ver,

                Cursor = cur,

                Template = new ControlTemplate(typeof(Thumb))

                {
                    VisualTree = GetFactory(new SolidColorBrush(Colors.Green))
                }
            };

            thumb.DragDelta += (s, e) =>
            {
                var element = AdornedElement as FrameworkElement;

                if (element == null)
                {
                    return;
                }



                Resize(element);



                switch (thumb.VerticalAlignment)
                {
                case VerticalAlignment.Bottom:

                    if (element.Height + e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height += e.VerticalChange;
                    }

                    break;

                case VerticalAlignment.Top:

                    if (element.Height - e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height -= e.VerticalChange;

                        Canvas.SetTop(element, Canvas.GetTop(element) + e.VerticalChange);
                    }

                    break;
                }

                switch (thumb.HorizontalAlignment)
                {
                case HorizontalAlignment.Left:

                    if (element.Width - e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width -= e.HorizontalChange;

                        Canvas.SetLeft(element, Canvas.GetLeft(element) + e.HorizontalChange);
                    }

                    break;

                case HorizontalAlignment.Right:

                    if (element.Width + e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width += e.HorizontalChange;
                    }

                    break;
                }



                e.Handled = true;
            };

            return(thumb);
        }
예제 #55
0
 static extern private void tguiLabel_setHorizontalAlignment(IntPtr cPointer, HorizontalAlignment alignment);
예제 #56
0
 public void method_18(HorizontalAlignment A_0)
 {
     this.horizontalAlignment_1 = A_0;
 }
예제 #57
0
 public static TableConstraint Alignment(HorizontalAlignment alignment)
 {
     return(new TableConstraint(horizontalAlignment: alignment));
 }
 public ChartValueAxisConstantLinesLabelBuilder HorizontalAlignment(HorizontalAlignment value)
 {
     base.Options["horizontalAlignment"] = value;
     return(this);
 }
예제 #59
0
 public static void SetHorizontalContentAlignment(Panel i, HorizontalAlignment input) => i.SetValue(HorizontalContentAlignmentProperty, input);
예제 #60
0
        private Thickness GetHorizontalGapMargin(Thickness tailPolygonMargin, PlacementMode placementMode, HorizontalAlignment horizontalAlignment)
        {
            if (horizontalAlignment == HorizontalAlignment.Right)
            {
                return(new Thickness(0, 0, tailPolygonMargin.Right + 2, 0));
            }

            // Increase top margin for top placement;
            var topMarginThickness = tailPolygonMargin.Top + (placementMode == PlacementMode.Top ? 1d : 0d);

            if (horizontalAlignment == HorizontalAlignment.Center)
            {
                return(new Thickness(tailPolygonMargin.Left, topMarginThickness, 0, 0));
            }

            if (horizontalAlignment == HorizontalAlignment.Left)
            {
                return(new Thickness(tailPolygonMargin.Left + 1, topMarginThickness, 0, 0));
            }

            return(new Thickness(0));
        }