-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAluElement.cs
192 lines (156 loc) · 6.23 KB
/
AluElement.cs
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using MetaphysicsIndustries.Crystalline;
using System.Windows.Forms;
using MetaphysicsIndustries.Epiphany;
using MetaphysicsIndustries.Utilities;
namespace MetaphysicsIndustries.Amethyst
{
public class AluElement : AmethystElement
{
protected AluElement(Node node, SizeV size)
: base(node, size)
{
}
public AluElement()
: this(new NullNode(), new SizeV(80, 60))
{
}
private string _text = string.Empty;
public override string Text
{
get { return _text; }
}
public override bool ShallProcessDoubleClick
{
get { return true; }
}
public override void ProcessDoubleClick(AmethystControl control)
{
TextElementPropertiesForm form = new TextElementPropertiesForm();
form.ElementText = Text;
form.ElementWidth = Width;
form.ElementHeight = Height;
form.ElementShallRenderTerminals = ShallRenderTerminals;
if (form.ShowDialog(control) == DialogResult.OK)
{
_text = form.ElementText;
Width = form.ElementWidth;
Height = form.ElementHeight;
_shallRenderTerminals = form.ElementShallRenderTerminals;
}
}
private bool _shallRenderTerminals = true;
public override bool ShallRenderTerminals
{
get { return _shallRenderTerminals; }
}
protected override void InitTerminals()
{
Terminal terminal;
terminal = new InputTerminal(new InputConnection<object>("s"));
terminal.Side = BoxOrientation.Left;
terminal.Position = Height / 2;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("a"));
terminal.Side = BoxOrientation.Up;
terminal.Position = Width / 3;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("b"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 2 * Width / 3;
Terminals.Add(terminal);
terminal = new OutputTerminal(new OutputConnection<object>("r"));
terminal.Side = BoxOrientation.Right;
terminal.Position = Height / 2;
Terminals.Add(terminal);
InitOutTerminals();
}
protected virtual void InitOutTerminals()
{
Terminal terminal;
terminal = new OutputTerminal(new OutputConnection<object>("do"));
terminal.Side = BoxOrientation.Down;
terminal.Position = Width / 2;
Terminals.Add(terminal);
}
}
[Serializable]
public class MuxElement : AluElement
{
public MuxElement()
: base(new NullNode(), new SizeV(180, 60))
{
}
protected override void InitTerminals()
{
Terminal terminal;
terminal = new InputTerminal(new InputConnection<object>("A"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 20;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("B"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 40;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("Adder"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 60;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("Bitwise"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 80;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("Shift"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 100;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("MultHi"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 120;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("MultLo"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 140;
Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("Comp"));
terminal.Side = BoxOrientation.Up;
terminal.Position = 160;
Terminals.Add(terminal);
//terminal = new InputTerminal(new InputConnection<object>("S0"));
//terminal.Side = BoxOrientation.Left;
//terminal.Position = 15;
//Terminals.Add(terminal);
terminal = new InputTerminal(new InputConnection<object>("S1"));
terminal.Side = BoxOrientation.Left;
terminal.Position = 30;
Terminals.Add(terminal);
//terminal = new InputTerminal(new InputConnection<object>("S2"));
//terminal.Side = BoxOrientation.Left;
//terminal.Position = 45;
//Terminals.Add(terminal);
terminal = new OutputTerminal(new OutputConnection<object>("Output"));
terminal.Side = BoxOrientation.Down;
terminal.Position = Width / 2;
Terminals.Add(terminal);
}
}
[Serializable]
public class MultAluElement : AluElement
{
protected override void InitOutTerminals()
{
Terminal terminal;
terminal = new OutputTerminal(new OutputConnection<object>("hi"));
terminal.Side = BoxOrientation.Down;
terminal.Position = 30;
Terminals.Add(terminal);
terminal = new OutputTerminal(new OutputConnection<object>("lo"));
terminal.Side = BoxOrientation.Down;
terminal.Position = 50;
Terminals.Add(terminal);
}
}
}