<commit_before>﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using PFE.Models;
using PFE.Configs;
using tablature_editor.Utils;

namespace PFE
{
    class DrawSurface : FrameworkElement
    {
        protected VisualCollection visuals;

        protected DrawingContext drawingContext;
        protected DrawingVisual drawingVisual;

        private bool isDrawing = false;

        public DrawSurface()
        {
            visuals = new VisualCollection(this);
        }

        public void StartDrawing()
        {
            isDrawing = true;

            visuals.Clear();
            drawingVisual = new DrawingVisual();
            drawingContext = drawingVisual.RenderOpen();
        }

        public void EndDrawing()
        {
            isDrawing = false;

            drawingContext.Close();
            visuals.Add(drawingVisual);
        }

        public void DrawBackground()
        {
            drawingContext.DrawRectangle(
                Brushes.Black,
                null,
                new Rect(new Point(0, 0), new Size(this.Width, this.Height)));
        }

        //TODO move logic manipulating tabCoord out of drawsurface
        public void DrawRectangle(CanvasCoord canvasCoord)
        {
            if (!isDrawing)
                throw new Exception();

            Point point = new Point(canvasCoord.x, canvasCoord.y);

            drawingContext.DrawRectangle(
                Brushes.LightBlue,
                null,
                new Rect(point, new Size(Config_DrawSurface.Inst().GridUnitWidth, Config_DrawSurface.Inst().GridUnitWidth)));
        }

        //TODO move logic manipulating tabCoord out of drawsurface
        public void DrawTextAtTabCoord(CanvasCoord canvasCoord, char text)
        {
            if (!isDrawing)
                throw new Exception("Something is wrong with the input text");
            
                Point point = new Point(canvasCoord.x, canvasCoord.y);
                DrawCharAtPoint(point, text);
        }

        private void DrawCharAtPoint(Point point, char c)
        {
            FormattedText formattedText =
                new FormattedText(
                    c.ToString(),
                    CultureInfo.GetCultureInfo("en-us"),
                    FlowDirection.LeftToRight,
                    Config_DrawSurface.Inst().TextFont,
                    Config_DrawSurface.Inst().FontSize,
                    Brushes.White);

            drawingContext.DrawText(
                formattedText,
                point);
        }

        protected override Visual GetVisualChild(int index)
        {
            return visuals[index];
        }

        protected override int VisualChildrenCount
        {
            get { return visuals.Count; }
        }
    }
}
<commit_msg>Removed old TODOs<commit_after>﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using PFE.Models;
using PFE.Configs;
using tablature_editor.Utils;

namespace PFE
{
    class DrawSurface : FrameworkElement
    {
        protected VisualCollection visuals;

        protected DrawingContext drawingContext;
        protected DrawingVisual drawingVisual;

        private bool isDrawing = false;

        public DrawSurface()
        {
            visuals = new VisualCollection(this);
        }

        public void StartDrawing()
        {
            isDrawing = true;

            visuals.Clear();
            drawingVisual = new DrawingVisual();
            drawingContext = drawingVisual.RenderOpen();
        }

        public void EndDrawing()
        {
            isDrawing = false;

            drawingContext.Close();
            visuals.Add(drawingVisual);
        }

        public void DrawBackground()
        {
            drawingContext.DrawRectangle(
                Brushes.Black,
                null,
                new Rect(new Point(0, 0), new Size(this.Width, this.Height)));
        }

        public void DrawRectangle(CanvasCoord canvasCoord)
        {
            if (!isDrawing)
                throw new Exception();

            Point point = new Point(canvasCoord.x, canvasCoord.y);

            drawingContext.DrawRectangle(
                Brushes.LightBlue,
                null,
                new Rect(point, new Size(Config_DrawSurface.Inst().GridUnitWidth, Config_DrawSurface.Inst().GridUnitWidth)));
        }

        public void DrawTextAtTabCoord(CanvasCoord canvasCoord, char text)
        {
            if (!isDrawing)
                throw new Exception("Something is wrong with the input text");
            
                Point point = new Point(canvasCoord.x, canvasCoord.y);
                DrawCharAtPoint(point, text);
        }

        private void DrawCharAtPoint(Point point, char c)
        {
            FormattedText formattedText =
                new FormattedText(
                    c.ToString(),
                    CultureInfo.GetCultureInfo("en-us"),
                    FlowDirection.LeftToRight,
                    Config_DrawSurface.Inst().TextFont,
                    Config_DrawSurface.Inst().FontSize,
                    Brushes.White);

            drawingContext.DrawText(
                formattedText,
                point);
        }

        protected override Visual GetVisualChild(int index)
        {
            return visuals[index];
        }

        protected override int VisualChildrenCount
        {
            get { return visuals.Count; }
        }
    }
}

{'fraction_non_alphanumeric': 0.07450271247739602, 'fraction_numerical': 0.0007233273056057866, 'mean_word_length': 1.6126594237128011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5439002', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1294, 'n_words': 312}