/// <summary> /// Selects a tile on the mouse-down event. /// IMPORTANT: Any changes that are done here regarding node-selection /// should be reflected in RouteView.Go() since that is an alternate way /// to select a tile. /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { // base.OnMouseDown(e); Select(); if (MapFile != null) // safety. { var loc = GetTileLocation(e.X, e.Y); if (loc.X != -1) { MapFile.Location = new MapLocation( // fire LocationSelectedEvent loc.Y, loc.X, MapFile.Level); MainViewUnderlay.Instance.MainViewOverlay.ProcessTileSelection(loc, loc); // set selected location for other viewers. // NOTE: drag-selection is not allowed here. if (RoutePanelMouseDownEvent != null) { var args = new RoutePanelEventArgs(); args.MouseButton = e.Button; args.Tile = MapFile[loc.Y, loc.X]; args.Location = MapFile.Location; RoutePanelMouseDownEvent(this, args); // fire RouteView.OnRoutePanelMouseDown() } SelectedPosition = loc; // NOTE: if a new 'SelectedPosition' is set before firing the } // RoutePanelMouseDownEvent, OnPaint() will draw a frame with } // incorrectly selected-link lines. So set the 'SelectedPosition' } // *after* the event happens.
protected override void OnMouseUp(MouseEventArgs e) { // base.OnMouseUp(e); if (MapFile != null && // safety. RoutePanelMouseUpEvent != null) { var loc = GetTileLocation(e.X, e.Y); if (loc.X != -1) { var args = new RoutePanelEventArgs(); args.MouseButton = e.Button; args.Tile = MapFile[loc.Y, loc.X]; args.Location = new MapLocation( loc.Y, loc.X, MapFile.Level); RoutePanelMouseUpEvent(this, args); } } }