protected override void OnPaint(PaintEventArgs e) { ClearScreen(e.Graphics); if (_processor != null && _currentImage != null) { // apply default stretch if necessary if (_currentImage.StretchType == StretchTypes.UseDefault) { _currentImage.StretchType = _processor.SlideShowConfig.StretchDefault; } // draw the image _currentImage.Draw(e.Graphics); // paint the fileName label if (_processor.SlideShowConfig.DisplayFileInfoDefault) { int width = Screen.PrimaryScreen.Bounds.Width - (int)_pauseLabel.GetBounds(e.Graphics).Width - 80; SizeF textSize = e.Graphics.MeasureString(_processor.CurrentImage.PathAndFileName, new Font("Times New Roman", 10), width); e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, (int)textSize.Width, (int)textSize.Height); e.Graphics.DrawString(_processor.CurrentImage.PathAndFileName, new Font("Times New Roman", 10f), new SolidBrush(Color.BlanchedAlmond), new RectangleF(0, 0, textSize.Width, textSize.Height)); } // paint the pause label if (!_slideTimer.Enabled) { e.Graphics.FillRegion(new SolidBrush(Color.Black), _pauseLabel); e.Graphics.DrawString("PAUSED", new Font("Arial", 14f), new SolidBrush(Color.BlanchedAlmond), _pauseLabel.GetBounds(e.Graphics)); } // paint the textfile text if (Utilities.EvaluateFlags(_processor.SlideShowConfig.DisplayTextDefault, _currentImage.TextDisplayFlag)) { string textStr = _processor.CurrentImage.GetTextFileString(); SizeF textSize = e.Graphics.MeasureString(textStr, new Font("Times New Roman", 10), Screen.PrimaryScreen.Bounds.Width); int y = Screen.PrimaryScreen.Bounds.Height - (int)textSize.Height; e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, y, Screen.PrimaryScreen.Bounds.Width, (int)textSize.Height); e.Graphics.DrawString(textStr, new Font("Times New Roman", 10f), new SolidBrush(Color.BlanchedAlmond), new RectangleF(0, y, Screen.PrimaryScreen.Bounds.Width, (int)textSize.Height)); } } else { if (_currentImage == null) { DrawErrorMessage(e.Graphics, StringConstants.GetString(StringNames.SCRIPT_EMPTY)); } else { DrawErrorMessage(e.Graphics, StringConstants.GetString(StringNames.LOAD_SLIDESHOW_FAILED)); } } base.OnPaint(e); }
private void PreviewForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { _graphicsObj.FillRectangle(new SolidBrush(Color.Black), _graphicsObj.VisibleClipBounds); ImageItem i = _parentForm.GetCurrentImageItem(); if (i != null) { i.Draw(_graphicsObj, Screen.PrimaryScreen.Bounds); } }