GUI/HardwareTypeImage.cs
author moel.mich
Wed, 18 Jul 2012 19:45:59 +0000
changeset 366 667c75cad937
parent 176 c16fd81b520a
child 370 8e4dedc41924
permissions -rw-r--r--
Changed the system tray icon font scaling to adapt to the size of the tray icon in pixels, because on Windows 7 the tray icon scales with the system font size, while on Windows XP the tray icons are always 16 pixels large.
moel@176
     1
/*
moel@176
     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@176
     6
 
moel@344
     7
  Copyright (C) 2010 Michael Möller <mmoeller@openhardwaremonitor.org>
moel@344
     8
	
moel@176
     9
*/
moel@176
    10
moel@176
    11
using System;
moel@176
    12
using System.Drawing;
moel@176
    13
using System.Collections.Generic;
moel@176
    14
using OpenHardwareMonitor.Hardware;
moel@176
    15
moel@176
    16
namespace OpenHardwareMonitor.GUI {
moel@176
    17
  public class HardwareTypeImage {
moel@176
    18
    private static HardwareTypeImage instance = new HardwareTypeImage();
moel@176
    19
moel@176
    20
    private IDictionary<HardwareType, Image> images = 
moel@176
    21
      new Dictionary<HardwareType, Image>();
moel@176
    22
moel@176
    23
    private HardwareTypeImage() { }
moel@176
    24
moel@176
    25
    public static HardwareTypeImage Instance {
moel@176
    26
      get { return instance; }
moel@176
    27
    }
moel@176
    28
moel@176
    29
    public Image GetImage(HardwareType hardwareType) {
moel@176
    30
      Image image;
moel@176
    31
      if (images.TryGetValue(hardwareType, out image)) {
moel@176
    32
        return image;
moel@176
    33
      } else {
moel@176
    34
        switch (hardwareType) {
moel@176
    35
          case HardwareType.CPU:
moel@176
    36
            image = Utilities.EmbeddedResources.GetImage("cpu.png");
moel@176
    37
            break;
moel@176
    38
          case HardwareType.GpuNvidia:
moel@176
    39
            image = Utilities.EmbeddedResources.GetImage("nvidia.png");
moel@176
    40
            break;
moel@176
    41
          case HardwareType.GpuAti:
moel@176
    42
            image = Utilities.EmbeddedResources.GetImage("ati.png");
moel@176
    43
            break;
moel@176
    44
          case HardwareType.HDD:
moel@176
    45
            image = Utilities.EmbeddedResources.GetImage("hdd.png");
moel@176
    46
            break;
moel@176
    47
          case HardwareType.Heatmaster:
moel@176
    48
            image = Utilities.EmbeddedResources.GetImage("bigng.png");
moel@176
    49
            break;
moel@176
    50
          case HardwareType.Mainboard:
moel@176
    51
            image = Utilities.EmbeddedResources.GetImage("mainboard.png");
moel@176
    52
            break;
moel@176
    53
          case HardwareType.SuperIO:
moel@176
    54
            image = Utilities.EmbeddedResources.GetImage("chip.png");
moel@176
    55
            break;
moel@176
    56
          case HardwareType.TBalancer:
moel@176
    57
            image = Utilities.EmbeddedResources.GetImage("bigng.png");
moel@176
    58
            break;
moel@176
    59
          default:
moel@176
    60
            image = new Bitmap(1, 1);
moel@176
    61
            break;
moel@176
    62
        }
moel@176
    63
        images.Add(hardwareType, image);
moel@176
    64
        return image;
moel@176
    65
      }
moel@176
    66
    }
moel@176
    67
  }
moel@176
    68
}