Пример #1
0
 public HeartRateForm() : this(
         Environment.CommandLine.Contains("--test")
         ? (IHeartRateService) new TestHeartRateService()
         : new HeartRateService(),
         HeartRateSettings.GetFilename(),
         DateTime.Now)
 {
 }
Пример #2
0
        internal static void Save(HeartRateSettings settings, string filename)
        {
            Debug.WriteLine($"Saving to {filename}");

            var protocol = new HeartRateSettingsProtocol(settings);

            using (var fs = File.Open(filename,
                                      FileMode.Create, FileAccess.Write))
            {
                _serializer.Serialize(fs, protocol);
            }
        }
Пример #3
0
 private HeartRateSettingsProtocol(HeartRateSettings settings)
 {
     Version             = settings.Version;
     FontName            = settings.FontName;
     AlertLevel          = settings.AlertLevel;
     UIFontName          = settings.UIFontName;
     WarnLevel           = settings.WarnLevel;
     AlertTimeout        = (int)settings.AlertTimeout.TotalMilliseconds;
     DisconnectedTimeout = (int)settings.DisconnectedTimeout.TotalMilliseconds;
     Color             = ColorToString(settings.Color);
     WarnColor         = ColorToString(settings.WarnColor);
     UIColor           = ColorToString(settings.UIColor);
     UIWarnColor       = ColorToString(settings.UIWarnColor);
     UIBackgroundColor = ColorToString(settings.UIBackgroundColor);
     Sizable           = settings.Sizable;
     LogFormat         = settings.LogFormat;
     LogDateFormat     = settings.LogDateFormat ?? DateTimeFormatter.DefaultColumn;
     LogFile           = settings.LogFile ?? " ";
 }
Пример #4
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;
            }
        }
Пример #5
0
        private void uxMenuEditSettings_Click(object sender, EventArgs e)
        {
            var thread = new Thread(() => {
                using (var process = Process.Start(new ProcessStartInfo {
                    FileName = HeartRateSettings.GetFilename(),
                    UseShellExecute = true,
                    Verb = "EDIT"
                }))
                {
                    process.WaitForExit();
                }

                lock (_updateSync)
                {
                    LoadSettingsLocked();
                }
            })
            {
                IsBackground = true,
                Name         = "Edit config"
            };

            thread.Start();
        }