本文整理汇总了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.
}
}
}
示例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.
}
}
}
示例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;
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}