private void OnKeyDown(object sender, KeyboardKeyEventArgs e) { if (!Focused) { return; } if (TextBoxHandler.TextBox != null) { if (e.Control && e.Key == Key.Minus) { if (TextBoxHandler.TextBox == null) { return; } var connection = TextBoxHandler.EditingConnection; connection.ParentNode.RemoveOutput(connection); TextBoxHandler.Destroy(false); connection.ParentNode.BuildConnections(); return; } TextBoxHandler.TextBox.OnKey(e); return; } KeybindHandler.Consume(new KeyCombo(e)); }
private void RegisterKeybinds() { KeybindHandler.Register(new KeyCombo("Delete Selection", Key.Delete), () => Selection.Delete()); KeybindHandler.Register(new KeyCombo("Reset Zoom", Key.R, KeyModifiers.Control), () => SetZoom(5)); KeybindHandler.Register( new KeyCombo("Reset Zoom and Pan", Key.R, KeyModifiers.Control | KeyModifiers.Shift), () => { SetZoom(5); _nodeRenderer.gridOffset = Vector2.Zero; }); KeybindHandler.Register(new KeyCombo("Add Output", Key.Plus, KeyModifiers.Control), () => { if (Selection.SingleSelectedNode == null || !Selection.SingleSelectedNode.NodeInfo.CanEditConnectors) { return; } AddOutput(Selection.SingleSelectedNode); }); KeybindHandler.Register(new KeyCombo("Copy", Key.C, KeyModifiers.Control), () => Selection.Copy()); KeybindHandler.Register(new KeyCombo("Cut", Key.X, KeyModifiers.Control), () => Selection.Cut()); KeybindHandler.Register(new KeyCombo("Paste", Key.V, KeyModifiers.Control), () => Selection.Paste(_mouseCanvasSpace.X, _mouseCanvasSpace.Y, !Keyboard[Key.ShiftLeft], _nodeRenderer.gridPitch)); KeybindHandler.Register(new KeyCombo("Open Project", Key.O, KeyModifiers.Control), () => DialogEditor.AskOpenFile()); KeybindHandler.Register(new KeyCombo("Save Project", Key.S, KeyModifiers.Control), () => DialogEditor.AskSaveFile()); KeybindHandler.Register(new KeyCombo("Save Project As", Key.S, KeyModifiers.Control | KeyModifiers.Shift), () => DialogEditor.AskSaveFileAs()); KeybindHandler.Register(new KeyCombo("Export Graph", Key.E, KeyModifiers.Control), () => DialogEditor.AskExportFile()); KeybindHandler.Register(new KeyCombo("Export Graph as JSON", Key.E, KeyModifiers.Control | KeyModifiers.Shift), () => DialogEditor.AskExportJsonFile()); }
private void HandleLoad(object sender, EventArgs e) { SetupOpenGl(); // Init keyboard to ensure first frame won't NPE Keyboard = OpenTK.Input.Keyboard.GetState(); _nodeRenderer = new NodeRenderer(this); Node.WidthCalculator = _nodeRenderer.GetNodeWidth; Selection = new SelectionHandler(this); DialogEditor = new FormDialogueEditor(this); DialogEditor.Show(); DialogEditor.Hide(); CreateContextMenu(null, 0, 0); _draggingConnectionPredicate = connection => Selection.DraggingConnection == null || Selection.DraggingConnection.ParentNode != connection.ParentNode && Selection.DraggingConnection.Side != connection.Side; RegisterKeybinds(); var keybinds = KeybindHandler.GetKeybinds(); Lumberjack.Info("Keybinds:"); foreach (var keyCombo in keybinds) { Lumberjack.Info($"- {keyCombo}"); } Lumberjack.Info("Window Loaded."); }