Exemple #1
0
        internal HeartRateForm(
            IHeartRateService service,
            string settingsFilename,
            DateTime now)
        {
            try
            {
                _settings = HeartRateSettings.CreateDefault(settingsFilename);
                LoadSettingsLocked();
                _settings.Save();
                _service         = service;
                _startedAt       = now;
                _iconBitmap      = new Bitmap(_iconWidth, _iconHeight);
                _iconGraphics    = Graphics.FromImage(_iconBitmap);
                _measurementFont = new Font(
                    _settings.FontName, _iconWidth,
                    GraphicsUnit.Pixel);
                _watchdog = new HeartRateServiceWatchdog(
                    TimeSpan.FromSeconds(10), _service);

                InitializeComponent();

                FormBorderStyle = _settings.Sizable
                    ? FormBorderStyle.Sizable
                    : FormBorderStyle.SizableToolWindow;
            }
            catch
            {
                TryDispose(service);
                throw;
            }
        }
        public HeartRateViewModel(IHeartRateService heartRateService)
        {
            _uiFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());

            _heartRateService = heartRateService;
            RegisterEvents();
        }
        public HeartRateViewModel( IHeartRateService heartRateService )
        {
            _uiFactory = new TaskFactory( TaskScheduler.FromCurrentSynchronizationContext() );

            _heartRateService = heartRateService;
            RegisterEvents();
        }
Exemple #4
0
        public HeartRateServiceWatchdog(
            TimeSpan timeout,
            IHeartRateService service)
        {
            _timeout = timeout;
            _service = service ?? throw new ArgumentNullException(nameof(service));
            _service.HeartRateUpdated += _service_HeartRateUpdated;

            var thread = new Thread(WatchdogThread)
            {
                Name         = GetType().Name,
                IsBackground = true
            };

            thread.Start();
        }
        internal HeartRateForm(
            IHeartRateService service,
            string settingsFilename,
            DateTime now)
        {
            try
            {
                // Order of operations -- _startedAt has to be set before
                // `LoadSettingsLocked` is called.
                _startedAt = now;

                _settings = HeartRateSettings.CreateDefault(settingsFilename);
                LoadSettingsLocked();
                _settings.Save();
                _service         = service;
                _iconBitmap      = new Bitmap(_iconWidth, _iconHeight);
                _iconGraphics    = Graphics.FromImage(_iconBitmap);
                _measurementFont = new Font(
                    _settings.FontName, _iconWidth,
                    GraphicsUnit.Pixel);
                _watchdog = new HeartRateServiceWatchdog(
                    TimeSpan.FromSeconds(10), _service);

                InitializeComponent();

                FormBorderStyle = _settings.Sizable
                    ? FormBorderStyle.Sizable
                    : FormBorderStyle.SizableToolWindow;

                CreateEnumSubmenu <ContentAlignment>(textAlignmentToolStripMenuItem,
                                                     textAlignmentToolStripMenuItemItem_Click);

                CreateEnumSubmenu <ImageLayout>(backgroundImagePositionToolStripMenuItem,
                                                backgroundImagePositionToolStripMenuItemItem_Click);
            }
            catch
            {
                service.TryDispose();
                throw;
            }
        }
Exemple #6
0
        internal HeartRateForm(
            IHeartRateService service,
            string settingsFilename,
            DateTime now)
        {
            try
            {
                _settings = HeartRateSettings.CreateDefault(settingsFilename);
                LoadSettingsLocked();
                _settings.Save();
                _service         = service;
                _startedAt       = now;
                _iconBitmap      = new Bitmap(_iconWidth, _iconHeight);
                _iconGraphics    = Graphics.FromImage(_iconBitmap);
                _measurementFont = new Font(
                    _settings.FontName, _iconWidth,
                    GraphicsUnit.Pixel);
                _watchdog = new HeartRateServiceWatchdog(
                    TimeSpan.FromSeconds(10), _service);

                InitializeComponent();

                FormBorderStyle = _settings.Sizable
                    ? FormBorderStyle.Sizable
                    : FormBorderStyle.SizableToolWindow;


                // EB:
                Locator.CurrentMutable.RegisterLazySingleton(() => new SettingsServiceImplementation(), typeof(ISettingsServiceImplementation));
                Locator.CurrentMutable.RegisterLazySingleton(() => new DependencyService(), typeof(IDependencyService));
                Locator.CurrentMutable.RegisterLazySingleton(() => new SettingsService(), typeof(ISettingsService));
                Locator.CurrentMutable.RegisterLazySingleton(() => new NeuronClient(), typeof(INeuronClient));
                this.neuronApplicationService = new NeuronApplicationService();
            }
            catch
            {
                TryDispose(service);
                throw;
            }
        }