private void TestAndCreate(Movie movie) { try { OwnProjections.Add(movie.Name, new Projection(this, movie)); IO_Handler.SuccessMessage($"New projection \"{movie.Name}\" has been added"); } catch (Exception e) { throw e; } }
//In Main: void NewCinemaMenu() { MenuTitle newCinemaMenu = "New Cinema Menu"; MenuItem[] newCinemaMenuItems = { }; ShowMenu(newCinemaMenu, newCinemaMenuItems); string cinemaName = IO_Handler.EnterString("Please, enter the name of the new cinema: "); if (ObjectContainer.CDB.Contains(ObjectContainer.CDB.Find(i => i.Name == cinemaName.ToUpper()))) { throw new Exception("This Cinema has already exists!"); } byte auditoriumCount = IO_Handler.EnterByte("Please, enter the number of auditoriums: "); new Cinema(cinemaName, auditoriumCount); CinemasMenuMethods[cinemaCounter++] = InCinemaMenu; IO_Handler.SuccessMessage($"New Cinema: \"{cinemaName}\" has been created with {auditoriumCount} Auditorium{(auditoriumCount>1?"s":"")} in it."); Thread.Sleep(sleepTime); }
} //Not implemented in PresentationLayer, so become obsolete: private Projection ReturnProjectionByName() { #region debug message #if DEBUG IO_Handler.LogItsCaller(); #endif #endregion string projectionName = ""; while (!OwnProjections.ContainsKey(projectionName)) { projectionName = IO_Handler.EnterString("Name of the movie you are looking for: ").ToUpper(); if (!OwnProjections.ContainsKey(projectionName)) { IO_Handler.ErrorMessage($"There is no such Projection in this Auditorium No#{Id} with the given name!"); Console.WriteLine("Please, pick one from the following:"); IO_Handler.PrintCollection(OwnProjections.Keys); } } Projection Result = OwnProjections[projectionName]; IO_Handler.SuccessMessage("Projection found!"); return(Result); } //Not implemented in PresentationLayer, so become obsolete:
bool ControlMenu(MenuItem[] MenuItems) { #region debug message #if DEBUG IO_Handler.LogItsCaller(); #endif #endregion bool invalid = true; while (invalid) { ConsoleKey ck = Console.ReadKey(false).Key; switch (ck) { case ConsoleKey.UpArrow: if (--index == -1) { index = MenuItems.Length - 1; } goto case ConsoleKey.Clear; case ConsoleKey.DownArrow: if (++index == MenuItems.Length) { index = 0; } goto case ConsoleKey.Clear; case ConsoleKey.PageDown: index = MenuItems.Length - 1; goto case ConsoleKey.Clear; case ConsoleKey.PageUp: index = 0; goto case ConsoleKey.Clear; case ConsoleKey.Enter: Console.Clear(); try { StackFrame sf = new StackFrame(2); string caller_lvl2 = sf.GetMethod().Name; if (caller_lvl2.Equals("InCinemaMenu")) { try { activeAuditorium = activeCinema.OwnAuditoriums[(byte)(index + 1)]; #region DEBUG #if DEBUG IO_Handler.SuccessMessage("ACTIVE AUDITORIUM GOT SET NOW!"); Thread.Sleep(800); #endif #endregion } catch (Exception e) { IO_Handler.ErrorMessage($"active auditorium not set:\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } } if (caller_lvl2.Equals("InProjectionMenu")) { try { activeProjection = activeAuditorium.OwnProjections.Skip(index).First().Value; } catch (Exception e) { IO_Handler.ErrorMessage($"active projection not set:\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } } GetThisMenuMethods()[index](); } catch (Exception e) { IO_Handler.ErrorMessage($"Error while opening this menu!\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } goto case ConsoleKey.Clear; case ConsoleKey.Escape: index = 0; return(false); case ConsoleKey.Clear: return(true); default: invalid = true; break; } } return(true); }