Ejemplo n.º 1
0
        /// <summary>
        /// open the help entry for the given component.
        /// </summary>
        /// <param name="obj">the name of the component, as string</param>
        public static void Open(string obj)
        {
            // Find closest exact or parent entry
            string key = obj;

            while (key != "" && !_docMap.ContainsKey(key))
            {
                int idx = key.IndexOf('.');
                if (idx < 1)
                {
                    key = "";
                }
                else
                {
                    key = key.Substring(0, idx);
                }
            }

            string suburl = "";

            if (key != "")
            {
                suburl = _docMap[key];
            }

            // Open the help URL
            string url = _mainUrl + suburl;

            IrssLog.Info("open help: " + url);
            Process.Start(url);
        }
Ejemplo n.º 2
0
 public void Stop()
 {
     try
     {
         watcher.Stop();
         IrssLog.Info("Stopped Hardware Monitoring.");
     }
     catch (ManagementException err)
     {
         IrssLog.Error("An error occurred while trying to stop hardware monitoring: " + err.Message);
     }
 }
Ejemplo n.º 3
0
 public void Start()
 {
     try
     {
         watcher.Start();
         IrssLog.Info("Started Hardware Monitoring. Waiting for an event...");
     }
     catch (ManagementException err)
     {
         IrssLog.Error("An error occurred while trying to receive an event: " + err.Message);
     }
 }
Ejemplo n.º 4
0
        private void HandleEvent(object sender,
                                 EventArrivedEventArgs e)
        {
            HardwareEventType eventType = (HardwareEventType)int.Parse(e.NewEvent.Properties["EventType"].Value.ToString());

            IrssLog.Debug("HandleEvent: EvenType = {0}", eventType);

            // handle only (dis)connects
            if (eventType == HardwareEventType.ConfigurationChanged ||
                eventType == HardwareEventType.DeviceDocking)
            {
                return;
            }

            // if eventtype is the same and timespan is < 1sec do nothing
            TimeSpan eventTimeout = DateTime.Now.Subtract(lastHardwareEventTime);

            if (lastEvent == eventType && eventTimeout.Milliseconds < 1000)
            {
                return;
            }

            // go on with event handling
            lastEvent             = eventType;
            lastHardwareEventTime = DateTime.Now;

            if (eventType == HardwareEventType.DeviceConnected)
            {
                IrssLog.Info("HardwareMonitor: Device connected");
                if (DeviceConnected != null)
                {
                    DeviceConnected();
                }
            }
            else
            {
                IrssLog.Info("HardwareMonitor: Device disconnected");
                if (DeviceDisconnected != null)
                {
                    DeviceDisconnected();
                }
            }
        }