summaryrefslogtreecommitdiff
path: root/grapher/Models/Options/AccelOptionSet.cs
blob: 34514022ccda50e26699558519fe6c337a969c9f (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using grapher.Models.Serialized;
using System.Drawing;
using System.Windows.Forms;

namespace grapher.Models.Options
{
    public class AccelOptionSet
    {
        public AccelOptionSet(
            Label title,
            Label activeValuesTitle,
            int topAnchor,
            AccelTypeOptions accelTypeOptions)
        {
            OptionsTitle = title;
            ActiveValuesTitle = activeValuesTitle;
            TopAnchor = topAnchor;
            Options = accelTypeOptions;

            ActiveValuesTitle.AutoSize = false;
            ActiveValuesTitle.TextAlign = ContentAlignment.MiddleCenter;

            Options.ShowFull();

            OptionsTitle.Top = TopAnchor;
            IsTitleMode = true;
            Hidden = false;
            SetRegularMode();
        }

        public int TopAnchor { get; }

        public Label OptionsTitle { get; }

        public Label ActiveValuesTitle { get; }

        public AccelTypeOptions Options { get; }

        public bool IsTitleMode { get; private set; }

        private bool Hidden { get; set; }

        public void SetRegularMode()
        {
            if (IsTitleMode)
            {
                IsTitleMode = false;

                Options.ShowFull();
                HideTitle();
            }
        }

        public void SetTitleMode(string title)
        {
            OptionsTitle.Text = title;

            if (!IsTitleMode)
            {
                IsTitleMode = true;

                Options.ShowShortened();
                DisplayTitle();
                Options.HandleLUTOptionsOnResize();
            }
        }

        public void Hide()
        {
            OptionsTitle.Hide();
            ActiveValuesTitle.Hide();
            Options.Hide();
            Hidden = true;
        }

        public void Show()
        {
            if (IsTitleMode)
            {
                OptionsTitle.Show();
            }

            ActiveValuesTitle.Show();
            Options.Show();
            Hidden = false;
        }

        public void DisplayTitle()
        {
            OptionsTitle.Show();

            Options.Top = OptionsTitle.Top + OptionsTitle.Height + Constants.OptionVerticalSeperation;
        }

        public void HideTitle()
        {
            OptionsTitle.Hide();

            Options.Top = TopAnchor;
        }

        public void SetArgsFromActiveValues(ref AccelArgs args)
        {
            Options.SetArgs(ref args);
        }

        public void SetActiveValues(ref AccelArgs args)
        {
            if (!Hidden)
            {
                Options.SetActiveValues(ref args);
            }
        }

        public void AlignActiveValues()
        {
            Options.AlignActiveValues();
        }
    }
}