summaryrefslogtreecommitdiff
path: root/grapher/Layouts/LayoutBase.cs
blob: eed171659257b83d294c40a3c53913a8ec0a6343 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace grapher.Layouts
{
    public abstract class LayoutBase
    {
        public const string Acceleration = "Acceleration";
        public const string Scale = "Scale";
        public const string Exponent = "Exponent";
        public const string Limit = "Limit";
        public const string Midpoint = "Midpoint";
        public const string Offset = "Offset";

        public LayoutBase()
        {
            ShowOptions = new bool[] { false, false, false, false };
            ShowOptionsXY = new bool[] { true, true };
            OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty };
            ButtonEnabled = true;
        }

        /// <summary>
        ///  Gets or sets mapping from acceleration type to identifying integer.
        ///  Must match accel_mode defined in rawaccel-settings.h
        /// </summary>
        public int Index { get; internal set; }

        public string Name { get; internal set; }

        internal bool[] ShowOptions { get; set; }

        internal bool[] ShowOptionsXY { get; set; }

        internal string[] OptionNames { get; set; }

        internal bool ButtonEnabled { get; set; }

        public void Layout(Option[] options, OptionXY[] optionsXY, Button button)
        {
            // Relies on AccelOptions to keep lengths correct.
            for (int i = 0; i < options.Length; i++)
            {
                if (ShowOptions[i])
                {
                    options[i].Show(OptionNames[i]);
                }
                else
                {
                    options[i].Hide();
                }
            }

            // Relies on AccelOptions to keep lengths correct.
            for (int i = 0; i< optionsXY.Length; i++)
            {
                if (ShowOptionsXY[i])
                {
                    optionsXY[i].Show();
                }
                else
                {
                    optionsXY[i].Hide();
                }
            }

            button.Enabled = ButtonEnabled;
        }
    }
}