author | moel.mich |
Sun, 21 Oct 2012 14:45:24 +0000 | |
changeset 383 | ace2c5fc4b7f |
parent 340 | 600962f8a298 |
permissions | -rw-r--r-- |
moel@1 | 1 |
/* |
moel@1 | 2 |
|
moel@344 | 3 |
This Source Code Form is subject to the terms of the Mozilla Public |
moel@344 | 4 |
License, v. 2.0. If a copy of the MPL was not distributed with this |
moel@344 | 5 |
file, You can obtain one at http://mozilla.org/MPL/2.0/. |
moel@1 | 6 |
|
moel@344 | 7 |
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org> |
moel@344 | 8 |
|
moel@1 | 9 |
*/ |
moel@1 | 10 |
|
moel@1 | 11 |
using System; |
moel@1 | 12 |
using System.Collections.Generic; |
moel@1 | 13 |
using OpenHardwareMonitor.Hardware; |
moel@1 | 14 |
|
moel@1 | 15 |
namespace OpenHardwareMonitor.GUI { |
moel@1 | 16 |
public class TypeNode : Node { |
moel@1 | 17 |
|
moel@1 | 18 |
private SensorType sensorType; |
moel@1 | 19 |
|
moel@1 | 20 |
public TypeNode(SensorType sensorType) : base() { |
moel@1 | 21 |
this.sensorType = sensorType; |
moel@1 | 22 |
|
moel@1 | 23 |
switch (sensorType) { |
moel@1 | 24 |
case SensorType.Voltage: |
moel@1 | 25 |
this.Image = Utilities.EmbeddedResources.GetImage("voltage.png"); |
moel@1 | 26 |
this.Text = "Voltages"; |
moel@1 | 27 |
break; |
moel@1 | 28 |
case SensorType.Clock: |
moel@1 | 29 |
this.Image = Utilities.EmbeddedResources.GetImage("clock.png"); |
moel@1 | 30 |
this.Text = "Clocks"; |
moel@1 | 31 |
break; |
moel@24 | 32 |
case SensorType.Load: |
moel@24 | 33 |
this.Image = Utilities.EmbeddedResources.GetImage("load.png"); |
moel@24 | 34 |
this.Text = "Load"; |
moel@24 | 35 |
break; |
moel@1 | 36 |
case SensorType.Temperature: |
moel@1 | 37 |
this.Image = Utilities.EmbeddedResources.GetImage("temperature.png"); |
moel@1 | 38 |
this.Text = "Temperatures"; |
moel@1 | 39 |
break; |
moel@1 | 40 |
case SensorType.Fan: |
moel@1 | 41 |
this.Image = Utilities.EmbeddedResources.GetImage("fan.png"); |
moel@1 | 42 |
this.Text = "Fans"; |
moel@1 | 43 |
break; |
moel@57 | 44 |
case SensorType.Flow: |
moel@57 | 45 |
this.Image = Utilities.EmbeddedResources.GetImage("flow.png"); |
moel@57 | 46 |
this.Text = "Flows"; |
moel@57 | 47 |
break; |
moel@118 | 48 |
case SensorType.Control: |
moel@118 | 49 |
this.Image = Utilities.EmbeddedResources.GetImage("control.png"); |
moel@118 | 50 |
this.Text = "Controls"; |
moel@118 | 51 |
break; |
moel@217 | 52 |
case SensorType.Level: |
moel@217 | 53 |
this.Image = Utilities.EmbeddedResources.GetImage("level.png"); |
moel@217 | 54 |
this.Text = "Levels"; |
moel@217 | 55 |
break; |
moel@317 | 56 |
case SensorType.Power: |
moel@317 | 57 |
this.Image = Utilities.EmbeddedResources.GetImage("power.png"); |
moel@317 | 58 |
this.Text = "Powers"; |
moel@317 | 59 |
break; |
moel@324 | 60 |
case SensorType.Data: |
moel@324 | 61 |
this.Image = Utilities.EmbeddedResources.GetImage("data.png"); |
moel@324 | 62 |
this.Text = "Data"; |
moel@324 | 63 |
break; |
moel@340 | 64 |
case SensorType.Factor: |
moel@340 | 65 |
this.Image = Utilities.EmbeddedResources.GetImage("factor.png"); |
moel@340 | 66 |
this.Text = "Factors"; |
moel@340 | 67 |
break; |
moel@1 | 68 |
} |
moel@111 | 69 |
|
moel@111 | 70 |
NodeAdded += new NodeEventHandler(TypeNode_NodeAdded); |
moel@111 | 71 |
NodeRemoved += new NodeEventHandler(TypeNode_NodeRemoved); |
moel@111 | 72 |
} |
moel@111 | 73 |
|
moel@111 | 74 |
private void TypeNode_NodeRemoved(Node node) { |
moel@111 | 75 |
node.IsVisibleChanged -= new NodeEventHandler(node_IsVisibleChanged); |
moel@111 | 76 |
node_IsVisibleChanged(null); |
moel@111 | 77 |
} |
moel@111 | 78 |
|
moel@111 | 79 |
private void TypeNode_NodeAdded(Node node) { |
moel@111 | 80 |
node.IsVisibleChanged += new NodeEventHandler(node_IsVisibleChanged); |
moel@111 | 81 |
node_IsVisibleChanged(null); |
moel@111 | 82 |
} |
moel@111 | 83 |
|
moel@111 | 84 |
private void node_IsVisibleChanged(Node node) { |
moel@111 | 85 |
foreach (Node n in Nodes) |
moel@111 | 86 |
if (n.IsVisible) { |
moel@111 | 87 |
this.IsVisible = true; |
moel@111 | 88 |
return; |
moel@111 | 89 |
} |
moel@111 | 90 |
this.IsVisible = false; |
moel@1 | 91 |
} |
moel@1 | 92 |
|
moel@1 | 93 |
public SensorType SensorType { |
moel@1 | 94 |
get { return sensorType; } |
moel@1 | 95 |
} |
moel@1 | 96 |
} |
moel@1 | 97 |
} |