本文整理汇总了C#中Parity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Parity.ToString方法的具体用法?C# Parity.ToString怎么用?C# Parity.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parity
的用法示例。
在下文中一共展示了Parity.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetComboBoxes
public void SetComboBoxes(String comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
{
try
{
cmbComPortName.Text = GetValidPortName(cmbComPortName.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
cmbComPortName.Text = "NONE";
}
cmbBaudRate.Text = baudRate.ToString();
cmbParity.SelectedIndex = GetIndexOfValue(cmbParity.Items, parity.ToString());
cmbDataBits.SelectedIndex = GetIndexOfValue(cmbDataBits.Items, dataBits.ToString());
switch (stopBits)
{
case StopBits.One:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
case StopBits.OnePointFive:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1.5");
break;
case StopBits.Two:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "2");
break;
case StopBits.None:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
default:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
}
}
示例2: SaveSettingss
private async void SaveSettingss(string port, int baud, Parity parity, Handshake handshake, int dataBits, StopBits stopBits)
{
writing = true;
XmlWriterSettings settings = new XmlWriterSettings { Indent = true, NewLineOnAttributes = true };
XmlWriter writer = XmlWriter.Create("Settings.xml", settings);
writer.WriteStartDocument();
writer.WriteStartElement("Settings");
writer.WriteElementString("Port", port);
writer.WriteElementString("Baudrate", baud.ToString());
writer.WriteElementString("Parity", parity.ToString());
writer.WriteElementString("Handshake", handshake.ToString());
writer.WriteElementString("Data_Bits", dataBits.ToString());
writer.WriteElementString("Stop_Bits", stopBits.ToString());
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
writing = false;
if(!initialization)
{
MessageDialogResult result = await MessageService.ShowMessage("Gespeichert!", "Settings wurden gespeichert!", MessageDialogStyle.Affirmative).ConfigureAwait(false);
}
}
示例3: Open
public bool Open(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
{
try
{
log.Debug(string.Format("准备打开串口{0},波特率{1},奇偶校验位{2},数据位{3},停止位{4}", portName, baudRate.ToString(), parity.ToString(), dataBits.ToString(), stopBits.ToString()));
comPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
if (comPort.IsOpen)
{
comPort.Close();
}
comPort.Open();
log.Debug(string.Format("成功打开串口{0}!", portName));
return true;
}
catch (Exception ex)
{
log.Info(string.Format("打开串口:{0}异常:{1}", portName, ex.ToString()));
return false;
}
}
示例4: SetPortParity
public static Parity SetPortParity(Parity defaultPortParity)
{
string parity;
Console.WriteLine("Available Parity options:");
foreach (string s in Enum.GetNames(typeof(Parity)))
{
Console.WriteLine(" {0}", s);
}
Console.Write("Parity({0}):", defaultPortParity.ToString());
parity = Console.ReadLine();
if (parity == "")
{
parity = defaultPortParity.ToString();
}
return (Parity)Enum.Parse(typeof(Parity), parity);
}
示例5: SetComboBoxes
public void SetComboBoxes(List<String> newList, String comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, bool rtsEnable, bool dtrEnable)
{
PopulatePortNameList(newList, comPortName);
cmbBaudRate.Text = baudRate.ToString();
cmbParity.SelectedIndex = GetIndexOfValue(cmbParity.Items, parity.ToString());
cmbDataBits.SelectedIndex = GetIndexOfValue(cmbDataBits.Items, dataBits.ToString());
switch (stopBits)
{
case StopBits.One:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
case StopBits.OnePointFive:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1.5");
break;
case StopBits.Two:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "2");
break;
case StopBits.None:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
default:
cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
break;
}
switch (handshake)
{
case Handshake.None:
cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "None");
break;
case Handshake.RequestToSend:
cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "RequestToSend");
break;
case Handshake.XOnXOff:
cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "XOnXOff");
break;
case Handshake.RequestToSendXOnXOff:
cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "Both");
break;
default:
cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "None");
break;
}
if (rtsEnable)
{
cmbRequestToSend.SelectedIndex = GetIndexOfValue(cmbRequestToSend.Items, "Enable");
}
else
{
cmbRequestToSend.SelectedIndex = GetIndexOfValue(cmbRequestToSend.Items, "Disable");
}
if (dtrEnable)
{
cmbDataTerminalReady.SelectedIndex = GetIndexOfValue(cmbDataTerminalReady.Items, "Enable");
}
else
{
cmbDataTerminalReady.SelectedIndex = GetIndexOfValue(cmbDataTerminalReady.Items, "Disable");
}
}
示例6: ParityToStr
/// <summary>
/// Переводит значение бита четности в рускоязычный аналог
/// </summary>
/// <param name="parity">Значение бита четности</param>
/// <returns>Рускоязычное значение бита четности</returns>
public static string ParityToStr(Parity parity)
{
switch (parity)
{
case Parity.Even:
return "нет";
case Parity.Odd:
return "нечетный";
case Parity.None:
return "четный";
default:
return parity.ToString();
}
}
示例7: SetPortParity
public static Parity SetPortParity(Parity defaultPortParity)
{
string parity = ConfigurationManager.AppSettings["Parity"];
if (string.IsNullOrEmpty(parity))
{
parity = defaultPortParity.ToString();
}
return (Parity)Enum.Parse(typeof(Parity), parity);
}
示例8: SetPortParity
// Display PortParity values and prompt user to enter a value.
public static Parity SetPortParity(Parity defaultPortParity)
{
string parity;
parity = defaultPortParity.ToString();
return (Parity)Enum.Parse(typeof(Parity), parity, true);
}
示例9: SetPortParity
public Parity SetPortParity(Parity defaultPortParity)
{
Console.WriteLine("Available Parity options:");
foreach (var s in Enum.GetNames(typeof(Parity)))
{
Console.WriteLine(" {0}", s);
}
Console.Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString(), true);
var parity = Console.ReadLine();
if (parity == "")
{
parity = defaultPortParity.ToString();
}
// ReSharper disable once AssignNullToNotNullAttribute
return (Parity)Enum.Parse(typeof(Parity), parity, true);
}