protected override void UpdateHover(int x, int y) { if (_mouseDownPanel != null && _mouseDownPanel.FlowControl == this) { int panelY = ClientArea.Y - VScrollPos; for (int i = 0; i < Panels.Count; ++i) { var panel = Panels[i]; var size = GetPanelSize(panel); int maxY = panelY + size.Height; if (panel == _mouseDownPanel) { _panelHover.Track(i, panel); panel.MouseMove(x - ClientArea.X + HScrollPos, y - panelY); break; } panelY = maxY; } } else { if (x >= ClientArea.X && x < ClientArea.Right) { bool hover = false; Graphics graphics = null; int panelY = ClientArea.Y - VScrollPos; for (int i = 0; i < Panels.Count; ++i) { var panel = Panels[i]; var size = GetPanelSize(panel); int maxY = panelY + size.Height; if (maxY >= y) { hover = true; _panelHover.Track(i, panel); panel.MouseMove(x - ClientArea.X + HScrollPos, y - panelY); break; } if (maxY >= ClientRectangle.Bottom) { break; } panelY = maxY; } if (!hover) { _panelHover.Drop(); } if (graphics != null) { graphics.Dispose(); } } else { _panelHover.Drop(); } } base.UpdateHover(x, y); }
public static void ApplyActions(List <Action> actions) { foreach (var action in actions) { TrackingService.Track(action); } }
protected override void OnMouseMove(int x, int y) { base.OnMouseMove(x, y); var htr = HitTest(x, y); if (_selecting) { UpdateSelection(x, y); } _lineHover.Track(htr.Line); if (htr.Column == 1 || htr.Column == 2) { if (_lineHover.Index >= 0 && _lineHover.Index < BlameFile.LineCount) { BlameHunk blameHunk; var line = GetLinesToContainingHunk(_lineHover.Index, out blameHunk); Revision revision = null; try { revision = _repository.Revisions[blameHunk.Commit.Hash]; } catch (Exception exc) when(!exc.IsCritical()) { } if (revision != null) { if (_revisionToolTip.Tag != null || _revisionToolTip.Revision != revision) { _revisionToolTip.Revision = revision; var point = new Point(Margin, Bounds.Y - FlowControl.VScrollPos); point.X += (GetDecimalDigits(BlameFile.LineCount) + 1) * CellSize.Width + _autorColumnWidth + _hashColumnWidth + 1; point.Y += line * CellSize.Height; point.Y += 2; if (ShowHeader) { point.Y += HeaderHeight; } if (point.Y < 1) { point.Y = 1; } _revisionToolTip.Show(FlowControl, point); _revisionToolTip.Tag = null; } } else { HideToolTip(); } } else { HideToolTip(); } } else { HideToolTip(); } }
public bool UpdateHover(Point point) { point = PointToClient(point); var rgn = Region; if (ClientRectangle.Contains(point) && (rgn == null || rgn.IsVisible(point))) { if (!_isHovered) { Opacity = ViewConstants.OpacityHover; Invalidate(); _isHovered = true; } var index = HitTestIndex(point); if (index == -1) { _buttonHover.Drop(); return(false); } else { _buttonHover.Track(index, _buttons[index]); return(true); } } else { Unhover(); return(false); } }
protected override void OnMouseMove(int x, int y) { if (FontHeight == -1) { return; } int id = HitTestFile(x, y); if (id == -1) { _fileHover.Drop(); id = HitTestFilter(x, y); if (id == -1) { _filterHover.Drop(); } else { _filterHover.Track(id, _changesByType[id]); } } else { _filterHover.Drop(); _fileHover.Track(id, _items[id]); } base.OnMouseMove(x, y); }
protected override void OnMouseMove(int x, int y) { var htr = HitTest(x, y); if (_selecting) { UpdateSelection(x, y); } _lineHover.Track(htr.Line); base.OnMouseMove(x, y); }
public void OnMouseMove(int x, int y) { int element = HitTest(x, y); _hoverElement.Track(element); if (element != -1) { var bounds = GetElementBounds(element); _elements[element].MouseMove(bounds, new Point(x, y)); } }
public void OnMouseMove(RectangleF rect, Point p) { var index = HitTest(rect, p); if (index != -1) { _hoveredLink.Track(index, _glyphs[index]); } else { _hoveredLink.Drop(); } }
public void OnMouseMove(int x, int y, MouseButtons button) { int id = HitTest(x, y); if (id == -1) { _buttonHover.Drop(); } else { _buttonHover.Track(id, _buttons[id]); } }
public void OnMouseDown(int x, int y, MouseButtons button) { int id = HitTest(x, y); if (id == -1) { _buttonPress.Drop(); } else { _buttonPress.Track(id, _buttons[id]); } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); int index = HitTest(e.X, e.Y); if (index != -1) { _tabHover.Track(index, _tabs[index]); } else { _tabHover.Drop(); } }
private int ScoreMove( Tuple <Position, Direction> move, HashSet <Position> visitedPositions, HashSet <Position> estimationOfMyPositions, MoveAction lastMoveAction, int iterations) { var trackingService = new TrackingService(estimationOfMyPositions, lastMoveAction); var moveAction = new MoveAction(move.Item2, Power.UNKNOWN); trackingService.Track(moveAction); if (iterations == 0) { return(trackingService.PossiblePositions.Count); } // next moves ? var curPosition = move.Item1; visitedPositions.Add(curPosition); var bestScore = -1; var neighborPositions = Map.GetNeighborPositions(curPosition); foreach (var neighbor in neighborPositions) { var newDirection = neighbor.Key; var newPos = neighbor.Value; if (visitedPositions.Contains(newPos) == false) { var newEstimationOfMyPositions = trackingService.PossiblePositions; var score = ScoreMove( new Tuple <Position, Direction>(newPos, newDirection), visitedPositions.ToHashSet(), trackingService.PossiblePositions.ToHashSet(), lastMoveAction, iterations - 1); if (score > bestScore) { bestScore = score; } } } return(bestScore); }
private bool TrySilence(out Direction direction, out int moves) { direction = Direction.E; moves = 0; if (_gameState.SilenceAvailable == false || MySubmarine.TrackingService.LostHealth == 0) { return(false); } var possibleSilenceMoves = SilenceAction.ComputeSilenceActions(MySubmarine.Position, MySubmarine.VisitedPositions); var bestScore = -1; var bestSilenceMove = (Direction.E, 0, MySubmarine.Position); Player.Debug($"{possibleSilenceMoves.Count} possibleSilenceMoves"); foreach (var currentSilenceMove in possibleSilenceMoves) { Player.Debug($"Evaluate {currentSilenceMove}"); var myPossiblePositions = MySubmarine.TrackingService.PossiblePositions; var lastMoveAction = MySubmarine.TrackingService.LastMoveAction; var trackingService = new TrackingService(myPossiblePositions, lastMoveAction); trackingService.Track(new SilenceAction(currentSilenceMove.Item1, currentSilenceMove.Item2)); var score = trackingService.PossiblePositions.Count; if (score > bestScore) { bestScore = score; bestSilenceMove = currentSilenceMove; Player.Debug($"bestSilenceMove: {bestSilenceMove} ({score})"); } } direction = bestSilenceMove.Item1; moves = bestSilenceMove.Item2; return(true); }
/// <summary>Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"/> event.</summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param> protected override void OnMouseMove(MouseEventArgs e) { if (_readyToFloat) { if (Math.Abs(_mdX - e.X) >= ViewConstants.ViewFloatDragMargin || Math.Abs(_mdY - e.Y) >= ViewConstants.ViewFloatDragMargin) { var form = _viewHost.GetRootOwnerForm(); _readyToFloat = false; var tab = _tabs[_floatId]; _viewHost.RemoveView(tab.View); var host = new ViewHost(_viewHost.Grid, false, false, new[] { tab.View }); var floatingForm = host.PrepareFloatingMode(); Capture = false; _viewHost.Focus(); floatingForm.Show(form); floatingForm.Shown += (sender, args) => ((ViewHost)((Form)sender).Controls[0]).StartMoving(e.X, e.Y); _floatId = -1; } } int areaId = _areaMouseDown; int tabId; int offset; if (areaId == -1) { areaId = HitTestArea(e.X, e.Y); } if (areaId == -1) { _areaHover.Drop(); } else { _areaHover.Track(areaId, null); } if (areaId == -1) { _areaHover.Drop(); tabId = -1; offset = 0; } else { if (_floatId == -1) { if (areaId == 1) { Rectangle bounds; tabId = HitTestTab(e.X, e.Y, out bounds); if (tabId == -1) { _tabHover.Drop(); } offset = bounds.X; } else { tabId = -1; offset = 0; } } else { areaId = 1; tabId = _floatId; offset = GetTabOffset(_floatId); } } switch (areaId) { case 0: _leftButtons.OnMouseMove(e.X, e.Y, e.Button); break; case 1: if (tabId != -1) { _tabHover.Track(tabId, _tabs[tabId]); int x = e.X; int y = e.Y; switch (_side) { case AnchorStyles.Top: case AnchorStyles.Bottom: x -= offset; break; case AnchorStyles.Left: case AnchorStyles.Right: y -= offset; break; } _tabs[tabId].OnMouseMove(x, y, e.Button); } break; case 2: _rightButtons.OnMouseMove(e.X - (Width - _rightButtons.Width), e.Y, e.Button); break; } base.OnMouseMove(e); }