private async void RunCreateApplianceDialog()
        {
            var       customDialog    = new CustomDialog();
            Appliance newAppliance    = new Appliance();
            var       dialogViewModel = new CreateApplianceDialogViewModel(newAppliance, true,
                                                                           closeHandler => _dialogCoordinator.HideMetroDialogAsync(this, customDialog), async completionHandler =>
            {
                newAppliance = completionHandler.NewAppliance;
                // Save to database
                using (var ctx = new AssistantContext())
                {
                    newAppliance.CreationDate = DateTime.Now;
                    ctx.Appliances.Add(newAppliance);
                    ctx.SaveChanges();
                }

                // Add to local list
                Appliances.Add(newAppliance);

                await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
                await _dialogCoordinator.ShowMessageAsync(this, "Succes", $"Komponentet {newAppliance.Name} blev gemt.");
            });

            customDialog.Content = new CreateApplianceDialogView {
                DataContext = dialogViewModel
            };

            await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
        }
        public void RestoreState(IStateSnippet savedState)
        {
            var state = (PlayerControllerStateSnippet)savedState;

            _warmthLevelTimeoutCounter  = state.WarmthLevelTimeoutCounter;
            _wetnessLevelTimeoutCounter = state.WetnessLevelTimeoutCounter;
            _warmthLerpTarget           = state.WarmthLerpTarget;
            _warmthLerpCounter          = state.WarmthLerpCounter;
            _warmthLerpBase             = state.WarmthLerpBase;
            _sleepingCounter            = state.SleepingCounter;
            _sleepDurationGameHours     = state.SleepDurationGameHours;
            _sleepHealthCheckPeriod     = state.SleepHealthCheckPeriod;
            _sleepHealthChecksLeft      = state.SleepHealthChecksLeft;
            _sleepStartTime             = state.SleepStartTime;
            _fatigueValueAfterSleep     = state.FatigueValueAfterSleep;

            _wetnessController.RestoreState((WetnessControllerSnippet)state.ChildStates["WetnessController"]);

            Clothes.Clear();

            foreach (var clothesItem in state.Clothes)
            {
                var newId = state.InventoryData.ItemsMapping.ContainsKey(clothesItem) ? state.InventoryData.ItemsMapping[clothesItem] : (Guid?)null;
                var item  = newId.HasValue ? _gc.Inventory.Items.FirstOrDefault(x => x.Id == newId.Value) : null;

                if (item as ClothesItemBase != null)
                {
                    Clothes.Add((ClothesItemBase)item);
                }
            }

            Appliances.Clear();

            foreach (var applianceItem in state.Appliances)
            {
                var newId = state.InventoryData.ItemsMapping.ContainsKey(applianceItem.ItemId) ? state.InventoryData.ItemsMapping[applianceItem.ItemId] : (Guid?)null;
                var item  = newId.HasValue ? _gc.Inventory.Items.FirstOrDefault(x => x.Id == newId.Value) : null;

                if (item as InventoryMedicalItemBase != null)
                {
                    Appliances.Add(new MedicalBodyAppliance {
                        BodyPart = applianceItem.BodyPart,
                        Item     = (InventoryMedicalItemBase)item
                    });
                }
            }
        }
Exemple #3
0
 public House()
 {
     Appliances.Add(new WashingMachine()
     {
         Name = "Clothes Washer",
         Description = "A middle of the range LG washer.",
         Power = 500.0f,
         UsePerYear = 52.0f,
         StarRating = 1.0f
     });
     Appliances.Add(new Television()
     {
         Name = "Television",
         Description = "42inch Samsung television.",
         Power = 58.0f,
         UsePerYear = 2*200.0f,
         StarRating = 1.0f
     });
 }
Exemple #4
0
        public static void ShowMenu()
        {
            string buf;
            bool   check = false;

            while (true)
            {
                PrintMenuTemplate();
                buf = Console.ReadLine();
                Console.Clear();
                switch (buf)
                {
                case "1":
                    int doorNum;
                    check = false;
                    Console.WriteLine("Please choose the (1)Rectangle or (2)Round doors: ");
                    while (!check)
                    {
                        if (int.TryParse(Console.ReadLine(), out doorNum))
                        {
                            switch (doorNum)
                            {
                            case 1:
                                CheckParams(out int heigth, out int width);
                                Console.WriteLine("Enter door model:");
                                Program.Doors.Add(new RectangleDoor(heigth, width, Console.ReadLine()));
                                check = true;
                                break;

                            case 2:
                                CheckParams(out int diametr);
                                Console.WriteLine("Enter door model:");
                                Program.Doors.Add(new RoundDoor(diametr, Console.ReadLine()));
                                check = true;
                                break;

                            default:
                                Console.WriteLine("Enter correct number!");
                                break;
                            }
                        }
                    }
                    break;

                case "2":
                    check = false;
                    while (!check)
                    {
                        Console.WriteLine("Please enter applience type(Fridge ,Cupboard ,Barrel , Ball ): ");
                        switch (Console.ReadLine().ToLower())
                        {
                        case "fridge":
                            CheckParams(out int frHeigth, out int frWidth, out int frLength);
                            Console.WriteLine("Enter item name:");
                            Appliances.Add(new Fridge(frHeigth, frWidth, frLength, Console.ReadLine()));
                            check = true;
                            break;

                        case "cupboard":
                            CheckParams(out int cbHeigth, out int cbWidth, out int cbLength);
                            Console.WriteLine("Enter item name:");
                            Appliances.Add(new Cupboard(cbHeigth, cbWidth, cbLength, Console.ReadLine()));
                            check = true;
                            break;

                        case "barrel":
                            CheckParams(out int brHeigth, out int brWidth);
                            Console.WriteLine("Enter item name:");
                            Appliances.Add(new Barrel(brHeigth, brWidth, Console.ReadLine()));
                            check = true;
                            break;

                        case "ball":
                            CheckParams(out int diametr);
                            Console.WriteLine("Enter item name:");
                            Appliances.Add(new Ball(diametr, Console.ReadLine()));
                            check = true;
                            break;

                        default:
                            Console.WriteLine("Wrong type, try again...");
                            break;
                        }
                    }
                    break;

                case "3":
                    foreach (Appliance item in Appliances)
                    {
                        foreach (Door door in Doors)
                        {
                            item.PrintStatus(item, door);
                        }
                    }
                    break;


                case "4":
                    Environment.Exit(0);
                    return;

                default:
                    Console.WriteLine("Please enter only existing menu option numbers!");
                    break;
                }
            }
        }