GUI/HardwareTypeImage.cs
author moel.mich
Wed, 16 Mar 2011 22:10:26 +0000
changeset 262 8731a1b81301
child 344 3145aadca3d2
permissions -rw-r--r--
Fixed Issue 179.
moel@176
     1
/*
moel@176
     2
  
moel@176
     3
  Version: MPL 1.1/GPL 2.0/LGPL 2.1
moel@176
     4
moel@176
     5
  The contents of this file are subject to the Mozilla Public License Version
moel@176
     6
  1.1 (the "License"); you may not use this file except in compliance with
moel@176
     7
  the License. You may obtain a copy of the License at
moel@176
     8
 
moel@176
     9
  http://www.mozilla.org/MPL/
moel@176
    10
moel@176
    11
  Software distributed under the License is distributed on an "AS IS" basis,
moel@176
    12
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
moel@176
    13
  for the specific language governing rights and limitations under the License.
moel@176
    14
moel@176
    15
  The Original Code is the Open Hardware Monitor code.
moel@176
    16
moel@176
    17
  The Initial Developer of the Original Code is 
moel@176
    18
  Michael Möller <m.moeller@gmx.ch>.
moel@176
    19
  Portions created by the Initial Developer are Copyright (C) 2010
moel@176
    20
  the Initial Developer. All Rights Reserved.
moel@176
    21
moel@176
    22
  Contributor(s):
moel@176
    23
moel@176
    24
  Alternatively, the contents of this file may be used under the terms of
moel@176
    25
  either the GNU General Public License Version 2 or later (the "GPL"), or
moel@176
    26
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
moel@176
    27
  in which case the provisions of the GPL or the LGPL are applicable instead
moel@176
    28
  of those above. If you wish to allow use of your version of this file only
moel@176
    29
  under the terms of either the GPL or the LGPL, and not to allow others to
moel@176
    30
  use your version of this file under the terms of the MPL, indicate your
moel@176
    31
  decision by deleting the provisions above and replace them with the notice
moel@176
    32
  and other provisions required by the GPL or the LGPL. If you do not delete
moel@176
    33
  the provisions above, a recipient may use your version of this file under
moel@176
    34
  the terms of any one of the MPL, the GPL or the LGPL.
moel@176
    35
 
moel@176
    36
*/
moel@176
    37
moel@176
    38
using System;
moel@176
    39
using System.Drawing;
moel@176
    40
using System.Collections.Generic;
moel@176
    41
using OpenHardwareMonitor.Hardware;
moel@176
    42
moel@176
    43
namespace OpenHardwareMonitor.GUI {
moel@176
    44
  public class HardwareTypeImage {
moel@176
    45
    private static HardwareTypeImage instance = new HardwareTypeImage();
moel@176
    46
moel@176
    47
    private IDictionary<HardwareType, Image> images = 
moel@176
    48
      new Dictionary<HardwareType, Image>();
moel@176
    49
moel@176
    50
    private HardwareTypeImage() { }
moel@176
    51
moel@176
    52
    public static HardwareTypeImage Instance {
moel@176
    53
      get { return instance; }
moel@176
    54
    }
moel@176
    55
moel@176
    56
    public Image GetImage(HardwareType hardwareType) {
moel@176
    57
      Image image;
moel@176
    58
      if (images.TryGetValue(hardwareType, out image)) {
moel@176
    59
        return image;
moel@176
    60
      } else {
moel@176
    61
        switch (hardwareType) {
moel@176
    62
          case HardwareType.CPU:
moel@176
    63
            image = Utilities.EmbeddedResources.GetImage("cpu.png");
moel@176
    64
            break;
moel@176
    65
          case HardwareType.GpuNvidia:
moel@176
    66
            image = Utilities.EmbeddedResources.GetImage("nvidia.png");
moel@176
    67
            break;
moel@176
    68
          case HardwareType.GpuAti:
moel@176
    69
            image = Utilities.EmbeddedResources.GetImage("ati.png");
moel@176
    70
            break;
moel@176
    71
          case HardwareType.HDD:
moel@176
    72
            image = Utilities.EmbeddedResources.GetImage("hdd.png");
moel@176
    73
            break;
moel@176
    74
          case HardwareType.Heatmaster:
moel@176
    75
            image = Utilities.EmbeddedResources.GetImage("bigng.png");
moel@176
    76
            break;
moel@176
    77
          case HardwareType.Mainboard:
moel@176
    78
            image = Utilities.EmbeddedResources.GetImage("mainboard.png");
moel@176
    79
            break;
moel@176
    80
          case HardwareType.SuperIO:
moel@176
    81
            image = Utilities.EmbeddedResources.GetImage("chip.png");
moel@176
    82
            break;
moel@176
    83
          case HardwareType.TBalancer:
moel@176
    84
            image = Utilities.EmbeddedResources.GetImage("bigng.png");
moel@176
    85
            break;
moel@176
    86
          default:
moel@176
    87
            image = new Bitmap(1, 1);
moel@176
    88
            break;
moel@176
    89
        }
moel@176
    90
        images.Add(hardwareType, image);
moel@176
    91
        return image;
moel@176
    92
      }
moel@176
    93
    }
moel@176
    94
  }
moel@176
    95
}