public override void ReturnSelect() { for (int i = 1; i < 9; i++) { if (i != 6) { if (checkLCell(i)) { Utils.CellSelector(getLCell(i)); } } else { if (checkLCell(i)) { Utils.RowSelector(getLCell(i)); if (getLCell(i).Position.Row == 7 || getLCell(i).Position.Row == 8 || getLCell(i).Position.Row == 14) { SourceGrid.Position P = new SourceGrid.Position(getLCell(i).Position.Row, 2); ((SourceGrid.Cells.Cell)getLCell(i).Grid.GetCell(P)).Value = inputData.s_rezba; } } } } }
/// <summary> /// 新增點字。 /// </summary> /// <param name="row">儲存格的列索引。</param> /// <param name="col">儲存格的行索引。</param> internal void InsertCell(int row, int col) { if (!CheckCellPosition(row, col)) { return; } EditCellForm form = new EditCellForm(); form.Mode = EditCellMode.Insert; if (form.ShowDialog() == DialogResult.OK) { int wordIdx = GetBrailleWordIndex(row, col); int lineIdx = GetBrailleLineIndex(row); BrailleLine brLine = m_BrDoc.Lines[lineIdx]; // 在第 wordIdx 個字之前插入新點字。 brLine.Words.Insert(wordIdx, form.BrailleWord); OnDataChanged(); // Update UI ReformatRow(row); SourceGrid.Position pos = new SourceGrid.Position(row, col + 1); brGrid.Selection.Focus(pos, true); // 修正選取的儲存格範圍。 } }
/// <summary> /// 刪除一個儲存格的點字。 /// </summary> internal void DeleteCell(int row, int col) { // 防錯:如果不是有效的儲存格位置就直接返回。 if (!CheckCellPosition(row, col)) { return; } row = GetBrailleRowIndex(row); int lineIdx = GetBrailleLineIndex(row); int wordIdx = GetBrailleWordIndex(row, col); BrailleLine brLine = m_BrDoc.Lines[lineIdx]; if (brLine.Words.Count == 1) // 如果要刪除該列的最後一個字,就整列刪除。 { DeleteLine(row, col, false); return; } brLine.Words.RemoveAt(wordIdx); OnDataChanged(); // Update UI ReformatRow(row); brGrid.Selection.ResetSelection(false); // 修正選取的儲存格範圍。 SourceGrid.Position pos = new SourceGrid.Position(row, col); brGrid.Selection.Focus(pos, true); }
void FindForm_TargetFound(object sender, DualEditFindForm.TargetFoundEventArgs args) { int row = GetGridRowIndex(args.LineIndex) + 1; int col = GetGridColumnIndex(args.LineIndex, args.WordIndex); SourceGrid.Position pos = new SourceGrid.Position(row, col); brGrid.Selection.Focus(pos, true); brGrid.Selection.SelectCell(pos, true); }
/// <summary> /// 到指定的列。 /// <param name="lineNumber">列號</param> /// </summary> private void GotoLine(int lineNum) { if (lineNum > m_BrDoc.LineCount) { lineNum = m_BrDoc.LineCount; } SourceGrid.Position pos = new SourceGrid.Position((lineNum - 1) * 3 + 1, 1); brGrid.ShowCell(pos, false); }
private void Mc_OnLeftClick(object sender, EventArgs e) { var ctx = (SourceGrid.CellContext)sender; var pos = ctx.Position; pos1 = pos; pos2 = SourceGrid.Position.Empty; UpdateDatesSet(); }
private void Mc_OnRightClick(object sender, EventArgs e) { var ctx = (SourceGrid.CellContext)sender; var pos = ctx.Position; if (pos1 == SourceGrid.Position.Empty) { return; } pos2 = pos; UpdateDatesSet(); }
/// <summary> /// 設定某個儲存格為 active cell。 /// </summary> /// <param name="pos">儲存格位置。</param> /// <param name="resetSelection">是否清除選取範圍。</param> /// <returns></returns> private bool GridFocusCell(SourceGrid.Position pos, bool resetSelection) { if (pos.Row >= brGrid.RowsCount) { return(false); } if (pos.Column >= brGrid.ColumnsCount) { return(false); } brGrid.Selection.SelectCell(pos, true); return(brGrid.Selection.Focus(pos, resetSelection)); }
private void DGResult_CellEnter(object sender, DataGridViewCellEventArgs e) { string NumberStr = DGResult.Rows[e.RowIndex].Cells[0].Value.ToString(); if (DG != null) { DG.ScrollTo(NumberStr.ToInt() + 1); } if (SG != null) { SourceGrid.Position p = new SourceGrid.Position(NumberStr.ToInt() + 1, 0); SG.SelectColumnRowCell(p.Row, p.Column, true); } this.Focus(); }
private void InternalLoadFile(string filename) { CursorHelper.ShowWaitCursor(); try { StatusText = "正在載入資料..."; BrailleDocument newBrDoc = BrailleDocument.LoadBrailleFile(filename); if (m_BrDoc != null) { m_BrDoc.Clear(); } m_BrDoc = newBrDoc; FileName = filename; IsDirty = false; // 2009-6-23: 防錯處理,有的檔案因為程式的 bug 而存入空的 BrailleLine,在此處自動濾掉. for (int i = m_BrDoc.LineCount - 1; i >= 0; i--) { // 把空的 BrailleLine 移除. if (m_BrDoc.Lines[i].CellCount < 1) { m_BrDoc.RemoveLine(i); IsDirty = true; } } StatusText = "正在準備顯示資料..."; brGrid.Rows.Clear(); brGrid.Columns.Clear(); m_IsInitialized = false; InitializeGrid(); FillGrid(m_BrDoc); // 焦點移至第一列的第一個儲存格。 SourceGrid.Position pos = new SourceGrid.Position(brGrid.FixedRows, brGrid.FixedColumns); GridFocusCell(pos, true); } finally { CursorHelper.RestoreCursor(); StatusText = ""; } }
private DateTime GetDateByPos(SourceGrid.Position pos) { if (YearUsed == -1) { return(DateTime.MinValue); } for (int i = 0; i < 12; i++) { var fc = GetMTFirstCell(i); if (pos.Column >= fc.X && pos.Column <= fc.X + 6 && pos.Row >= fc.Y + 1 && pos.Row <= fc.Y + 6) { return(MonthData.GetByCoord(YearUsed, i, pos.Row - fc.Y - 1, pos.Column - fc.X)); } } return(DateTime.MinValue); }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); //I use the OnValueChanged to link the value of 2 cells // changing the value of the other cell SourceGrid.Position otherCell = new SourceGrid.Position(sender.Position.Row, mDependencyColumn); SourceGrid.CellContext otherContext = new SourceGrid.CellContext(sender.Grid, otherCell); object newVal = sender.Value; if (ConvertFunction != null) newVal = ConvertFunction(newVal); if (!object.Equals(otherContext.Value, newVal)) otherContext.Value = newVal; }
private void dataGrid_DoubleClick(object sender, EventArgs e) { SourceGrid.Position cPosition = this.dataGrid.Selection.ActivePosition; if (cPosition != SourceGrid.Position.Empty) { _ParameterInfo cParam = source[cPosition.Row - 1] as _ParameterInfo; string sValue = cParam.Value; if (cParam.Items == null) { this.dataGrid.Columns[1].DataCell.Editor = __cTextBox; } else { __cComboBox.StandardValues = cParam.Items; this.dataGrid.Columns[1].DataCell.Editor = __cComboBox; } } }
public void ReturnSelect() { if (LCells.grid1.Cell != null) { CellSelector(LCells.grid1); } if (LCells.grid2.Cell != null) { CellSelector(LCells.grid2); } if (LCells.grid3.Cell != null) { CellSelector(LCells.grid3); } if (LCells.grid4.Cell != null) { CellSelector(LCells.grid4); } if (LCells.grid5.Cell != null) { CellSelector(LCells.grid5); } if (LCells.grid6.Cell != null) { RowSelector(LCells.grid6); if ((LCells.grid6.Position.Row == 7) || (LCells.grid6.Position.Row == 8) || (LCells.grid6.Position.Row == 14)) { SourceGrid.Position P = new SourceGrid.Position(LCells.grid6.Position.Row, 2); ((SourceGrid.Cells.Cell)LCells.grid6.Grid.GetCell(P)).Value = IData.s_rezba; } } if (LCells.grid7.Cell != null) { RowSelector(LCells.grid7); } if (LCells.grid8.Cell != null) { CellSelector(LCells.grid8); } }
public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e) { base.OnValueChanged(sender, e); //I use the OnValueChanged to link the value of 2 cells // changing the value of the other cell SourceGrid.Position otherCell = new SourceGrid.Position(sender.Position.Row, mDependencyColumn); SourceGrid.CellContext otherContext = new SourceGrid.CellContext(sender.Grid, otherCell); object newVal = sender.Value; if (ConvertFunction != null) { newVal = ConvertFunction(newVal); } if (!object.Equals(otherContext.Value, newVal)) { otherContext.Value = newVal; } }
internal void DeleteLine(int row, int col, bool needConfirm) { // 防錯:如果不是有效的儲存格位置就直接返回。 if (!CheckCellPosition(row, col)) { return; } // 選取欲刪除的列,讓使用者容易知道。 SourceGrid.Position activePos = brGrid.Selection.ActivePosition; GridSelectRow(row, true); if (needConfirm && MsgBoxHelper.ShowOkCancel("確定要刪除整列?") != DialogResult.OK) { GridSelectRow(row, false); GridFocusCell(activePos, true); return; } row = GetBrailleRowIndex(row); // 確保列索引為點字列。 int lineIdx = GetBrailleLineIndex(row); BrailleLine brLine = m_BrDoc.Lines[lineIdx]; brLine.Clear(); brLine = null; m_BrDoc.Lines.RemoveAt(lineIdx); OnDataChanged(); // 更新 UI。 brGrid.Rows.RemoveRange(row, 3); RefreshRowNumbers(); GridSelectRow(row, false); GridFocusCell(activePos, true); }
/// <summary> /// 在指定處斷行。 /// </summary> /// <param name="row"></param> /// <param name="col"></param> private void BreakLine(int row, int col) { int wordIdx = GetBrailleWordIndex(row, col); if (wordIdx == 0) // 若在第一個字元處斷行,其實就等於插入一列。 { InsertLine(row, col); return; } int lineIdx = GetBrailleLineIndex(row); BrailleLine brLine = m_BrDoc.Lines[lineIdx]; BrailleLine newLine = brLine.Copy(wordIdx, 255); // 複製到新行。 newLine.TrimEnd(); // 去尾空白。 m_BrDoc.Lines.Insert(lineIdx + 1, newLine); brLine.RemoveRange(wordIdx, 255); // 從原始串列中刪除掉已經複製到新行的點字。 OnDataChanged(); // Update UI // 換上新列 RecreateRow(row); FillRow(m_BrDoc[lineIdx], row, true); // 插入新列 GridInsertRowAt(row + 3); FillRow(m_BrDoc[lineIdx + 1], row + 3, true); // 重新填列號 RefreshRowNumbers(); SourceGrid.Position pos = new SourceGrid.Position(row + 3, brGrid.FixedColumns); brGrid.Selection.Focus(pos, true); // 修正選取的儲存格範圍。 }
/// <summary> /// 插入一個空方。 /// </summary> /// <param name="grid"></param> /// <param name="row"></param> /// <param name="col"></param> /// <param name="count">插入幾個空方。</param> internal void InsertBlankCell(int row, int col, int count) { // 防錯:如果不是有效的儲存格位置就直接返回。 if (!CheckCellPosition(row, col)) { return; } int wordIdx = GetBrailleWordIndex(row, col); int lineIdx = GetBrailleLineIndex(row); BrailleLine brLine = m_BrDoc.Lines[lineIdx]; while (count > 0) { brLine.Words.Insert(wordIdx, BrailleWord.NewBlank()); count--; } OnDataChanged(); // Update UI. ReformatRow(row); SourceGrid.Position pos = new SourceGrid.Position(row, col + 1); brGrid.Selection.Focus(pos, true); // 修正選取的儲存格範圍。 }
/// <summary> /// cast cell on position pos to rich text box /// </summary> /// <param name="pos"></param> /// <returns></returns> private SourceGrid.Cells.RichTextBox getRichTextBoxCell(SourceGrid.Grid grid, SourceGrid.Position pos) { return(grid.GetCell(pos) as SourceGrid.Cells.RichTextBox); }