示例#1
0
 public Light(int x, int y, LightCircuit circuit, LightColor color, LightShape shape)
 {
     Assembly assembly = Assembly.GetExecutingAssembly();
       string lightName = Enum.GetName(color.GetType(), color).ToLower();
       string resourceOn = string.Format("JamesAllen.XmasLights.Images.{0}_on.png", lightName);
       string resourceOff = string.Format("JamesAllen.XmasLights.Images.{0}_off.png", lightName);
       Stream streamOn = assembly.GetManifestResourceStream(resourceOn);
       Stream streamOff = assembly.GetManifestResourceStream(resourceOff);
       imageOn = (Image)Bitmap.FromStream(streamOn);
       imageOff = (Image)Bitmap.FromStream(streamOff);
       this.position = new Point(x, y);
       this.circuit = circuit;
       this.color = color;
       this.shape = shape;
 }
示例#2
0
        private void InitializeLights()
        {
            // Get handle to desktop
              desktopDC = GetDC(IntPtr.Zero);

              // Create some objects
              lights = new List<Light>();
              circuits = new List<LightCircuit>();
              LightCircuit circuit1 = new LightCircuit();
              LightCircuit circuit2 = new LightCircuit();
              LightCircuit circuit3 = new LightCircuit();
              LightCircuit circuit4 = new LightCircuit();

              // Create list of lights
              int width = Screen.PrimaryScreen.Bounds.Width;
              for (int i = 0; i < width; i = i + 100)
              {
            switch ((i / 100) % 4)
            {
              case 0:
            lights.Add(new Light(i, 5, circuit1, Light.LightColor.Red, Light.LightShape.Oval));
            break;

              case 1:
            lights.Add(new Light(i, 5, circuit2, Light.LightColor.Green, Light.LightShape.Oval));
            break;

              case 2:
            lights.Add(new Light(i, 5, circuit3, Light.LightColor.Yellow, Light.LightShape.Oval));
            break;

              case 3:
            lights.Add(new Light(i, 5, circuit4, Light.LightColor.Purple, Light.LightShape.Oval));
            break;
            }
              }

              // Create light of light circuits
              circuits.Add(circuit1);
              circuits.Add(circuit2);
              circuits.Add(circuit3);
              circuits.Add(circuit4);
        }