English 中文(简体)
1. 采用无奥潘特方法的斜体
原标题:Draw an ellipse without OnPaint method
  • 时间:2009-10-06 09:38:33
  •  标签:

I was looking about some GDI tutorial but everything I have found so far works with OnPaint method, which passes Paintarguments to Graphics. I have not found how to start from scratch, I mean how to use Graphics class itself? This is the whole code I have treid that just doesnt work for me:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Pen pen= new Pen(Color.Red, 3);
            Graphics g;
            g = this.CreateGraphics();
    g.DrawEllipse(pen, 150, 150, 100, 100);
        }
    }
}

它只是做任何事情。 我以新的形式审判了它,没有。

事先感谢你!

最佳回答

这部法典很可能是大韩民国的,它正像你所希望的那样 drawing。 然而,在Load活动之后,将举办<条码>PaintBackground活动,并举办<条码>PaintEvent,因为表格是显示的。 <>PaintBackground,一经缺席,即可删除控制的内容,有效删除你刚才所引述的字句。

油漆是两个阶段的过程:

for each (region in set of regions that need updating)
{
  PaintBackground (region)
  Paint (region)
}

如果控制内容没有改变或用户行动没有改变控制可见度,那么窗户管理人只能重塑需要更新的控制部分。

因此,你为什么想在Load方法中提一下 el? 通常,在需要提取东西时,你只想提取一些东西,在需要参考的<条码>、印章/代码>和<条码>时,就告诉你什么形式。

你们是否担心点火? 还是是一个速度问题? 快要提一下。 然而,浮油更难固定。 你们需要绘制一份比图,绘制比图,并在油漆活动期间为控制绘制比图。 此外,将<条码>印第/条码> 事件无所作为——没有抹去控制,而是造成浮油的时代。

EDIT:一例,Im ,2005年版。

  1. Create a new C# winform application.
  2. 在表格1.c中添加以下内容:

    protected override void OnPaintBackground (PaintEventArgs e)
    {
      // do nothing! prevents flicker
    }
    
    protected override void OnPaint (PaintEventArgs e)
    {
      e.Graphics.FillRectangle (new SolidBrush (BackColor), e.ClipRectangle);
    
      Point
        mouse = PointToClient (MousePosition);
    
      e.Graphics.DrawEllipse (new Pen (ForeColor), new Rectangle (mouse.X - 20, mouse.Y - 10, 40, 20));
    }
    
    protected override void OnMouseMove (MouseEventArgs e)
    {
      base.OnMouseMove (e);
      Invalidate ();
    }
    
  3. 编造和操作。

问题回答

暂无回答




相关问题
热门标签