예제 #1
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val)
 {
     _unit       = unit;
     _type       = type;
     _val        = val;
     _additional = null;
 }
예제 #2
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val, string additional)
 {
     _unit       = unit;
     _type       = type;
     _val        = val;
     _additional = additional;
     if (_additional.Length > 20)
     {
         _additional = _additional.Substring(0, 17) + "...";
     }
 }
예제 #3
0
        public static object GetMetric(SystemMetricTypes metricType, out Type valueType)
        {
            switch (metricType)
            {
            case SystemMetricTypes.StartupType:
                valueType = typeof(WindowsStartupTypes);
                break;

            case SystemMetricTypes.IsWindowsStarterEdition:
            case SystemMetricTypes.IsWindowsMediaCenterEdition:
            case SystemMetricTypes.IsSystemDocked:
            case SystemMetricTypes.IsTablePC:
            case SystemMetricTypes.IsRemoteSession:
            case SystemMetricTypes.IsShuttingDown:
            case SystemMetricTypes.IsSlowProcessor:
                valueType = typeof(bool);
                break;

            case SystemMetricTypes.Digitizers:
                valueType = typeof(Digitizers);
                break;

            case SystemMetricTypes.MonitorCount:
                valueType = typeof(int);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(metricType), metricType, null);
            }

            var metric = NativeMethods.GetSystemMetrics((int)metricType);

            return(valueType.IsEnum ? Enum.Parse(valueType, metric.ToString())
                : metric.GetType() != valueType?Convert.ChangeType(metric, valueType)
                       : metric);
        }
예제 #4
0
 public List<sSystemMetric> GetValues(SystemMetricTypes[] types)
 {
     Monitor.Enter(_lock);
     List<sSystemMetric> ret = new List<sSystemMetric>();
     foreach (SystemMetricTypes type in types)
     {
         if (_values.ContainsKey(type))
         {
             if (_values[type] is List<sSystemMetric>)
                 ret.AddRange((List<sSystemMetric>)_values[type]);
             else if (_values[type] is sSystemMetric)
                 ret.Add((sSystemMetric)_values[type]);
         }
     }
     Monitor.Exit(_lock);
     return ret;
 }
예제 #5
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val, string additional) :
     this(type, unit, (long)Math.Floor(val), additional)
 {
 }
예제 #6
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val, string additional)
     : this(type, unit, (decimal)val, additional)
 {
 }
예제 #7
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val) :
     this(type, unit, (long)Math.Floor(val))
 {
 }
예제 #8
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val)
     : this(type, unit, (decimal)val)
 {
 }
예제 #9
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val, string additional):
     this(type,unit,(long)Math.Floor(val),additional)
 { }
예제 #10
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val,string additional)
     : this(type, unit, (decimal)val,additional) { }
예제 #11
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val,string additional)
 {
     _unit = unit;
     _type = type;
     _val = val;
     _additional = additional;
     if (_additional.Length > 20)
         _additional = _additional.Substring(0, 17) + "...";
 }
예제 #12
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, decimal val) :
     this(type,unit,(long)Math.Floor(val))
 {
 }
예제 #13
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, float val)
     : this(type, unit, (decimal)val) { }
예제 #14
0
 public sSystemMetric(SystemMetricTypes type, MetricUnits unit, long val)
 {
     _unit = unit;
     _type = type;
     _val = val;
     _additional = null;
 }