Exemple #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PortStatus portStatus = (PortStatus)value;

            string status = Application.Current.Resources["String_PortStatus_" + portStatus.ToString()] as string;

            if (string.IsNullOrEmpty(status))
            {
                return(portStatus.ToString());
            }

            return(status);
        }
Exemple #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PortStatus portStatus = (PortStatus)value;

            string status = LocalizationManager.GetStringByKey("String_PortStatus_" + portStatus.ToString());

            if (string.IsNullOrEmpty(status))
            {
                return(portStatus.ToString());
            }

            return(status);
        }
Exemple #3
0
        public void Test_ValidPortStatus(PortStatus status)
        {
            const int minPort = 1;
            const int maxPort = 2;

            var spScanner = new SerialPortScanner();
            var cancellationTokenSource = new CancellationTokenSource();
            var cToken = cancellationTokenSource.Token;

            IList <IPrintablePortStatus> sResult = default;

            try
            {
                var task = spScanner.ScanAsync(new ScanProperties(minPort, maxPort, status), cToken);
                sResult = task.Result.ToList();
            }
            catch (Exception e)
            {
                Assert.True(false, e.Message);
            }
            finally
            {
                cancellationTokenSource.Dispose();
            }

            bool statusOk;

            if (status == PortStatus.Any)
            {
                statusOk = ((maxPort - minPort) + 1) == sResult.Count;
            }
            else
            {
                var portStatusString = status.ToString();
                statusOk = sResult.All(x => x.GetStatusString() == portStatusString);
            }

            Assert.True(statusOk);
        }
 public SerialPortStatus(string name, PortStatus status)
 {
     _name   = name;
     _status = status.ToString();
 }
 protected string GetStatusDescription(PortStatus status)
 {
     return(MonitoringResource.ResourceManager.GetString("PortStatus" + status) ?? status.ToString());
 }
Exemple #6
0
 public PortStatusData(string port, PortStatus status)
 {
     _name       = port;
     _status     = status.ToString();
     _portStatus = status;
 }
 protected string GetStatusDescription(PortStatus status)
 {
     return MonitoringResource.ResourceManager.GetString("PortStatus" + status) ?? status.ToString();
 }
 public WebPortStatus(int port, PortStatus status)
 {
     _name   = port.ToString();
     _status = status.ToString();
 }