コード例 #1
0
        private void Settings_FormClosed(object sender, FormClosedEventArgs e)
        {
            var settings = new SettingsObj
            {
                Font         = FontSerializationHelper.Serialize(_font),
                Color1       = btnColor1.BackColor,
                Color2       = btnColor2.BackColor,
                BorderColor  = btnBorderColor.BackColor,
                GradientType = cbxGradientType.SelectedIndex
            };

            File.WriteAllText(_savePath, JsonConvert.SerializeObject(settings));
        }
コード例 #2
0
        public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            // perform some action depending on the notification type
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (type)
            {
            case NotificationType.PluginStartup:
                // while (!Debugger.IsAttached) Thread.Sleep(1);
                try
                {
                    try
                    {
                        _settings = JsonConvert.DeserializeObject <SettingsObj>(File.ReadAllText(SettingsPath));
                    }
                    catch (Exception)
                    {
                        _settings = new SettingsObj
                        {
                            BorderColor  = Color.Black,
                            Color1       = Color.GhostWhite,
                            Color2       = Color.LightGray,
                            FontActual   = new Font(FontFamily.GenericSansSerif, 34.0f, FontStyle.Regular, GraphicsUnit.Point),
                            GradientType = 1
                        };
                    }

                    StartupMenuItem();
                    StartupForm();

                    if (_timer != null && _timer.Enabled)
                    {
                        _timer.Enabled = false;
                    }
                    _timer = new Timer(UpdateIntervalMs)
                    {
                        AutoReset = false
                    };
                    _timer.Elapsed += TimerTick;
                    _timer.Start();
                }
                catch (Exception e)
                {
                    _mbApiInterface.MB_Trace(e.ToString());
                }
                break;
            }
        }
コード例 #3
0
        // Thread unsafe!!!
        public static void UpdateFromSettings(SettingsObj settings, int width)
        {
            _mainFont = settings.FontActual;
            _subFont  = new Font(_mainFont.FontFamily, _mainFont.Size * 0.8f, _mainFont.Style, _mainFont.Unit, _mainFont.GdiCharSet);
            _borderPen?.Dispose();
            _borderPen = new Pen(settings.BorderColor, 2f)
            {
                LineJoin = LineJoin.Round,
                EndCap   = LineCap.Round,
                StartCap = LineCap.Round
            };
            _type   = (GredientType)settings.GradientType;
            _color1 = settings.Color1;
            _color2 = settings.Color2;

            _width = width;
        }
コード例 #4
0
 private void SaveSettings(SettingsObj settings)
 {
     File.WriteAllText(SettingsPath, JsonConvert.SerializeObject(settings));
 }
コード例 #5
0
        public void UpdateFromSettings(SettingsObj settings)
        {
            LyricsRenderer.UpdateFromSettings(settings, Width);

            Redraw();
        }
コード例 #6
0
 public FrmSettings(SettingsObj settings)
 {
     InitializeComponent();
     cbxGradientType.SelectedIndex = 0;
     _settings = settings;
 }
コード例 #7
0
        public FrmLyrics(SettingsObj settings)
        {
            _settings = settings;

            InitializeComponent();
        }