blob: 0235bc7d60fac487ea003343cc1c4d274ee180b9 (
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
|
using grapher.Layouts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace grapher
{
public class AccelOptions
{
public const int PossibleOptionsCount = 3;
public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase>
{
new DefaultLayout(),
new LinearLayout(),
new ClassicLayout(),
new NaturalLayout(),
new LogLayout(),
new SigmoidLayout(),
new PowerLayout(),
}.ToDictionary(k => k.Name);
public AccelOptions(
ComboBox accelDropdown,
Option[] options)
{
AccelDropdown = accelDropdown;
AccelDropdown.Items.Clear();
AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray());
AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
if (options.Length > PossibleOptionsCount)
{
throw new Exception("Layout given too many options.");
}
Options = options;
}
public ComboBox AccelDropdown { get; }
public int AccelerationIndex { get; private set; }
public Option[] Options { get; }
private void OnIndexChanged(object sender, EventArgs e)
{
var AccelerationTypeString = AccelDropdown.SelectedItem.ToString();
var AccelerationType = AccelerationTypes[AccelerationTypeString];
AccelerationIndex = AccelerationType.Index;
AccelerationType.Layout(Options);
}
}
}
|