Exemplo n.º 1
0
        /// <summary>
        /// Gets the brush color for meter.
        /// TODO: This should be done in XAML not here!
        /// </summary>
        /// <param name="meterType">Type of the meter.</param>
        /// <returns></returns>
        private Brush GetBrushColorForMeter(ReceiverEvents.SensorDeviceType meterType)
        {
            // Various colors to be used for targets
            Color[] targetColors = new Color[]
            {
                Color.FromRgb(0xFF, 0xBA, 0x00),
                Color.FromRgb(0xE3, 0x19, 0x39),
                Color.FromRgb(0xFF, 0x8B, 0x00),
                Color.FromRgb(0x64, 0x1C, 0xA2),
                Color.FromRgb(0x00, 0xCF, 0x60),
                Color.FromRgb(0x1E, 0x54, 0x9E),
                Color.FromRgb(0xC6, 0xD8, 0x00),
                Color.FromRgb(0xFF, 0x5F, 0x00)
            };

            switch (meterType)
            {
            case ReceiverEvents.SensorDeviceType.Chung:
                return(new SolidColorBrush(Color.FromRgb(0x00, 0x7D, 0x0C3)));

            case ReceiverEvents.SensorDeviceType.Hong:
                return(new SolidColorBrush(Color.FromRgb(0xE3, 0x19, 0x37)));

            case ReceiverEvents.SensorDeviceType.Target:
                Color color = targetColors[(_targetNumber % targetColors.Length)];
                return(new SolidColorBrush(color));
            }

            return(Brushes.Gray);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sets the type of the meter.
 /// </summary>
 /// <param name="meterType">Type of the meter.</param>
 public void SetMeterType(ReceiverEvents.SensorDeviceType meterType)
 {
     MeterType   = meterType;
     DisplayName = meterType.ToString();
     HasPanels   = (meterType == ReceiverEvents.SensorDeviceType.Target);
     if (meterType == ReceiverEvents.SensorDeviceType.Target)
     {
         if (_targetNumber == 0)
         {
             _targetNumber = ++_targetCount;
         }
         DisplayName += " " + _targetNumber;
     }
     MeterColor = GetBrushColorForMeter(meterType);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the DeviceRegistered event of the Receiver control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.DeviceRegisteredEventArgs"/> instance containing the event data.</param>
        private void Receiver_DeviceRegistered(object sender, DeviceRegistrationEventData e)
        {
            // Used to keep monitor from going into suspend when we have receiver activity
            Helpers.ActivitySimulator.MoveMouse();

            _logger.Log("Publishing device registration received event to EventAggregator", Category.Info, Priority.Low);
            ReceiverEvents.SensorDeviceType sensorType = ReceiverEvents.SensorDeviceType.Unknown;
            switch (e.OpCode)
            {
            case OpCodes.ChungRegistered: sensorType = ReceiverEvents.SensorDeviceType.Chung; break;

            case OpCodes.HongRegistered: sensorType = ReceiverEvents.SensorDeviceType.Hong; break;

            case OpCodes.TargetRegistered: sensorType = ReceiverEvents.SensorDeviceType.Target; break;
            }
            _eventAggregator.GetEvent <ReceiverEvents.DeviceRegistered>().Publish(new ReceiverEvents.DeviceRegistered()
            {
                SensorId   = e.Id.ToString(),
                SensorType = sensorType
            });
        }