当前位置: 首页>>代码示例>>C#>>正文


C# ResourceWriter.AddResource方法代码示例

本文整理汇总了C#中System.Resources.ResourceWriter.AddResource方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceWriter.AddResource方法的具体用法?C# ResourceWriter.AddResource怎么用?C# ResourceWriter.AddResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Resources.ResourceWriter的用法示例。


在下文中一共展示了ResourceWriter.AddResource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

//引入命名空间
using System;
using System.IO;
using System.Resources;

public class Example
{
   public static void Main()
   {
      // Get the image as an array of bytes.
      FileStream byteStream = new FileStream("AppIcon.jpg", FileMode.Open);
      Byte[] bytes = new Byte[(int) byteStream.Length];
      byteStream.Read(bytes, 0, (int) byteStream.Length);
      
      // Create the resource file.
      using (ResourceWriter rw = new ResourceWriter(@".\UIImages.resources")) {
         rw.AddResource("AppIcon", byteStream);
         // Add any other resources.
      }
   }
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:21,代码来源:ResourceWriter.AddResource

示例2: Main

//引入命名空间
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Resources;

public class Example
{
   public static void Main()
   {
      // Bitmap as stream
      MemoryStream bitmapStream = new MemoryStream();
      Bitmap bmp = new Bitmap(@".\\AppImage.jpg");
      bmp.Save(bitmapStream, ImageFormat.Jpeg);
          
      using (ResourceWriter rw = new ResourceWriter(@".\UIImages.resources"))
      {
         rw.AddResource("Bitmap", bitmapStream);
         // Add other resources.
      }
   }
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:23,代码来源:ResourceWriter.AddResource

示例3: Main

//引入命名空间
using System;
using System.Resources;

public class Example
{
   public static void Main()
   {
      DonorColumns columns = new DonorColumns("Emplyee #", "Name", 
                                              "Total Amount", "Last Donation Date",
                                              "Last Donation Amount");
      ResourceWriter resFile = new ResourceWriter(@".\UIResources.resources");
      resFile.AddResource("Title", "Corporate Gold Star Donors");
      resFile.AddResource("NColumns", 5);
      resFile.AddResource("AppDate", new DateTime(2011, 5, 28));
      resFile.AddResource("AppVersion", new Version(1, 0, 217));
      resFile.AddResource("HRVersion", true);
      resFile.Generate();
      resFile.Close();               
   }
}

// Class to hold potentially localized column names.
[Serializable] public class DonorColumns
{
   readonly string ID;
   readonly string Name;
   readonly string Total;
   readonly string Last;
   readonly string Amt;

   public DonorColumns(string id, string name, string total, 
                  string last, string amt)
   {                  
      this.ID = id;
      this.Name = name;
      this.Total = total;
      this.Last = last;
      this.Amt = amt;                        
   }   
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:41,代码来源:ResourceWriter.AddResource

示例4: Main

//引入命名空间
using System;
using System.Resources;
using System.IO;

public class WriteResources 
{
    public static void Main(string[] args) 
    {  
        // Create a file stream to encapsulate items.resources.
        FileStream fs = new FileStream("items.resources", 
        FileMode.OpenOrCreate,FileAccess.Write);

        // Open a resource writer to write from the stream.
        IResourceWriter writer = new ResourceWriter(fs);
    
        // Add resources to the resource writer.
        writer.AddResource("String 1", "First String");
        writer.AddResource("String 2", "Second String");
        writer.AddResource("String 3", "Third String");

        // Write the resources to the stream, and close it.
        writer.Close();
    }
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:25,代码来源:ResourceWriter.AddResource

示例5: Main

//引入命名空间
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Resources;

public class Example
{
   public static void Main()
   {
      // Bitmap as stream
      MemoryStream bitmapStream = new MemoryStream();
      Bitmap bmp = new Bitmap(@".\\AppImage.jpg");
      bmp.Save(bitmapStream, ImageFormat.Jpeg);
          
      ResourceWriter rw = new ResourceWriter(@".\UIImages.resources");
      rw.AddResource("Bitmap", bitmapStream, true);
      // Add other resources.
      rw.Generate();
   }
}
开发者ID:.NET开发者,项目名称:System.Resources,代码行数:22,代码来源:ResourceWriter.AddResource

示例6: Main

//引入命名空间
using System;
using System.Globalization;
using System.Resources;
using System.Collections;

class Class1 {
  static void Main(string[] args) {
      ResourceWriter resourceWriter = new ResourceWriter("Java2s.resources");

      resourceWriter.AddResource("key 1", "First value");
      resourceWriter.AddResource("key 2", "Second value");
      resourceWriter.AddResource("key 3", "Third value");
      resourceWriter.Generate();
      resourceWriter.Close();

      ResourceReader resourceReader = new ResourceReader("Java2s.resources");
      IDictionaryEnumerator resourceReaderEn = resourceReader.GetEnumerator();
      while (resourceReaderEn.MoveNext())
      {
         Console.WriteLine("Name: {0} - Value: {1}", 
            resourceReaderEn.Key.ToString().PadRight(10, ' '), 
            resourceReaderEn.Value);
      }
      resourceReader.Close();
   }
}
开发者ID:C#程序员,项目名称:System.Resources,代码行数:27,代码来源:ResourceWriter.AddResource

示例7: ResourceWriter.AddResource(String key, Image value)

//引入命名空间
using System;
  using System.Resources;
  using System.Drawing;
  using System.Windows.Forms;
  using System.Reflection;

  class ResourceGenerator
  {
    static void Main(string[] args)
    {
      ResourceWriter rw;
      rw = new ResourceWriter("myResources.resources");

      rw.AddResource("anImage", new Bitmap("winter.jpg"));

      rw.AddResource("welcomeString", "www.java2s.com");
      rw.Generate();

    }
  }
开发者ID:C#程序员,项目名称:System.Resources,代码行数:21,代码来源:ResourceWriter.AddResource


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