<commit_before>﻿/* Copyright (c) 2016 <NAME>
 * This code is distributed under the terms of the MIT License (https://opensource.org/licenses/MIT)
 * GitHub Repository: https://github.com/stefan-baumann/MultislitSimulator
 */

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MultislitSimulator.Rendering
{
    public abstract class RenderingSurfaceBase
        : Control
    {
        protected RenderingSurfaceBase()
        {
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
        }

        protected abstract void Render(Graphics g);

        protected override void OnPaint(PaintEventArgs e)
        {
            //e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            using (BufferedGraphics g = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(Point.Empty, this.Size)))
            {
                //g.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                this.Render(g.Graphics);

                g.Graphics.DrawString("<NAME>", this.Font, Brushes.White, new Rectangle(Point.Empty, new Size(this.Width - 10, this.Height - 5)), new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Far });

                g.Render();
            }

            base.OnPaint(e);
        }
    }<commit_msg>Added documentation to the RenderingSurfaceBase class<commit_after>﻿/* Copyright (c) 2016 <NAME>
 * This code is distributed under the terms of the MIT License (https://opensource.org/licenses/MIT)
 * GitHub Repository: https://github.com/stefan-baumann/MultislitSimulator
 */

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MultislitSimulator.Rendering
{
    /// <summary>
    /// A base class for UI elements which rely on high-speed rendering and complete userpaint.
    /// </summary>
    /// <seealso cref="System.Windows.Forms.Control" />
    public abstract class RenderingSurfaceBase
        : Control
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderingSurfaceBase"/> class.
        /// </summary>
        protected RenderingSurfaceBase()
        {
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
        }

        /// <summary>
        /// Renders the content to specified <see cref="Graphics"/> object.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> object.</param>
        protected abstract void Render(Graphics g);

        /// <summary>
        /// Paints this <see cref="RenderingSurfaceBase"/> to the screen.
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            //Additional graphics buffering even though the control is already double-buffered itself - just to be sure
            using (BufferedGraphics g = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(Point.Empty, this.Size)))
            {
                this.Render(g.Graphics);

                //"Copyright notice" :P
                g.Graphics.DrawString("<NAME>", this.Font, Brushes.White, new Rectangle(Point.Empty, new Size(this.Width - 10, this.Height - 5)), new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Far });

                g.Render();
            }

            base.OnPaint(e);
        }
    }
{'fraction_non_alphanumeric': 0.10875194199896426, 'fraction_numerical': 0.004142931123770067, 'mean_word_length': 2.634054562558796, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6817650', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1018, 'n_words': 252}