Exemplo n.º 1
0
        private void UpdateUICore()
        {
            if (uxBpmLabel.Font.FontFamily.Name != _settings.UIFontName ||
                uxBpmLabel.Font.Style != _settings.UIFontStyle ||
                _lastSettings?.UIFontUseSize != _settings.UIFontUseSize ||
                _lastSettings?.UIFontSize != _settings.UIFontSize)
            {
                UpdateLabelFontLocked();
            }

            if (uxBpmLabel.TextAlign != _settings.UITextAlignment)
            {
                uxBpmLabel.TextAlign = _settings.UITextAlignment;
                UpdateSubmenus();
            }

            if (uxBpmLabel.BackgroundImageLayout != _settings.UIBackgroundLayout)
            {
                uxBpmLabel.BackgroundImageLayout = _settings.UIBackgroundLayout;
                UpdateSubmenus();
            }

            if (uxBpmLabel.BackColor != _settings.UIBackgroundColor)
            {
                uxBpmLabel.BackColor = _settings.UIBackgroundColor;
            }

            if (_lastSettings?.UIBackgroundFile != _settings.UIBackgroundFile)
            {
                var oldBackgroundImage = uxBpmLabel.BackgroundImage;
                var backgroundFile     = _settings.UIBackgroundFile;

                if (!string.IsNullOrWhiteSpace(backgroundFile) &&
                    File.Exists(backgroundFile))
                {
                    try
                    {
                        var image = Image.FromFile(backgroundFile);
                        uxBpmLabel.BackgroundImage = image;
                        oldBackgroundImage.TryDispose();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show($"Unable to load background image file \"{backgroundFile}\" due to error: {e}");
                    }
                }
                else
                {
                    uxBpmLabel.BackgroundImage = null;
                    oldBackgroundImage.TryDispose();
                }
            }

            _lastSettings = _settings.Clone();

            Invalidate();
        }
Exemplo n.º 2
0
        private void UpdateUICore()
        {
            uxBpmLabel.BackColor = _settings.UIBackgroundColor;

            var fontx = _settings.UIFontName;

            if (uxBpmLabel.Font.FontFamily.Name != fontx)
            {
                UpdateLabelFontLocked();
            }

            if (_lastSettings?.UIBackgroundFile != _settings.UIBackgroundFile)
            {
                var oldBackgroundImage = uxBpmLabel.BackgroundImage;
                var backgroundFile     = _settings.UIBackgroundFile;

                if (!string.IsNullOrWhiteSpace(backgroundFile) &&
                    File.Exists(backgroundFile))
                {
                    try
                    {
                        var image = Image.FromFile(backgroundFile);
                        uxBpmLabel.BackgroundImage = image;
                        oldBackgroundImage.TryDispose();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show($"Unable to load background image file \"{backgroundFile}\" due to error: {e}");
                    }
                }
                else
                {
                    uxBpmLabel.BackgroundImage = null;
                    oldBackgroundImage.TryDispose();
                }
            }

            if (_lastSettings?.UIBackgroundLayout != _settings.UIBackgroundLayout)
            {
                uxBpmLabel.BackgroundImageLayout = _settings.UIBackgroundLayout;
            }

            _lastSettings = _settings.Clone();
        }