private void InitialiseMouseController() { m_mouseController = new MouseController <TNode>(Colors, Redraw, shift => Shift(shift), (screen) => ScrollIfRequired(screen), (p, z) => Zoom(p, z), () => new ZOrderedQuadTree <TNode>(SpatiallyOrderedNodes, CurrentFile.RelativePosition), () => new Fake <UnorderedTuple2 <Output> >(SpatiallyOrderedConnections.Select(a => a.Item1)), () => CurrentFile.Groups, MyEdit, n => CurrentFile.Remove(n.Only(), Enumerable.Empty <NodeGroup>(), m_localization), Snap, SnapGroup, UIInfo, id => CurrentFile.GetNode(id)); drawWindow.MouseDown += (a, args) => m_mouseController.MouseDown(DrawWindowToGraphSpace(args.Location), args.Location, args.Button); drawWindow.MouseUp += (a, args) => m_mouseController.MouseUp(DrawWindowToGraphSpace(args.Location), args.Location, args.Button); drawWindow.MouseMove += (a, args) => { m_mouseController.MouseMove(DrawWindowToGraphSpace(args.Location), args.Location); }; drawWindow.MouseDoubleClick += (a, args) => m_mouseController.MouseDoubleClick(DrawWindowToGraphSpace(args.Location), args.Button); drawWindow.MouseWheel += (a, args) => m_mouseController.MouseWheel(DrawWindowToGraphSpace(args.Location), args, Control.ModifierKeys); drawWindow.MouseCaptureChanged += (a, args) => m_mouseController.MouseCaptureChanged(); m_mouseController.Changed += (a) => { CurrentFile.UndoableFile.Change(a); ResizeDocument(); }; m_mouseController.SelectionChanged += Redraw; m_mouseController.PlainClick += (p) => { if (m_keyMapping[m_keyHeld] != null) { AddNode(m_keyMapping[m_keyHeld], p); } }; m_mouseController.SelectionChanged += () => m_conversation.BringToFront(Selected); drawWindow.KeyDown += (o, k) => { m_mouseController.KeyHeld = m_keyMapping.ContainsKey(k.KeyCode) ? k.KeyCode : (Keys?)null; m_keyHeld = k.KeyCode; if (k.KeyCode.IsSet(Keys.ShiftKey)) { Redraw(); } }; drawWindow.KeyUp += (o, k) => { m_mouseController.KeyHeld = null; if (k.KeyCode.IsSet(Keys.ShiftKey)) { Redraw(); } }; drawWindow.LostFocus += (o, e) => m_mouseController.KeyHeld = null; m_mouseController.StateChanged += () => { drawWindow.Cursor = m_mouseController.m_state.Cursor; }; m_mouseController.HoverNodeChanged += () => { if (m_mouseController.HoverNode != null) { if (ShowIds) { m_toolTip.Active = true; m_toolTip.SetToolTip(drawWindow, m_mouseController.HoverNode.Data.NodeId.Serialized()); m_toolTip.OwnerDraw = false; } else { m_toolTip.OwnerDraw = true; var node = m_mouseController.HoverNode as ConversationNode <INodeGui>; EditableUI renderer = new EditableUI(node, new PointF(0, 0), m_localization.Localize); renderer.UpdateArea(); ToolTipPopup = (sender, e) => { e.ToolTipSize = renderer.Area.Size.ToSize(); }; DrawToolTip = (sender, e) => { using (var m = new Matrix()) { m.Translate(renderer.Area.Width / 2, renderer.Area.Height / 2); e.Graphics.Transform = m; } renderer.Draw(e.Graphics, false, m_colorScheme); }; m_toolTip.SetToolTip(drawWindow, m_mouseController.HoverNode.Data.NodeId.Serialized()); m_toolTip.Active = true; } } else { m_toolTip.Active = false; m_toolTip.SetToolTip(drawWindow, null); } }; }