Example #1
0
        protected MobileBase(IOutput output, BackgroundWorkerFactoryMethod backgroundWorkerFactory = null)
        {
            this.output = output;

            SMSProvider.SMSReciever += SMSMessenger.AddMessage;

            var workerFactory = backgroundWorkerFactory ?? new BackgroundWorkerFactoryMethod();

            Battery = new Battery();
            BackgroundWorkerBase discharge = workerFactory.CreateWorker(() => {
                while (true)
                {
                    Thread.Sleep(2500);
                    Battery.ChangeCharge(-Battery.CapacityWh / 100);
                }
            });

            discharge.Start();

            managebleChargeAction = new ManageableAction(new Action(() => {
                Thread.Sleep(1000);
                Battery.ChangeCharge(Charger == null ? 0f : (float)Math.Pow(Charger.ChargeCurrentMa, 2) * 0.00005f);
            }));
            BackgroundWorkerBase charge = workerFactory.CreateWorker(() => managebleChargeAction.ThreadStart());

            charge.Start();
        }
Example #2
0
        public FormCharging()
        {
            InitializeComponent();

            comboBoxFormatter.SelectedIndex = 0;
            comboBoxFormatter.Items.AddRange(formatterFactory.AvailableNames.ToArray());

            currentFormatter = formatterFactory.DefaultFormatter;

            mobile = new ModernMobile(output);
            mobile.SMSMessenger.MessageAdded += (message, isAdded) => {
                if (!phonesSet.Contains(message.Number))
                {
                    phonesSet.Add(message.Number);
                    Invoke(new Action(() => comboBoxPhone.Items.Add(message.Number)));
                }

                if (mobile.SMSMessenger.MessageHistory.Count > MAXIMUM_OUTPUT)
                {
                    List <Message> temp = mobile.SMSMessenger.MessageHistory;
                    temp.RemoveRange(0, messageHistoryCopy.Count - MAXIMUM_OUTPUT);
                    messageHistoryCopy = temp;
                }
                else
                {
                    messageHistoryCopy = mobile.SMSMessenger.MessageHistory;
                }

                try {
                    Invoke(new Action(RefreshListView));
                }
                catch (ObjectDisposedException) {}
                catch (InvalidOperationException) {}
            };

            int notMainThreadSmsCount = 1;
            BackgroundWorkerFactoryMethod workerFactory = new BackgroundWorkerFactoryMethod();

            manageableAction = new ManageableAction(new Action(() => {
                if (notMainThreadSmsCount == 1)
                {
                    Thread.Sleep(300);
                }

                mobile.ReceiveSMS($"SMS #{notMainThreadSmsCount++} NOT from Main thread.", "700");

                Thread.Sleep(1000);
            }));
            SMSBackgroundSender = workerFactory.CreateWorker(() => manageableAction.ThreadStart());
            SMSBackgroundSender.Start();

            UpdateChargeBar();
        }
Example #3
0
 public SimCorpMobile(IOutput output, BackgroundWorkerFactoryMethod backgroundWorkerFactory = null) : base(output, backgroundWorkerFactory)
 {
     OledScreen = new OLEDScreen(output, new CoordsFlat(720, 1280), new SizeFlat(50f, 100f));
 }
Example #4
0
 public ModernMobile(IOutput output, BackgroundWorkerFactoryMethod backgroundWorkerFactory = null) : base(output, backgroundWorkerFactory)
 {
     Screen = new RetinaScreen(output, new CoordsFlat(1080, 1920), new SizeFlat(50f, 100f));
 }