• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Drawing.StringFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Drawing.StringFormat的典型用法代码示例。如果您正苦于以下问题:C# StringFormat类的具体用法?C# StringFormat怎么用?C# StringFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringFormat类属于System.Drawing命名空间,在下文中一共展示了StringFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WaterMarkerImage

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Method to watermark image
        /// </summary>
        ///
        /// <remarks>   Ken Hofgesang, 5/7/2012 </remarks>
        ///
        /// <param name="ImgPath">   Path for Source Image. </param>
        /// <param name="watermark">        String for watermark information. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static Bitmap WaterMarkerImage(string ImgPath, string watermark)
        {
            Bitmap bmp;
            bmp = new Bitmap(ImgPath);
            Graphics graphicsObject;
            int x, y;
            try
            {
                //Create graphics object from bitmap
                graphicsObject = Graphics.FromImage(bmp);
            }
            catch (Exception e)
            {
                //Initilize new Bitmap for watermark info
                Bitmap bmpNew = new Bitmap(bmp.Width, bmp.Height);
                graphicsObject = Graphics.FromImage(bmpNew);
                graphicsObject.DrawImage(bmp, new Rectangle(0, 0, bmpNew.Width, bmpNew.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel);
                bmp = bmpNew;
            }
            //Adjust font size based on original image size and the length of watermark text
            int startsize = (bmp.Width / watermark.Length);
            //x and y cordinates to draw watermark string
            x = 0;
            y = bmp.Height / 4;

            System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.NoWrap);
            //Draw watermark on Image
            graphicsObject.DrawString(watermark, new Font("Times New Roman", startsize, FontStyle.Bold), new SolidBrush(Color.FromArgb(60, 255, 255, 255)), x, y, drawFormat);
            //return Image
            return (bmp);
        }
开发者ID:corner87,项目名称:CSIT555_Class_Project,代码行数:41,代码来源:CopyrightProtectionForm.cs


示例2: BaseTextItem

		public BaseTextItem():base() {
			this.dataType = "System.String";
			this.stringFormat = StringFormat.GenericTypographic;
			this.contentAlignment = ContentAlignment.TopLeft;
			this.stringTrimming = StringTrimming.None;
			VisibleInReport = true;
		}
开发者ID:OmerRaviv,项目名称:SharpDevelop,代码行数:7,代码来源:BaseTextItem.cs


示例3: EDSToolTip_Draw

        void EDSToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.ToolTipText.Trim() != "")
            {
                //e.DrawBackground();
                Graphics g = e.Graphics;

                //draw background
                LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(Point.Empty, e.Bounds.Size), Color.FromArgb(250, 252, 253), Color.FromArgb(206, 220, 240), LinearGradientMode.Vertical);
                g.FillRectangle(lgb, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
                lgb.Dispose();

                //Console.WriteLine(e.ToolTipText);

                //draw border
                ControlPaint.DrawBorder(g, e.Bounds, SystemColors.GrayText, ButtonBorderStyle.Dashed);
                //draw Image
                g.DrawImage(image, new Point(5, 5));

                // Draw the custom text.
                // The using block will dispose the StringFormat automatically.
                using (StringFormat sf = new StringFormat())
                {
                    using (Font f = new Font("Tahoma", 8))
                    {
                        e.Graphics.DrawString(e.ToolTipText, f,
                            Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 30, StringFormat.GenericTypographic);
                    }
                }
            }
        }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:31,代码来源:EDSToolTip.cs


示例4: Text

 public void Text(string text, Font font, uint argb, Rectangle rect, StringFormat format)
 {
     graphics.DrawString(
         text, font,
         new SolidBrush(argb.ToColor()),
         rect, format);
 }
开发者ID:matheus2984,项目名称:SoulEngine,代码行数:7,代码来源:GraphicsHelper.cs


示例5: DiffViewer

        public DiffViewer(TaskScheduler scheduler, HeapRecording instance)
            : base(scheduler)
        {
            InitializeComponent();

            ListFormat = new StringFormat {
                Trimming = StringTrimming.None,
                FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox
            };

            Timeline.ItemValueGetter = GetBytesTotal;
            Timeline.ItemValueFormatter = MainWindow.FormatSizeBytes;

            Instance = instance;
            if (Instance != null) {
                Timeline.Items = Instance.Snapshots;
                Instance.TracebacksFiltered += Instance_TracebacksFiltered;
                ViewHistogramByModuleMenu.Enabled = ViewHistogramByFunctionMenu.Enabled = true;
                ViewHistogramBySourceFolderMenu.Enabled = ViewHistogramBySourceFileMenu.Enabled = true;
                ViewHistogramByNamespaceMenu.Enabled = ViewTreemapMenu.Enabled = true;
            } else {
                Timeline.Visible = false;
                MainSplit.Height += Timeline.Bottom - MainSplit.Bottom;
                ViewHistogramByModuleMenu.Enabled = ViewHistogramByFunctionMenu.Enabled = false;
                ViewHistogramBySourceFolderMenu.Enabled = ViewHistogramBySourceFileMenu.Enabled = false;
                ViewHistogramByNamespaceMenu.Enabled = ViewTreemapMenu.Enabled = false;
            }
        }
开发者ID:kg,项目名称:HeapProfiler,代码行数:28,代码来源:DiffViewer.cs


示例6: Print

		/// <summary>
		/// Print header
		/// </summary>
		/// <param name="g">Graphics object where the data will be drawn</param>
		/// <param name="area">Area where to print</param>
		/// <param name="columns">Columns</param>
		public override void Print(Graphics g, ref RectangleF area, IList columns, int page)
		{
			StringFormat stringFormat;
			float		 height;

			stringFormat = new StringFormat(StringFormat.GenericDefault);
			height		 = font.GetHeight(g);

			// Write columns label
			foreach (Column column in columns)
			{
				RectangleF rect;

				stringFormat.Alignment = column.Alignment;

				rect = new RectangleF(
					column.X, area.Top,
					column.Width, height);

				g.DrawString(
					column.Label,
					font,
					brush,
					rect,
					stringFormat);
			}

			// Draw separator line
			g.DrawLine(pen, area.Left, area.Top + height + lineDistance, area.Right, area.Top + height + lineDistance);

			area.Y      += height + lineDistance * 2;
			area.Height -= height + lineDistance * 2;
		}
开发者ID:andrepontesmelo,项目名称:imjoias,代码行数:39,代码来源:Header.cs


示例7: CreateNativeLabel

        internal static CCTexture2D CreateNativeLabel(string text, CCSize dimensions, CCTextAlignment hAlignment,
		                                   CCVerticalTextAlignment vAlignment, string fontName,
		                                   float fontSize, CCColor4B textColor)
		{

		    if (string.IsNullOrEmpty(text))
		    {
		        return new CCTexture2D();
		    }

		    var font = CreateFont (fontName, fontSize);

            if (dimensions.Equals(CCSize.Zero))
            {
                CreateBitmap(1, 1);

                var ms = _graphics.MeasureString(text, font);
                
                dimensions.Width = ms.Width;
                dimensions.Height = ms.Height;
            }

            CreateBitmap((int)dimensions.Width, (int)dimensions.Height);

            var stringFormat = new StringFormat();

		    switch (hAlignment)
		    {
		        case CCTextAlignment.Left:
                    stringFormat.Alignment = StringAlignment.Near;
		            break;
		        case CCTextAlignment.Center:
                    stringFormat.Alignment = StringAlignment.Center;
		            break;
		        case CCTextAlignment.Right:
                    stringFormat.Alignment = StringAlignment.Far;
		            break;
		    }

		    switch (vAlignment)
		    {
		        case CCVerticalTextAlignment.Top:
        		    stringFormat.LineAlignment = StringAlignment.Near;
		            break;
		        case CCVerticalTextAlignment.Center:
        		    stringFormat.LineAlignment = StringAlignment.Center;
		            break;
		        case CCVerticalTextAlignment.Bottom:
        		    stringFormat.LineAlignment = StringAlignment.Far;
		            break;
		    }

            _graphics.DrawString(text, font, _brush, new RectangleF(0, 0, dimensions.Width, dimensions.Height), stringFormat);
            _graphics.Flush();

			var texture = new CCTexture2D();
			texture.InitWithStream (SaveToStream(), Microsoft.Xna.Framework.Graphics.SurfaceFormat.Bgra4444);

			return texture;
		}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:60,代码来源:CCLabelUtilities-Gdi.cs


示例8: Draw

        /// <summary>
        /// Draws the Card at its location
        /// </summary>
        /// <param name="g">The Graphics object to draw on</param>
        public override void Draw(Graphics g)
        {
            Color colour = this.GetColor();

            g.FillRectangle(new SolidBrush(colour), _rekt);     // Fill

            if (Selected)
            {
                g.DrawRectangle(new Pen(Brushes.Black, 2), _rekt);  // Draw outline
            }
            else
            {

                g.DrawRectangle(new Pen(Brushes.White, 4), _rekt);  // White 4pt
                g.DrawRectangle(new Pen(Brushes.Black, 1), _rekt);  // Black border 1pt
            }

            // The number
            int fontHeight = _rekt.Height / 4;
            Font arial = new Font("Arial", fontHeight, FontStyle.Bold);

            // Fancy Centering
            StringFormat stringFormat = new StringFormat();
            stringFormat.Alignment = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;

            g.DrawString(this.Value.ToString(), arial, Brushes.Black, _rekt, stringFormat); // Black text (the number)
        }
开发者ID:WillMoreland,项目名称:BalloonCup,代码行数:32,代码来源:Card.cs


示例9: OnDrawItem

        /// <summary>Override for the drawing of the control to include a Close Tab button</summary>
        /// <param name="e"></param>
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            RectangleF tabTextArea = RectangleF.Empty;
            for(int nIndex = 0 ; nIndex < this.TabCount ; nIndex++)
            {
                tabTextArea = (RectangleF)this.GetTabRect(nIndex);

                using(SolidBrush brush = new SolidBrush(this.TabPages[nIndex].BackColor))
                {
                    //Clear the tab
                    e.Graphics.FillRectangle(brush, tabTextArea);
                }

                Bitmap bmp = nIndex == this.SelectedIndex ? Resources.activeClose : Resources.inactiveClose;
                e.Graphics.DrawImage(bmp, tabTextArea.X + tabTextArea.Width - (CLOSE_ICON_PADDING + CLOSE_ICON_SIZE), tabTextArea.Y + CLOSE_ICON_PADDING, CLOSE_ICON_SIZE, CLOSE_ICON_SIZE);
                bmp.Dispose();

                string str = this.TabPages[nIndex].Text;
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;
                using(SolidBrush brush = new SolidBrush(this.TabPages[nIndex].ForeColor))
                {
                    //Draw the tab header text
                    e.Graphics.DrawString(str, this.Font, brush, tabTextArea,stringFormat);
                }
            }
        }
开发者ID:meandthewallaby,项目名称:Edrych,代码行数:30,代码来源:TabControlExt.cs


示例10: GetEyeOfSightImage

        private static Bitmap GetEyeOfSightImage()
        {
            var roestte = new Bitmap(120, 120);
            
            //Anyone for a more sophisticated roestte?
            using (var g = Graphics.FromImage(roestte))
            {
                var t = new Matrix(1f, 0f, 0f, 1f, 60, 60);
                g.Transform = t;

                var f = new Font("Arial", 20, FontStyle.Bold);
                var b = new SolidBrush(Color.Black);
                var p = new Pen(Color.Black, 5);
                var sf = new StringFormat(StringFormat.GenericTypographic) {Alignment = StringAlignment.Center};
                var rect = new RectangleF(- 45f, - 45f, 90f, 90f);

                foreach (var s in Directions)
                {
                    g.DrawString(s, f, b, 0, -55, sf);
                    g.DrawArc(p, rect, 290f, 50f);
                    g.RotateTransform(90f);
                }
            }
            return roestte;
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:25,代码来源:EyeOfSight.cs


示例11: RepertoryImage

        public static void RepertoryImage(Graphics drawDestination)
        {
            StringFormat itemStringFormat = new StringFormat();
            RectangleF itemBox = new RectangleF(10, 30, 42, 10);
            RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
            itemStringFormat.Alignment = StringAlignment.Center;
            itemStringFormat.LineAlignment = StringAlignment.Far;
            drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
            if (mMscStyle == MscStyle.SDL){
                PointF[] capPolygon = new PointF[3];
                capPolygon[0] = new PointF(61, 40);
                capPolygon[1] = new PointF(53, 44);
                capPolygon[2] = new PointF(53, 36);
                drawDestination.FillPolygon(Brushes.Black,capPolygon);
                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
            }
            else if(mMscStyle == MscStyle.UML2){

                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,43);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,37);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));

            }
            itemStringFormat.Dispose();
        }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:31,代码来源:LostMessageExtension.cs


示例12: DrawMenuItem

        /// <summary>
        /// �������˵���
        /// </summary>
        public static void DrawMenuItem(System.Windows.Forms.DrawItemEventArgs e, MenuItem mi)
        {
            if ( (e.State & DrawItemState.HotLight) == DrawItemState.HotLight )
            {

                DrawHoverRect(e, mi);
            }
            else if ( (e.State & DrawItemState.Selected) == DrawItemState.Selected )
            {
                DrawSelectionRect(e, mi);
            }
            else
            {
                Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width,
                e.Bounds.Height -1);
                e.Graphics.FillRectangle(new SolidBrush(Globals.MainColor), rect);
                e.Graphics.DrawRectangle(new Pen(Globals.MainColor), rect);
            }

            StringFormat sf = new StringFormat();

            //�������־���
            sf.LineAlignment = StringAlignment.Center;
            sf.Alignment = StringAlignment.Center;

            //��������
            e.Graphics.DrawString(mi.Text,
                Globals.menuFont,
                new SolidBrush(Globals.TextColor),
                e.Bounds,
                sf);
        }
开发者ID:algz,项目名称:GDIDrawFlow,代码行数:35,代码来源:MainMenuItemDrawing.cs


示例13: DrawString

 public abstract void DrawString(
     string s,
     Font font,
     Brush brush,
     RectangleF layoutRectangle,
     StringFormat format
 );
开发者ID:jrahhali,项目名称:squirrely,代码行数:7,代码来源:Game.cs


示例14: SnakePit

        public SnakePit()
        {
            this.screen = DeviceGraphics.GetScreen();
            this.screen.Clear(Color.White);
            this.numCellsX = (DeviceGraphics.ScreenXSize / cellSize) - 2;
            this.numCellsY = ((DeviceGraphics.ScreenYSize - scoreBoardHeight) / cellSize) - 2;
            this.cellOfsX = cellSize;
            this.cellOfsY = cellSize;
            this.rnd = new Random();
            this.food = null;
            this.score = 0;
            this.level = 1;

            using (Brush brush = new HatchBrush(HatchStyle.DiagonalCross, Color.Black, Color.White)) {
                this.screen.FillRectangle(brush, 0, 0, DeviceGraphics.ScreenXSize, cellSize);
                this.screen.FillRectangle(brush, 0, cellSize, cellSize, this.numCellsY * cellSize);
                this.screen.FillRectangle(brush, (1 + this.numCellsX) * cellSize, cellSize, cellSize, this.numCellsY * cellSize);
                this.screen.FillRectangle(brush, 0, (1 + this.numCellsY) * cellSize, DeviceGraphics.ScreenXSize, cellSize);
            }
            this.screen.DrawRectangle(Pens.Black, cellSize - 1, cellSize - 1,
                this.numCellsX * cellSize + 1, this.numCellsY * cellSize + 1);

            using (Font f = new Font("tahoma", 15)) {
                using (StringFormat sf = new StringFormat()) {
                    sf.Alignment = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    this.screen.DrawString("<", f, Brushes.Black, new RectangleF(0, 220, 64, 20), sf);
                    this.screen.DrawString("v", f, Brushes.Black, new RectangleF(64, 220, 64, 20), sf);
                    this.screen.DrawString("^", f, Brushes.Black, new RectangleF(128, 220, 64, 20), sf);
                    this.screen.DrawString(">", f, Brushes.Black, new RectangleF(192, 220, 64, 20), sf);
                }
            }

            this.ShowScore();
        }
开发者ID:memsom,项目名称:dotNetAnywhere-wb,代码行数:35,代码来源:SnakePit.cs


示例15: TextBoxTextRenderer

		static TextBoxTextRenderer ()
		{
			// On Windows, we want to use TextRenderer (GDI)
			// On Linux, we want to use DrawString (GDI+)
			// TextRenderer provides translation from TextRenderer to
			// DrawString, but I doubt it's exact enough.
			// Another option would be to put Pango here for Linux.
			int platform = (int)Environment.OSVersion.Platform;
			
			if (platform == 4 || platform == 128 || platform == 6)
				use_textrenderer = false;
			else
				use_textrenderer = true;

			// windows 2000 doesn't draw with gdi if bounds are In32.MaxValue
			max_size = new Size (Int16.MaxValue, Int16.MaxValue);
			
			sf_nonprinting = new StringFormat (StringFormat.GenericTypographic);
			sf_nonprinting.Trimming = StringTrimming.None;
			sf_nonprinting.FormatFlags = StringFormatFlags.DisplayFormatControl;	
			sf_nonprinting.HotkeyPrefix = HotkeyPrefix.None;		

			sf_printing = StringFormat.GenericTypographic;
			sf_printing.HotkeyPrefix = HotkeyPrefix.None;
			
			measure_cache = new Hashtable ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:27,代码来源:TextBoxTextRenderer.cs


示例16: Operation

        /// <summary>
        /// 主要作業方法
        /// </summary>
        public Image Operation()
        {
            Graphics g = Graphics.FromImage(image);
            _mask_pos_x = (image.Width / 2) + _Xoffset;
            SizeF steSize = new SizeF();
            for (int i = _FontMaxSize; i >= _FontMinSize; i--)
            {
                using (Font testFont = new Font(_FontFamily, i, FontStyle.Bold))
                {
                    steSize = g.MeasureString(_text, testFont);

                    if ((ushort)steSize.Width < (ushort)_Width || i == _FontMinSize)
                    {

                        using (SolidBrush semiTransBrush = new SolidBrush(_fontcolor))
                        {
                            StringFormat StrFormat = new StringFormat();
                            StrFormat.Alignment = StringAlignment.Center;
                            g.DrawString(_text, testFont, semiTransBrush, new PointF(_mask_pos_x, _mask_pos_y), StrFormat);
                            semiTransBrush.Dispose();
                        }
                        testFont.Dispose();
                        break;
                    }
                }
            }

            return image;
        }
开发者ID:patw0929,项目名称:patw-aspnet-appcode,代码行数:32,代码来源:DrawTextCenter.cs


示例17: CommunicationVisualizer

        public CommunicationVisualizer(SharpNeatLib.CPPNs.SubstrateDescription _sd, ModularNetwork _net)
        {
            InitializeComponent();
            //zlevel = _zlevel;

            drawFont = new System.Drawing.Font("Arial", 8);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

             drawFormat = new System.Drawing.StringFormat();

            sd = _sd;

            net = _net;
            _net.UpdateNetworkEvent += networkUpdated;
            activation = new activationLevels[200];
          //  outgoingActivation = new List<float>[200];

            for (int i = 0; i < activation.Length; i++)
            {
                activation[i] = new activationLevels();
                //outgoingActivation[i] = new List<float>();
                    

            }
            penConnection = new Pen(Color.Black);
            penRed = new Pen(Color.Red);

            this.SetStyle(
    ControlStyles.AllPaintingInWmPaint |
    ControlStyles.UserPaint |
    ControlStyles.DoubleBuffer, true);
        }
开发者ID:zaheeroz,项目名称:qd-maze-simulator,代码行数:32,代码来源:CommunicationVisualizer.cs


示例18: OnPaint

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            //base.OnPaint(e);

            Graphics g = e.Graphics;
            g.Clear(this.Parent.BackColor);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle rect = new Rectangle(Point.Empty, e.ClipRectangle.Size);
            rect.Width -= 1;
            rect.Height -= 1;

            Color coutBorder;
            Color cinnerBorder;
            Color cbackgroundTop;
            Color cbackgroundBottom;
            Color ctext;

            if (mouseover)
            {
                coutBorder = ButtonColor.HoverOutBorder;
                cinnerBorder = ButtonColor.HoverInnerBorder;
                cbackgroundTop = ButtonColor.HoverBackgroundTop;
                cbackgroundBottom = ButtonColor.HoverBackgroundBottom;
                ctext = mousedown ? Color.Black : ButtonColor.HoverText;
            }
            else
            {
                coutBorder = ButtonColor.OutBorder;
                cinnerBorder = ButtonColor.InnerBorder;
                cbackgroundTop = ButtonColor.BackgroundTop;
                cbackgroundBottom = ButtonColor.BackgroundBottom;
                ctext = ButtonColor.Text;
            }


            using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(rect, 2))
            {
                using (LinearGradientBrush lgBrush = new LinearGradientBrush(Point.Empty, new Point(rect.Width, rect.Height),
                    cbackgroundTop, cbackgroundBottom))
                {
                    g.FillPath(lgBrush, path);
                }

                g.DrawPath(new Pen(coutBorder), path);
                rect.Inflate(-1, -1);
                using (GraphicsPath path2 = GraphicsTools.CreateRoundRectangle(rect, 2))
                {
                    g.DrawPath(new Pen(cinnerBorder), path2);
                }
            }

            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            g.DrawString(this.Text, this.Font, new SolidBrush(ctext), e.ClipRectangle, sf);

            UpdateBounds(this.Location.X, this.Location.Y, this.Width, this.Height, e.ClipRectangle.Width, e.ClipRectangle.Height);
        }
开发者ID:Vinna,项目名称:DeepInSummer,代码行数:60,代码来源:Button.cs


示例19: DrawAppointment

        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
开发者ID:bshultz,项目名称:ctasks,代码行数:60,代码来源:Office11Renderer.cs


示例20: OnPaint

        /// <summary>
        /// <see cref="Control.OnPaint"/>
        /// </summary>
		protected override void OnPaint(PaintEventArgs pe)
		{
			StringFormat format = new StringFormat();
			format.LineAlignment = StringAlignment.Center;
			format.Alignment = StringAlignment.Center;
			string panValue;
			if(pan == 0.0)
			{
				pe.Graphics.FillRectangle(Brushes.Orange,(this.Width/2) - 1  ,1,3,this.Height-2);
				panValue = "C";
			}
			else if(pan > 0)
			{
				pe.Graphics.FillRectangle(Brushes.Orange,(this.Width/2),1,(int) ((this.Width/2) * pan),this.Height-2);
				panValue = String.Format("{0:F0}%R",pan*100);
			}
			else
			{
				pe.Graphics.FillRectangle(Brushes.Orange,(int)((this.Width/2) * (pan+1)),1,(int) ((this.Width/2) * (0-pan)),this.Height-2);
				panValue = String.Format("{0:F0}%L",pan*-100);
			}
			pe.Graphics.DrawRectangle(Pens.Black,0,0,this.Width-1,this.Height-1);

			pe.Graphics.DrawString(panValue,this.Font,
				Brushes.Black,this.ClientRectangle,format);
			// Calling the base class OnPaint
			//base.OnPaint(pe);
		}
开发者ID:Shadetheartist,项目名称:Numboard-2.0,代码行数:31,代码来源:PanSlider.cs



注:本文中的System.Drawing.StringFormat类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawing.TextureBrush类代码示例发布时间:2022-05-26
下一篇:
C# Drawing.SolidBrush类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap