Create and use resource files in. NET (1)

Source: Internet
Author: User
Tags border color resource

In. NET, you can create resource files (. resx) for use by programs, and you can include custom resources such as pictures, strings, and so on in a resource file. To use these files in your program. Below we will create a resource file called Skins.resx, which loads some of the resources required by the program UI to draw the program interface.

First we create a new Windows program (Windows application) and add the following code to the Form1_Load:

      ResXResourceWriter rw = new ResXResourceWriter ("Skins.resx");
      Skins Image Bottom_left = Image.FromFile ("Bottom_left.gif");
      Image Bottom_middle = Image.FromFile ("Bottom_middle.gif");
      Image bottom_right = Image.FromFile ("Bottom_right.gif");
      Image middle_left = Image.FromFile ("Middle_left.gif");
      Image middle_right = Image.FromFile ("Middle_right.gif");
      Image top_left = Image.FromFile ("Top_left.gif");
      Image Top_middle = Image.FromFile ("Top_middle.gif");
      Image top_right = Image.FromFile ("Top_right.gif");
      Image sysbutton_close = Image.FromFile ("Sysbutton_close.gif");
      Image sysbutton_min = Image.FromFile ("Sysbutton_min.gif");
      ico Image acc_config = image.fromfile ("Acc_config.png");
      Image acc_everyday = Image.FromFile ("Acc_everyday.png");
      Image Acc_search = Image.FromFile ("Acc_search.png");
      Image acc_statistics = Image.FromFile ("Acc_statistics.png"); Image sys_towards = Image.fromfilE ("Sys_towards.png"); Colors string BackColor = "#E5F6F9"; window and control background color string bordercolor = "#79C6BC"; Control border Color String ForeColor = "#79C6BC"; The foreground color of the control, that is, the font color string activecolor = "#79C6BC"; Color string activebackcolor = "#DAF1F3" When the control activates (gets focus); Control background Color String inactivecolor = "#C0E5E4" When the control is activated; Color//add Skins RW When the control is inactive (loses focus).
      AddResource ("Bottom_left", bottom_left); rw.
      AddResource ("Bottom_middle", Bottom_middle); rw.
      AddResource ("Bottom_right", bottom_right); rw.
      AddResource ("Middle_left", middle_left); rw.
      AddResource ("Middle_right", middle_right); rw.
      AddResource ("Top_left", top_left); rw.
      AddResource ("Top_middle", Top_middle); rw.
      AddResource ("Top_right", top_right); rw.
      AddResource ("Sysbutton_close", sysbutton_close); rw.
      AddResource ("Sysbutton_min", sysbutton_min); Add Colors RW.
      AddResource ("BackColor", BackColor); rw.
     AddResource ("BorderColor", bordercolor); rw.
      AddResource ("ForeColor", ForeColor); rw.
      AddResource ("Activecolor", Activecolor); rw.
      AddResource ("Activebackcolor", Activebackcolor); rw.
      AddResource ("Inactivecolor", Inactivecolor); Add ico rw.
      AddResource ("Acc_config", acc_config); rw.
      AddResource ("Acc_everyday", acc_everyday); rw.
      AddResource ("Acc_search", Acc_search); rw.
      AddResource ("Acc_statistics", acc_statistics); rw.
  
      AddResource ("Sys_towards", sys_towards); rw.
      Generate (); rw. Close ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.