Example #1
0
        // GET: Home/Edit/5/tv
        public ActionResult Edit(int?id, string device)
        {
            switch (device)
            {
            case "Tv":
                Session["SelectedDevice"] = db.Tvs.Find(id);
                Session["DeviceConsole"]  = new DeviceConsole(db.Tvs.Find(id));
                break;

            case "Fridge":
                Session["SelectedDevice"] = db.Fridges.Find(id);
                Session["DeviceConsole"]  = new DeviceConsole(db.Fridges.Find(id));
                break;

            case "Lamp":
                Session["SelectedDevice"] = db.Lamps.Find(id);
                Session["DeviceConsole"]  = new DeviceConsole(db.Lamps.Find(id));
                break;

            case "Cooker":
                Session["SelectedDevice"] = db.Cookers.Find(id);
                Session["DeviceConsole"]  = new DeviceConsole(db.Cookers.Find(id));
                break;

            case "Microwave":
                Session["SelectedDevice"] = db.Microwaves.Find(id);
                Session["DeviceConsole"]  = new DeviceConsole(db.Microwaves.Find(id));
                break;

            default:
                break;
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
 // Ok
 protected void LinkButtonOk_Click(object sender, EventArgs e)
 {
     if (selectedDevice != null)
     {
         db.Entry(selectedDevice).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         Session["SelectedDevice"] = null;
         Session["DeviceConsole"]  = null;
         selectedDevice            = null;
         deviceConsole             = null;
         RefreshPage();
     }
 }
Example #3
0
        // Create
        public void Create(string device)
        {
            switch (device)
            {
            case "Tv":
                Tv tv = new Tv();
                db.Tvs.Add(tv);
                db.SaveChanges();
                Session["SelectedDevice"] = tv;
                Session["DeviceConsole"]  = new DeviceConsole(tv);
                break;

            case "Fridge":
                Fridge fridge = new Fridge();
                db.Fridges.Add(fridge);
                db.SaveChanges();
                Session["SelectedDevice"] = fridge;
                Session["DeviceConsole"]  = new DeviceConsole(fridge);
                break;

            case "Lamp":
                Lamp lamp = new Lamp();
                db.Lamps.Add(lamp);
                db.SaveChanges();
                Session["SelectedDevice"] = lamp;
                Session["DeviceConsole"]  = new DeviceConsole(lamp);
                break;

            case "Cooker":
                Cooker cooker = new Cooker();
                db.Cookers.Add(cooker);
                db.SaveChanges();
                Session["SelectedDevice"] = cooker;
                Session["DeviceConsole"]  = new DeviceConsole(cooker);
                break;

            case "Microwave":
                Microwave microwave = new Microwave();
                db.Microwaves.Add(microwave);
                db.SaveChanges();
                Session["SelectedDevice"] = microwave;
                Session["DeviceConsole"]  = new DeviceConsole(microwave);
                break;

            default:
                break;
            }
            selectedDevice = (Session["SelectedDevice"] as Device);
            deviceConsole  = (Session["DeviceConsole"] as DeviceConsole);
            RefreshPage();
        }
Example #4
0
        // GET: Home/Create/tv
        public ActionResult Create(string device)
        {
            switch (device)
            {
            case "Tv":
                Tv tv = new Tv();
                db.Tvs.Add(tv);
                db.SaveChanges();
                Session["SelectedDevice"] = tv;
                Session["DeviceConsole"]  = new DeviceConsole(tv);
                break;

            case "Fridge":
                Fridge fridge = new Fridge();
                db.Fridges.Add(fridge);
                db.SaveChanges();
                Session["SelectedDevice"] = fridge;
                Session["DeviceConsole"]  = new DeviceConsole(fridge);
                break;

            case "Lamp":
                Lamp lamp = new Lamp();
                db.Lamps.Add(lamp);
                db.SaveChanges();
                Session["SelectedDevice"] = lamp;
                Session["DeviceConsole"]  = new DeviceConsole(lamp);

                break;

            case "Cooker":
                Cooker cooker = new Cooker();
                db.Cookers.Add(cooker);
                db.SaveChanges();
                Session["SelectedDevice"] = cooker;
                Session["DeviceConsole"]  = new DeviceConsole(cooker);

                break;

            case "Microwave":
                Microwave microwave = new Microwave();
                db.Microwaves.Add(microwave);
                db.SaveChanges();
                Session["SelectedDevice"] = microwave;
                Session["DeviceConsole"]  = new DeviceConsole(microwave);
                break;

            default:
                break;
            }
            return(RedirectToAction("Index"));
        }
Example #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         if (Session["SelectedDevice"] != null)
         {
             selectedDevice = (Session["SelectedDevice"] as Device);
         }
         if (Session["DeviceConsole"] != null)
         {
             deviceConsole = (Session["DeviceConsole"] as DeviceConsole);
         }
     }
     else
     {
         console.Visible = false;
     }
     InitDevicePanel();
 }
Example #6
0
        // Select Device
        public void LinkButtonSelectDevice_Click(object sender, EventArgs e)
        {
            string device = (sender as LinkButton).Attributes[("data-device")];
            int    id     = Convert.ToInt32((sender as LinkButton).Attributes[("data-id")]);

            switch (device)
            {
            case "Tv":
                selectedDevice = db.Tvs.Find(id);
                deviceConsole  = new DeviceConsole(db.Tvs.Find(id));
                break;

            case "Fridge":
                selectedDevice = db.Fridges.Find(id);
                deviceConsole  = new DeviceConsole(db.Fridges.Find(id));
                break;

            case "Lamp":
                selectedDevice = db.Lamps.Find(id);
                deviceConsole  = new DeviceConsole(db.Lamps.Find(id));
                break;

            case "Cooker":
                selectedDevice = db.Cookers.Find(id);
                deviceConsole  = new DeviceConsole(db.Cookers.Find(id));
                break;

            case "Microwave":
                selectedDevice = db.Microwaves.Find(id);
                deviceConsole  = new DeviceConsole(db.Microwaves.Find(id));
                break;

            default:
                selectedDevice = null;
                deviceConsole  = null;
                break;
            }
            Session["SelectedDevice"] = selectedDevice;
            Session["DeviceConsole"]  = deviceConsole;
            RefreshPage();
        }
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        if (_deviceConsolePrefab != null)
        {
            DeviceConsole = GameObject.Instantiate(_deviceConsolePrefab);
            DeviceConsole.transform.SetParent(transform);
            DeviceConsole.SetVisible(false);

            AppConsoleCommands.Setup();
        }

        serverConfig = new ServerConfiguration();

        hudMain.gameObject.SetActive(true);
        hudStageAvatar.gameObject.SetActive(true);
        serverConfigScreen.gameObject.SetActive(false);
        serverConnectScreen.gameObject.SetActive(false);
    }
Example #8
0
        // Delete
        protected void LinkButtonDelete_Click(object sender, EventArgs e)
        {
            if (selectedDevice != null)
            {
                string device = (selectedDevice as Device).TypeDevice();
                int    id     = (selectedDevice as Device).Id;

                switch (device)
                {
                case "Tv":
                    Tv tv = db.Tvs.Find(id);
                    if (tv != null)
                    {
                        db.Tvs.Remove(tv);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(tv.Id, tv.TypeDevice());
                    }
                    break;

                case "Fridge":
                    Fridge fridge = db.Fridges.Find(id);
                    if (fridge != null)
                    {
                        db.Fridges.Remove(fridge);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(fridge.Id, fridge.TypeDevice());
                    }
                    break;

                case "Lamp":
                    Lamp lamp = db.Lamps.Find(id);
                    if (lamp != null)
                    {
                        db.Lamps.Remove(lamp);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(lamp.Id, lamp.TypeDevice());
                    }
                    break;

                case "Cooker":
                    Cooker cooker = db.Cookers.Find(id);
                    if (cooker != null)
                    {
                        db.Cookers.Remove(cooker);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(cooker.Id, cooker.TypeDevice());
                    }
                    break;

                case "Microwave":
                    Microwave microwave = db.Microwaves.Find(id);
                    if (microwave != null)
                    {
                        db.Microwaves.Remove(microwave);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(microwave.Id, microwave.TypeDevice());
                    }
                    break;

                default:
                    break;
                }
                Session["SelectedDevice"] = null;
                Session["DeviceConsole"]  = null;
                selectedDevice            = null;
                deviceConsole             = null;
                RefreshPage();
            }
        }
Example #9
0
 public Task <bool> DisableAsync() => DeviceConsole.DisableAsync(BuiltinDeviceId);