本文整理汇总了C#中StopBits.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StopBits.ToString方法的具体用法?C# StopBits.ToString怎么用?C# StopBits.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StopBits
的用法示例。
在下文中一共展示了StopBits.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例3: SetPortStopBits
public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
string stopBits;
Console.WriteLine("Available Stop Bits options:");
foreach (string s in Enum.GetNames(typeof(StopBits)))
{
Console.WriteLine(" {0}", s);
}
Console.Write("Stop Bits({0}):", defaultPortStopBits.ToString());
stopBits = Console.ReadLine();
if (stopBits == "")
{
stopBits = defaultPortStopBits.ToString();
}
return (StopBits)Enum.Parse(typeof(StopBits), stopBits);
}
示例4: SetPortStopBits
// Display StopBits values and prompt user to enter a value.
public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
string stopBits;
Console.WriteLine("Available StopBits options:");
foreach (string s in Enum.GetNames(typeof(StopBits)))
{
Console.WriteLine(" {0}", s);
}
Console.Write("Enter StopBits value (None is not supported and \n" +
"raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
stopBits = Console.ReadLine();
if (stopBits == "")
{
stopBits = defaultPortStopBits.ToString();
}
return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
}
示例5: StopBitsToStr
/// <summary>
/// Переводит количество стоповых битов в строку
/// </summary>
/// <param name="stopBits">Число стоповых битов</param>
/// <returns>Значение количества стоповых бит</returns>
public static string StopBitsToStr(StopBits stopBits)
{
switch (stopBits)
{
case StopBits.None:
return "0";
case StopBits.One:
return "1";
case StopBits.OnePointFive:
return "1.5";
case StopBits.Two:
return "2";
default:
return stopBits.ToString();
}
}
示例6: SetPortStopBits
public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
string stopBits = ConfigurationManager.AppSettings["StopBits"];
if (string.IsNullOrEmpty(stopBits))
{
stopBits = defaultPortStopBits.ToString();
}
return (StopBits)Enum.Parse(typeof(StopBits), stopBits);
}
示例7: SetPortStopBits
// Display StopBits values and prompt user to enter a value.
public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
string stopBits;
stopBits = defaultPortStopBits.ToString();
return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
}
示例8: SetPortStopBits
public StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
Console.WriteLine("Available StopBits options:");
foreach (var s in Enum.GetNames(typeof(StopBits)))
{
Console.WriteLine(" {0}", s);
}
Console.Write("Enter StopBits value (None is not supported and \n" +
"raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
var stopBits = Console.ReadLine();
if (stopBits == "")
{
stopBits = defaultPortStopBits.ToString();
}
// ReSharper disable once AssignNullToNotNullAttribute
return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
}