コード例 #1
0
        private void Itinialize()
        {
            this.Database.EnsureCreated();
            if (Flight.Any())
            {
                return;
            }

            Airplane.Add(new Airplane {
                Name = "Boing_747"
            });
            City.Add(new City {
                Name = "Moscow"
            });
            City.Add(new City {
                Name = "London"
            });
            Flight.Add(new Flight
            {
                AirplaneID   = 1,
                StartCityID  = 1,
                FinishCityID = 2,
                Time         = new System.DateTime(2021, 3, 13, 23, 0, 0)
            });
            SaveChanges();
        }
コード例 #2
0
        private void Itinialize()
        {
            this.Database.EnsureCreated();
            if (Flight.Any())
            {
                return;
            }

            Airplane.Add(new Airplane {
                Name = "Boing_747"
            });
            Airplane.Add(new Airplane {
                Name = "Boing_746"
            });
            Airplane.Add(new Airplane {
                Name = "Boing_770"
            });
            Airplane.Add(new Airplane {
                Name = "Boing_761"
            });
            Airplane.Add(new Airplane {
                Name = "Boing_745"
            });
            City.Add(new City {
                Name = "Moscow"
            });
            City.Add(new City {
                Name = "Venus"
            });
            City.Add(new City {
                Name = "Paris"
            });
            City.Add(new City {
                Name = "London"
            });
            SaveChanges();
            Flight.Add(new Flight
            {
                AirplaneID   = Airplane.ToList()[0].ID,
                StartCityID  = City.ToList()[0].ID,
                FinishCityID = City.ToList()[1].ID,
                Time         = new System.DateTime(2021, 3, 20, 19, 30, 0)
            });
            Flight.Add(new Flight
            {
                AirplaneID   = Airplane.ToList()[1].ID,
                StartCityID  = City.ToList()[1].ID,
                FinishCityID = City.ToList()[2].ID,
                Time         = new System.DateTime(2021, 3, 21, 10, 0, 0)
            });
            SaveChanges();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var city     = new City();
            var monument = new Monument()
            {
                Name         = "monument named after Pushkin",
                DateOfCreate = DateTime.Now,
            };

            var restaurant = new Restaurant()
            {
                Title         = "Povoreshkin",
                CountOfTables = 10,
            };

            var theatre = new Theatre()
            {
                Title = "Vakhtangov theater",
                CountOfAttractions = 5,
            };

            city.Add(monument);
            city.Add(restaurant);
            city.Add(theatre);

            Console.WriteLine("XML graphic:");
            Console.WriteLine();

            city.Accept(new XmlVisitor());

            Console.WriteLine("Html graphic:");
            Console.WriteLine();

            city.Accept(new HtmlVisitor());

            Console.ReadLine();
        }
コード例 #4
0
        public ActionResult Add(SETUP_City city)
        {
            City dpCity = new City();
            int  id     = dpCity.Add(city);

            if (id > 0)
            {
                return(RedirectToAction("Index", "City"));
            }
            else
            {
                TempData["error"] = "Opps! Somthing went wrong!";
                return(RedirectToAction("Add", "City"));
            }
        }
コード例 #5
0
ファイル: Register2.cshtml.cs プロジェクト: rohnn7/DietSite
        public async void OnGet()
        {
            List <country> countries = await _communicationservice.GetCountries();

            foreach (var c in countries)
            {
                SelectListItem s = new SelectListItem();
                s.Text  = c.CountryName;
                s.Value = c.CountryID.ToString();
                Country.Add(s);
            }
            SelectListItem x    = Country.Where(p => p.Selected).FirstOrDefault();
            country        coun = countries.Where(p => p.CountryID == int.Parse(x.Value)).First <country>();
            List <state>   st   = await _communicationservice.GetState(coun.CountryID);

            foreach (var c in st)
            {
                SelectListItem s = new SelectListItem();
                s.Text  = c.Statename;
                s.Value = c.Stateid.ToString();
                State.Add(s);
            }
            SelectListItem y   = State.Where(p => p.Selected).FirstOrDefault();
            state          sta = st.Where(p => p.Stateid == int.Parse(y.Value)).First <state>();
            List <city>    ct  = await _communicationservice.GetCities(sta.Stateid);

            foreach (var c in ct)
            {
                SelectListItem s = new SelectListItem();
                s.Text  = c.CityName;
                s.Value = c.CID.ToString();
                City.Add(s);
            }
            SelectListItem z   = City.Where(p => p.Selected).FirstOrDefault();
            city           cty = ct.Where(p => p.CID == int.Parse(z.Value)).First <city>();

            cityid = cty.CID;
        }
コード例 #6
0
        public static void Access()
        {
            Console.Clear();
            Console.WriteLine(welcomeText);
            String input;

            String[] keys;

            while (true)
            {
                Console.Write("> ");
                input = Console.ReadLine();
                keys  = input.Split(' ');

                switch (keys[0].ToLower())
                {
                case "import":
                    if (keys.Length >= 3)
                    {
                        Type type = LanguageTools.ParseType(keys[1]);
                        if (type == null)
                        {
                            Console.WriteLine("The type \"" + keys[1] + "\" does not exist.\n");
                            break;
                        }
                        String path = savefolder + "/" + type + "/" + LanguageTools.GetWordsStarting(keys, 2) + ".json";
                        if (!File.Exists(path))
                        {
                            Console.WriteLine("No " + type + " file named \"" + LanguageTools.GetWordsStarting(keys, 2) + "\" found.\n");
                            break;
                        }
                        GameObject imported = JsonConvert.DeserializeObject <GameObject[]>(File.ReadAllText(path))[0];

                        if (!ConsoleTools.ConfirmOverwriteIfConflict(imported))
                        {
                            break;
                        }

                        if (imported is IQueriable)
                        {
                            ((IQueriable)imported).Query();
                        }

                        if (ConsoleTools.Confirms("\nThe above " + type + " will be imported. Confirm?", true))
                        {
                            City.Add(imported);
                            Console.WriteLine(imported.name + " has been imported.\n");
                        }
                        else
                        {
                            Console.WriteLine("Operation cancelled\n");
                        }

                        City.Sort();
                        break;
                    }

                    if (keys.Length == 2)
                    {
                        if (keys[1] == "all")
                        {
                            String[] files;

                            files = Directory.GetFiles(savefolder + "/Parahumans");
                            for (int i = 0; i < files.Length; i++)
                            {
                                City.Add(JsonConvert.DeserializeObject <Parahuman[]>(File.ReadAllText(files[i]))[0]);
                            }

                            files = Directory.GetFiles(savefolder + "/Teams");
                            for (int i = 0; i < files.Length; i++)
                            {
                                Team imported = JsonConvert.DeserializeObject <Team[]>(File.ReadAllText(files[i]))[0];
                                for (int j = 0; j < imported.roster.Count; j++)
                                {
                                    if (City.Get <Parahuman>(imported.roster[j]) == null)
                                    {
                                        imported.roster.RemoveAt(j);
                                        j--;
                                    }
                                }
                                City.Add(imported);
                            }

                            Console.WriteLine("Imported all\n");
                            City.Sort();
                            break;
                        }
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "export":
                    if (keys.Length >= 3)
                    {
                        GameObject obj = City.Get(LanguageTools.ParseType(keys[1]), LanguageTools.GetWordsStarting(keys, 2));
                        if (obj == null)
                        {
                            ConsoleTools.PrintNotFound <GameObject>(LanguageTools.GetWordsStarting(keys, 2));
                            break;
                        }
                        String path = savefolder + "/" + obj.GetType() + "/" + obj.name + ".json";
                        if (File.Exists(path))
                        {
                            if (!ConsoleTools.Confirms("A " + obj.GetType() + " file called \"" + obj.name + "\" already exists. Overwrite?", true))
                            {
                                Console.WriteLine("Operation cancelled\n");
                                break;
                            }
                        }
                        File.WriteAllText(path, JsonConvert.SerializeObject(new GameObject[] { obj }));
                        Console.WriteLine(obj.name + " has been exported to " + path + ".\n");

                        break;
                    }

                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "create":
                    if (keys.Length == 2)
                    {
                        Type type = LanguageTools.ParseType(keys[1]);
                        if (type == null || type.IsAssignableFrom(typeof(GameObject)))
                        {
                            ConsoleTools.PrintTypeNotFound(keys[1]);
                            break;
                        }
                        GameObject       newObj = (GameObject)type.GetConstructor(new Type[] { }).Invoke(new object[] { });
                        List <FieldInfo> fields = new List <FieldInfo>(newObj.GetType().GetFields());
                        fields.Sort((x, y) => ((OrderAttribute)x.GetCustomAttribute(typeof(OrderAttribute))).order.CompareTo(
                                        ((OrderAttribute)y.GetCustomAttribute(typeof(OrderAttribute))).order));
                        for (int i = 0; i < fields.Count; i++)
                        {
                            ConsoleTools.RequestFieldAndSet(fields[i], newObj);
                        }
                        if (!ConsoleTools.ConfirmOverwriteIfConflict(newObj))
                        {
                            break;
                        }
                        ConsoleTools.QueryObject(newObj);
                        if (!ConsoleTools.Confirms("The above team will be created. Confirm?", true))
                        {
                            Console.WriteLine("Operation cancelled\n");
                            break;
                        }
                        City.Add(newObj);
                        Console.WriteLine(newObj.name + " has been created. \n");
                        break;
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "query":
                    if (keys.Length >= 3)
                    {
                        GameObject obj = City.Get(LanguageTools.ParseType(keys[1]), LanguageTools.GetWordsStarting(keys, 2));
                        if (obj == null)
                        {
                            ConsoleTools.PrintNotFound <GameObject>(LanguageTools.GetWordsStarting(keys, 2));
                            break;
                        }
                        List <FieldInfo> fields = new List <FieldInfo>(obj.GetType().GetFields());
                        fields.Sort((x, y) => ((OrderAttribute)x.GetCustomAttribute(typeof(OrderAttribute))).order.CompareTo(
                                        ((OrderAttribute)y.GetCustomAttribute(typeof(OrderAttribute))).order));
                        for (int i = 0; i < fields.Count; i++)
                        {
                            ConsoleTools.QueryField(fields[i], obj);
                        }
                        break;
                    }
                    if (keys.Length == 2)
                    {
                        if (keys[1] == "teams")
                        {
                            foreach (Team team in City.GetAll <Team>())
                            {
                                team.Query();
                            }
                            break;
                        }
                        if (keys[1] == "parahumans")
                        {
                            foreach (Parahuman parahuman in City.GetAll <Parahuman>())
                            {
                                parahuman.Query();
                            }
                            break;
                        }
                        if (keys[1] == "external")
                        {
                            String[] files;

                            files = Directory.GetFiles(savefolder + "/Parahumans");
                            Console.WriteLine("\n Parahumans:");
                            for (int i = 0; i < files.Length; i++)
                            {
                                Console.WriteLine("   " + files[i]);
                            }

                            files = Directory.GetFiles(savefolder + "/Teams");
                            Console.WriteLine("\n Teams:");
                            for (int i = 0; i < files.Length; i++)
                            {
                                Console.WriteLine("   " + files[i]);
                            }
                            Console.WriteLine("");
                            break;
                        }
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "delete":
                    if (keys.Length == 2)
                    {
                        GameObject obj = City.Get(LanguageTools.ParseType(keys[1]), LanguageTools.GetWordsStarting(keys, 2));
                        if (obj == null)
                        {
                            ConsoleTools.PrintNotFound <GameObject>(LanguageTools.GetWordsStarting(keys, 2));
                            break;
                        }
                        City.Delete(obj);
                        City.Sort();
                        break;
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "edit":
                    if (keys.Length >= 2)
                    {
                        Parahuman parahuman = City.Get <Parahuman>(LanguageTools.GetWordsStarting(keys, 1));
                        if (parahuman == null)
                        {
                            ConsoleTools.PrintNotFound <Parahuman>(LanguageTools.GetWordsStarting(keys, 1));
                            break;
                        }
                        ParahumanConsole.Access(parahuman);
                        Console.WriteLine(welcomeText);
                        City.Sort();
                        break;
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "move":
                    if (keys.Length >= 2)
                    {
                        Type type = LanguageTools.ParseType(keys[1]);
                        if (type == null)
                        {
                            ConsoleTools.PrintTypeNotFound(keys[1]);
                            break;
                        }
                        GameObject obj = City.Get(type, LanguageTools.GetWordsStarting(keys, 2));
                        if (obj == null)
                        {
                            ConsoleTools.PrintNotFound(LanguageTools.GetWordsStarting(keys, 2));
                            break;
                        }

                        ContainerGameObject container1 = City.GetParentOf(obj);
                        if (container1 != null)
                        {
                            container1.Remove(obj);
                        }

                        GameObject container2 = ConsoleTools.RequestObject("Enter destination: ");
                        if (container2 == null)
                        {
                            break;
                        }
                        if (!(container2 is ContainerGameObject))
                        {
                            Console.WriteLine(container2.name + " cannot contain objects.\n");
                            break;
                        }
                        if (!((ContainerGameObject)container2).Add(obj))
                        {
                            Console.WriteLine(container2.name + " cannot hold objects of type " + obj.GetType() + ".\n");
                            break;
                        }

                        Console.WriteLine(obj.name + " has been moved" + ((container1 == null) ? "" : (" from " + ((GameObject)container1).name)) + " to " + container2.name + ".\n");
                        break;
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "set":
                    if (keys.Length >= 4)
                    {
                        GameObject obj = City.Get(LanguageTools.ParseType(keys[2]), LanguageTools.GetWordsStarting(keys, 3));
                        if (obj == null)
                        {
                            ConsoleTools.PrintNotFound <GameObject>(LanguageTools.GetWordsStarting(keys, 3));
                            break;
                        }
                        FieldInfo field = obj.GetType().GetField(keys[1]);
                        if (field == null)
                        {
                            ConsoleTools.PrintNotFound <FieldInfo>(keys[1]);
                            break;
                        }
                        if (!ConsoleTools.RequestFieldAndSet(field, obj))
                        {
                            Console.WriteLine("This field type is not supported");
                        }
                        Console.WriteLine("");
                        break;
                    }
                    ConsoleTools.PrintInvalidSyntax();
                    break;

                case "quit":
                    Console.WriteLine("");
                    return;

                default:
                    ConsoleTools.PrintInvalidCommand();
                    break;
                }
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: yuri410/lrvbsvnicg
        public static void Test()
        {
            Player player = new Player("");
            SimulationRegion region = new SimulationRegion();

            City city = new City(region);
            City city2 = new City(region);

            IniSection sect = new IniSection("");
            sect.Add("Name", "HUST");
            sect.Add("Longitude", "0");
            sect.Add("Latitude", "0");
            sect.Add("Population", "150");
            sect.Add("Size", UrbanSize.Large.ToString());

            city.Parse(sect);



            sect = new IniSection("");
            sect.Add("Name", "Home");
            sect.Add("Longitude", "1");
            sect.Add("Latitude", "0");
            sect.Add("Population", "1");
            sect.Add("Size", UrbanSize.Small.ToString());

            city2.Parse(sect);

            region.Add(city);
            //region.Add(city2);

            //city.AddNearbyCity(city2);
            //city2.AddNearbyCity(city);



            OilField oilFld = new OilField(region);
            sect = new IniSection("");
            sect.Add("Amount", "100000");
            sect.Add("Latitude", "1");
            sect.Add("Longitude", "0");
            oilFld.Parse(sect);
            region.Add(oilFld);


            CityPluginType plgType = new CityPluginType();
            sect = new IniSection("");
            sect.Add("Cost", "100");
            sect.Add("HRCSpeed", "100");
            sect.Add("Behaviour", CityPluginBehaviourType.CollectorFactory.ToString());
            plgType.Parse(sect);

            CityPlugin plg = new CityPlugin(plgType, CityPluginTypeId.OilRefinary);
            city.Add(plg);



            plgType = new CityPluginType();
            sect = new IniSection("");
            sect.Add("Cost", "100");
            sect.Add("FoodConvRate", "0.50");
            sect.Add("FoodCostSpeed", "100");
            sect.Add("Behaviour", CityPluginBehaviourType.CollectorFactory.ToString());
            plgType.Parse(sect);
            plg = new CityPlugin(plgType, CityPluginTypeId.BiofuelFactory);
            city.Add(plg);



            //OilField oil = new OilField(region);
            //Forest forest = new Forest(region);
            float c = 0;
            while (true)
            {
                Console.Clear();
                Console.WriteLine("Energy Status:");
                Console.Write(" Current Food Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentFood);
                Console.Write(" Current HR Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentHR);
                Console.Write(" Current LR Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentLR);
                Console.Write(" Current Natural HR   ");
                Console.WriteLine(region.EnergyStatus.RemainingHR);
                Console.Write(" Current Natural LR   ");
                Console.WriteLine(region.EnergyStatus.RemainingLR);



                Console.WriteLine("City :" + city.Name);
                Console.WriteLine("City Status:");
                Console.Write(" Development   ");
                Console.WriteLine(city.Development);
                Console.Write(" Population   ");
                Console.WriteLine(city.Population);
                Console.Write(" Disease   ");
                Console.WriteLine(city.Disease);
                Console.Write(" Size   ");
                Console.WriteLine(city.Size);

                Console.WriteLine(" Local  H[{0}] L[{1}] F[{2}]", city.LocalHR.Current, city.LocalLR.Current, city.LocalFood.Current);
                Console.WriteLine(" Drain  H[{0}] L[{1}] F[{2}]", city.GetSelfHRCSpeed(), city.GetSelfLRCSpeed(), city.GetSelfFoodCostSpeed());
                Console.WriteLine(" Ratio  H[{0:P}] L[{1:P}] F[{2:P}]", city.SelfHRCRatio, city.SelfLRCRatio, city.SelfFoodCostRatio);

                c += city.GetCarbonChange();

                //city.LocalFood.Commit(250);
                //city.LocalHR.Commit(250);
                city.LocalLR.Commit(100);

                //Console.WriteLine("City :" + city2.Name);
                //Console.WriteLine("City Status:");
                //Console.Write(" Development   ");
                //Console.WriteLine(city2.Development);
                //Console.Write(" Population   ");
                //Console.WriteLine(city2.Population);
                //Console.Write(" Disease   ");
                //Console.WriteLine(city2.Disease);
                //Console.Write(" Size   ");
                //Console.WriteLine(city2.Size);

                //Console.WriteLine(" Local  H[{0}] L[{1}] F[{2}]", city2.LocalHR.Current, city2.LocalLR.Current, city2.LocalFood.Current);
                //Console.WriteLine(" Drain  H[{0}] L[{1}] F[{2}]", city2.GetSelfHRCSpeed(), city2.GetSelfLRCSpeed(), city2.GetSelfFoodCostSpeed());
                //Console.WriteLine(" Ratio  H[{0:P}] L[{1:P}] F[{2:P}]", city2.SelfHRCRatio, city2.SelfLRCRatio, city2.SelfFoodCostRatio);


                //c += city2.GetCarbonChange();


                Console.WriteLine("World Carbon {0}", c);

                GameTime gt = new GameTime(0, 0, TimeSpan.FromHours(1), TimeSpan.FromHours(1));
                region.Update(gt);

                Thread.Sleep(5);
            }
        }
コード例 #8
0
        public void OptionsCity()
        {
            city = new City();
            string option = "S";

            do
            {
                Console.Clear();
                Console.WriteLine("Escriba 'C' para consultar ciudades");
                Console.WriteLine("Escriba 'A' para añadir una ciudad ");
                Console.WriteLine("Escriba 'M' para modificar una ciudad ");
                Console.WriteLine("Escriba 'E' para eliminar una ciudad ");
                Console.WriteLine("Escriba 'S' para volver al menú principal ");
                option = Console.ReadLine();
                switch (option)
                {
                case "C":
                    city.ConsultAll();
                    Console.ReadKey();
                    break;

                case "A":
                    Console.WriteLine("Escriba el nombre de la ciudad a agregar");
                    string namecity = Console.ReadLine();
                    city = new City()
                    {
                        Name = namecity
                    };
                    city.Add();
                    Console.ReadKey();
                    break;

                case "M":
                    Console.WriteLine("Escriba el Id de la ciudad a modificar");
                    city.ConsultAll();
                    string idaux = Console.ReadLine();
                    int    id    = Int32.Parse(idaux);
                    Console.WriteLine("Escriba el nuevo nombre de la ciudad");
                    string namecity1 = Console.ReadLine();
                    city = new City()
                    {
                        Id = id, Name = namecity1
                    };
                    city.Modify();
                    Console.ReadKey();
                    break;

                case "E":
                    Console.WriteLine("Escriba el Id de la ciudad a eliminar");
                    city.ConsultAll();
                    string idaux1 = Console.ReadLine();
                    int    id1    = Int32.Parse(idaux1);
                    city = new City()
                    {
                        Id = id1
                    };
                    city.Delete();
                    Console.ReadKey();
                    break;

                case "S":
                    break;

                default:
                    Console.WriteLine("Opción no válida");
                    break;
                }
            }while (option != "S");

            Console.ReadKey();
        }
コード例 #9
0
ファイル: AnalysisPage.xaml.cs プロジェクト: yunussob/ImPatho
            public async void UpdateGraphView()
            {
                List <String> diseaseListRepeatedValues     = new List <string>();
                List <String> allergyListRepeatedValues     = new List <string>();
                List <String> addictionListRepeatedValues   = new List <string>();
                List <String> vaccinationListRepeatedValues = new List <string>();
                List <String> operationListRepeatedValues   = new List <string>();
                List <String> cityListRepeatedValues        = new List <string>();

                Sex.Clear();
                City.Clear();
                Blood.Clear();
                Married.Clear();
                Addiction.Clear();
                Allergy.Clear();
                Operation.Clear();
                Vaccine.Clear();
                Disease.Clear();

                foreach (var i in resultList)
                {
                    diseaseListRepeatedValues.AddRange(i.Diseases.Values.ToList());
                    allergyListRepeatedValues.AddRange(i.Allergy);
                    operationListRepeatedValues.AddRange(i.Operation);
                    addictionListRepeatedValues.AddRange(i.Addiction);
                    vaccinationListRepeatedValues.AddRange(i.Vaccines.Values.ToList());
                    cityListRepeatedValues.Add(i.City);
                }


                //displaying sex pie chart
                int x = resultList.Count(i => i.Sex == 'M');

                window = CoreWindow.GetForCurrentThread();
                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    if (resultList.Count() != 0)
                    {
                        Sex.Add(new TestClass()
                        {
                            Category = "Male", Number = (int)Math.Round((double)x * 100 / resultList.Count())
                        });
                        Sex.Add(new TestClass()
                        {
                            Category = "Female", Number = (int)Math.Round((double)100 * (resultList.Count() - x) / resultList.Count())
                        });
                    }
                    else
                    {
                        sexGraph.ChartSubTitle = "No results found";
                    }
                });

                //display married pie chart
                int y = resultList.Count(i => i.Married == true);

                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    if (resultList.Count() != 0)
                    {
                        Married.Add(new TestClass()
                        {
                            Category = "Married", Number = (int)Math.Round((double)y * 100 / resultList.Count())
                        });
                        Married.Add(new TestClass()
                        {
                            Category = "Unmarried", Number = (int)Math.Round(((double)resultList.Count() - y) * 100 / resultList.Count())
                        });
                    }
                    else
                    {
                        marriedGraph.ChartSubTitle = "No results found";
                    }
                });

                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display cities graph
                    foreach (var i in cityListRepeatedValues.Distinct())
                    {
                        City.Add(new TestClass()
                        {
                            Category = i, Number = cityListRepeatedValues.Count(j => j.Equals(i))
                        });
                    }
                    if (City.Count == 0)
                    {
                        cityGraph.ChartSubTitle = "No results found";
                    }
                });

                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display blood group chart
                    List <String> bloodgrp = new List <string>();
                    foreach (var i in resultList)
                    {
                        bloodgrp.Add(i.BloodGroup);
                    }
                    foreach (var i in bloodgrp.Distinct())
                    {
                        Blood.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = resultList.Count(j => j.BloodGroup.Equals(i.ToString()))
                        });
                    }
                    if (Blood.Count == 0)
                    {
                        bloodGraph.ChartSubTitle = "No results found";
                    }
                });

                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display disease graph
                    foreach (var i in diseaseListRepeatedValues.Distinct())
                    {
                        Disease.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = diseaseListRepeatedValues.Count(j => j.Equals(i))
                        });
                    }
                    if (Disease.Count == 0)
                    {
                        diseaseGraph.ChartSubTitle = "No diseases found";
                    }
                });
                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display addictions graph
                    foreach (var i in addictionListRepeatedValues.Distinct())
                    {
                        Addiction.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = addictionListRepeatedValues.Count(j => j.Equals(i))
                        });
                    }
                    if (Addiction.Count == 0)
                    {
                        addictionGraph.ChartSubTitle = "No addictions found";
                    }
                });
                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display addictions graph
                    //display operations graph
                    foreach (var i in operationListRepeatedValues.Distinct())
                    {
                        Operation.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = operationListRepeatedValues.Count(j => j.Equals(i.ToString()))
                        });
                    }
                    if (Operation.Count == 0)
                    {
                        operationGraph.ChartSubTitle = "No operations found";
                    }
                });

                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    foreach (var i in allergyListRepeatedValues.Distinct())
                    {
                        Allergy.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = allergyListRepeatedValues.Count(j => j.Equals(i.ToString()))
                        });
                    }
                    if (Allergy.Count == 0)
                    {
                        allergyGraph.ChartSubTitle = "No allergies found";
                    }
                });
                window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate
                {
                    //display vaccine graph
                    foreach (var i in vaccinationListRepeatedValues.Distinct())
                    {
                        Vaccine.Add(new TestClass()
                        {
                            Category = i.ToString(), Number = vaccinationListRepeatedValues.Count(j => j.Equals(i.ToString()))
                        });
                    }
                    if (Vaccine.Count == 0)
                    {
                        vaccineGraph.ChartSubTitle = "No vaccinations found";
                    }
                });
            }
コード例 #10
0
ファイル: Program.cs プロジェクト: yuri410/lrvbsvnicg
        public static void Test()
        {
            Player           player = new Player("");
            SimulationRegion region = new SimulationRegion();

            City city  = new City(region);
            City city2 = new City(region);

            IniSection sect = new IniSection("");

            sect.Add("Name", "HUST");
            sect.Add("Longitude", "0");
            sect.Add("Latitude", "0");
            sect.Add("Population", "150");
            sect.Add("Size", UrbanSize.Large.ToString());

            city.Parse(sect);



            sect = new IniSection("");
            sect.Add("Name", "Home");
            sect.Add("Longitude", "1");
            sect.Add("Latitude", "0");
            sect.Add("Population", "1");
            sect.Add("Size", UrbanSize.Small.ToString());

            city2.Parse(sect);

            region.Add(city);
            //region.Add(city2);

            //city.AddNearbyCity(city2);
            //city2.AddNearbyCity(city);



            OilField oilFld = new OilField(region);

            sect = new IniSection("");
            sect.Add("Amount", "100000");
            sect.Add("Latitude", "1");
            sect.Add("Longitude", "0");
            oilFld.Parse(sect);
            region.Add(oilFld);


            CityPluginType plgType = new CityPluginType();

            sect = new IniSection("");
            sect.Add("Cost", "100");
            sect.Add("HRCSpeed", "100");
            sect.Add("Behaviour", CityPluginBehaviourType.CollectorFactory.ToString());
            plgType.Parse(sect);

            CityPlugin plg = new CityPlugin(plgType, CityPluginTypeId.OilRefinary);

            city.Add(plg);



            plgType = new CityPluginType();
            sect    = new IniSection("");
            sect.Add("Cost", "100");
            sect.Add("FoodConvRate", "0.50");
            sect.Add("FoodCostSpeed", "100");
            sect.Add("Behaviour", CityPluginBehaviourType.CollectorFactory.ToString());
            plgType.Parse(sect);
            plg = new CityPlugin(plgType, CityPluginTypeId.BiofuelFactory);
            city.Add(plg);



            //OilField oil = new OilField(region);
            //Forest forest = new Forest(region);
            float c = 0;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Energy Status:");
                Console.Write(" Current Food Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentFood);
                Console.Write(" Current HR Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentHR);
                Console.Write(" Current LR Storage   ");
                Console.WriteLine(region.EnergyStatus.CurrentLR);
                Console.Write(" Current Natural HR   ");
                Console.WriteLine(region.EnergyStatus.RemainingHR);
                Console.Write(" Current Natural LR   ");
                Console.WriteLine(region.EnergyStatus.RemainingLR);



                Console.WriteLine("City :" + city.Name);
                Console.WriteLine("City Status:");
                Console.Write(" Development   ");
                Console.WriteLine(city.Development);
                Console.Write(" Population   ");
                Console.WriteLine(city.Population);
                Console.Write(" Disease   ");
                Console.WriteLine(city.Disease);
                Console.Write(" Size   ");
                Console.WriteLine(city.Size);

                Console.WriteLine(" Local  H[{0}] L[{1}] F[{2}]", city.LocalHR.Current, city.LocalLR.Current, city.LocalFood.Current);
                Console.WriteLine(" Drain  H[{0}] L[{1}] F[{2}]", city.GetSelfHRCSpeed(), city.GetSelfLRCSpeed(), city.GetSelfFoodCostSpeed());
                Console.WriteLine(" Ratio  H[{0:P}] L[{1:P}] F[{2:P}]", city.SelfHRCRatio, city.SelfLRCRatio, city.SelfFoodCostRatio);

                c += city.GetCarbonChange();

                //city.LocalFood.Commit(250);
                //city.LocalHR.Commit(250);
                city.LocalLR.Commit(100);

                //Console.WriteLine("City :" + city2.Name);
                //Console.WriteLine("City Status:");
                //Console.Write(" Development   ");
                //Console.WriteLine(city2.Development);
                //Console.Write(" Population   ");
                //Console.WriteLine(city2.Population);
                //Console.Write(" Disease   ");
                //Console.WriteLine(city2.Disease);
                //Console.Write(" Size   ");
                //Console.WriteLine(city2.Size);

                //Console.WriteLine(" Local  H[{0}] L[{1}] F[{2}]", city2.LocalHR.Current, city2.LocalLR.Current, city2.LocalFood.Current);
                //Console.WriteLine(" Drain  H[{0}] L[{1}] F[{2}]", city2.GetSelfHRCSpeed(), city2.GetSelfLRCSpeed(), city2.GetSelfFoodCostSpeed());
                //Console.WriteLine(" Ratio  H[{0:P}] L[{1:P}] F[{2:P}]", city2.SelfHRCRatio, city2.SelfLRCRatio, city2.SelfFoodCostRatio);


                //c += city2.GetCarbonChange();


                Console.WriteLine("World Carbon {0}", c);

                GameTime gt = new GameTime(0, 0, TimeSpan.FromHours(1), TimeSpan.FromHours(1));
                region.Update(gt);

                Thread.Sleep(5);
            }
        }