summaryrefslogtreecommitdiff
path: root/grapher/Models/Serialized/GUISettings.cs
blob: 8c182aeb8e7c4d73ca28a9792fc165dda08b795c (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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace grapher.Models.Serialized
{
    [Serializable]
    public class GUISettings
    {
        public GUISettings(
            Field dpiField,
            Field pollRateField,
            ToolStripMenuItem autoWriteMenuItem)
        {
            BindToGUI(dpiField, pollRateField, autoWriteMenuItem);
        }

        public bool AutoWriteToDriverOnStartup { get; set; }

        public int DPI { get; set; }

        public int PollRate { get; set; }

        [field: NonSerialized]
        private Field DpiField { get; set; }

        [field: NonSerialized]
        private Field PollRateField { get; set; }

        [field: NonSerialized]
        private ToolStripMenuItem AutoWriteMenuItem { get; set; }

        public void UpdateSettings()
        {
            DPI = (int)DpiField.Data;
            PollRate = (int)PollRateField.Data;
            AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked;
        }

        public void BindToGUI(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem)
        {
            DpiField = dpiField;
            PollRateField = pollRateField;
            AutoWriteMenuItem = autoWriteMenuItem;
        }
    }
}