?? xmlhandler.cs
字號:
using System;
using System.IO;
using System.Xml;
using TXML;
namespace VirtualPhotoOrganizer.Util
{
/// <summary>
/// handles Xml file access for TommazzosPhotoAlbum
/// </summary>
internal class XmlHandler
{
// the files used for storing TPA settings
private static string SettingsDir = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + "\\VirtualPhotoOrganizer";
private static string VPO_Settings = SettingsDir + "\\Settings.xml";
private static string VPO_RootAlbum = SettingsDir + "\\RootAlbum.xml";
private static string _LangFile = "English.xml";
public XmlHandler() {
// no ctor required - all methods are static
}
/// <summary>
/// Returns a reference to a TXmlReader pointing to the VPO settings file
/// </summary>
internal static TXmlReader OpenSettingsReader() {
if (!File.Exists(VPO_Settings)) // check if the file doesn't exist
{
// check if the directory exists
if (!Directory.Exists(SettingsDir))
Directory.CreateDirectory(SettingsDir);
// create a new file with a TXmlWriter
TXmlWriter writer = new TXmlWriter(VPO_Settings, "VPO_Settings", 4);
writer.Close();
}
// open the file with a TXmlReader
TXmlReader reader = new TXmlReader(VPO_Settings);
return reader;
}
/// <summary>
/// Returns a reference to a TXmlWriter pointing to the VPO settings file
/// </summary>
internal static TXmlWriter OpenSettingsWriter() {
// check if directory exists
if (!Directory.Exists(SettingsDir))
Directory.CreateDirectory(SettingsDir);
// create TXmlWriter
TXmlWriter writer = new TXmlWriter(VPO_Settings, "VPO_Settings", 4);
return writer;
}
/// <summary>
/// Returns a reference to a TXmlReader pointing to the VPO RootAlbum file
/// </summary>
internal static TXmlReader OpenRootAlbumReader() {
if (!File.Exists(VPO_RootAlbum)) // check if the file doesn't exist
{
// check if the directory exists
if (!Directory.Exists(SettingsDir))
Directory.CreateDirectory(SettingsDir);
// create a new file with a TXmlWriter
TXmlWriter writer = new TXmlWriter(VPO_RootAlbum, "VPO_RootAlbum", 4);
writer.Close();
}
// open the file with a TXmlReader
TXmlReader reader = new TXmlReader(VPO_RootAlbum);
return reader;
}
/// <summary>
/// Returns a reference to a TXmlWriter pointing to the VPO RootAlbum file
/// </summary>
internal static TXmlWriter OpenRootAlbumWriter() {
// check if directory exists
if (!Directory.Exists(SettingsDir))
Directory.CreateDirectory(SettingsDir);
// if the file already exists delete it
if (File.Exists(VPO_RootAlbum))
File.Delete(VPO_RootAlbum);
// create TXmlWriter
TXmlWriter writer = new TXmlWriter(VPO_RootAlbum, "VPO_RootAlbum", 4);
return writer;
}
/// <summary>
/// accessor for the Lang_File property
/// </summary>
internal static string LangFile {
get { return _LangFile; }
set { _LangFile = value; }
}
/// <summary>
/// Returns a reference to a TXmlReader pointing to the currently selected language file
/// </summary>
internal static TXmlReader OpenLangFile() {
// open the file with a TXmlReader
TXmlReader reader = new TXmlReader(System.Windows.Forms.Application.StartupPath + "\\Lang\\" + _LangFile);
return reader;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -