📄 viewopts.cs
字号:
elem = doc.CreateElement(SendMouseLocWhenIdleName);
elem.InnerText = SendMouseLocWhenIdle.ToString();
rootElem.AppendChild(elem);
elem = doc.CreateElement(MouseAccelModeName);
elem.InnerText = MouseAccelMode.ToString();
switch(MouseSpeed)
{
case MouseSpeed.Low:
elem.SetAttribute(MouseSpeedName, LowName);
break;
case MouseSpeed.High:
elem.SetAttribute(MouseSpeedName, HighName);
break;
default:
elem.SetAttribute(MouseSpeedName, NormalName);
break;
}
rootElem.AppendChild(elem);
}
internal void Load(string fileName)
{
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
ReadFromXml(doc, doc.DocumentElement);
}
private XmlElement FindXmlElem(XmlDocument doc, XmlElement rootElem, string tagName)
{
XmlNodeList list = doc.GetElementsByTagName(tagName);
for(int i = 0; i < list.Count; i++)
if(list[i].ParentNode == rootElem)
return (XmlElement)list[i];
throw new FormatException("The specified element [" + tagName + "] is not found.");
}
internal void ReadFromXml(XmlDocument doc, XmlElement rootElem)
{
bool elemExists = false;
XmlElement elem = FindXmlElem(doc, rootElem, PixelSizeName);
switch(elem.InnerText)
{
case Force8BitName:
PixelSize = PixelSize.Force8Bit;
break;
case Force16BitName:
PixelSize = PixelSize.Force16Bit;
break;
case UnspecName:
PixelSize = PixelSize.Unspec;
break;
default:
throw new FormatException("PixelSize is invalid.");
}
elem = FindXmlElem(doc, rootElem, IsFullScrnName);
IsFullScrn = Boolean.Parse(elem.InnerText);
elem = FindXmlElem(doc, rootElem, OrientationName);
switch(elem.InnerText)
{
case PortraitName:
Orientation = Orientation.Portrait;
break;
case Portrait180Name:
Orientation = Orientation.Portrait180;
break;
case Landscape90Name:
Orientation = Orientation.Landscape90;
break;
case Landscape270Name:
Orientation = Orientation.Landscape270;
break;
default:
throw new FormatException("Orientation is invalid.");
}
try
{
elem = FindXmlElem(doc, rootElem, CliScalingName);
elemExists = true;
}
catch(FormatException)
{
elemExists = false;
}
if(elemExists)
{
switch(elem.InnerText)
{
case NoneName:
CliScaling = CliScaling.None;
break;
case OneHalfName:
CliScaling = CliScaling.OneHalf;
break;
case OneThirdName:
CliScaling = CliScaling.OneThird;
break;
case OneFourthName:
CliScaling = CliScaling.OneFourth;
break;
case OneFifthName:
CliScaling = CliScaling.OneFifth;
break;
case DoubleName:
CliScaling = CliScaling.Double;
break;
case AutoName:
CliScaling = CliScaling.Auto;
break;
case CustomName:
CliScaling = CliScaling.Custom;
break;
default:
throw new FormatException("Client-side scaling setting is invalid.");
}
try
{
CliScalingWidth = UInt16.Parse(elem.GetAttribute(WidthName));
CliScalingHeight = UInt16.Parse(elem.GetAttribute(HeightName));
}
catch(ArgumentNullException)
{
throw new FormatException("Client-side scaling setting is invalid.");
}
catch(OverflowException)
{
throw new FormatException("Client-side scaling setting is invalid.");
}
catch(FormatException)
{
throw new FormatException("Client-side scaling setting is invalid.");
}
}
else
{
CliScaling = CliScaling.None;
CliScalingWidth = 0;
CliScalingHeight = 0;
}
try
{
elem = FindXmlElem(doc, rootElem, ServScalingName);
elemExists = true;
}
catch(FormatException)
{
elemExists = false;
}
if(elemExists)
{
switch(elem.InnerText)
{
case DefaultName:
ServScaling = ServScaling.Default;
break;
case NoneName:
ServScaling = ServScaling.None;
break;
case OneHalfName:
ServScaling = ServScaling.OneHalf;
break;
case OneThirdName:
ServScaling = ServScaling.OneThird;
break;
case OneFourthName:
ServScaling = ServScaling.OneFourth;
break;
case OneFifthName:
ServScaling = ServScaling.OneFifth;
break;
case OneSixthName:
ServScaling = ServScaling.OneSixth;
break;
case OneSeventhName:
ServScaling = ServScaling.OneSeventh;
break;
case OneEighthName:
ServScaling = ServScaling.OneEighth;
break;
case OneNinthName:
ServScaling = ServScaling.OneNinth;
break;
default:
throw new FormatException("Server-side scaling setting is invalid.");
}
}
else
ServScaling = ServScaling.Default;
elem = FindXmlElem(doc, rootElem, ViewOnlyName);
ViewOnly = Boolean.Parse(elem.InnerText);
elem = FindXmlElem(doc, rootElem, ShareServName);
ShareServ = Boolean.Parse(elem.InnerText);
try
{
elem = FindXmlElem(doc, rootElem, ScrnUpdAlgoName);
elemExists = true;
}
catch(FormatException)
{
elemExists = false;
}
if(elemExists)
{
switch(elem.InnerText)
{
case AsapName:
ScrnUpdAlgo = ScrnUpdAlgo.Asap;
break;
case BatchName:
ScrnUpdAlgo = ScrnUpdAlgo.Batch;
break;
default:
throw new FormatException("Screen update setting is invalid.");
}
}
else
ScrnUpdAlgo = ScrnUpdAlgo.Batch;
try
{
elem = FindXmlElem(doc, rootElem, SendMouseLocWhenIdleName);
elemExists = true;
}
catch(FormatException)
{
elemExists = false;
}
SendMouseLocWhenIdle = elemExists? Boolean.Parse(elem.InnerText) : false;
try
{
elem = FindXmlElem(doc, rootElem, MouseAccelModeName);
elemExists = true;
}
catch(FormatException)
{
elemExists = false;
}
if(elemExists)
{
MouseAccelMode = Boolean.Parse(elem.InnerText);
try
{
switch(elem.GetAttribute(MouseSpeedName))
{
case LowName:
MouseSpeed = MouseSpeed.Low;
break;
case NormalName:
MouseSpeed = MouseSpeed.Normal;
break;
case HighName:
MouseSpeed = MouseSpeed.High;
break;
default:
throw new FormatException();
}
}
catch(ArgumentNullException)
{
throw new FormatException("Mouse speed setting is invalid.");
}
catch(OverflowException)
{
throw new FormatException("Mouse speed scaling setting is invalid.");
}
catch(FormatException)
{
throw new FormatException("Mouse speed scaling setting is invalid.");
}
}
else
{
MouseAccelMode = true;
MouseSpeed = MouseSpeed.Normal;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -