internal virtual void OnMouseMove(MouseEventArgs e) { if (e.Y < RowHeight) { ColumnController <T> currentColumn = GetColumnAt(e.X); if (currentColumn != null) { if (currentColumn != SelectedColumn) { UnselectAll(); SelectedColumn = currentColumn; } SelectedColumn.OnMouseMove(e); this.OnInvalidate(); return; } } SelectedRow = GetRowAt(e.Y); CellController <T> currentCell = GetCellAt(e.X, SelectedRow); if (currentCell != SelectedCell) { UnselectAll(); SelectedCell = currentCell; } if (SelectedCell != null) { SelectedCell.OnMouseMove(e); this.OnInvalidate(); } }
private void clearSelectedCell() { if (SelectedCell != null) { SelectedCell.DeselectCell(); SelectedCell = null; } }
private void UnHighlightNote() { if (PreviousSelectedNote == null || (SelectedCell.Column() == PreviousSelectedNote.Column && SelectedCell.Row() == PreviousSelectedNote.Row)) { return; } measureGrid.Children.Remove(PreviousSelectedNote.Canvas); PreviousSelectedNote = measure.UnHighlightNote(PreviousSelectedNote.Column, PreviousSelectedNote.Row); measureGrid.AddInGrid(PreviousSelectedNote); }
public void IsSelected_ShouldReturnTrueForReplaced() { //Arrange SelectedCell subject = new SelectedCell(null); //Act Bool actual = subject.IsSelected(); //Assert ((bool)actual).Should().BeTrue(); }
private void AddNote() { Note note = measure.Add(SelectedCell.Column(), SelectedCell.Row()); if (note != null) { SelectedNote = note; MostRecentAddedNote = note; } AddNoteToXAML(note); }
public void Value_ShouldReturnValueOfOrigin() { //Arrange Glyph origin = new Glyph('?'); SelectedCell subject = new SelectedCell(origin); //Act string actual = subject.Value(); //Assert actual.Should().Be("?"); }
internal virtual void OnMouseDown(MouseEventArgs e) { if (SelectedCell != null) { SelectedCell.OnMouseDown(e); this.OnInvalidate(); } else if (SelectedColumn != null) { SelectedColumn.OnMouseDown(e); this.OnInvalidate(); } }
private void GridCellMouseDoubleClickHandler(GridCell targetCell, GridCell.GridCellInteractionEventArgs e) { if (SelectedCell == targetCell && SelectedCell.IsEditable) { return; } UnpointCell(); SelectedCell.UncheckCell(); SelectedCell = targetCell; SelectedCell.IsEditable = true; UpdateBinding(); }
internal virtual void OnMouseUp(MouseEventArgs e) { if (SelectedRow != null && SelectedCell != null) { SelectedCell.OnMouseUp(e); this.OnInvalidate(); this.OnCellClick(SelectedRow.Model, SelectedCell.View.Column); } else if (SelectedColumn != null) { SelectedColumn.OnMouseUp(e); this.OnInvalidate(); } }
private void OnMeasureGridRightClicked(MouseButtonEventArgs e) { UpdateSelectedColumnAndRow(e.Source as FrameworkElement); Note note = measure.GetNote(SelectedCell.Column(), SelectedCell.Row()); if (note != null) { UnHighlightNote(); measure.Delete(note.Column, note.Row); measureGrid.Children.Remove(note.Canvas); SelectedNote = null; PreviousSelectedNote = null; } }
public bool TrySelect(GridCoordinates targetCell) { if (!watchedCells.ContainsKey(targetCell)) { return(false); } if (targetCell.Equals(SelectedCell.CellPosition)) { return(false); } UnpointCell(); SelectedCell.UncheckCell(); SelectedCell = watchedCells[targetCell]; SelectedCell.IsSelected = true; UpdateBinding(); return(true); }
public bool TryMoveSelection(Direction dir) { if (SelectedCell == null) { return(false); } if (!CoordsInDirectionExist(dir, out GridCoordinates targetCoordinates)) { return(false); } SelectedCell.UncheckCell(); SelectedCell = watchedCells[targetCoordinates]; SelectedCell.IsSelected = true; UnpointCell(); UpdateBinding(); return(true); }
private void UpdateHighlightedNote() { if (measure.GetNote(SelectedCell.Column(), SelectedCell.Row()) == null) { HighlightNote(MostRecentAddedNote); } else { Note selectedNote = measure.GetNote(SelectedCell.Column(), SelectedCell.Row()); if (selectedNote == null) { return; } HighlightNote(selectedNote); } UnHighlightNote(); }
private void selectCell(CellViewModel cellVM) { // Deselect old cell first if (SelectedCell != null && SelectedCell != cellVM) { SelectedCell.DeselectCell(); } // Don't reselect the same cell. Treat it as a deselect instead and bail out. if (SelectedCell == cellVM) { clearSelectedCell(); return; } // Note the select and signal the cell's viewmodel that it make the cell/peg look selected. SelectedCell = cellVM; var holdPosition = PegHoldPosition.position; cellVM.SelectCell(holdPosition); // Audio feedback of select audioManager.PlaySelect(); }
private void UpdateSelectedColumnAndRow(FrameworkElement source) { if (source.Parent is Grid) { if (source.GetType() == typeof(Canvas)) { SelectedCell = new Dictionary <string, int> { { "column", ((source as Canvas).Tag as Cell).column }, { "row", ((source as Canvas).Tag as Cell).row } }; } else { SelectedCell = new Dictionary <string, int> { { "column", (int)source.GetValue(Grid.ColumnProperty) }, { "row", (int)source.GetValue(Grid.RowProperty) } }; } Note note = measure.GetNote(SelectedCell.Column(), SelectedCell.Row()); if (note != null) { SelectedNote = note; } } else { //testing purposes int col = (int)source.GetValue(Grid.ColumnProperty); int row = (int)source.GetValue(Grid.RowProperty); UpdateSelectedColumnAndRow(source.Parent as FrameworkElement); } }
/// <summary> Add a row. If insertatrow=-1, add to end. Else inserted before index</summary> public void AddRow(GLDataGridViewRow row, int insertatrow = -1) { System.Diagnostics.Debug.Assert(row.Parent == this && row.HeaderStyle.Parent != null); // ensure created by us row.HeaderStyle.Changed += (e1) => { ContentInvalidateLayout(); }; // header style changed, need a complete refresh row.AutoSizeGeneration = 0; row.Changed += (e1) => { contentpanel.RowChanged(row.Index); // inform CP UpdateScrollBar(); // update scroll bar }; row.SelectionChanged += (rw, cellno) => { //System.Diagnostics.Debug.WriteLine($"Selection changed on {rw.Index} {cellno}"); if (cellno == -1) // if whole row select { if (rw.Selected) // turning on { if (!AllowUserToSelectMultipleRows) // if not allowed multirow, clear all { ClearSelection(); } if (!selectedcells.ContainsKey(rw.Index)) { selectedcells[rw.Index] = new HashSet <int>(); } foreach (var c in rw.Cells) { selectedcells[rw.Index].Add(c.Index); } SelectedRow?.Invoke(rw, true); } else { // turning off foreach (var c in rw.Cells) { selectedcells[rw.Index].Remove(c.Index); } if (selectedcells[rw.Index].Count == 0) { selectedcells.Remove(rw.Index); } SelectedRow?.Invoke(rw, false); } } else if (rows[rw.Index].Cells[cellno].Selected) // individual cell turning on { if (!selectedcells.ContainsKey(rw.Index)) { selectedcells[rw.Index] = new HashSet <int>(); } selectedcells[rw.Index].Add(cellno); SelectedCell?.Invoke(rows[rw.Index].Cells[cellno], true); } else { selectedcells[rw.Index].Remove(cellno); // or turning off if (selectedcells[rw.Index].Count == 0) { selectedcells.Remove(rw.Index); } SelectedCell?.Invoke(rows[rw.Index].Cells[cellno], false); } contentpanel.RowChanged(row.Index); // inform CP }; if (insertatrow == -1) { row.SetRowNo(rows.Count, (rows.Count & 1) != 0 ? DefaultAltRowCellStyle : DefaultCellStyle); rows.Add(row); contentpanel.AddRow(row.Index); // see if content panel needs redrawing } else { rows.Insert(insertatrow, row); for (int i = insertatrow; i < rows.Count; i++) { rows[i].SetRowNo(i, (i & 1) != 0 ? DefaultAltRowCellStyle : DefaultCellStyle); } contentpanel.InsertRow(row.Index); // see if content panel needs redrawing } UpdateScrollBar(); }
private bool IsNotePresentOnSelectedCell() { return(measure.GetNote(SelectedCell.Column(), SelectedCell.Row()) != null); }