private void keyPressedHandler(string keyPressed, Keys key) { if (Showing) { Console.Console console = Console.Console.Instance; if (console.History.Count > 0) { bool doHistory = false; if (key == Keys.Down) { doHistory = true; if (this.historyIndex == -1) { this.historyIndex = 0; } else { this.historyIndex++; } } else if (key == Keys.Up) { doHistory = true; if (this.historyIndex == -1) { this.historyIndex = console.History.Count - 1; } else { this.historyIndex--; } } if (doHistory) { if (this.historyIndex >= console.History.Count) { this.historyIndex = 0; } else if (this.historyIndex < 0) { this.historyIndex = console.History.Count - 1; } ConsoleInputView.Text = console.History[this.historyIndex]; ConsoleInputView.SetCursorPos(ConsoleInputView.Text.Length, 0); } } } }
/// <summary> /// Populates the doctors table. /// </summary> public static void Doctors() { // Delete all the doctors unitOfWork.Doctors.Entities.ToList().ForEach(doctor => { unitOfWork.Accounts.Remove(doctor.Account); unitOfWork.Addresses.Remove(doctor.Person.Address); unitOfWork.Addresses.Remove(doctor.Address); unitOfWork.Persons.Remove(doctor.Person); unitOfWork.Doctors.Remove(doctor); }); // Add all the doctors unitOfWork.Doctors.Add(new Doctor { Person = new Person { FirstName = "Camelia", LastName = "Berea", BirthDate = new DateTime(1975, 2, 7), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "2750207421129", PhoneNo = "+(40) 767 139 215", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("București"), City = "București", Street = "Căminului", StreetNo = "26", ZipCode = "139423" }, }, Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("București"), City = "București", Street = "Șoseaua Iancului", StreetNo = "10", ZipCode = "136920" }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("berea123") }, Active = true }); VivusConsole.WriteLine($"Doctors: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the person statuses table. /// </summary> public static void PersonStatuses() { // Delete all the person statuses unitOfWork.PersonStatuses.Entities.ToList().ForEach(s => unitOfWork.PersonStatuses.Remove(s)); // Add all the person statuses unitOfWork.PersonStatuses.Add(new PersonStatus { Type = "Alive" }); unitOfWork.PersonStatuses.Add(new PersonStatus { Type = "Dead" }); VivusConsole.WriteLine($"Person statuses: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the RHs table. /// </summary> public static void RHs() { // Delete all the RHs unitOfWork.RHs.Entities.ToList().ForEach(rh => unitOfWork.RHs.Remove(rh)); // Add all the RHs unitOfWork.RHs.Add(new RH { Type = "Positive" }); unitOfWork.RHs.Add(new RH { Type = "Negative" }); VivusConsole.WriteLine($"RHs: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the request priorities table. /// </summary> public static void RequestPriorities() { // Delete all the request priorities unitOfWork.RequestPriorities.Entities.ToList().ForEach(p => unitOfWork.RequestPriorities.Remove(p)); // Add all the request priorities unitOfWork.RequestPriorities.Add(new RequestPriority { Type = "Low" }); unitOfWork.RequestPriorities.Add(new RequestPriority { Type = "Medium" }); unitOfWork.RequestPriorities.Add(new RequestPriority { Type = "High" }); VivusConsole.WriteLine($"Request priorities: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the genders table. /// </summary> public static void Genders() { // Delete all the genders unitOfWork.Genders.Entities.ToList().ForEach(g => unitOfWork.Genders.Remove(g)); // Add all the genders unitOfWork.Genders.Add(new Gender { Type = "Male" }); unitOfWork.Genders.Add(new Gender { Type = "Female" }); unitOfWork.Genders.Add(new Gender { Type = "Not specified" }); VivusConsole.WriteLine($"Genders: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the administrators table. /// </summary> public static void Administrators() { // Delete all the administrators unitOfWork.Administrators.Entities.ToList().ForEach(admin => { unitOfWork.Accounts.Remove(admin.Account); unitOfWork.Addresses.Remove(admin.Person.Address); unitOfWork.Persons.Remove(admin.Person); unitOfWork.Administrators.Remove(admin); }); // Add all the administrators unitOfWork.Administrators.Add(new Administrator { Person = new Person { FirstName = "Mihai", LastName = "Nitu", BirthDate = new DateTime(1979, 7, 20), Gender = unitOfWork.Genders.Entities.First(g => g.Type == "Male"), Nin = "1790720425218", PhoneNo = "+(40) 727 109 531", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "București"), City = "București", Street = "Remus", StreetNo = "7", ZipCode = "030167" }, }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("nitu1234") }, IsOwner = true, Active = true }); VivusConsole.WriteLine($"Admnistrators: { unitOfWork.Complete() }"); }
/// <summary> /// Starts the console application. /// </summary> /// <param name="args">The console parameters.</param> private static void Main(string[] args) { //Populate.Counties(); //Populate.Genders(); //Populate.BloodContainerTypes(); //Populate.BloodTypes(); //Populate.RHs(); //Populate.PersonStatuses(); //Populate.RequestPriorities(); //Populate.Administrators(); //Populate.DonationCenters(); //Populate.DonationCentersPersonnel(); //Populate.Doctors(); //Populate.Donors(); //Populate.Patients(); VivusConsole.WriteLine("Everything is already generated! Be careful if you wanna play with the fire. c;"); VivusConsole.WriteLine("Press any key to continue...", false); VivusConsole.ReadKey(); }
/// <summary> /// Populates the donation centers personnel table. /// </summary> public static void DonationCentersPersonnel() { // Delete all the donation centers personnel unitOfWork.DCPersonnel.Entities.ToList().ForEach(personnel => { unitOfWork.Accounts.Remove(personnel.Account); unitOfWork.Addresses.Remove(personnel.Person.Address); unitOfWork.Persons.Remove(personnel.Person); unitOfWork.DCPersonnel.Remove(personnel); }); // Add all the donation centers personnel unitOfWork.DCPersonnel.Add(new DCPersonnel { Person = new Person { FirstName = "Daniel", LastName = "Moldovan", BirthDate = new DateTime(1980, 11, 4), Gender = unitOfWork.Genders.Entities.First(g => g.Type == "Male"), Nin = "1801104123318", PhoneNo = "+(40) 722 129 315", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Cluj"), City = "Cluj-Napoca", Street = "Slatina", StreetNo = "2", ZipCode = "400000" }, }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("moldovan") }, Active = true }); VivusConsole.WriteLine($"Donation Centers Personnel: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the blood types table. /// </summary> public static void BloodTypes() { // Delete all the blood types unitOfWork.BloodTypes.Entities.ToList().ForEach(t => unitOfWork.BloodTypes.Remove(t)); // Add all the blood types unitOfWork.BloodTypes.Add(new BloodType { Type = "A" }); unitOfWork.BloodTypes.Add(new BloodType { Type = "B" }); unitOfWork.BloodTypes.Add(new BloodType { Type = "AB" }); unitOfWork.BloodTypes.Add(new BloodType { Type = "O" }); VivusConsole.WriteLine($"Blood types: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the blood container types table. /// </summary> public static void BloodContainerTypes() { // Delete all the blood container types unitOfWork.BloodContainerTypes.Entities.ToList().ForEach(t => unitOfWork.BloodContainerTypes.Remove(t)); // Add all the blood container types unitOfWork.BloodContainerTypes.Add(new BloodContainerType { Type = "Thrombocytes" }); unitOfWork.BloodContainerTypes.Add(new BloodContainerType { Type = "Red cells" }); unitOfWork.BloodContainerTypes.Add(new BloodContainerType { Type = "Plasma" }); unitOfWork.BloodContainerTypes.Add(new BloodContainerType { Type = "Blood" }); VivusConsole.WriteLine($"Blood container types: { unitOfWork.Complete() }"); }
public VirtualStream(Console.Console console) { _console = console; _buffer = new MemoryStream(); }
public VirtualConsole(Session session, Console.Console console) { _writer = new VirtualWriter(console); _session = session; _console = console; }
public VirtualWriter(Console.Console console) { _console = console; }
/// <summary> /// Populates the patients table. /// </summary> public static void Patients() { // Delete all the patients unitOfWork.Patients.Entities.ToList().ForEach(patient => { unitOfWork.Addresses.Remove(patient.Person.Address); unitOfWork.Persons.Remove(patient.Person); unitOfWork.Patients.Remove(patient); }); // Add all the patients unitOfWork.Patients.Add(new Patient { Person = new Person { FirstName = "Magda", LastName = "Petrescu", BirthDate = new DateTime(1988, 7, 2), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "2880702243246", PhoneNo = "+(40) 743 425 761", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Maramureș"), City = "Baia Mare", Street = "Melodiei", StreetNo = "3", ZipCode = "4000000" } }, PersonStatus = (unitOfWork.PersonStatuses as PersonStatusesRepository).PersonStatus("Alive"), BloodType = (unitOfWork.BloodTypes as BloodTypesRepository).BloodType("AB"), RH = (unitOfWork.RHs as RhsRepository).RH("Positive") }); unitOfWork.Patients.Add(new Patient { Person = new Person { FirstName = "Vlad", LastName = "Dumitru", BirthDate = new DateTime(2002, 11, 15), Gender = (unitOfWork.Genders as GendersRepository).Gender("Male"), Nin = "5021115384320", PhoneNo = "+(40) 752 002 472", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Vâlcea"), City = "Râmnicu Vâlcea", Street = "Știrbei Vodă", StreetNo = "3", ZipCode = "2400184" } }, PersonStatus = (unitOfWork.PersonStatuses as PersonStatusesRepository).PersonStatus("Alive"), BloodType = (unitOfWork.BloodTypes as BloodTypesRepository).BloodType("A"), RH = (unitOfWork.RHs as RhsRepository).RH("Negative") }); unitOfWork.Patients.Add(new Patient { Person = new Person { FirstName = "Aurel", LastName = "Nicolescu", BirthDate = new DateTime(1992, 3, 1), Gender = (unitOfWork.Genders as GendersRepository).Gender("Male"), Nin = "1920301056591", PhoneNo = "+(40) 736 959 637", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Bihor"), City = "Oradea", Street = "Carașului", StreetNo = "26", ZipCode = null } }, PersonStatus = (unitOfWork.PersonStatuses as PersonStatusesRepository).PersonStatus("Dead"), BloodType = (unitOfWork.BloodTypes as BloodTypesRepository).BloodType("O"), RH = (unitOfWork.RHs as RhsRepository).RH("Negative") }); unitOfWork.Patients.Add(new Patient { Person = new Person { FirstName = "Sergiu", LastName = "Ionescu", BirthDate = new DateTime(1986, 4, 10), Gender = (unitOfWork.Genders as GendersRepository).Gender("Male"), Nin = "1860410173657", PhoneNo = "+(40) 769 161 432", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Galați"), City = "Tecuci", Street = "Focșani", StreetNo = "25", ZipCode = "805300" } }, PersonStatus = (unitOfWork.PersonStatuses as PersonStatusesRepository).PersonStatus("Alive"), BloodType = (unitOfWork.BloodTypes as BloodTypesRepository).BloodType("B"), RH = (unitOfWork.RHs as RhsRepository).RH("Negative") }); unitOfWork.Patients.Add(new Patient { Person = new Person { FirstName = "Oana", LastName = "Șerban", BirthDate = new DateTime(1971, 10, 6), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "2711006227892", PhoneNo = "+(40) 729 973 344", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Iași"), City = "Iași", Street = "Brândușa", StreetNo = "35", ZipCode = null } }, PersonStatus = (unitOfWork.PersonStatuses as PersonStatusesRepository).PersonStatus("Alive"), BloodType = (unitOfWork.BloodTypes as BloodTypesRepository).BloodType("O"), RH = (unitOfWork.RHs as RhsRepository).RH("Positive") }); VivusConsole.WriteLine($"Patients: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the donors table. /// </summary> public static void Donors() { // Delete all the donors unitOfWork.Donors.Entities.ToList().ForEach(donor => { unitOfWork.Accounts.Remove(donor.Account); unitOfWork.Addresses.Remove(donor.Person.Address); unitOfWork.Addresses.Remove(donor.ResidenceAddress); unitOfWork.Persons.Remove(donor.Person); unitOfWork.Donors.Remove(donor); }); // Add all the donors unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Adina", LastName = "Huțanu", BirthDate = new DateTime(1995, 9, 10), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "2950910121090", PhoneNo = "+(40) 766 218 996", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Cluj"), City = "Cluj-Napoca", Street = "Colibița", StreetNo = "10", ZipCode = "4000000" }, }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("hutanu12") } }); unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Valeria", LastName = "Constantinescu", BirthDate = new DateTime(2006, 7, 3), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "6060703322149", PhoneNo = "+(40) 764 551 811", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Sibiu"), City = "Cisnădie", Street = "Vișinilor", StreetNo = "18", ZipCode = "555300" }, }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("constantinescu") }, DonationCenter = unitOfWork.DonationCenters.Entities.Single(dc => dc.Name == "Spitalul Clinic Județean de Urgență Cluj-Napoca"), BloodType = unitOfWork.BloodTypes.Entities.Single(bt => bt.Type == "B"), RH = unitOfWork.RHs.Entities.Single(rh => rh.Type == "Positive"), }); unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Laurențiu", LastName = "Funar", BirthDate = new DateTime(1993, 3, 20), Gender = (unitOfWork.Genders as GendersRepository).Gender("Not specified"), Nin = "1930320086840", PhoneNo = "+(40) 796 569 360", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Brașov"), City = "Făgăraș", Street = "Teiului", StreetNo = "21" } }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("funar123") }, DonationCenter = unitOfWork.DonationCenters.Entities.Single(dc => dc.Name == "Spitalul Județean de Urgență Brașov"), BloodType = unitOfWork.BloodTypes.Entities.Single(bt => bt.Type == "AB"), RH = unitOfWork.RHs.Entities.Single(rh => rh.Type == "Negative"), }); unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Zsolt", LastName = "Meggyesfalvi", BirthDate = new DateTime(1995, 2, 5), Gender = (unitOfWork.Genders as GendersRepository).Gender("Not specified"), Nin = "1950205265074", PhoneNo = "+(40) 759 397 104", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Mureș"), City = "Târgu Mureș", Street = "Grădinarilor", StreetNo = "11B", ZipCode = "540013" } }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("meggyesfalvi") }, DonationCenter = unitOfWork.DonationCenters.Entities.Single(dc => dc.Name == "Spitalul Clinic Județean de Urgență Cluj-Napoca"), BloodType = unitOfWork.BloodTypes.Entities.Single(bt => bt.Type == "A"), RH = unitOfWork.RHs.Entities.Single(rh => rh.Type == "Negative"), }); unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Cezar", LastName = "Ionesco", BirthDate = new DateTime(1984, 10, 10), Gender = (unitOfWork.Genders as GendersRepository).Gender("Male"), Nin = "1841010227210", PhoneNo = "+(40) 741 366 096", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Iași"), City = "Pașcani", Street = "Cosminului", StreetNo = "2", ZipCode = "705203" } }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("ionesco1") }, DonationCenter = unitOfWork.DonationCenters.Entities.Single(dc => dc.Name == "Spitalul Clinic Județean de Urgență Târgu Mureș"), BloodType = unitOfWork.BloodTypes.Entities.Single(bt => bt.Type == "AB"), RH = unitOfWork.RHs.Entities.Single(rh => rh.Type == "Negative"), }); unitOfWork.Donors.Add(new Donor { Person = new Person { FirstName = "Tamara", LastName = "Kerekes", BirthDate = new DateTime(1987, 5, 27), Gender = (unitOfWork.Genders as GendersRepository).Gender("Female"), Nin = "2870527307703", PhoneNo = "+(40) 762 817 520", Address = new Address { County = (unitOfWork.Counties as CountiesRepository).County("Satu Mare"), City = "Satu Mare", Street = "Trandafirilor", StreetNo = "110" } }, Account = new Account { Email = "*****@*****.**", Password = BCrypt.HashPassword("kerekes1") }, DonationCenter = unitOfWork.DonationCenters.Entities.Single(dc => dc.Name == "Spitalul Clinic Județean de Urgență Cluj-Napoca"), BloodType = unitOfWork.BloodTypes.Entities.Single(bt => bt.Type == "O"), RH = unitOfWork.RHs.Entities.Single(rh => rh.Type == "Positive"), }); VivusConsole.WriteLine($"Donors: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the counties table. /// </summary> public static void Counties() { // Delete all the counties unitOfWork.Counties.Entities.ToList().ForEach(c => unitOfWork.Counties.Remove(c)); // Add all the counties unitOfWork.Counties.Add(new County { Name = "Alba" }); unitOfWork.Counties.Add(new County { Name = "Arad" }); unitOfWork.Counties.Add(new County { Name = "Argeș" }); unitOfWork.Counties.Add(new County { Name = "Bacău" }); unitOfWork.Counties.Add(new County { Name = "Bihor" }); unitOfWork.Counties.Add(new County { Name = "Bistrița-Năsăud" }); unitOfWork.Counties.Add(new County { Name = "Botoșani" }); unitOfWork.Counties.Add(new County { Name = "Brașov" }); unitOfWork.Counties.Add(new County { Name = "Brăila" }); unitOfWork.Counties.Add(new County { Name = "București" }); unitOfWork.Counties.Add(new County { Name = "Buzău" }); unitOfWork.Counties.Add(new County { Name = "Caraș-Severin" }); unitOfWork.Counties.Add(new County { Name = "Călărași" }); unitOfWork.Counties.Add(new County { Name = "Cluj" }); unitOfWork.Counties.Add(new County { Name = "Constanța" }); unitOfWork.Counties.Add(new County { Name = "Covasna" }); unitOfWork.Counties.Add(new County { Name = "Dâmbovița" }); unitOfWork.Counties.Add(new County { Name = "Dolj" }); unitOfWork.Counties.Add(new County { Name = "Galați" }); unitOfWork.Counties.Add(new County { Name = "Giurgiu" }); unitOfWork.Counties.Add(new County { Name = "Gorj" }); unitOfWork.Counties.Add(new County { Name = "Harghita" }); unitOfWork.Counties.Add(new County { Name = "Hunedoara" }); unitOfWork.Counties.Add(new County { Name = "Ialomița" }); unitOfWork.Counties.Add(new County { Name = "Iași" }); unitOfWork.Counties.Add(new County { Name = "Ilfov" }); unitOfWork.Counties.Add(new County { Name = "Maramureș" }); unitOfWork.Counties.Add(new County { Name = "Mehedinți" }); unitOfWork.Counties.Add(new County { Name = "Mureș" }); unitOfWork.Counties.Add(new County { Name = "Neamț" }); unitOfWork.Counties.Add(new County { Name = "Olt" }); unitOfWork.Counties.Add(new County { Name = "Prahova" }); unitOfWork.Counties.Add(new County { Name = "Satu Mare" }); unitOfWork.Counties.Add(new County { Name = "Sălaj" }); unitOfWork.Counties.Add(new County { Name = "Sibiu" }); unitOfWork.Counties.Add(new County { Name = "Suceava" }); unitOfWork.Counties.Add(new County { Name = "Teleorman" }); unitOfWork.Counties.Add(new County { Name = "Timiș" }); unitOfWork.Counties.Add(new County { Name = "Tulcea" }); unitOfWork.Counties.Add(new County { Name = "Vaslui" }); unitOfWork.Counties.Add(new County { Name = "Vâlcea" }); unitOfWork.Counties.Add(new County { Name = "Vrancea" }); VivusConsole.WriteLine($"Counties: { unitOfWork.Complete() }"); }
/// <summary> /// Populates the dontaion centers table. /// </summary> public static void DonationCenters() { // Delete all the donation centers unitOfWork.DonationCenters.Entities.ToList().ForEach(dc => { unitOfWork.Addresses.Remove(dc.Address); unitOfWork.DonationCenters.Remove(dc); }); // Add all the donation centers unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Clinic Județean de Urgență Cluj-Napoca", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Cluj"), City = "Cluj-Napoca", Street = "Clinicilor", StreetNo = "3-5", ZipCode = "400000" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Universitar de Urgență București", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "București"), City = "București", Street = "Splaiul Independenței", StreetNo = "169", ZipCode = "050098" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Județean de Urgență Alba Iulia", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Alba"), City = "Alba Iulia", Street = "Revoluției 1989", StreetNo = "23", ZipCode = "510007" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Județean de Urgență Brașov", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Brașov"), City = "Brașov", Street = "Calea București", StreetNo = "25", ZipCode = "500326" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Clinic Județean de Urgență Sibiu", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Sibiu"), City = "Sibiu", Street = "Corneliu Coposu", StreetNo = "2-4", ZipCode = "550245" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Județean de Urgență Târgu Jiu", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Gorj"), City = "Târgu Jiu", Street = "Tudor Vladimirescu", StreetNo = "17", ZipCode = "210132" } }); unitOfWork.DonationCenters.Add(new DonationCenter { Name = "Spitalul Clinic Județean de Urgență Târgu Mureș", Address = new Address { County = unitOfWork.Counties.Entities.First(c => c.Name == "Mureș"), City = "Târgu Mureș", Street = "Gheorghe Marinescu", StreetNo = "50", ZipCode = "540136" } }); VivusConsole.WriteLine($"Donation centers: { unitOfWork.Complete() }"); }
protected override void LoadContent() { this.MapContent = new ContentManager(this.Services); this.MapContent.RootDirectory = this.Content.RootDirectory; GeeUIMain.Font = this.Content.Load<SpriteFont>(this.Font); if (this.firstLoadContentCall) { this.firstLoadContentCall = false; if (!Directory.Exists(this.MapDirectory)) Directory.CreateDirectory(this.MapDirectory); string challengeDirectory = Path.Combine(this.MapDirectory, "Challenge"); if (!Directory.Exists(challengeDirectory)) Directory.CreateDirectory(challengeDirectory); #if VR if (this.VR) { this.vrLeftMesh.Load(this, Ovr.Eye.Left, this.vrLeftFov); this.vrRightMesh.Load(this, Ovr.Eye.Right, this.vrRightFov); new CommandBinding(this.ReloadedContent, (Action)this.vrLeftMesh.Reload); new CommandBinding(this.ReloadedContent, (Action)this.vrRightMesh.Reload); this.reallocateVrTargets(); this.vrCamera = new Camera(); this.AddComponent(this.vrCamera); } #endif this.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Immediate; this.GeeUI = new GeeUIMain(); this.AddComponent(GeeUI); this.ConsoleUI = new ConsoleUI(); this.AddComponent(ConsoleUI); this.Console = new Console.Console(); this.AddComponent(Console); Lemma.Console.Console.BindType(null, this); Lemma.Console.Console.BindType(null, Console); // Initialize Wwise AkGlobalSoundEngineInitializer initializer = new AkGlobalSoundEngineInitializer(Path.Combine(this.Content.RootDirectory, "Wwise")); this.AddComponent(initializer); this.Listener = new AkListener(); this.Listener.Add(new Binding<Vector3>(this.Listener.Position, this.Camera.Position)); this.Listener.Add(new Binding<Vector3>(this.Listener.Forward, this.Camera.Forward)); this.Listener.Add(new Binding<Vector3>(this.Listener.Up, this.Camera.Up)); this.AddComponent(this.Listener); // Create the renderer. this.LightingManager = new LightingManager(); this.AddComponent(this.LightingManager); this.Renderer = new Renderer(this, true, true, true, true, true); this.AddComponent(this.Renderer); this.Renderer.ReallocateBuffers(this.ScreenSize); this.renderParameters = new RenderParameters { Camera = this.Camera, IsMainRender = true }; // Load strings this.Strings.Load(Path.Combine(this.Content.RootDirectory, "Strings.xlsx")); this.UI = new UIRenderer(); this.UI.GeeUI = this.GeeUI; this.AddComponent(this.UI); PCInput input = new PCInput(); this.AddComponent(input); Lemma.Console.Console.BindType(null, input); Lemma.Console.Console.BindType(null, UI); Lemma.Console.Console.BindType(null, Renderer); Lemma.Console.Console.BindType(null, LightingManager); input.Add(new CommandBinding(input.GetChord(new PCInput.Chord { Modifier = Keys.LeftAlt, Key = Keys.S }), delegate() { // High-resolution screenshot bool originalModelsVisible = Editor.EditorModelsVisible; Editor.EditorModelsVisible.Value = false; Screenshot s = new Screenshot(); this.AddComponent(s); s.Take(new Point(4096, 2304), delegate() { string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string path; int i = 0; do { path = Path.Combine(desktop, string.Format("lemma-screen{0}.png", i)); i++; } while (File.Exists(path)); Screenshot.SavePng(s.Buffer, path); Editor.EditorModelsVisible.Value = originalModelsVisible; s.Delete.Execute(); }); })); this.performanceMonitor = new ListContainer(); this.performanceMonitor.Add(new Binding<Vector2, Point>(performanceMonitor.Position, x => new Vector2(x.X, 0), this.ScreenSize)); this.performanceMonitor.AnchorPoint.Value = new Vector2(1, 0); this.performanceMonitor.Visible.Value = false; this.performanceMonitor.Name.Value = "PerformanceMonitor"; this.UI.Root.Children.Add(this.performanceMonitor); Action<string, Property<double>> addTimer = delegate(string label, Property<double> property) { TextElement text = new TextElement(); text.FontFile.Value = this.Font; text.Add(new Binding<string, double>(text.Text, x => label + ": " + (x * 1000.0).ToString("F") + "ms", property)); this.performanceMonitor.Children.Add(text); }; Action<string, Property<int>> addCounter = delegate(string label, Property<int> property) { TextElement text = new TextElement(); text.FontFile.Value = this.Font; text.Add(new Binding<string, int>(text.Text, x => label + ": " + x.ToString(), property)); this.performanceMonitor.Children.Add(text); }; TextElement frameRateText = new TextElement(); frameRateText.FontFile.Value = this.Font; frameRateText.Add(new Binding<string, float>(frameRateText.Text, x => "FPS: " + x.ToString("0"), this.frameRate)); this.performanceMonitor.Children.Add(frameRateText); addTimer("Physics", this.physicsTime); addTimer("Update", this.updateTime); addTimer("Render", this.renderTime); addCounter("Draw calls", this.drawCalls); addCounter("Triangles", this.triangles); addCounter("Working set", this.workingSet); Lemma.Console.Console.AddConCommand(new ConCommand("perf", "Toggle the performance monitor", delegate(ConCommand.ArgCollection args) { this.performanceMonitor.Visible.Value = !this.performanceMonitor.Visible; })); try { IEnumerable<string> globalStaticScripts = Directory.GetFiles(Path.Combine(this.Content.RootDirectory, "GlobalStaticScripts"), "*", SearchOption.AllDirectories).Select(x => Path.Combine("..\\GlobalStaticScripts", Path.GetFileNameWithoutExtension(x))); foreach (string scriptName in globalStaticScripts) this.executeStaticScript(scriptName); } catch (IOException) { } this.UIFactory = new UIFactory(); this.AddComponent(this.UIFactory); this.AddComponent(this.Menu); // Have to do this here so the menu's Awake can use all our loaded stuff this.Spawner = new Spawner(); this.AddComponent(this.Spawner); this.UI.IsMouseVisible.Value = true; AKRESULT akresult = AkBankLoader.LoadBank("SFX_Bank_01.bnk"); if (akresult != AKRESULT.AK_Success) Log.d(string.Format("Failed to load main sound bank: {0}", akresult)); #if ANALYTICS this.SessionRecorder = new Session.Recorder(this); this.SessionRecorder.Add("Position", delegate() { Entity p = PlayerFactory.Instance; if (p != null && p.Active) return p.Get<Transform>().Position; else return Vector3.Zero; }); this.SessionRecorder.Add("Health", delegate() { Entity p = PlayerFactory.Instance; if (p != null && p.Active) return p.Get<Player>().Health; else return 0.0f; }); this.SessionRecorder.Add("Framerate", delegate() { return this.frameRate; }); this.SessionRecorder.Add("WorkingSet", delegate() { return this.workingSet; }); this.AddComponent(this.SessionRecorder); this.SessionRecorder.Add(new Binding<bool, Config.RecordAnalytics>(this.SessionRecorder.EnableUpload, x => x == Config.RecordAnalytics.On, this.Settings.Analytics)); #endif this.DefaultLighting(); new SetBinding<float>(this.Settings.SoundEffectVolume, delegate(float value) { AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.VOLUME_SFX, MathHelper.Clamp(value, 0.0f, 1.0f)); }); new SetBinding<float>(this.Settings.MusicVolume, delegate(float value) { AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.VOLUME_MUSIC, MathHelper.Clamp(value, 0.0f, 1.0f)); }); new TwoWayBinding<LightingManager.DynamicShadowSetting>(this.Settings.DynamicShadows, this.LightingManager.DynamicShadows); new TwoWayBinding<float>(this.Settings.MotionBlurAmount, this.Renderer.MotionBlurAmount); new TwoWayBinding<float>(this.Settings.Gamma, this.Renderer.Gamma); new TwoWayBinding<bool>(this.Settings.Bloom, this.Renderer.EnableBloom); new TwoWayBinding<bool>(this.Settings.SSAO, this.Renderer.EnableSSAO); new Binding<float>(this.Camera.FieldOfView, this.Settings.FieldOfView); foreach (string file in Directory.GetFiles(this.MapDirectory, "*.xlsx", SearchOption.TopDirectoryOnly)) this.Strings.Load(file); new Binding<string, Config.Lang>(this.Strings.Language, x => x.ToString(), this.Settings.Language); new NotifyBinding(this.SaveSettings, this.Settings.Language); new CommandBinding(this.MapLoaded, delegate() { this.Renderer.BlurAmount.Value = 0.0f; this.Renderer.Tint.Value = new Vector3(1.0f); }); #if VR if (this.VR) { Action loadVrEffect = delegate() { this.vrEffect = this.Content.Load<Effect>("Effects\\Oculus"); }; loadVrEffect(); new CommandBinding(this.ReloadedContent, loadVrEffect); this.UI.Add(new Binding<Point>(this.UI.RenderTargetSize, this.ScreenSize)); this.VRUI = new Lemma.Components.ModelNonPostProcessed(); this.VRUI.MapContent = false; this.VRUI.DrawOrder.Value = 100000; // On top of everything this.VRUI.Filename.Value = "Models\\plane"; this.VRUI.EffectFile.Value = "Effects\\VirtualUI"; this.VRUI.Add(new Binding<Microsoft.Xna.Framework.Graphics.RenderTarget2D>(this.VRUI.GetRenderTarget2DParameter("Diffuse" + Lemma.Components.Model.SamplerPostfix), this.UI.RenderTarget)); this.VRUI.Add(new Binding<Matrix>(this.VRUI.Transform, delegate() { Matrix rot = this.Camera.RotationMatrix; Matrix mat = Matrix.Identity; mat.Forward = rot.Right; mat.Right = rot.Forward; mat.Up = rot.Up; mat *= Matrix.CreateScale(7); mat.Translation = this.Camera.Position + rot.Forward * 4.0f; return mat; }, this.Camera.Position, this.Camera.RotationMatrix)); this.AddComponent(this.VRUI); this.UI.Setup3D(this.VRUI.Transform); } #endif #if ANALYTICS bool editorLastEnabled = this.EditorEnabled; new CommandBinding<string>(this.LoadingMap, delegate(string newMap) { if (this.MapFile.Value != null && !editorLastEnabled) { this.SessionRecorder.RecordEvent("ChangedMap", newMap); if (!this.IsChallengeMap(this.MapFile) && this.MapFile.Value != Main.MenuMap) this.SaveAnalytics(); } this.SessionRecorder.Reset(); editorLastEnabled = this.EditorEnabled; }); #endif new CommandBinding<string>(this.LoadingMap, delegate(string newMap) { this.CancelScheduledSave(); }); #if !DEVELOPMENT IO.MapLoader.Load(this, MenuMap); this.Menu.Show(initial: true); #endif #if ANALYTICS if (this.Settings.Analytics.Value == Config.RecordAnalytics.Ask) { this.Menu.ShowDialog("\\analytics prompt", "\\enable analytics", delegate() { this.Settings.Analytics.Value = Config.RecordAnalytics.On; }, "\\disable analytics", delegate() { this.Settings.Analytics.Value = Config.RecordAnalytics.Off; }); } #endif #if VR if (this.oculusNotFound) this.Menu.HideMessage(null, this.Menu.ShowMessage(null, "Error: no Oculus found."), 6.0f); if (this.VR) { this.Menu.EnableInput(false); Container vrMsg = this.Menu.BuildMessage("\\vr message", 300.0f); vrMsg.AnchorPoint.Value = new Vector2(0.5f, 0.5f); vrMsg.Add(new Binding<Vector2, Point>(vrMsg.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.5f), this.ScreenSize)); this.UI.Root.Children.Add(vrMsg); input.Bind(this.Settings.RecenterVRPose, PCInput.InputState.Down, this.VRHmd.RecenterPose); input.Bind(this.Settings.RecenterVRPose, PCInput.InputState.Down, delegate() { if (vrMsg != null) { vrMsg.Delete.Execute(); vrMsg = null; } this.Menu.EnableInput(true); }); } else #endif { input.Bind(this.Settings.ToggleFullscreen, PCInput.InputState.Down, delegate() { if (this.Settings.Fullscreen) // Already fullscreen. Go to windowed mode. this.ExitFullscreen(); else // In windowed mode. Go to fullscreen. this.EnterFullscreen(); }); } input.Bind(this.Settings.QuickSave, PCInput.InputState.Down, delegate() { this.SaveWithNotification(true); }); } else { this.ReloadingContent.Execute(); foreach (IGraphicsComponent c in this.graphicsComponents) c.LoadContent(true); this.ReloadedContent.Execute(); } this.GraphicsDevice.RasterizerState = new RasterizerState { MultiSampleAntiAlias = false }; if (this.spriteBatch != null) this.spriteBatch.Dispose(); this.spriteBatch = new SpriteBatch(this.GraphicsDevice); }
protected override void LoadContent() { if (this.firstLoadContentCall) { // Initialize Wwise AkGlobalSoundEngineInitializer initializer = new AkGlobalSoundEngineInitializer(Path.Combine(this.Content.RootDirectory, "Wwise")); this.AddComponent(initializer); this.Listener = new AkListener(); this.Listener.Add(new Binding<Vector3>(this.Listener.Position, this.Camera.Position)); this.Listener.Add(new Binding<Vector3>(this.Listener.Forward, this.Camera.Forward)); this.Listener.Add(new Binding<Vector3>(this.Listener.Up, this.Camera.Up)); this.AddComponent(this.Listener); // Create the renderer. this.LightingManager = new LightingManager(); this.AddComponent(this.LightingManager); this.Renderer = new Renderer(this, this.ScreenSize, true, true, true, true); this.AddComponent(this.Renderer); this.renderParameters = new RenderParameters { Camera = this.Camera, IsMainRender = true }; this.firstLoadContentCall = false; this.UI = new UIRenderer(); this.AddComponent(this.UI); GeeUI.GeeUI.Initialize(this); this.ConsoleUI = new ConsoleUI(); this.AddComponent(ConsoleUI); this.Console = new Console.Console(); this.AddComponent(Console); PCInput input = new PCInput(); this.AddComponent(input); #if DEVELOPMENT input.Add(new CommandBinding(input.GetChord(new PCInput.Chord { Modifier = Keys.LeftAlt, Key = Keys.S }), delegate() { // High-resolution screenshot Screenshot s = new Screenshot(); this.AddComponent(s); s.Take(new Point(4096, 2304), delegate() { string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string path; int i = 0; do { path = Path.Combine(desktop, "lemma-screen" + i.ToString() + ".png"); i++; } while (File.Exists(path)); using (Stream stream = File.OpenWrite(path)) s.Buffer.SaveAsPng(stream, s.Size.X, s.Size.Y); s.Delete.Execute(); }); })); #endif #if PERFORMANCE_MONITOR this.performanceMonitor = new ListContainer(); this.performanceMonitor.Add(new Binding<Vector2, Point>(performanceMonitor.Position, x => new Vector2(0, x.Y), this.ScreenSize)); this.performanceMonitor.AnchorPoint.Value = new Vector2(0, 1); this.performanceMonitor.Visible.Value = false; this.performanceMonitor.Name.Value = "PerformanceMonitor"; this.UI.Root.Children.Add(this.performanceMonitor); Action<string, Property<double>> addTimer = delegate(string label, Property<double> property) { TextElement text = new TextElement(); text.FontFile.Value = "Font"; text.Add(new Binding<string, double>(text.Text, x => label + ": " + (x * 1000.0).ToString("F") + "ms", property)); this.performanceMonitor.Children.Add(text); }; Action<string, Property<int>> addCounter = delegate(string label, Property<int> property) { TextElement text = new TextElement(); text.FontFile.Value = "Font"; text.Add(new Binding<string, int>(text.Text, x => label + ": " + x.ToString(), property)); this.performanceMonitor.Children.Add(text); }; TextElement frameRateText = new TextElement(); frameRateText.FontFile.Value = "Font"; frameRateText.Add(new Binding<string, float>(frameRateText.Text, x => "FPS: " + x.ToString("0"), this.frameRate)); this.performanceMonitor.Children.Add(frameRateText); addTimer("Physics", this.physicsTime); addTimer("Update", this.updateTime); addTimer("Pre-frame", this.preframeTime); addTimer("Raw render", this.rawRenderTime); addTimer("Shadow render", this.shadowRenderTime); addTimer("Post-process", this.postProcessTime); addTimer("Non-post-processed", this.unPostProcessedTime); addCounter("Draw calls", this.drawCalls); addCounter("Triangles", this.triangles); input.Add(new CommandBinding(input.GetChord(new PCInput.Chord { Modifier = Keys.LeftAlt, Key = Keys.P }), delegate() { this.performanceMonitor.Visible.Value = !this.performanceMonitor.Visible; })); #endif try { IEnumerable<string> globalStaticScripts = Directory.GetFiles(Path.Combine(this.Content.RootDirectory, "GlobalStaticScripts"), "*", SearchOption.AllDirectories).Select(x => Path.Combine("..\\GlobalStaticScripts", Path.GetFileNameWithoutExtension(x))); foreach (string scriptName in globalStaticScripts) this.executeStaticScript(scriptName); } catch (IOException) { } } else { foreach (IDrawableComponent c in this.drawables) c.LoadContent(true); foreach (IDrawableAlphaComponent c in this.alphaDrawables) c.LoadContent(true); foreach (IDrawablePostAlphaComponent c in this.postAlphaDrawables) c.LoadContent(true); foreach (IDrawablePreFrameComponent c in this.preframeDrawables) c.LoadContent(true); foreach (INonPostProcessedDrawableComponent c in this.nonPostProcessedDrawables) c.LoadContent(true); this.ReloadedContent.Execute(); } this.GraphicsDevice.RasterizerState = new RasterizerState { MultiSampleAntiAlias = false }; }