コード例 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            object[] data = (object[])e.Parameter;


            tomato = (Tomato)data[0];
            string[] tasks = (string[])data[1];

            foreach (string task in tasks)
            {
                ListTask.Items.Add(new CustomItemList(task));
            }

            tomato.TimerCompleteEvent += Tomato_TimerCompleteEvent;
            tomato.TimerTickEvent     += Tomato_TimerTickEvent;
            tomato.TimerStopEvent     += Tomato_TimerStopEvent;
            LoadList();

            TxtTime.Text = "";
            BeginExecutedExtension();

            if (!tomato.AbleInternet)
            {
                netConnection = new InternetConnection(InternetAbled);
                netConnection.StartVerification();
            }
        }
コード例 #2
0
        public static List <Tomato> AugmentData(List <Tomato> tomatoes)
        {
            var copyTomatoes     = new List <Tomato>(tomatoes);
            var tomatosAugmented = new List <Tomato>();

            foreach (Tomato norm in tomatoes)
            {
                var flipH = new Tomato(
                    (int)norm.Type,
                    norm.ColoredImage.Flip(FlipType.Horizontal),
                    norm.GrayImage1.Flip(FlipType.Horizontal),
                    norm.GrayImage2.Flip(FlipType.Horizontal),
                    norm.Name
                    );
                var flipV = new Tomato(
                    (int)norm.Type,
                    norm.ColoredImage.Flip(FlipType.Vertical),
                    norm.GrayImage1.Flip(FlipType.Vertical),
                    norm.GrayImage2.Flip(FlipType.Vertical),
                    norm.Name
                    );
                tomatosAugmented.Add(flipV);
                tomatosAugmented.Add(flipH);
            }
            copyTomatoes.AddRange(tomatosAugmented);
            return(copyTomatoes);
        }
コード例 #3
0
        /// <summary>
        /// 添加一个已完成的番茄钟
        /// </summary>
        /// <param name="taskID"></param>
        /// <param name="tomatoID"></param>
        public void FinishedOneTomato(Tomato tomato)
        {
            using (var context = Context)
            {
                var taskInfo = context.TaskModels.FirstOrDefault(t => t.TaskID == tomato.TaskID);
                if (taskInfo == null)
                {
                    throw new Exception("TaskID of tomato does not exist");
                }

                // 将番茄钟加入表中
                context.TomatoesModels.Add(tomato);

                // 修改任务状态
                taskInfo.FinishedTomatoCount++;

                // 修改相关文件状态
                List <string> relativeFiles = GetFilePath(tomato.BeginTime, tomato.EndTime);
                foreach (string relativeFile in relativeFiles)
                {
                    context.TaskFileModels.Add(new TaskFile()
                    {
                        TaskID   = taskInfo.TaskID,
                        FilePath = relativeFile
                    });
                }

                context.SaveChanges();
            }
        }
コード例 #4
0
        public AddOrder(Customer customer)
        {
            InitializeComponent();
            ACustomer = customer;
            Coffee                  aCoffee            = new Coffee();
            CoffeeDarkRoast         aDarkRoastCoffee   = new CoffeeDarkRoast();
            SandwichWithBacon       aBaconSandwich     = new SandwichWithBacon();
            SandwichWithEggSalad    aEggSandwich       = new SandwichWithEggSalad();
            SandwichWithRoastedBeef aRoastBeefSandwich = new SandwichWithRoastedBeef();
            Tea       aTea      = new Tea();
            Milk      aMilk     = new Milk();
            Suggar    aSuggar   = new Suggar();
            Sweetener aSweetner = new Sweetener();
            Cheese    aCheese   = new Cheese();
            Mayo      aMayo     = new Mayo();
            Lettuce   aLettuce  = new Lettuce();
            Tomato    aTomato   = new Tomato();

            lbxOrders.Items.Add(aCoffee);
            lbxOrders.Items.Add(aDarkRoastCoffee);
            lbxOrders.Items.Add(aBaconSandwich);
            lbxOrders.Items.Add(aEggSandwich);
            lbxOrders.Items.Add(aRoastBeefSandwich);
            lbxOrders.Items.Add(aTea);
            lbxAdditions.Items.Add(aSweetner);
            lbxAdditions.Items.Add(aMilk);
            lbxAdditions.Items.Add(aSuggar);
            lbxAdditions.Items.Add(aCheese);
            lbxAdditions.Items.Add(aMayo);
            lbxAdditions.Items.Add(aLettuce);
            lbxAdditions.Items.Add(aTomato);
        }
コード例 #5
0
        public void RefrigeratorTestTwo()
        {
            Refrigerator refrigerator = new Refrigerator();
            Tomato       tomato       = new Tomato();
            Cabbage      cabbage      = new Cabbage();
            LadyFinger   ladyFinger   = new LadyFinger();

            refrigerator.AddVegetable(tomato, 25);
            refrigerator.SetVegetableMinimumQuantity(tomato, 10);
            refrigerator.AddVegetable(cabbage, 10);
            refrigerator.SetVegetableMinimumQuantity(cabbage, 2);
            refrigerator.AddVegetable(ladyFinger, 7);
            refrigerator.SetVegetableMinimumQuantity(ladyFinger, 2);

            refrigerator.TakeOutVegetable(tomato, 20);
            refrigerator.TakeOutVegetable(cabbage, 7);

            var actualVegetableQuantity = refrigerator.CheckRefrigeratorContents();

            var expectedVegetableQuantity = new List <KeyValuePair <Vegetable, int> >();

            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 5));
            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 3));
            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 7));

            Assert.Equal(expectedVegetableQuantity, actualVegetableQuantity);
        }
コード例 #6
0
 public void Chop(Mobile from)
 {
     if (from.InRange(this.GetWorldLocation(), 1))
     {
         if (from == m_sower)
         {
             from.Direction = from.GetDirectionTo(this);
             double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100;
             if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue))
             {
                 Tomato fruit = new Tomato(Utility.Random(m_yield + 2));
                 from.AddToBackpack(fruit);
                 if (Utility.RandomDouble() <= .1)
                 {
                     Vines logs = new Vines(); from.AddToBackpack(logs);
                 }
             }
             this.Delete();
             from.SendMessage("You chop the plant up");
         }
         else
         {
             from.SendMessage("You do not own this plant !!!");
         }
     }
     else
     {
         from.SendLocalizedMessage(500446);
     }
 }
コード例 #7
0
        public static void InitializeApis()
        {
            var serviceCodes = new Dictionary <string, string>();

            try
            {
                using (StreamReader sr = new StreamReader("servicecodes.key"))
                {
                    while (!sr.EndOfStream)
                    {
                        String line  = sr.ReadLine();
                        var    split = line.Split('=');
                        serviceCodes.Add(split[0], split[1]);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            RequestChecker.TmDbReadyOrWait();
            TmdbApi = new Tmdb(serviceCodes["Tmdb"], "de");

            RequestChecker.TomatoReadyOrWait();
            TomatoApi = new Tomato(serviceCodes["Tomato"]);
        }
コード例 #8
0
        public void VegetableTrackerTest()
        {
            VegetableTracker     vegetableTracker     = new VegetableTracker();
            ConfigurationManager configurationManager = new ConfigurationManager(StorageFactory.GetStorage("inMemory"));
            Tomato     tomato     = new Tomato();
            Cabbage    cabbage    = new Cabbage();
            LadyFinger ladyFinger = new LadyFinger();


            var vegetableQuantity = new List <KeyValuePair <Vegetable, int> >();

            vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 25));
            vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 3));
            vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 2));

            configurationManager.SetMinimumQuantity(tomato, 5);
            configurationManager.SetMinimumQuantity(cabbage, 5);
            configurationManager.SetMinimumQuantity(ladyFinger, 5);

            var expectedInsufficientVegetables = new List <KeyValuePair <Vegetable, int> >();

            expectedInsufficientVegetables.Add(new KeyValuePair <Vegetable, int>(cabbage, 3));
            expectedInsufficientVegetables.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 2));

            var actualInsufficientVegetables = vegetableTracker.GetInsufficientVegetableQuantity(vegetableQuantity, configurationManager);

            Assert.Equal(expectedInsufficientVegetables, actualInsufficientVegetables);
        }
コード例 #9
0
        static Drink SelectDrink()
        {
            Drink drink = null;

            do
            {
                Console.WriteLine("Bonjour");
                Console.WriteLine("Veuillez choisir votre boisson !");
                Console.WriteLine("Taper 1 pour un café, taper 2 pour un thé et taper 3 pour une soupe");
                string userChoice = Console.ReadLine();
                switch (userChoice)
                {
                case "1":
                    drink = new Coffee();
                    break;

                case "2":
                    drink = new Tea();
                    break;

                case "3":
                    drink = new Tomato();
                    break;

                default:
                    Console.WriteLine("Je n'ai pas compris votre demande, réessayez");
                    break;
                }
            } while (drink == null);

            return(drink);
        }
コード例 #10
0
        /// <summary>
        /// 获取一个番茄的效率
        /// </summary>
        /// <param name="tomato"></param>
        /// <returns></returns>
        private double GetTomatoEfficiency(Tomato tomato)
        {
            tomato = GetFullTomato(tomato.TomatoID);
            if (tomato == null)
            {
                return(0);
            }

            TimeStatisticService tss            = TimeStatisticService.GetTimeStatisticService();
            List <UserActivity>  userActivities = tss.GetUserActivitiesWithin(tomato.BeginTime, tomato.EndTime);
            TimeSpan             focusTime      = new TimeSpan();
            TimeSpan             totalTime      = tomato.EndTime - tomato.BeginTime;

            if (totalTime.TotalSeconds <= 0)
            {
                return(0);
            }

            List <string> focusAppNames = new List <string>();

            foreach (var focusApp in tomato.FocusApps)
            {
                focusAppNames.Add(focusApp.AppName);
            }

            foreach (UserActivity userActivity in userActivities)
            {
                if (focusAppNames.Contains(userActivity.Name))
                {
                    focusTime += userActivity.SpanTime;
                }
            }

            return(focusTime.TotalSeconds / totalTime.TotalSeconds);
        }
コード例 #11
0
        public void ConfigurationManagerTest()
        {
            ConfigurationManager configurationManager = new ConfigurationManager(StorageFactory.GetStorage("inMemory"));
            Tomato tomato = new Tomato();

            configurationManager.SetMinimumQuantity(tomato, 4);
            Assert.Equal(4, configurationManager.GetMinimumQuantity(tomato));
        }
コード例 #12
0
        public void InMemoryStorageClassTest()
        {
            InMemoryStorage storage = new InMemoryStorage();
            Tomato          tomato  = new Tomato();

            storage.SetVegetableMinimumQuantity(tomato, 5);
            Assert.Equal(5, storage.GetVegetableMinimumQuantity(tomato));
        }
コード例 #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tomato tomato = db.Tomatoes.Find(id);

            db.Tomatoes.Remove(tomato);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #14
0
        public void MinimunVegetableQuantity()
        {
            ConfigurationManager configurationManager = new ConfigurationManager(new InMemoryStorage());
            Tomato tomato = new Tomato();

            configurationManager.SetMinimumQuantity(tomato, 2000);

            Assert.Equal(2000, configurationManager.GetMinimumQuantity(tomato));
        }
コード例 #15
0
        static void Main()
        {
            Tomato t = new Tomato("Помидор", 122, 80);

            GeneralSalad salad = new GeneralSalad("Greek", new List <ISaladItem>());

            //GeneralSalad s1 = new GeneralSalad("GGGG", new LinkedList<ISaladItem>());
            salad.Items.Add(t);
        }
コード例 #16
0
        public void Test_Tomato()
        {
            //arrange
            var sut = new Tomato();

            //act

            //assert
            Assert.True(sut.name.Equals("Tomato"));
        }
コード例 #17
0
        public void Post([FromBody] JObject value)
        {
            Tomato posted = value.ToObject <Tomato>();

            using (TomatoDb db = new TomatoDb())
            {
                db.Tomatos.Add(posted);
                db.SaveChanges();
            }
        }
コード例 #18
0
        public void TestFileBasedMemory()
        {
            StorageFactory       storageFactory       = new StorageFactory();
            ConfigurationManager configurationManager = new ConfigurationManager(storageFactory.GetStorage("filebased"));
            Tomato tomato = new Tomato();

            configurationManager.SetMinimumQuantity(tomato, 8);

            Assert.Equal(configurationManager.GetMinimumQuantity(tomato), 8);
        }
コード例 #19
0
        public void GetMinimumQuantityTest()
        {
            var    inMemoryStorage = new InMemoryStorage();
            var    config          = new ConfigurationManager(inMemoryStorage);
            Tomato tomato          = new Tomato();

            config.SetMinimumQuantity(tomato, 5);

            Assert.AreEqual(5, config.GetMinimumQuantity(tomato));
        }
コード例 #20
0
        static void Main(string[] args)
        {
            Pizza pizza = new PizzaPepperoni();

            Console.WriteLine($"{pizza.name} цена: {pizza.Price()}");
            pizza = new Tomato(pizza);
            Console.WriteLine($"{pizza.name} цена: {pizza.Price()}");
            pizza = new Chilli(pizza);
            Console.WriteLine($"{pizza.name} цена:{pizza.Price()}");
            Console.ReadKey();
        }
コード例 #21
0
 public ActionResult Edit([Bind(Include = "Form_ID,Veg_ID,Form,Average_Retail_Price_Dollars,Price_Unit,Preparation_yield_Factor,Size_Cup_Equivalent,Size_Unit,Average_Price_Per_Cup_Dollars")] Tomato tomato)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tomato).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Veg_ID = new SelectList(db.Vegetables, "Veg_ID", "Veg_Name", tomato.Veg_ID);
     return(View(tomato));
 }
コード例 #22
0
        public void TestToCheckTheQuantityOfTomatoes()
        {
            Refrigerator refrigerator = new Refrigerator();
            Tomato       tomato       = new Tomato();
            Cabbage      cabbage      = new Cabbage();

            refrigerator.AddVegetable(tomato, 10);
            refrigerator.AddVegetable(cabbage, 10);

            Assert.Equal(10, refrigerator.GetVegetableQuantity(tomato));
        }
コード例 #23
0
        public void TestInsufficiencyNotification()
        {
            Refrigerator refrigerator = new Refrigerator();
            Tomato       tomato       = new Tomato();

            refrigerator.AddVegetable(tomato, 20);
            refrigerator.SetMinimumQuantity(tomato, 8);
            refrigerator.TakeOutVegetable(tomato, 15);

            Assert.Equal("Sent notification to refrigerator", refrigerator.SendNotification());
        }
コード例 #24
0
        public void Put(int id, [FromBody] JObject value)
        {
            Tomato posted = value.ToObject <Tomato>();

            posted.Id = id; // Ensure an id is attached
            using (TomatoDb db = new TomatoDb())
            {
                db.Tomatos.Update(posted);
                db.SaveChanges();
            }
        }
コード例 #25
0
        public IActionResult Create(Tomato tomato)
        {
            if (ModelState.IsValid)
            {
                _context.Tomatoes.Add(tomato);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tomato));
        }
コード例 #26
0
        public void TestWhenQuantityIsSufficient()
        {
            Refrigerator refrigerator = new Refrigerator();
            Tomato       tomato       = new Tomato();
            Cabbage      cabbage      = new Cabbage();

            refrigerator.AddVegetable(tomato, 10);
            refrigerator.AddVegetable(cabbage, 8);
            string message = refrigerator.TakeOutVegetable(tomato, 2);

            Assert.Equal(8, refrigerator.GetVegetableQuantity(tomato));
        }
コード例 #27
0
        static void Main()
        {
            Tomato       t     = new Tomato("Cherry", 100, 15);
            Tomato       t2    = new Tomato("Tomato", 200, 18 * 2);
            GeneralSalad salad = new GeneralSalad("Greek", new List <ISaladItem>());

            salad.Items.Add(t);
            salad.Items.Add(t2);

            Console.WriteLine("Salad " + salad);
            Console.ReadKey();
        }
コード例 #28
0
 public Taco(IngredientFactory ingredientFactory)
 {
     _poultry     = ingredientFactory.GetPoultry();
     _meat        = ingredientFactory.GetMeat();
     _vegetation  = ingredientFactory.GetVegetation();
     _cheese      = ingredientFactory.GetCheese();
     _guacomole   = ingredientFactory.GetGuacomole();
     _rice        = ingredientFactory.GetRice();
     _beans       = ingredientFactory.GetBeans();
     _creamCheese = ingredientFactory.GetCreamCheese();
     _tomato      = ingredientFactory.GetTomato();
     _chili       = ingredientFactory.GetChili();
 }
コード例 #29
0
        public void TestWhenQuantityReachesMinimumLimitAndOrderAutomaticallyPlaced()
        {
            Refrigerator refrigerator = new Refrigerator();
            Tomato       tomato       = new Tomato();
            Cabbage      cabbage      = new Cabbage();

            refrigerator.AddVegetable(tomato, 10);
            refrigerator.AddVegetable(cabbage, 8);

            string message = refrigerator.TakeOutVegetable(tomato, 10);

            Assert.Equal(5, refrigerator.GetVegetableQuantity(tomato));
        }
コード例 #30
0
        static void Main(string[] args)
        {
            var myTomato    = new Tomato(VeggieColor.Red);
            var mySourdough = new Sourdough(MoistureLevel.Moist, TextureType.Fluffy);
            var myChicken   = new Chicken(Meats.MeatTexture.Tender, Meats.MeatCut.Shredded);
            var myMayo      = new Mayo(FlavorType.Creamy, AmountType.Extra);

            var mySandwich = new Sandwich(mySourdough, myChicken, myTomato, myMayo);

            mySandwich.OrderSandwich();

            Console.ReadLine();
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: skoant/CherryTomato
        private static void DisplayUpcomingMovies()
        {
            string apiKey = ConfigurationManager.AppSettings["ApiKey"];

            //A Tomato is the main object that will allow you to access RottenTomatoes information.
            //Be sure to provide it with your API key in String format.
            var tomato = new Tomato(apiKey);

            //The movies are automatically ordered according to their gross at the box-office.
            //Unfortunately the JSON API doesn't offer the gross (money earned) only their relative position
            //on the charts.
            var movies = tomato.FindUpcomingMoviesList();

            foreach (var movie in movies)
            {
                Console.WriteLine(movie.Title);
            }
        }
コード例 #32
0
ファイル: FruitTub.cs プロジェクト: greeduomacro/hubroot
		private void InitContents( FruitType type )
		{
			Food item = null;
			byte count = (byte)Utility.RandomMinMax( 10, 30 );

			for( byte i = 0; i < count; i++ )
			{
				switch( type )
				{
					default:
					case FruitType.Apples: item = new Apple(); break;
					case FruitType.Bananas: item = new Banana(); break;
					case FruitType.Bread: item = new BreadLoaf(); break;
					case FruitType.Gourds: item = new Gourd(); break;
					case FruitType.Grapes: item = new Grapes(); break;
					case FruitType.Lemons: item = new Lemon(); break;
					case FruitType.Tomatoes: item = new Tomato(); break;
					case FruitType.Vegetables1:
					case FruitType.Vegetables2:
					case FruitType.Vegetables3:
						{
							switch( Utility.Random( 4 ) )
							{
								case 0: item = new Carrot(); break;
								case 1: item = new Onion(); break;
								case 2: item = new Pumpkin(); break;
								case 3: item = new Gourd(); break;
							}
							break;
						}
				}

				if( item != null )
					DropItem( item );
			}
		} 
コード例 #33
0
ファイル: Program.cs プロジェクト: skoant/CherryTomato
        private static void FindingMovieByName()
        {
            string apiKey = ConfigurationManager.AppSettings["ApiKey"];

            //A Tomato is the main object that will allow you to access RottenTomatoes information.
            //Be sure to provide it with your API key in String format.
            var tomato = new Tomato(apiKey);

            var results = tomato.FindMovieByQuery("The Incredible Hulk");
            foreach (var movieSearchResult in results)
            {
                Console.WriteLine(movieSearchResult.Title);
            }
        }
コード例 #34
0
 public BifrostCPUWorker(Tomato.DCPU cpu)
 {
     CPU = cpu;
     ExecutionInterval = 1000 / 120;
 }
コード例 #35
0
ファイル: Program.cs プロジェクト: skoant/CherryTomato
        private static void FindingMovieByIdNumber()
        {
            string apiKey = ConfigurationManager.AppSettings["ApiKey"];

            //A Tomato is the main object that will allow you to access RottenTomatoes information.
            //Be sure to provide it with your API key in String format.
            var tomato = new Tomato(apiKey);

            //Finding a movie by it's RottenTomatoes internal ID number.
            Movie movie = tomato.FindMovieById(9818);

            //The Movie object, contains all sorts of goodies you might want to know about a movie.
            Console.WriteLine(movie.Title);
            Console.WriteLine(movie.Year);
        }