// Initialize protected override void Initialize() { if (!DesignMode) { _view = Parent as EditBlueprintSocketsView; // Resources _spriteBatch = new SpriteBatch(GraphicsDevice); _pixel = new Texture2D(GraphicsDevice, 1, 1); _pixel.SetData <Color>(new[] { Color.White }); // Input System.Windows.Forms.Application.Idle += delegate { Invalidate(); }; MouseMove += new System.Windows.Forms.MouseEventHandler(EditBlueprintSocketsGraphics_MouseMove); MouseDown += new System.Windows.Forms.MouseEventHandler(EditBlueprintSocketsGraphics_MouseDown); FindForm().KeyPreview = true; FindForm().KeyDown += new System.Windows.Forms.KeyEventHandler(Parent_KeyDown); FindForm().KeyUp += new System.Windows.Forms.KeyEventHandler(EditBlueprintSocketsGraphics_KeyUp); } }
// Arrange scraps button clicked private void arrangeScrapsButton_Click(object sender, EventArgs e) { // Create a copy of the blueprint EditorBlueprint copy = _controller.initializeBlueprint(selectedBlueprint.data); // Create edit view editBlueprintSocketsView = new EditBlueprintSocketsView(copy); // Open view if (editBlueprintSocketsView.ShowDialog() == DialogResult.OK) { _controller.swapBlueprint(selectedBlueprint, copy); } // Reset scraps foreach (BlueprintScrap scrap in selectedBlueprint.scraps) { scrap.currentCraftPosition = Vector2.Zero; scrap.connected.Clear(); } // Reset sockets foreach (BlueprintSocket socket in selectedBlueprint.sockets) { socket.satisfied = false; socket.opposingSocket.satisfied = false; } // Close view editBlueprintSocketsView = null; }