private void UpdateControls() { hovered = null; foreach (var control in controls) { control.Value.UpdateMouseState(cursor, leftMouse, rightMouse); if (control.Value.Hovered) { hovered = control.Value; } } }
public MainForm() { InitializeComponent(); controls = new Dictionary <string, NewControl>(); ReadTheme(); NewControl control; control = new NewControl(""); control.MouseDownLeft += StartRelocaing; control.MouseUpLeft += StopRelocaing; controls.Add("control_box", control); control = new NewControl(""); control.MouseEnter += () => Cursor.Current = Cursors.SizeNS; control.MouseLeave += () => Cursor.Current = Cursors.Default; control.MouseDownLeft += () => resize = 5; control.MouseUpLeft += () => resize = 0; controls.Add("bottom_grip", control); control = new NewControl(""); control.MouseEnter += () => Cursor.Current = Cursors.SizeWE; control.MouseLeave += () => Cursor.Current = Cursors.Default; control.MouseDownLeft += () => resize = 3; control.MouseUpLeft += () => resize = 0; controls.Add("right_grip", control); control = new NewControl(""); control.MouseEnter += () => Cursor.Current = Cursors.SizeNWSE; control.MouseLeave += () => Cursor.Current = Cursors.Default; control.MouseDownLeft += () => resize = 4; control.MouseUpLeft += () => resize = 0; controls.Add("bottom_right_grip", control); control = new NewControl("CloseButton"); control.MouseClickLeft += CloseForm; controls.Add("corner_exit", control); control = new NewControl(""); control.MouseLeave += GameMouseLeave; control.MouseMove += GameMouseMove; control.MouseDownLeft += GameMouseDown; control.MouseUpLeft += GameMouseUp; control.MouseClickRight += GameMouseRightClick; controls.Add("game_field", control); controlBoxHeight = 25; minWidth = 50; minHeight = 50 + controlBoxHeight; gameWidth = 9; gameHeight = 9; bombCount = 10; StartGame(); FormResize(); updater.Start(); }