コード例 #1
0
ファイル: DrawConsoleUI.cs プロジェクト: quela/myprojects
        public static void DrawConsole(int width, int height)
        {
            Console.SetWindowSize(width, height);
            Product testEventProduct = new Product();
            Ads testEventAds = new Ads();

            while (!isFinished)
            {
                testEventProduct.Promotion += Product_OnPromotionTypeChanged;
                testEventProduct.CheckForPromotion(StockRoom.ProductList());
                DrawBorders(width, height);

                Console.WriteLine(" ****** !!! Advertisements !!! ******");
                testEventAds.AdsEH += Ads_AdsTypeChanged;
                testEventAds.CheckForActiveAds(AdsStock.GetAllAds());
                Console.WriteLine(" ****** !!! Advertisements !!! ******");
                DrawBorders(width, height);

                Console.WriteLine("   You are browsing as {0}", 
                    currentCustomer == null ? "nobody! Register or login." : currentCustomer.Name + ".");
                DrawBorders(width, height);

                DrawMenu(width);
                int choice = DrawSubMenu();
                ShowChoice(choice);

                AskToContinue(); //Gives time to user can read message

                Console.Clear();
            }
        }
コード例 #2
0
ファイル: Ads.cs プロジェクト: quela/myprojects
 protected void AdsTypeChanged(Ads ads)
 {
     if (AdsEH != null)
     {
         Console.WriteLine("Company: {0} ads content: {1}", ads.companyName, ads.adsContent);
         AdsEventArgs args = new AdsEventArgs(ads.companyName, ads.adsContent);
         AdsEH(this, args);
     }
 }
コード例 #3
0
ファイル: AdsStock.cs プロジェクト: quela/myprojects
        public static List<Ads> GetAllAds()
        {
            //Tozi metod ne trqbva da se pravi tochno taka... shte se opitam da go opravq po-kusno
            //Pravq nqkakuv sravnitelno burz variant za rotaciq na reklamite, zashtoto nqmame mnogo vreme :D

            int seconds = DateTime.Now.Second;

            adsList.Clear(); //zasega slagam tova, zashtoto inache se natrupvat elementite v List<Ads> GetAds

            //Rotation can be implemented with randomizer if more than 3

            Ads firstAds = new Ads("First company", "Google", seconds <= 20 ? true : false);
            Ads secondAds = new Ads("Second company", "Yahoo", seconds > 40 ? true : false);
            Ads thirdAds = new Ads("Third company", "Microsoft", (seconds > 20 && seconds <= 40) ? true : false);
            adsList.Add(firstAds);
            adsList.Add(secondAds);
            adsList.Add(thirdAds);
            return adsList;
        }
コード例 #4
0
ファイル: AdsStock.cs プロジェクト: quela/myprojects
 public void AddAds(Ads ads)
 {
     adsList.Add(ads);
 }