MonoFlat.MonoFlat_Button.ImageLocation C# (CSharp) Method

ImageLocation() private static method

private static ImageLocation ( StringFormat SF, SizeF Area, SizeF ImageArea ) : PointF
SF System.Drawing.StringFormat
Area System.Drawing.SizeF
ImageArea System.Drawing.SizeF
return System.Drawing.PointF
        private static PointF ImageLocation(StringFormat SF, SizeF Area, SizeF ImageArea)
        {
            PointF MyPoint = new PointF();
            switch (SF.Alignment)
            {
                case StringAlignment.Center:
                    MyPoint.X = (float)((Area.Width - ImageArea.Width) / 2);
                    break;
                case StringAlignment.Near:
                    MyPoint.X = 2;
                    break;
                case StringAlignment.Far:
                    MyPoint.X = Area.Width - ImageArea.Width - 2;
                    break;

            }

            switch (SF.LineAlignment)
            {
                case StringAlignment.Center:
                    MyPoint.Y = (float)((Area.Height - ImageArea.Height) / 2);
                    break;
                case StringAlignment.Near:
                    MyPoint.Y = 2;
                    break;
                case StringAlignment.Far:
                    MyPoint.Y = Area.Height - ImageArea.Height - 2;
                    break;
            }
            return MyPoint;
        }

Usage Example

コード例 #1
0
ファイル: MonoFlat_Button.cs プロジェクト: Leaked0/OM95-EXO
        // Token: 0x06000091 RID: 145 RVA: 0x0000EC04 File Offset: 0x0000CE04
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            PointF pointF = MonoFlat_Button.ImageLocation(this.GetStringFormat(this.ImageAlign), base.Size, this.ImageSize);

            switch (this.MouseState)
            {
            case 0:
                graphics.FillPath(this.InactiveGB, this.Shape);
                graphics.DrawPath(this.P1, this.Shape);
                if (this.Image == null)
                {
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    graphics.DrawImage(this._Image, pointF.X, pointF.Y, (float)this.ImageSize.Width, (float)this.ImageSize.Height);
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case 1:
                graphics.FillPath(this.PressedGB, this.Shape);
                graphics.DrawPath(this.P3, this.Shape);
                if (this.Image == null)
                {
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    graphics.DrawImage(this._Image, pointF.X, pointF.Y, (float)this.ImageSize.Width, (float)this.ImageSize.Height);
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                break;
            }
            base.OnPaint(e);
        }