Resource(资源)
来源:互联网 发布:悦木之源菌菇水 知乎 编辑:程序博客网 时间:2024/05/04 07:05
logo.gif
using System;
using System.Drawing;
using System.Resources;
class resource
...{
static void Main(string []args)
...{
ResourceWriter rw=new ResourceWriter("Demo.resources");
using(Image image=Image.FromFile("logo.gif"))
...{
rw.AddResource("logo",image);
rw.AddResource("Title","C# Program");
rw.AddResource("Author","Hello World!");
rw.Close();
}
}
}
using System.Drawing;
using System.Resources;
class resource
...{
static void Main(string []args)
...{
ResourceWriter rw=new ResourceWriter("Demo.resources");
using(Image image=Image.FromFile("logo.gif"))
...{
rw.AddResource("logo",image);
rw.AddResource("Title","C# Program");
rw.AddResource("Author","Hello World!");
rw.Close();
}
}
}
csc string.cs
运行string.exe
生成Demo.resouuces资源文件。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;
using System.Resources;
static class Program
...{
static void Main()
...{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
Assembly assembly=Assembly.GetExecutingAssembly();
rm=new ResourceManager("Demo",assembly);
logo.Image=(Image)rm.GetObject("logo");
}
private void Form1_Load(object sender, EventArgs e)
...{
}
private void InitializeComponent()
...{
this.logo = new System.Windows.Forms.PictureBox();
this.Anthor = new System.Windows.Forms.Label();
this.Cource = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.logo)).BeginInit();
this.SuspendLayout();
this.logo.Location = new System.Drawing.Point(87, 12);
this.logo.Name = "logo";
this.logo.Size = new System.Drawing.Size(200, 180);
this.logo.TabIndex = 0;
this.logo.TabStop = false;
this.Anthor.AutoSize = true;
this.Anthor.Location = new System.Drawing.Point(148, 252);
this.Anthor.Name = "Anthor";
this.Anthor.Size = new System.Drawing.Size(35, 13);
this.Anthor.TabIndex = 1;
this.Anthor.Text = "label1";
this.Cource.AutoSize = true;
this.Cource.Location = new System.Drawing.Point(148, 205);
this.Cource.Name = "Cource";
this.Cource.Size = new System.Drawing.Size(35, 13);
this.Cource.TabIndex = 2;
this.Cource.Text = "label1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(393, 380);
this.Controls.Add(this.Cource);
this.Controls.Add(this.Anthor);
this.Controls.Add(this.logo);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.logo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Resources.ResourceManager rm;
private System.Windows.Forms.PictureBox logo;
private System.Windows.Forms.Label Anthor;
private System.Windows.Forms.Label Cource;
}
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;
using System.Resources;
static class Program
...{
static void Main()
...{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
Assembly assembly=Assembly.GetExecutingAssembly();
rm=new ResourceManager("Demo",assembly);
logo.Image=(Image)rm.GetObject("logo");
}
private void Form1_Load(object sender, EventArgs e)
...{
}
private void InitializeComponent()
...{
this.logo = new System.Windows.Forms.PictureBox();
this.Anthor = new System.Windows.Forms.Label();
this.Cource = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.logo)).BeginInit();
this.SuspendLayout();
this.logo.Location = new System.Drawing.Point(87, 12);
this.logo.Name = "logo";
this.logo.Size = new System.Drawing.Size(200, 180);
this.logo.TabIndex = 0;
this.logo.TabStop = false;
this.Anthor.AutoSize = true;
this.Anthor.Location = new System.Drawing.Point(148, 252);
this.Anthor.Name = "Anthor";
this.Anthor.Size = new System.Drawing.Size(35, 13);
this.Anthor.TabIndex = 1;
this.Anthor.Text = "label1";
this.Cource.AutoSize = true;
this.Cource.Location = new System.Drawing.Point(148, 205);
this.Cource.Name = "Cource";
this.Cource.Size = new System.Drawing.Size(35, 13);
this.Cource.TabIndex = 2;
this.Cource.Text = "label1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(393, 380);
this.Controls.Add(this.Cource);
this.Controls.Add(this.Anthor);
this.Controls.Add(this.logo);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.logo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Resources.ResourceManager rm;
private System.Windows.Forms.PictureBox logo;
private System.Windows.Forms.Label Anthor;
private System.Windows.Forms.Label Cource;
}
csc /resource:demo.resources form.cs
运行form.exe
- Resource(资源)
- 资源resource
- 资源 Resource
- 资源注射(@Resource)
- 关于资源Resource
- Android - 资源(resource)
- Android - 使用资源(resource)
- spring resource资源
- Spring 资源Resource 模块
- WPF Resource资源
- WPF的资源(Resource)?
- Spring Resource 资源
- 82-资源resource类型
- Spring Resource加载资源
- 资源Resource之values
- 资源访问 - Resource
- Usb3--resource资源初始化
- resource资源加载
- 食疗妙法解脱发
- 大家好
- VB截屏保存图片
- 郁闷的早晨
- 针对眼睛的食疗
- Resource(资源)
- Globalization Patterns in WCF
- sscanf函数的高级用法
- 送别二炮官兵!
- 发布程序时“未给任务“SignFile”的所需参数“CertificateThumbprint”赋值. ”的处理
- 人生箴言:人生之最
- 一个不错的外国Flash游戏
- 球中瑞雪 (Snow Globe) ——关于用程序实现圣诞水晶球的设想
- EventHandler解释