|
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace QiHe.CodeLib
{
public class UIText
{
public static void Save(Control control, string filename)
{
StreamWriter writer = File.CreateText(filename);
Write(control, writer);
writer.Close();
}
public static void Load(Control control, string filename)
{
StreamReader reader = File.OpenText(filename);
Read(control, reader);
reader.Close();
}
public static void Write(Control control, StreamWriter writer)
{
if (control is TextBox) return;
if (control is ComboBox) return;
if (control is NumericUpDown) return;
writer.WriteLine(control.Text);
foreach (Control ctrl in control.Controls)
{
Write(ctrl, writer);
}
}
public static void Read(Control control, StreamReader reader)
{
if (control is TextBox) return;
if (control is ComboBox) return;
if (control is NumericUpDown) return;
string text = reader.ReadLine();
if (text != null)
{
control.Text = text;
foreach (Control ctrl in control.Controls)
{
Read(ctrl, reader);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.