コード例 #1
0
        public void Load()
        {
            var protocol = HeartRateSettingsProtocol.Load(_filename);

            if (protocol == null)
            {
                return;
            }

            FontName            = protocol.FontName;
            UIFontName          = protocol.UIFontName;
            AlertLevel          = protocol.AlertLevel;
            WarnLevel           = protocol.WarnLevel;
            AlertTimeout        = TimeSpan.FromMilliseconds(protocol.AlertTimeout);
            DisconnectedTimeout = TimeSpan.FromMilliseconds(protocol.DisconnectedTimeout);
            Color              = ColorFromString(protocol.Color);
            WarnColor          = ColorFromString(protocol.WarnColor);
            UIColor            = ColorFromString(protocol.UIColor);
            UIWarnColor        = ColorFromString(protocol.UIWarnColor);
            UIBackgroundColor  = ColorFromString(protocol.UIBackgroundColor);
            UIBackgroundFile   = protocol.UIBackgroundFile;
            UIBackgroundLayout = Enum.TryParse <ImageLayout>(
                protocol.UIBackgroundLayout, true, out var layout)
                ? layout : ImageLayout.Stretch;
            Sizable       = protocol.Sizable;
            LogFormat     = protocol.LogFormat;
            LogDateFormat = protocol.LogDateFormat;
            LogFile       = protocol.LogFile;
            IBIFile       = protocol.IBIFile;

            // In the future:
            // if (protocol.Version >= 2) ...
        }
コード例 #2
0
        public void Load()
        {
            var protocol = HeartRateSettingsProtocol.Load();

            if (protocol == null)
            {
                return;
            }

            FontName            = protocol.FontName;
            UIFontName          = protocol.UIFontName;
            AlertLevel          = protocol.AlertLevel;
            WarnLevel           = protocol.WarnLevel;
            AlertTimeout        = TimeSpan.FromMilliseconds(protocol.AlertTimeout);
            DisconnectedTimeout = TimeSpan.FromMilliseconds(protocol.DisconnectedTimeout);
            Color             = ColorFromString(protocol.Color);
            WarnColor         = ColorFromString(protocol.WarnColor);
            UIColor           = ColorFromString(protocol.UIColor);
            UIWarnColor       = ColorFromString(protocol.UIWarnColor);
            UIBackgroundColor = ColorFromString(protocol.UIBackgroundColor);
            Sizable           = protocol.Sizable;

            // In the future:
            // if (protocol.Version >= 2) ...
        }
コード例 #3
0
        public void Load()
        {
            var protocol = HeartRateSettingsProtocol.Load(_filename);

            if (protocol == null)
            {
                return;
            }

            FontName            = protocol.FontName;
            UIFontName          = protocol.UIFontName;
            UIFontStyle         = EnumOrDefault(protocol.UIFontStyle, FontStyle.Regular);
            UIFontSize          = protocol.UIFontSize ?? 20;
            UIFontUseSize       = protocol.UIFontUseSize;
            UIWindowSizeX       = protocol.UIWindowSizeX;
            UIWindowSizeY       = protocol.UIWindowSizeY;
            UITextAlignment     = EnumOrDefault(protocol.UITextAlignment, ContentAlignment.MiddleCenter);
            AlertLevel          = protocol.AlertLevel;
            WarnLevel           = protocol.WarnLevel;
            AlertTimeout        = TimeSpan.FromMilliseconds(protocol.AlertTimeout);
            DisconnectedTimeout = TimeSpan.FromMilliseconds(protocol.DisconnectedTimeout);
            Color              = ColorFromString(protocol.Color);
            WarnColor          = ColorFromString(protocol.WarnColor);
            UIColor            = ColorFromString(protocol.UIColor);
            UIWarnColor        = ColorFromString(protocol.UIWarnColor);
            UIBackgroundColor  = ColorFromString(protocol.UIBackgroundColor);
            UIBackgroundFile   = protocol.UIBackgroundFile;
            UIBackgroundLayout = EnumOrDefault(protocol.UIBackgroundLayout, ImageLayout.Stretch);
            Sizable            = protocol.Sizable;
            LogFormat          = protocol.LogFormat;
            LogDateFormat      = protocol.LogDateFormat;
            LogFile            = protocol.LogFile;
            IBIFile            = protocol.IBIFile;

            // A hack fix from a bug that's been fixed.
            if (UITextAlignment == 0)
            {
                UITextAlignment = ContentAlignment.MiddleCenter;
            }
            if (UIFontSize <= 0)
            {
                UIFontSize = 20;
            }
            if (UIWindowSizeX <= 0)
            {
                UIWindowSizeX = 350;
            }
            if (UIWindowSizeY <= 0)
            {
                UIWindowSizeY = 250;
            }

            // In the future:
            // if (protocol.Version >= 2) ...
        }
コード例 #4
0
        public static void Save(HeartRateSettings settings)
        {
            Debug.WriteLine($"Saving to {_filename}");

            var protocol = new HeartRateSettingsProtocol(settings);

            using (var fs = File.OpenWrite(_filename))
            {
                _serializer.Serialize(fs, protocol);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
0
 public void Save()
 {
     HeartRateSettingsProtocol.Save(this);
 }
コード例 #7
0
 public void Save()
 {
     HeartRateSettingsProtocol.Save(this, _filename);
 }