コード例 #1
0
ファイル: AppContext.cs プロジェクト: teleriddler/GlucoseTray
        private void CreateIcon()
        {
            IsCriticalLow = false;
            var service = new GlucoseFetchService(new GlucoseFetchConfiguration
            {
                DexcomUsername        = Constants.DexcomUsername,
                DexcomPassword        = Constants.DexcomPassword,
                FetchMethod           = Constants.FetchMethod,
                NightscoutUrl         = Constants.NightscoutUrl,
                NightscoutAccessToken = Constants.AccessToken,
                UnitDisplayType       = Constants.GlucoseUnitType
            }, _logger);

            FetchResult = service.GetLatestReading();
            var value = FetchResult.Value.ToString();

            if (value.Contains("."))
            {
                value = FetchResult.Value.ToString("0.0");
            }
            trayIcon.Text = $"{value}   {FetchResult.Time.ToLongTimeString()}  {FetchResult.TrendIcon}";
            if (FetchResult.Value <= Constants.CriticalLowBg)
            {
                IsCriticalLow = true;
            }
            _iconService.CreateTextIcon(FetchResult.Value, IsCriticalLow, trayIcon);
        }
コード例 #2
0
        private async Task CreateIcon()
        {
            IsCriticalLow = false;
            var service = new GlucoseFetchService(new GlucoseFetchConfiguration
            {
                DexcomUsername        = Constants.DexcomUsername,
                DexcomPassword        = Constants.DexcomPassword,
                FetchMethod           = Constants.FetchMethod,
                NightscoutUrl         = Constants.NightscoutUrl,
                NightscoutAccessToken = Constants.AccessToken,
                UnitDisplayType       = Constants.GlucoseUnitType
            }, _logger);

            PreviousFetchResult = FetchResult;
            FetchResult         = await service.GetLatestReading().ConfigureAwait(false);

            trayIcon.Text = GetGlucoseMessage();
            if (FetchResult.Value <= Constants.CriticalLowBg)
            {
                IsCriticalLow = true;
            }
            _iconService.CreateTextIcon(FetchResult, IsCriticalLow, trayIcon);

            if (PreviousFetchResult != null &&
                PreviousFetchResult.TrendIcon != "⮅" && PreviousFetchResult.TrendIcon != "⮇" &&
                (FetchResult.TrendIcon == "⮅" || FetchResult.TrendIcon == "⮇"))
            {
                // Show balloon when the trend changes to double arrow
                trayIcon.ShowBalloonTip(3000, "Glucose", $"{FetchResult.TrendIcon} {FetchResult.Value}", ToolTipIcon.Warning);
            }

            if (PreviousFetchResult != null &&
                PreviousFetchResult.Value < Constants.HighBg && FetchResult.Value >= Constants.HighBg)
            {
                // Show balloon when it crosses the HighBG threshold
                trayIcon.ShowBalloonTip(3000, "Glucose", $"{FetchResult.TrendIcon} {FetchResult.Value}", ToolTipIcon.Warning);
            }

            if (PreviousFetchResult != null &&
                PreviousFetchResult.Value > Constants.LowBg && FetchResult.Value <= Constants.LowBg)
            {
                // Show balloon when it crosses the LowBG threshold
                trayIcon.ShowBalloonTip(3000, "Glucose", $"{FetchResult.TrendIcon} {FetchResult.Value}", ToolTipIcon.Warning);
            }
        }
コード例 #3
0
ファイル: AppContext.cs プロジェクト: augure2004/GlucoseTray
        private async Task CreateIcon()
        {
            IsCriticalLow = false;
            var service = new GlucoseFetchService(new GlucoseFetchConfiguration
            {
                DexcomUsername        = Constants.DexcomUsername,
                DexcomPassword        = Constants.DexcomPassword,
                FetchMethod           = Constants.FetchMethod,
                NightscoutUrl         = Constants.NightscoutUrl,
                NightscoutAccessToken = Constants.AccessToken,
                UnitDisplayType       = Constants.GlucoseUnitType
            }, _logger);

            FetchResult = await service.GetLatestReading().ConfigureAwait(false);

            trayIcon.Text = GetGlucoseMessage();
            if (FetchResult.Value <= Constants.CriticalLowBg)
            {
                IsCriticalLow = true;
            }
            _iconService.CreateTextIcon(FetchResult, IsCriticalLow, trayIcon);
        }