/// <summary> /// Handles a power state change. /// </summary> /// <param name = "batteryService">The battery service.</param> public void HandlePowerStateChange(IBatteryService batteryService) { // State change, make sure we're in a valid state if (batteryService.IsValidState) { if (_lastPowerEvent == null // FSIGAP - just keep track of ac state changes.. battery level changes were causing battery/AC code to run || _lastPowerEvent == EventType.SwitchToAc && batteryService.OnBattery || // changed from ac to on battery _lastPowerEvent == EventType.SwitchToBattery && batteryService.OnAcPower // changes from battery to on ac ) { EventType eventType; if (batteryService.OnAcPower) { eventType = EventType.SwitchToAc; } else { eventType = EventType.SwitchToBattery; } // Check the event state //ProcessStateChange(eventType); _lastPowerEvent = eventType; // Execute all of the actions for this event if they are within the threshold var batteryLifePercent = batteryService.GetSystemPowerStatus().BatteryLifePercent; _profile.GetActionsForEvent(eventType) .TakeWhile(a => batteryLifePercent >= (a.BatteryPercentMin) && batteryLifePercent <= (a.BatteryPercentMax)) .Each(a => a.Execute()); } } }
public HomePageViewModel(IModuleManager moduleManager, INavigationService navigationService, IBatteryService batteryService, IPageDialogService pageDialogService) { _moduleManager = moduleManager; _navigationService = navigationService; _batteryService = batteryService; _pageDialogService = pageDialogService; GetBatteryStatusCommand = new DelegateCommand(GetBatteryStatus).ObservesCanExecute(() => AllFieldsAreValid); }
public BatteryServiceTests() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "TestDb").Options; this.connection = new ApplicationDbContext(options); this.batteryRepository = new EfRepository <Battery>(this.connection); this.batteryService = new BatteryService(this.batteryRepository); }
public EstadoBateriaPageViewModel(INavigationService navigationService, IBatteryService batteryService, IPageDialogService pageDialogService) { _navigationService = navigationService; _batteryService = batteryService; _pageDialogService = pageDialogService; GetBatteryStatusCommand = new DelegateCommand(GetBatteryStatus).ObservesCanExecute(() => true); }
static BatterySaverCore() { _batteryService = new BatteryService(); // Remove the event listener on application exit Application.ApplicationExit += (sender, e) => { SystemEvents.PowerModeChanged -= OnSystemEventsOnPowerModeChanged; SystemTray.Instance.Dispose(); }; }
public NewReminderViewModel(INavService navService, IDataStore <Reminder> dataStore, IVibrationService vibrationService, IHapticsService hapticsService, IBatteryService batteryService) : base(navService, dataStore) { _vibrationService = vibrationService; _hapticsService = hapticsService; _batteryService = batteryService; SaveCommand = new Command(OnSave, ValidateSave); CancelCommand = new Command(OnCancel); this.PropertyChanged += (_, __) => SaveCommand.ChangeCanExecute(); }
public SpeakPageViewModel( INavigationService navigationService, IPageDialogService pageDialog, IBatteryService batteryService, IScanBarcode scanBarcode) : base(navigationService) { SpeakCommand = new DelegateCommand(Speak); _pageDialog = pageDialog; _batteryService = batteryService; _scanBarcode = scanBarcode; }
public BatteryAdminController( ICategoriesService categoriesService, IBrandsService brandsService, IBatteryService batteryService, ICapacityService capacityService, IAmperageService amperageService, ITechnologyService technologyService) { this.categoriesService = categoriesService; this.brandsService = brandsService; this.batteryService = batteryService; this.capacityService = capacityService; this.amperageService = amperageService; this.technologyService = technologyService; }
public void Dispose() { _service = null; _mockBatteryRepo = null; _mockComponentRepo = null; _batteryStaticData1 = null; _batteryStaticData = null; _batteryFullChargedCapacity1 = null; _batteryFullChargedCapacities = null; _win32Battery1 = null; _win32Batteries = null; _battery1 = null; _batteries = null; GC.SuppressFinalize(this); }
/// <summary> /// Monitors the state. /// </summary> /// <param name = "batteryService">The battery service.</param> private void MonitorBatteryLevel(IBatteryService batteryService) { if (_lastKnownState == null) { _lastKnownState = batteryService.GetSystemPowerStatus(); } var currentState = batteryService.GetSystemPowerStatus(); if (currentState.BatteryLifePercent != _lastKnownState.BatteryLifePercent) { _lastKnownState = currentState; HandleBatteryLevelChange(batteryService, currentState.BatteryLifePercent, currentState.BatteryLifePercent - _lastKnownState.BatteryLifePercent); return; } _lastKnownState = currentState; }
/// <summary> /// Handles a battery level change. /// </summary> /// <param name = "batteryService">The battery service.</param> /// <param name = "batteryLifePercent">The battery life percent.</param> /// <param name = "percentageDelta">The amout of change in percent.</param> public void HandleBatteryLevelChange(IBatteryService batteryService, int batteryLifePercent, int percentageDelta) { EventType eventType = EventType.BatteryPercentDecreased; if (percentageDelta > 0) { eventType = EventType.BatteryPercentIncreased; } // Check the event state ProcessStateChange(eventType); // Execute all of the actions that are within the battery threshold and have not yet been executed // NOTE: actions are only executed ONCE after they've reached their threshold _profile.GetActionsForEvent(eventType) .TakeWhile(a => !a.HasExecuted && batteryLifePercent >= (a.BatteryPercentMin) && batteryLifePercent <= (a.BatteryPercentMax)) .Each(a => a.Execute()); }
public AddMaintenanceForm() { InitializeComponent(); logger = new Logger.Logger(); oilService = new OilService(); taxService = new TaxService(); tiresService = new TiresService(); clutchService = new ClutchService(); batteryService = new BatteryService(); reviewService = new ReviewService(); coolantService = new CoolantService(); oilFilterService = new OilFilterService(); brakeFluidService = new BrakeFluidService(); rearBrakesService = new RearBrakesService(); frontBrakesService = new FrontBrakesService(); maintenanceService = new MaintenanceService(); contributionService = new ContributionService(); }
/// <summary> /// Starts the power state monitor. /// </summary> /// <remarks> /// We could register for the power setting notifications via RegisterPowerSettingNotification, but this only availablein Vista+ /// </remarks> /// <param name = "batteryService">The battery service.</param> public void StartBatteryLevelMonitor(IBatteryService batteryService) { if (_monitorThread == null) { // Save the battery service _batteryService = batteryService; if (batteryService.OnAcPower) { _lastPowerEvent = EventType.SwitchToAc; } else { _lastPowerEvent = EventType.SwitchToBattery; } // Create monitoring thread var threadStart = new ThreadStart(MonitorBatteryLevel); _monitorThread = new Thread(threadStart) { Name = "Batter State Monitor - BW Worker" }; _monitorThread.Start(); } }
public BatteriesController(IBatteryService batteryService, IMapper mapper) { _batteryService = batteryService; _mapper = mapper; }
public BatteryController(IBatteryService batteryService) { _batteryService = batteryService; }
/// <summary> /// Konstruktor bezparametryczny /// snippet - ctor + tab tab /// </summary> public BatteryController(IBatteryService _batteryService) { _batteries = new ApplicationDbGeneric <Battery>(); batteryService = _batteryService; }
public BatteryController(IBatteryService service, ILogger <BatteryController> logger) : base(service, logger) { this.service = service; }
public BatteryAlarmForm() { InitializeComponent(); //Registry Model _regModel = new RegistryModel() { KeyName = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", ValueName = "ARTHA.BatteryAlarm.AutoRun", Value = "C:\\Program Files\\ARTHA.BatteryAlarm\\ARTHA.BatteryAlarm.exe\" -autorun", RegValueKind = RegistryValueKind.String }; //registry Factory Instansiate _regFactory = new RegistryFactory(_regModel); //Checked or not if (_regFactory.IsRegistryExist()) { chkAutorun.Checked = true; } else { chkAutorun.Checked = false; } // general seting for xml model and factory _xmlFactory = new XmlValueFactory(XmlConstant.XmlFileLocation); _xmlModel = new XmlModel() { ElementName = XmlConstant.XmlElementName, AttrKeyName = XmlConstant.XmlKey, AttrValueName = XmlConstant.XmlValue }; this.ShowInTaskbar = false; //sound Player _soundPlayer = new SoundPlayer(); //timer _timer = new Timer(); _timer.Tick += new EventHandler(BatteryTimer_Tick); _timer.Interval = Constant.DefaultIntervalTimer; _timer.Start(); //instansiate service and model _batteryService = new BatteryService(); _alarmService = new AlarmService(); _alarmModel = new AlarmModel(); _batteryModel = new BatteryModel(); //populate Batery Level combobox cmbBateryLevel.DataSource = PopulateComboBox(Constant.MinBateryLevel, Constant.MaxBateryLevel, Constant.MultipleIterationValue); InitializeAlarmTrigger(); //button close Event Handler btnMinimize.Click += new EventHandler(btnMinimize_Click); //button open file event Handler btnOpenFile.Click += new EventHandler(btnOpenFile_Click); //button save setting event handler btnSaveSetting.Click += new EventHandler(btnSaveSetting_Click); //label Warning LabelTitle.Text = Constant.AppName; LabelTitle.AutoSize = Constant.LabelSet.AutoSize; LabelTitle.Font = Constant.LabelSet.Font; //button Stop Sound Event Handler btnStopSound.Click += new EventHandler(btnStopSound_Click); //label prosen label2.Text = Constant.Prosen; }
private void SetupService() { _service = new BatteryService(_mockBatteryRepo.Object, _mockComponentRepo.Object); }
public BatteryMonitorController(IBatteryService batteryService) { this.batteryService = batteryService; }