|
10 | 10 | using Maxstupo.LogicSandbox.Logic; |
11 | 11 | using Maxstupo.LogicSandbox.Logic.Components; |
12 | 12 | using Maxstupo.LogicSandbox.Properties; |
| 13 | + using Maxstupo.LogicSandbox.Shapes; |
13 | 14 | using Maxstupo.LogicSandbox.Utility.Interaction; |
14 | 15 |
|
15 | 16 | public partial class FormMain : Form { |
@@ -64,6 +65,9 @@ private void FormMain_Load(object sender, EventArgs e) { |
64 | 65 | // TEMP: Allow auto discovery of components. |
65 | 66 | // TEMP: move to more suitable location. |
66 | 67 | AddComponentToLibrary(new Power("", 0, 0)); |
| 68 | + AddComponentToLibrary(new Toggle("", 0, 0)); |
| 69 | + AddComponentToLibrary(new PushOn("", 0, 0)); |
| 70 | + AddComponentToLibrary(new PushOff("", 0, 0)); |
67 | 71 | AddComponentToLibrary(new NotGate("", 0, 0)); |
68 | 72 | AddComponentToLibrary(new OrGate("", 0, 0)); |
69 | 73 | AddComponentToLibrary(new PortIn("", 0, 0)); |
@@ -121,16 +125,22 @@ private void Canvas_Paint(object sender, PaintEventArgs e) { |
121 | 125 | selector.Draw(g); |
122 | 126 | } |
123 | 127 |
|
| 128 | + private Shape componentOver; |
| 129 | + |
124 | 130 | private void Canvas_MouseDown(object sender, MouseEventArgs e) { |
125 | 131 |
|
126 | 132 | if (e.Button == MouseButtons.Left) { |
127 | 133 |
|
| 134 | + componentOver = circuit.GetComponentOver(); |
| 135 | + if (componentOver != null) |
| 136 | + componentOver.UpdateMouseState(true); |
| 137 | + |
128 | 138 | selectedPin = circuit.GetPinOver(); |
129 | 139 | if (selectedPin == null) { |
130 | 140 |
|
131 | 141 | bool additiveMode = ModifierKeys.HasFlag(AdditiveKey); // Previous selection not cleared. |
132 | 142 |
|
133 | | - if (!selector.Start(canvas.MouseWorldX, canvas.MouseWorldY, additiveMode, (x, y) => circuit.GetComponentOver())) { |
| 143 | + if (!selector.Start(canvas.MouseWorldX, canvas.MouseWorldY, additiveMode, (x, y) => circuit.GetComponentMouseOverOrDescentants())) { |
134 | 144 |
|
135 | 145 | transformer.Clear(); |
136 | 146 | transformer.AddItems(selector.SelectedItems); |
@@ -164,6 +174,10 @@ private void Canvas_MouseMove(object sender, MouseEventArgs e) { |
164 | 174 | private void Canvas_MouseUp(object sender, MouseEventArgs e) { |
165 | 175 | if (e.Button == MouseButtons.Left) { |
166 | 176 |
|
| 177 | + if (componentOver != null) |
| 178 | + componentOver.UpdateMouseState(false); |
| 179 | + |
| 180 | + |
167 | 181 | bool additiveMode = ModifierKeys.HasFlag(AdditiveKey); // Previous selection not cleared. |
168 | 182 | bool inclusiveMode = ModifierKeys.HasFlag(InclusiveKey); // Item must be inside of selection bounds. |
169 | 183 |
|
|
0 commit comments