/// <summary>Display an entry box for the user to edit cell data.</summary> private void ShowEntryBox() { Selection.GetSelection(out int selectedColumnIndex, out int selectedRowIndex); var cellBounds = sheet.CalculateBounds(selectedColumnIndex, selectedRowIndex); entry = new Entry(); entry.SetSizeRequest((int)cellBounds.Width - 3, (int)cellBounds.Height - 10); entry.WidthChars = 5; entry.Text = sheet.DataProvider.GetCellContents(selectedColumnIndex, selectedRowIndex); entry.KeyPressEvent += OnEntryKeyPress; if (!sheet.CellPainter.TextLeftJustify(selectedColumnIndex, selectedRowIndex)) { entry.Alignment = 1; // right } if (sheet.Children.Length == 1) { fix = (Fixed)sheet.Child; } else { fix = new Fixed(); sheet.Add(fix); } fix.Put(entry, (int)cellBounds.Left + 1, (int)cellBounds.Top + 1); sheet.ShowAll(); sheet.Refresh(); entry.GrabFocus(); }
/// <summary>Invoked when the user has moved the horizontal scroll bar.</summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments.</param> private void OnHorizontalScrollbarChanged(object sender, EventArgs e) { if (sheet.NumberHiddenColumns != horizontalScrollbar.Value) { sheet.NumberHiddenColumns = (int)horizontalScrollbar.Value; sheet.Refresh(); } }
/// <summary>Invoked when the user presses a key.</summary> /// <param name="sender">Sender of event.</param> /// <param name="evnt">The event data.</param> private void OnKeyPressEvent(object sender, EventKey evnt) { if (Editor == null || !Editor.IsEditing) { if (evnt.Key == Gdk.Key.Right && evnt.State == ModifierType.ControlMask) { MoveToFarRight(); } else if (evnt.Key == Gdk.Key.Left && evnt.State == ModifierType.ControlMask) { MoveToFarLeft(); } else if (evnt.Key == Gdk.Key.Down && evnt.State == ModifierType.ControlMask) { MoveToBottom(); } else if (evnt.Key == Gdk.Key.Up && evnt.State == ModifierType.ControlMask) { MoveToTop(); } else if (evnt.Key == Gdk.Key.Left) { MoveLeft(); } else if (evnt.Key == Gdk.Key.Right) { MoveRight(); } else if (evnt.Key == Gdk.Key.Down) { MoveDown(); } else if (evnt.Key == Gdk.Key.Up) { MoveUp(); } else if (evnt.Key == Gdk.Key.Page_Down) { PageDown(); } else if (evnt.Key == Gdk.Key.Page_Up) { PageUp(); } sheet.Refresh(); } }