コード例 #1
0
        private void PictureBox_Paint(object sender, PaintEventArgs e)
        {
            Quote q;

            if (string.IsNullOrWhiteSpace(_configSettings.SourcePath))
            {
                q = QuoteManager.Default;
            }
            else
            {
                QuoteManager manager = QuoteManager.Create(_configSettings.SourcePath);
                q = manager?.ReadRandom() ?? QuoteManager.Default;
            }

            QuoteRenderer renderer = new QuoteRenderer(new RenderSettings()
            {
                TextFont            = _configSettings.TextFont,
                TextColor           = _configSettings.TextColor,
                TextAlignment       = (TextAlignment)_configSettings.TextAlignment,
                BackgroundColor     = _configSettings.BackgroundColor,
                BackgroundImagePath = _configSettings.BackgroundImagePath,
                BackgroundAlignment = (BackgroundAlignment)_configSettings.BackgroundAlignment,
                BackgroundOpacity   = _configSettings.BackgroundOpacity
            });

            renderer.RenderText(q, e.Graphics, (sender as PictureBox).ClientRectangle);
        }
コード例 #2
0
        public void Initialize(bool isPreview)
        {
            if (_isInitialized)
            {
                return;
            }

            _isInitialized = true;

            _renderer = new QuoteRenderer(new RenderSettings()
            {
                BackgroundAlignment = (BackgroundAlignment)Settings.Default.BackgroundAlignment,
                BackgroundColor     = Settings.Default.BackgroundColor,
                BackgroundImagePath = Settings.Default.BackgroundImagePath,
                BackgroundOpacity   = Settings.Default.BackgroundOpacity,
                TextAlignment       = (TextAlignment)Settings.Default.TextAlignment,
                TextColor           = Settings.Default.TextColor,
                TextFont            = Settings.Default.TextFont
            });

            QuoteManager manager = QuoteManager.Create(Settings.Default.SourcePath);

            if (manager != null)
            {
                _quote = manager.ReadRandom();
            }
            else
            {
                _quote = QuoteManager.Default;
            }
        }