<commit_before>﻿//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// C# Port port by: <NAME>
//                  <EMAIL>
// Copyright (C) 2007
//
// Permission to copy, use, modify, sell and distribute this software 
// is granted provided this copyright notice appears in all copies. 
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
using System;

using MatterHackers.Agg;
using MatterHackers.Agg.VertexSource;
using MatterHackers.VectorMath;

namespace MatterHackers.Agg.UI
{
    public class CheckBoxViewStates : GuiWidget
    {
        private GuiWidget normal;
        private GuiWidget normalHover;
        private GuiWidget switchNormalToPressed;
        private GuiWidget pressed;
        private GuiWidget pressedHover;
        private GuiWidget switchPressedToNormal;
        private GuiWidget disabled;

        public CheckBoxViewStates(GuiWidget normal, GuiWidget switchNormalToPressed, GuiWidget pressed, GuiWidget switchPressedToNormal)
            : this(normal, normal, switchNormalToPressed, pressed, pressed, switchPressedToNormal, normal)
        {
        }

        public CheckBoxViewStates(GuiWidget normal, GuiWidget normalHover, GuiWidget switchNormalToPressed, 
            GuiWidget pressed, GuiWidget pressedHover, GuiWidget switchPressedToNormal, 
            GuiWidget disabled)
        {
            this.normal = normal;
            this.normalHover = normalHover;
            this.switchNormalToPressed = switchNormalToPressed;

            this.pressed = pressed;
            this.pressedHover = pressedHover;
            this.switchPressedToNormal = switchPressedToNormal;
            this.disabled = disabled;

            AddChild(normal);
            AddChild(normalHover);
            AddChild(switchNormalToPressed);

            AddChild(pressed);
            AddChild(pressedHover);
            AddChild(switchPressedToNormal);
            AddChild(disabled);

            SetBoundsToEncloseChildren();

            normalHover.Visible = false;
            switchNormalToPressed.Visible = false;
            pressed.Visible = false;
            pressedHover.Visible = false;
            switchPressedToNormal.Visible = false;
            disabled.Visible = false;

            normal.Visible = true;
        }

        public override void OnParentChanged(EventArgs e)
        {
            CheckBox parentButton = (CheckBox)Parent;

            parentButton.MouseEnter += SetCorrectVisibilityStates;
            parentButton.MouseDown += SetCorrectVisibilityStates;
            parentButton.MouseUp += SetCorrectVisibilityStates;
            parentButton.MouseLeave += SetCorrectVisibilityStates;
            parentButton.CheckedStateChanged += SetCorrectVisibilityStates;

            base.OnParentChanged(e);
        }

        public override void OnClosing(out bool cancelClose)
        {

            CheckBox parentButton = (CheckBox)Parent;

            parentButton.MouseEnter -= SetCorrectVisibilityStates;
            parentButton.MouseDown -= SetCorrectVisibilityStates;
            parentButton.MouseUp -= SetCorrectVisibilityStates;
            parentButton.MouseLeave -= SetCorrectVisibilityStates;
            parentButton.CheckedStateChanged += SetCorrectVisibilityStates;
            base.OnClosing(out cancelClose);
        }        
<commit_msg>Got rid of the code in OnClosing that was not working.<commit_after>﻿//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// C# Port port by: <NAME>
//                  <EMAIL>
// Copyright (C) 2007
//
// Permission to copy, use, modify, sell and distribute this software 
// is granted provided this copyright notice appears in all copies. 
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
using System;

using MatterHackers.Agg;
using MatterHackers.Agg.VertexSource;
using MatterHackers.VectorMath;

namespace MatterHackers.Agg.UI
{
    public class CheckBoxViewStates : GuiWidget
    {
        private GuiWidget normal;
        private GuiWidget normalHover;
        private GuiWidget switchNormalToPressed;
        private GuiWidget pressed;
        private GuiWidget pressedHover;
        private GuiWidget switchPressedToNormal;
        private GuiWidget disabled;

        public CheckBoxViewStates(GuiWidget normal, GuiWidget switchNormalToPressed, GuiWidget pressed, GuiWidget switchPressedToNormal)
            : this(normal, normal, switchNormalToPressed, pressed, pressed, switchPressedToNormal, normal)
        {
        }

        public CheckBoxViewStates(GuiWidget normal, GuiWidget normalHover, GuiWidget switchNormalToPressed, 
            GuiWidget pressed, GuiWidget pressedHover, GuiWidget switchPressedToNormal, 
            GuiWidget disabled)
        {
            this.normal = normal;
            this.normalHover = normalHover;
            this.switchNormalToPressed = switchNormalToPressed;

            this.pressed = pressed;
            this.pressedHover = pressedHover;
            this.switchPressedToNormal = switchPressedToNormal;
            this.disabled = disabled;

            AddChild(normal);
            AddChild(normalHover);
            AddChild(switchNormalToPressed);

            AddChild(pressed);
            AddChild(pressedHover);
            AddChild(switchPressedToNormal);
            AddChild(disabled);

            SetBoundsToEncloseChildren();

            normalHover.Visible = false;
            switchNormalToPressed.Visible = false;
            pressed.Visible = false;
            pressedHover.Visible = false;
            switchPressedToNormal.Visible = false;
            disabled.Visible = false;

            normal.Visible = true;
        }

        CheckBox widgetWithHooksToUs;
        void RemoveLinks()
        {
            if (widgetWithHooksToUs != null)
            {
                widgetWithHooksToUs.MouseEnter -= SetCorrectVisibilityStates;
                widgetWithHooksToUs.MouseDown -= SetCorrectVisibilityStates;
                widgetWithHooksToUs.MouseUp -= SetCorrectVisibilityStates;
                widgetWithHooksToUs.MouseLeave -= SetCorrectVisibilityStates;
                widgetWithHooksToUs.CheckedStateChanged -= SetCorrectVisibilityStates;
            }
        }
        
        void CreateLinks(CheckBox parent)
        {
            RemoveLinks();
            
            widgetWithHooksToUs = parent;

            widgetWithHooksToUs.MouseEnter += SetCorrectVisibilityStates;
            widgetWithHooksToUs.MouseDown += SetCorrectVisibilityStates;
            widgetWithHooksToUs.MouseUp += SetCorrectVisibilityStates;
            widgetWithHooksToUs.MouseLeave += SetCorrectVisibilityStates;
            widgetWithHooksToUs.CheckedStateChanged += SetCorrectVisibilityStates;
        }

        public override void OnParentChanged(EventArgs e)
        {
            CreateLinks((CheckBox)Parent);

            base.OnParentChanged(e);
        }

        public override void OnClosed(EventArgs e)
        {
            RemoveLinks();

            base.OnClosed(e);
        }

{'fraction_non_alphanumeric': 0.10589476460503758, 'fraction_numerical': 0.003692469998681261, 'mean_word_length': 2.0531400966183573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6253647', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1792, 'n_words': 423}