Csharp/C Sharp/GUI Windows Form/ResXResourceWriter — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:31, 26 мая 2010

Add image Resource

using System;
using System.Collections.Generic;
using System.Text;
using System.Resources;
using System.Drawing;
class Program
{
  static void Main(string[] args)
  {
    ResXResourceWriter rw = new ResXResourceWriter("Demo.resx");
    using (Image image = Image.FromFile("logo.gif"))
    {
      rw.AddResource("WroxLogo", image);
      rw.AddResource("Title", "C#");
      rw.AddResource("Chapter", "L");
      rw.AddResource("Author", "C");
      rw.AddResource("Publisher", "W");
      rw.Close();
    }
  }
}


make a .resx file

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Resources;

public class MainClass {
    public static void Main() {
        ResXResourceWriter w = new ResXResourceWriter(@"C:\ResXForm.resx");
        Image i = new Bitmap("happyDude.bmp");
        w.AddResource("happyDude", i);
        w.AddResource("welcomeString", "Hello new resource format!");
        w.Generate();
        w.Close();
        // Make a new *.resources file.
        ResourceWriter rw = new ResourceWriter(@"C:\myResources.resources");
        // Add 1 image and 1 string.
        rw.AddResource("happyDude", new Bitmap("happyDude.bmp"));
        rw.AddResource("welcomeString", "Hello new resource format!");
        rw.Generate();
        rw.Close();
    }
}