Extract UserControls from IssueVision Part I — PaneCaption

來源:互聯網
上載者:User
文章目錄
  • PaneCaption

IssueVision is the code example for Smart Client at DevDays 2004. You can get more infomation from DevDays 2004 video .

There are several XP style UserControls contained in this solution. Now, let's extract them for our own projects.

PaneCaption

PaneCaption draws the caption for each pane. Contains an active state and draws the caption different for each state. Caption is drawn with a gradient fill and antialias font.

Just pick out two files, PaneCaption.cs PaneCaption.resx, we can extract this control.

Create your new “windows control library” project MyControls and add the tow files to your project folder. Build this project and test it in another project.

ok, it's working now!

oh, wait! Why AnitAlias dose not work? I changed again and again, but it is only available in design time! What's wrong ?

yeah, you find out a little bug (i think it belongs the IDE what i am using -- VS.NET2003). Let's defeat it.

look at the following codes:

private bool m_antiAlias = false ; 

 

  [CategoryAttribute("Appearance")]
  [DescriptionAttribute("If should draw the text as antialiased.")]
   [DefaultValueAttribute( true )]
  public bool AntiAlias {
   get {
    return m_antiAlias;
   } 

   set {
    m_antiAlias = value;
    Invalidate();
   }
  } 

 

understood?

what? did not?

oh, my god. Let me explain.

“[DefaultValueAttribute(true)]” means the default value of this property(AntiAlias) is “true“; “private bool m_antiAlias = false;“ means it sets the property variant into “false“ when you put the control on form(design time).

As we known, in visual studio, it will modify the InitializeComponent() automatically when you changed a value in property toolbox. Now, the initialized value is “false” not the default value “true”. Obviously, the IDE think it's the default value! So, it write the opposite code.

Thus, modify “private bool m_antiAlias = false;”into “private bool m_antiAlias = true;”then you will enable “AntiAlias” ability.

Moreover, AllowActive has this problem too. I believe you can solve it yourself.

Enjoy it. ;)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.