コード例 #1
0
 public FormMessageFormating()
 {
     InitializeComponent();
     InitializeComboBoxFormatting();
     OnMessageAdded              += NotifyMessageAdded;
     OnMessageDeleted            += NotifyMessageRemoved;
     BatteryBase.OnChargeChanged += DisplayCharge;
     BatteryBase.OnChargeLess10  += LowBatteryNotification;
     BatteryBase.OnChargeZero    += LockOnZeroChargeLevel;
     LithiumLonBattery            = new LithiumLonBattery(4000);
     InitializeComboBoxUsers();
     Factory();
 }
コード例 #2
0
        static void Main(string[] args)
        {
            OLEDScreen        screen                  = new OLEDScreen(5, 1920, 1080);
            LithiumLonBattery battery                 = new LithiumLonBattery(4000);
            PhoneSpeaker      speaker                 = new PhoneSpeaker(1000, new ConsoleOutput());
            SimCorpMobile     simMobile               = new SimCorpMobile(screen, battery, speaker);
            SamsungHeadset    samsungHeadsetComp      = new SamsungHeadset(300, new ConsoleOutput());
            IPhoneHeadset     iPhoneHeadsetComp       = new IPhoneHeadset(350, new ConsoleOutput());
            IAudioController  samsungHeadset          = (IAudioController)samsungHeadsetComp;
            IAudioController  iPhoneHeadset           = (IAudioController)iPhoneHeadsetComp;
            List <string>     playComponentsMenuItems = new List <string>();

            playComponentsMenuItems.Add("Phone speaker");
            playComponentsMenuItems.Add("Samsung Headset");
            playComponentsMenuItems.Add("iPhone Headset");
            int userPlaybackChoice = 0;

            while (true)
            {
                while (userPlaybackChoice == 0)
                {
                    Console.WriteLine(simMobile.ToString());
                    Console.WriteLine("Please select component (specify index)\n");
                    foreach (string item in playComponentsMenuItems)
                    {
                        Console.Write(playComponentsMenuItems.IndexOf(item) + 1 + ". ");
                        Console.WriteLine(item);
                    }
                    Console.Write("\nYour choice: ");
                    userPlaybackChoice = CheckUserInput(Console.ReadLine(), playComponentsMenuItems);
                }
                switch (userPlaybackChoice)
                {
                case 1:
                    simMobile.Play();
                    break;

                case 2:
                    simMobile.Play(samsungHeadset);
                    break;

                case 3:
                    simMobile.Play(iPhoneHeadset);
                    break;
                }
                userPlaybackChoice = 0;
                Console.ReadKey();
                Console.Clear();
            }
        }
コード例 #3
0
 private void DisplayCharge()
 {
     progressBarCharge.Value = (int)(LithiumLonBattery.GetBatteryChargeLevel() * 100);
     labelChargePers.Text    = ((int)(LithiumLonBattery.GetBatteryChargeLevel() * 100)).ToString() + "%";
 }