
| 親メニュー | 子メニュー | メソッド | 説明 |
|---|---|---|---|
| ユーザー設定(&U) | |||
| ファイルを起動(&E) | Exec | 既定のプログラムから起動します | |
| フォントを設定(&F) | SetFont | フォントを設定します | |
| リスト(&L) | TopList | トップからのリストを印字します | |
| パスワード(&P) | PassWord | パスワードをタイプします | |
| 設定(&S) | SetPass | パスワードを設定します | |
| 解除(&R) | ResetPass | パスワードを解除します |
private void Exec(object sender, EventArgs e)
{
if (File.Exists(m_sou))
System.Diagnostics.Process.Start(m_sou);
}
|
class form01
{
[STAThread]
public static void Main(string[] args)
{
MyForm mf;
if (args.Length==0) mf = new MyForm();
else mf = new MyForm(args[0]);
Application.Run(mf);
}
}
|
public MyForm(string str)
{
InitializeComponent();
this.Resize += new System.EventHandler(this.FormResize);
this.Load += new System.EventHandler(MyForm_Load);
this.FormClosing += new FormClosingEventHandler(Form_Closing);
m_file = str;
}
|
Font m_font; // フォント情報
private void SetFont(object sender, EventArgs e)
{
FontDialog fontDialog1 = new FontDialog();
fontDialog1.Font = m_font;
fontDialog1.MaxSize = 32;
fontDialog1.MinSize = 9;
fontDialog1.FontMustExist = true;
fontDialog1.FixedPitchOnly = true;
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
m_font = fontDialog1.Font;
this.treeView1.Font = m_font;
this.richTextBox1.Font = m_font;
}
fontDialog1.Dispose();
}
|
private void TopList(object sender, EventArgs e)
{
FormView((TreeNode)t_node[m_Idx]);
}
|
private void MyForm_Load(object sender, System.EventArgs e)
{
・・・
button1.Hide();
textBox1.Hide();
textBox2.Hide();
・・・
}
|
private void PassWord(object sender, EventArgs e)
{
richTextBox1.Hide();
button1.Show();
textBox1.Show();
}
|
private void button_Click(object sender, EventArgs e)
{
m_sou = textBox1.Text;
m_des = textBox2.Text;
button1.Hide();
textBox1.Hide();
textBox2.Hide();
richTextBox1.Show();
}
|
Font m_font; // フォント情報
string m_sou; // パスワード
string m_file = "C:\\TMP\\Test2.mem";
string XML_File = @"C:\tmp\memo.xml";
public class XmlClass
{ public string name; // Font Name
public float point; // Font Size
public string file; // File Name
}
|
private void Form_Closing(object sender, FormClosingEventArgs e)
{
DialogResult rc;
CheckText();
if (m_UP)
{
rc = MessageBox.Show("保存しないで終了?", "選択", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (rc == DialogResult.No)
{
e.Cancel = true;
return;
}
}
XmlClass obj = new XmlClass();
obj.name = m_font.Name;
obj.point = m_font.SizeInPoints;
obj.file = m_file;
System.Xml.Serialization.XmlSerializer serializer =
new System.Xml.Serialization.XmlSerializer(typeof(XmlClass));
System.IO.FileStream fs =
new System.IO.FileStream(XML_File, System.IO.FileMode.Create);
serializer.Serialize(fs, obj);
}
|
private void MyForm_Load(object sender, System.EventArgs e)
{
Width = 1200;
Height = 600;
if (File.Exists(XML_File)) //ファイルの有無をチェック
{
System.Xml.Serialization.XmlSerializer serializer =
new System.Xml.Serialization.XmlSerializer(typeof(XmlClass));
System.IO.FileStream fs =
new System.IO.FileStream(XML_File, System.IO.FileMode.Open);
XmlClass obj = (XmlClass)serializer.Deserialize(fs);
fs.Close();
int point = (int)obj.point;
m_font = new Font(obj.name, point);
//m_file = obj.file;
}
else m_font = new Font("MS 明朝", 12);
richTextBox1.Font = m_font;
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.UIFonts;
treeView1.Font = m_font;
ReadFile(m_file);
m_Idx = 0;
this.Text = m_file;
button1.Hide();
textBox1.Hide();
textBox2.Hide();
treeView1.TopNode.Expand();
richTextBox1.Text = (string)t_txt[0];
}
|
エラー 1 型または名前空間名 'Xml' は名前空間 'System' に存在しません。 アセンブリ参照が不足しています。 |
using System.Xml.Serialization; // System.Xml.dll を追加 |
[Next Chapter ↓] Menu α版
[Previous Chapter ↑] ToolStrip を実装