summaryrefslogtreecommitdiff
path: root/grapher/Models/Options/CheckBoxOption.cs
blob: 83b2d7ad7ab4b3e5c7089a3b4c456259c8058ed5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System.Windows.Forms;

namespace grapher.Models.Options
{
    public class CheckBoxOption : OptionBase
    {
        public CheckBoxOption(CheckBox checkBox)
        {
            CheckBox = checkBox;
            Show(string.Empty);
        }

        public CheckBox CheckBox { get; }

        public override bool Visible
        {
            get
            {
                return CheckBox.Visible || ShouldShow;
            }
        }

        public override int Left
        {
            get
            {
                return CheckBox.Left;
            }
            set
            {
                CheckBox.Left = value;
            }
        }

        public override int Height
        {
            get
            {
                return CheckBox.Height;
            }
        }

        public override int Top
        {
            get
            {
                return CheckBox.Top;
            }
            set
            {
                CheckBox.Top = value;
            }
        }

        public override int Width
        {
            get
            {
                return CheckBox.Width;
            }
            set
            {
                CheckBox.Width = value;
            }
        }

        /// <summary>
        /// For some reason, setting CheckBox.Show() does not result in visible not being true on GUI startup.
        /// This is inconsistent with the other options, which do.
        /// Keep this bool for allowing Visible to still be the signal for option snapping.
        /// </summary>
        private bool ShouldShow { get; set; }

        public override void AlignActiveValues()
        {
        }

        public override void Hide()
        {
            CheckBox.Hide();
            ShouldShow = false;
            CheckBox.Enabled = false;
        }

        public override void Show(string Name)
        {
            CheckBox.Show();
            ShouldShow = true;
            CheckBox.Enabled = true;
            CheckBox.Name = Name;
        }
    }
}