<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;

using ZD.Common;
using ZD.Gui.Zen;

namespace ZD.Gui
{
    partial class OneResultControl
    {
        /// <summary>
        /// Paints all hilites in headword.
        /// </summary>
        private void doPaintHanziHilites(Graphics g, Color bgcol)
        {
            if (res.HanziHiliteStart == -1)
                return;

            g.SmoothingMode = SmoothingMode.None;
            HeadBlock hb;
            RectangleF rect;
            // Width of gradient
            float gradw = ideoSize.Width / 2.0F;
            // Extent of gradient outside character
            float gradext = 0;
            using (Brush b = new SolidBrush(Magic.HiliteColor))
            {
                // In simplified
                if (headInfo.SimpBlocks.Count != 0)
                {
                    // Solid highlight on each character
                    for (int ix = res.HanziHiliteStart; ix != res.HanziHiliteStart + res.HanziHiliteLength; ++ix)
                    {
                        hb = headInfo.SimpBlocks[ix];
                        rect = new RectangleF(hb.Loc.X, hb.Loc.Y, hb.Size.Width, hb.Size.Height);
                        g.FillRectangle(b, rect);
                    }
                    // First and last chars get gradient on left and right
                    hb = headInfo.SimpBlocks[res.HanziHiliteStart];
                    rect = new RectangleF(hb.Loc.X, hb.Loc.Y, gradw, hb.Size.Height);
                    rect.X -= gradext;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(rect, bgcol, Magic.HiliteColor, LinearGradientMode.Horizontal))
                    {
                        g.FillRectangle(lgb, rect);
                    }
                    hb = headInfo.SimpBlocks[res.HanziHiliteStart + res.HanziHiliteLength - 1];
                    rect = new RectangleF(hb.Loc.X + hb.Size.Width, hb.Loc.Y, gradw, hb.Size.Height);
                    rect.X += gradext;
                    rect.X -= gradw;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(rect, Magic.HiliteColor, bgcol, LinearGradientMode.Horizontal))
                    {<commit_msg>fix: gradient brush workaround for hanzi hilites<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;

using ZD.Common;
using ZD.Gui.Zen;

namespace ZD.Gui
{
    partial class OneResultControl
    {
        /// <summary>
        /// Paints all hilites in headword.
        /// </summary>
        private void doPaintHanziHilites(Graphics g, Color bgcol)
        {
            if (res.HanziHiliteStart == -1)
                return;

            g.SmoothingMode = SmoothingMode.None;
            HeadBlock hb;
            RectangleF rect, brushRect;
            // Width of gradient
            float gradw = ideoSize.Width / 2.0F;
            // Extent of gradient outside character
            float gradext = 0;
            using (Brush b = new SolidBrush(Magic.HiliteColor))
            {
                // In simplified
                if (headInfo.SimpBlocks.Count != 0)
                {
                    // Solid highlight on each character
                    for (int ix = res.HanziHiliteStart; ix != res.HanziHiliteStart + res.HanziHiliteLength; ++ix)
                    {
                        hb = headInfo.SimpBlocks[ix];
                        rect = new RectangleF(hb.Loc.X, hb.Loc.Y, hb.Size.Width, hb.Size.Height);
                        g.FillRectangle(b, rect);
                    }
                    // First and last chars get gradient on left and right
                    hb = headInfo.SimpBlocks[res.HanziHiliteStart];
                    rect = new RectangleF(hb.Loc.X, hb.Loc.Y, gradw, hb.Size.Height);
                    rect.X -= gradext;
                    // Brush must extend beyond due to gradient brush bug
                    brushRect = rect;
                    brushRect.X -= 1;
                    brushRect.Width += 1;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(brushRect, bgcol, Magic.HiliteColor, LinearGradientMode.Horizontal))
                    {
                        g.FillRectangle(lgb, rect);
                    }
                    hb = headInfo.SimpBlocks[res.HanziHiliteStart + res.HanziHiliteLength - 1];
                    rect = new RectangleF(hb.Loc.X + hb.Size.Width, hb.Loc.Y, gradw, hb.Size.Height);
                    rect.X += gradext;
                    rect.X -= gradw;
                    // Brush must extend beyond due to gradient brush bug
                    brushRect = rect;
                    brushRect.X -= 1;
                    brushRect.Width += 1;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(brushRect, Magic.HiliteColor, bgcol, LinearGradientMode.Horizontal))
                    {
{'fraction_non_alphanumeric': 0.08943089430894309, 'fraction_numerical': 0.003484320557491289, 'mean_word_length': 1.4418714555765595, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5606733', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1385, 'n_words': 335}