Beispiel #1
0
 public Scene(string _Name, Scene _LandScapeFrom)
 {
     name = _Name;
     foreach (ClickableRegion region in _LandScapeFrom.ClickablePoints)
     {
         ClickableRegion reg = new ClickableRegion();
         reg.X = region.Y;
         reg.Y = region.X;
         reg.Radius = region.Radius;
         reg.Target = region.Target;
         ClickablePoints.Add(reg);
     }
     Background = new Bitmap(_LandScapeFrom.Background.Height, _LandScapeFrom.Background.Width);
     for (int Y = 0; Y < Background.Height; Y++)
     {
         for (int X = 0; X < Background.Width; X++)
         {
             ((Bitmap)Background).SetPixel(X, Y, ((Bitmap)(_LandScapeFrom.Background)).GetPixel(Y, X));
         }
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            if (!HttpListener.IsSupported) Console.WriteLine("HTTPListener class is not supported on your machine.");

            Scene scene1 = new Scene("portrait");
            scene1.ClickablePoints.Add(new Scene.ClickableRegion(280.0f / 320, 40.0f / 480, 0.2f, "Solder"));
            scene1.ClickablePoints.Add(new Scene.ClickableRegion(40.0f / 320, 40.0f / 480, 0.2f, "Lamp"));
            scene1.ClickablePoints.Add(new Scene.ClickableRegion(40.0f / 320, 120.0f / 480, 0.1f, "Fan"));

            scene1.ClickablePoints.Add(new Scene.ClickableRegion(280.0f / 320, 350.0f / 480, 0.2f, "Charger"));
            scene1.ClickablePoints.Add(new Scene.ClickableRegion(280.0f / 320, 450.0f / 480, 0.2f, "Kitchen"));

            scene1.Background = Image.FromStream(new System.IO.FileStream("background.png", System.IO.FileMode.Open));

            Scene.Scenes.Add(scene1);

            //Scene.Scenes.Add(new Scene("landscape", scene1));

            // Create a listener.
            listener = new HttpListener();
            //listener.AuthenticationSchemes = AuthenticationSchemes.Basic;//might be phun

            Thread thread = new Thread(new ThreadStart(listen));
            thread.Start();

            K8055.Initialize(0);

            bool doorbell = false;
            DateTime doorbellexpire = DateTime.Now;
            while (true)
            {
                if (K8055.GetDigital(0))
                {
                    if (!doorbell)
                    {
                        doorbellexpire = DateTime.Now + new TimeSpan(0, 0, 0, 5);
                        doorbell = true;
                    }
                }
                if (doorbell)
                {
                    K8055.SetDigital(4, true);
                    if (doorbellexpire < DateTime.Now)
                        doorbell = false;
                }
                foreach (Scene scene in Scene.Scenes)
                {
                    foreach (Scene.ClickableRegion region in scene.ClickablePoints)
                    {
                        if (region.Target.ToLower() == "lamp")
                        {
                            K8055.SetDigital(2, region.Pressed || doorbell);
                        }
                        if (region.Target.ToLower() == "kitchen")
                        {
                            K8055.SetDigital(3, region.Pressed || doorbell);
                        }
                        if (region.Target.ToLower() == "fan")
                        {
                            K8055.SetDigital(4, region.Pressed || doorbell);
                        }
                        if (region.Target.ToLower() == "charger")
                        {
                            K8055.SetDigital(0, region.Pressed);
                        }
                        if (region.Target.ToLower() == "solder")
                        {
                            K8055.SetDigital(1, region.Pressed);
                        }
                    }
                }

                Thread.Sleep(50);
            }
            listener.Stop();
        }