public override void OnClick(CellContext sender, EventArgs e) { base.OnClick(sender, e); if (mLastButton == MouseButtons.Left) UIChangeChecked(sender, e); }
public override void OnKeyPress(CellContext sender, KeyPressEventArgs e) { base.OnKeyPress(sender, e); if (e.KeyChar == ' ') UIChangeChecked(sender, e); }
/// <summary> /// Start editing the cell passed. Do not call this method for start editing a cell, you must use CellContext.StartEdit. /// </summary> /// <param name="cellContext">Cell to start edit</param> internal override void InternalStartEdit(CellContext cellContext) { base.InternalStartEdit(cellContext); if (Control == null) throw new SourceGridException("Control cannot be null"); if (IsEditing == false && EnableEdit) { //verifico di non avere ancora una cella associata if (EditCell!=null) throw new SourceGridException("There is already a Cell in edit state"); if (IsControlAttached() == false) AttachControl(cellContext.Grid); mLinkedControl.Position = cellContext.Position; //aggiorno la posizione cellContext.Grid.ArrangeLinkedControls(); OnStartingEdit(cellContext, Control); //With this method the edit start SetEditCell(cellContext); //Set the control value SafeSetEditValue(cellContext.Cell.Model.ValueModel.GetValue(cellContext)); //Show the control ShowControl(Control); } }
public override void OnMouseUp(CellContext sender, MouseEventArgs e) { base.OnMouseUp(sender, e); m_IsWidthResize = false; m_IsHeightResize = false; }
public override void OnMouseLeave(CellContext sender, EventArgs e) { base.OnMouseLeave(sender, e); if (mApplyOnMouseEnter) ResetCursor(sender, e); }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnDoubleClick (CellContext sender, EventArgs e) { base.OnDoubleClick(sender, e); if (sender.Cell != null && sender.Cell.Controller != null) sender.Cell.Controller.OnDoubleClick(sender, e); }
/// <summary> /// This method is called just before the edit start. You can use this method to customize the editor with the cell informations. /// </summary> /// <param name="cellContext"></param> /// <param name="editorControl"></param> protected override void OnStartingEdit(CellContext cellContext, Control editorControl) { base.OnStartingEdit(cellContext, editorControl); System.Windows.Forms.DateTimePicker dtPicker = (System.Windows.Forms.DateTimePicker)editorControl; dtPicker.Font = cellContext.Cell.View.Font; }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnKeyPress (CellContext sender, KeyPressEventArgs e) { base.OnKeyPress(sender, e); if (sender.Cell != null && sender.Cell.Controller != null && e.Handled == false) sender.Cell.Controller.OnKeyPress(sender, e); }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnDragEnter(CellContext sender, DragEventArgs e) { base.OnDragEnter (sender, e); if (sender.Cell != null && sender.Cell.Controller != null) sender.Cell.Controller.OnDragEnter(sender, e); }
public override void OnClick(CellContext sender, EventArgs e) { base.OnClick(sender, e); if (mLastButton == MouseButtons.Left) OnExecuted(sender, e); }
/// <summary> /// Fired when editing is ended /// </summary> public override void OnEditEnded(CellContext sender, EventArgs e) { base.OnEditEnded (sender, e); if (sender.Cell != null && sender.Cell.Controller != null) sender.Cell.Controller.OnEditEnded(sender, e); }
public override void OnMouseMove(CellContext sender, MouseEventArgs e) { base.OnMouseMove(sender, e); //Mouse multi selection //First check if the multi selection is enabled and the active position is valid if (sender.Grid.Selection.EnableMultiSelection == false || sender.Grid.MouseDownPosition.IsEmpty() || sender.Grid.MouseDownPosition != sender.Grid.Selection.ActivePosition) return; //Check if the mouse position is valid Position mousePosition = sender.Grid.PositionAtPoint(new Point(e.X, e.Y)); if (mousePosition.IsEmpty()) return; //If the position type is different I don't continue // bacause this can cause problem for example when selection the fixed rows when the scroll is on a position > 0 // that cause all the rows to be selected if (sender.Grid.GetPositionType(mousePosition) != sender.Grid.GetPositionType(sender.Grid.Selection.ActivePosition)) return; sender.Grid.ChangeMouseSelectionCorner(mousePosition); }
public override void OnFocusLeft(CellContext sender, EventArgs e) { base.OnFocusLeft (sender, e); if (sender.Grid!=null) sender.Grid.InvalidateCell(sender.Position); }
protected override void PrepareView(CellContext context) { // Do not start base prepare view, as it will render the text as normal TextGDI. // base.PrepareView(context); PrepareVisualElementRichTextBox(context); }
public override void OnMouseUp(CellContext sender, MouseEventArgs e) { base.OnMouseUp (sender, e); //Note: I can't use the click event because I don't have Button information (Control.MouseButtons returns always None inside the Click event) Point currentPoint = sender.Grid.PointToClient(System.Windows.Forms.Control.MousePosition); Rectangle cellRect = sender.Grid.PositionToRectangle(sender.Position); float distance; DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(cellRect, currentPoint, out distance); //eseguo il sort solo se non sono attualmente in resize if ( IsSortEnable(sender) && partType == DevAge.Drawing.RectanglePartType.ContentArea && e.Button == System.Windows.Forms.MouseButtons.Left ) { // AlanP: Dec 2013. Do not do a sort if the MouseUp is after a coulmnWidthResize Resizable resizableHeader = (Resizable)sender.Cell.Controller.FindController(typeof(Resizable)); if (resizableHeader != null) { // If the mouse down initiated a resize of the header on this cell we don't want to do a sort if (resizableHeader.MouseDownStartedWidthResize) { return; } } Models.ISortableHeader sortHeader = (Models.ISortableHeader)sender.Cell.Model.FindModel(typeof(Models.ISortableHeader)); Models.SortStatus l_Status = sortHeader.GetSortStatus(sender); if (l_Status.Style == DevAge.Drawing.HeaderSortStyle.Ascending) SortColumn(sender, false, l_Status.Comparer); else SortColumn(sender, true, l_Status.Comparer); } }
protected virtual void grid_MouseDown(GridVirtual sender, System.Windows.Forms.MouseEventArgs e) { //verifico che l'eventuale edit sia terminato altrimenti esco if (sender.Selection.ActivePosition.IsEmpty() == false) { CellContext focusCell = new CellContext(sender, sender.Selection.ActivePosition); if (focusCell.Cell != null && focusCell.IsEditing()) { if (focusCell.EndEdit(false) == false) return; } } //scateno eventi di MouseDown Position position = sender.PositionAtPoint( new Point(e.X, e.Y) ); if (position.IsEmpty() == false) { Cells.ICellVirtual cellMouseDown = sender.GetCell(position); if (cellMouseDown != null) { sender.ChangeMouseDownCell(position, position); //Cell.OnMouseDown CellContext cellContext = new CellContext(sender, position, cellMouseDown); sender.Controller.OnMouseDown(cellContext, e); } } else sender.ChangeMouseDownCell(Position.Empty, Position.Empty); }
public override void OnEditStarting(CellContext sender, System.ComponentModel.CancelEventArgs e) { base.OnEditStarting (sender, e); //Invalidate the selection to redraw the selection border sender.Grid.Selection.Invalidate(); }
/// <summary> /// Fired when editing is ended /// </summary> /// <param name="e"></param> public override void OnEditEnded(CellContext sender, EventArgs e) { base.OnEditEnded (sender, e); //Invalidate the selection to redraw the selection border sender.Grid.Selection.Invalidate(); }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnFocusLeft(CellContext sender, EventArgs e) { base.OnFocusLeft (sender, e); if (sender.Cell != null && sender.Cell.Controller != null) sender.Cell.Controller.OnFocusLeft(sender, e); }
public override void OnMouseDown(CellContext sender, System.Windows.Forms.MouseEventArgs e) { base.OnMouseDown(sender, e); if (e.Button != MouseButtons.Left) return; GridVirtual grid = sender.Grid; //Check the control and shift key status bool controlPress = ((Control.ModifierKeys & Keys.Control) == Keys.Control && (grid.SpecialKeys & GridSpecialKeys.Control) == GridSpecialKeys.Control); bool shiftPress = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift && (grid.SpecialKeys & GridSpecialKeys.Shift) == GridSpecialKeys.Shift); if (shiftPress == false || grid.Selection.EnableMultiSelection == false) { //Handle Control key bool mantainSelection = grid.Selection.EnableMultiSelection && controlPress; grid.Selection.Focus(sender.Position, !mantainSelection); } else //handle shift key { grid.Selection.ResetSelection(true); Range rangeToSelect = new Range(grid.Selection.ActivePosition, sender.Position); grid.Selection.SelectRange(rangeToSelect, true); } }
/// <summary> /// OnValueChanged /// </summary> public override void OnValueChanged(CellContext sender, EventArgs e) { base.OnValueChanged (sender, e); //gestione eventuale link ad una property if (m_LinkPropertyInfo != null) m_LinkPropertyInfo.SetValue(m_LinkObject, sender.Cell.Model.ValueModel.GetValue(sender),null); }
/// <summary> /// Reset the original cursor /// </summary> public virtual void ResetCursor(CellContext sender, EventArgs e) { if (Cursor != null) { if (sender.Grid.Cursor == Cursor) sender.Grid.Cursor = null; } }
protected override void PrepareView(CellContext context) { base.PrepareView(context); PrepareVisualElementText(context); PrepareVisualElementImage(context); }
protected virtual void PrepareVisualElementRichTextBox(CellContext context) { ElementRichText.Value = context.Cell.Model.ValueModel.GetValue(context) as DevAge.Windows.Forms.RichText; ElementRichText.ForeColor = ForeColor; ElementRichText.TextAlignment = TextAlignment; ElementRichText.Font = GetDrawingFont(context.Grid); ElementRichText.RotateFlipType = RotateFlipType; }
/// <summary> /// This method is called just before the edit start. You can use this method to customize the editor with the cell informations. /// </summary> /// <param name="cellContext"></param> /// <param name="editorControl"></param> protected override void OnStartingEdit(CellContext cellContext, Control editorControl) { base.OnStartingEdit(cellContext, editorControl); DevAge.Windows.Forms.DevAgeTextBoxButton editor = (DevAge.Windows.Forms.DevAgeTextBoxButton)editorControl; //to set the scroll of the textbox to the initial position (otherwise the textbox use the previous scroll position) editor.TextBox.SelectionStart = 0; editor.TextBox.SelectionLength = 0; }
/// <summary> /// Sets the effect of the selected text. /// </summary> public void SetSelectionEffect(CellContext cellContext, DevAge.Windows.Forms.EffectType effect) { ValueChangeEventArgs valArgs = new ValueChangeEventArgs(null, effect); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// Change the font of the selected text. /// </summary> /// <param name="cellContext"></param> /// <param name="color"></param> public void SetSelectionColor(CellContext cellContext, Color color) { ValueChangeEventArgs valArgs = new ValueChangeEventArgs(null, color); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// Change the font of the selected text. /// </summary> /// <param name="cellContext"></param> /// <param name="font"></param> public void SetSelectionFont(CellContext cellContext, Font font) { ValueChangeEventArgs valArgs = new ValueChangeEventArgs(null, font); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnClick (CellContext sender, EventArgs e) { base.OnClick(sender, e); if ( sender.Cell.Editor != null && (sender.Cell.Editor.EditableMode & EditableMode.SingleClick) == EditableMode.SingleClick && sender.Grid.Selection.ActivePosition == sender.Position) sender.StartEdit(); }
public void SetValue(CellContext cellContext, object p_Value) { DevAge.ComponentModel.ValueEventArgs valArgs = new DevAge.ComponentModel.ValueEventArgs(p_Value); if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanging(cellContext, valArgs); m_Value = valArgs.Value; if (cellContext.Grid != null) cellContext.Grid.Controller.OnValueChanged(cellContext, EventArgs.Empty); }
/// <summary> /// Change the cursor with the cursor of the cell /// </summary> /// <param name="e"></param> protected virtual void ApplyToolTipText(CellContext sender, EventArgs e) { Models.IToolTipText toolTip; if ((toolTip = (Models.IToolTipText)sender.Cell.Model.FindModel(typeof(Models.IToolTipText))) != null) { string text = toolTip.GetToolTipText(sender); if (text != null && text.Length > 0) { sender.Grid.ToolTipText = text; sender.Grid.ToolTip.ToolTipTitle = ToolTipTitle; sender.Grid.ToolTip.ToolTipIcon = ToolTipIcon; sender.Grid.ToolTip.IsBalloon = IsBalloon; if (BackColor.IsEmpty == false) { sender.Grid.ToolTip.BackColor = BackColor; } if (ForeColor.IsEmpty == false) { sender.Grid.ToolTip.ForeColor = ForeColor; } } } }
protected override void PrepareView(CellContext context) { base.PrepareView(context); if (context.CellRange.Contains(context.Grid.MouseDownPosition)) { Background.Style = DevAge.Drawing.ButtonStyle.Pressed; } else if (context.CellRange.Contains(context.Grid.MouseCellPosition)) { Background.Style = DevAge.Drawing.ButtonStyle.Hot; } #if !MOD //the focus rectangle does not look good. Then we have 3 rectangles - cell border (or probably the active cell border), button border and focus rect. else if (context.CellRange.Contains(context.Grid.Selection.ActivePosition)) { Background.Style = DevAge.Drawing.ButtonStyle.Focus; } #endif else { Background.Style = DevAge.Drawing.ButtonStyle.Normal; } }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnFocusEntered(CellContext sender, EventArgs e) { base.OnFocusEntered(sender, e); //sposto la visuale su questa cella sender.Grid.ShowCell(sender.Position); //Getsione dell'edit sul focus, non lo metto all'interno della cella perchè un utente potrebbe chiamare direttamente il metodo SetFocusCell senza passare dalla cella if (sender.Cell.Editor != null && (sender.Cell.Editor.EditableMode & EditableMode.Focus) == EditableMode.Focus) { sender.StartEdit(); } if (sender.Grid != null) { sender.Grid.InvalidateCell(sender.Position); } if (sender.Cell != null && sender.Cell.Controller != null) { sender.Cell.Controller.OnFocusEntered(sender, e); } }
/// <summary> /// Called when the checked button has changed in a radio button cell group. /// Basically, note the cell passed in sender's state and if it is checked /// we uncheck all other buttons in the array list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UIChangeChecked(CellContext sender, EventArgs e) { // See if the passed cell is checked. // If so, unckeck all the other cells. SourceGrid.Cells.RadioButton cell = sender.Cell as SourceGrid.Cells.RadioButton; if (cell != null) { if (cell.Checked) { foreach (SourceGrid.Cells.RadioButton c in this._radioButtons) { if (c != cell) { if (c.Checked) { c.Checked = false; } } } } } }
public override void OnMouseDown(CellContext sender, MouseEventArgs e) { base.OnMouseDown(sender, e); m_IsHeightResize = false; m_IsWidthResize = false; Rectangle l_CellRect = sender.Grid.PositionToRectangle(sender.Position); Point mousePoint = new Point(e.X, e.Y); DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(l_CellRect, mousePoint, out mDistanceFromBorder); if (((ResizeMode & CellResizeMode.Width) == CellResizeMode.Width) && partType == DevAge.Drawing.RectanglePartType.RightBorder) { m_IsWidthResize = true; } else if (((ResizeMode & CellResizeMode.Height) == CellResizeMode.Height) && partType == DevAge.Drawing.RectanglePartType.BottomBorder) { m_IsHeightResize = true; } }
public void No_ValueChanging_Event_If_Value_Does_Not_Change() { CustomEvents events = new CustomEvents(); events.ValueChanging += delegate(object sender, ValueChangeEventArgs e) { Assert.Fail("We did not change value, no event expected"); }; Grid grid = new Grid(); grid.Redim(1, 1); grid[0, 0] = new SourceGrid.Cells.Cell(1, typeof(int)); grid[0, 0].AddController(events); CellContext context = new CellContext(grid, new Position(0, 0)); // assert that we have already 1 inside this cell Assert.AreEqual(1, context.Value); // change the value of the cell to the same value // this should not fire ValueChanged event handler context.Cell.Editor.SetCellValue(context, 1); }
public virtual object GetValue(CellContext cellContext) { AddressInstance adr = (cellContext.Grid as FRomGrid).DataSource.Address; //Порядковый номер с нуля int n = cellContext.Position.Row - cellContext.Grid.FixedRows; //Если фиксированных больше одной и сейчас проходим по первой, //заполняем ее порядковым номером if (cellContext.Grid.FixedColumns > 1 && cellContext.Position.Column == 0) { return(n + 1); } if (adr.YMapConstName.Length != 0) { From f = (cellContext.Grid as FRomGrid).DataSource.GetFRom(); return(f.GetMap(adr.YMapConstName)[n, 0, ViewEnum.Scale]); } else { return(n + 1); } }
protected virtual void grid_MouseMove(GridVirtual sender, System.Windows.Forms.MouseEventArgs e) { Position l_PointPosition = sender.PositionAtPoint(new Point(e.X, e.Y)); Cells.ICellVirtual l_CellPosition = sender.GetCell(l_PointPosition); #region Mouse Multiselection if (e.Button == MouseButtons.Left && sender.Selection.EnableMultiSelection) { //Only if there is a FocusCell CellContext focusCellContext = new CellContext(sender, sender.Selection.ActivePosition); if (focusCellContext.Cell != null && focusCellContext.IsEditing() == false) { Position l_SelCornerPos = l_PointPosition; Cells.ICellVirtual l_SelCorner = l_CellPosition; //If the current Focus Cell is a scrollable cell then search the current cell (under the mouse)only in scrollable cells // see PositionAtPoint with false parameter if (sender.GetPositionType(sender.Selection.ActivePosition) == CellPositionType.Scrollable) { l_SelCornerPos = sender.PositionAtPoint(new Point(e.X, e.Y)); l_SelCorner = sender.GetCell(l_PointPosition); } if (l_SelCornerPos.IsEmpty() == false && l_SelCorner != null) { //Only if the user start the selection with a cell (m_MouseDownCell!=null) if (sender.MouseDownPosition.IsEmpty() == false && sender.Selection.Contains(sender.MouseDownPosition)) { sender.ChangeMouseSelectionCorner(l_SelCornerPos); sender.ShowCell(l_SelCornerPos); } } } } #endregion }
/// <summary> /// Toggle the value of the current cell and if AutoChangeValueOfSelectedCells is true of all the selected cells. /// Simulate an edit operation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UIChangeChecked(CellContext sender, EventArgs e) { Models.ICheckBox checkModel = (Models.ICheckBox)sender.Cell.Model.FindModel(typeof(Models.ICheckBox));; if (checkModel == null) { throw new SourceGrid.SourceGridException("Models.ICheckBox not found"); } Models.CheckBoxStatus checkStatus = checkModel.GetCheckBoxStatus(sender); if (checkStatus.CheckEnable) { bool newVal = true; if (checkStatus.Checked != null) { newVal = !checkStatus.Checked.Value; } sender.StartEdit(); try { checkModel.SetCheckedValue(sender, newVal); sender.EndEdit(false); OnCheckedChanged(EventArgs.Empty); } catch (Exception ex) { sender.EndEdit(true); throw new Exception(string.Empty, ex); } //change the status of all selected control if (AutoChangeValueOfSelectedCells) { AutoChangeValues(sender, newVal); } } }
public override void Render(CellContext context, StateType state, double cellWidth, double cellHeight) { context.Context.Translate(0, 0.5); int draw_x = 0; foreach (int i in AttributesForBoundObject) { Gdk.Pixbuf render_pixbuf = pixbufs[i]; if (render_pixbuf != null) { Cairo.Rectangle pixbuf_area = new Cairo.Rectangle(draw_x, (cellHeight - render_pixbuf.Height) / 2, render_pixbuf.Width, render_pixbuf.Height); if (!context.Opaque) { context.Context.Save(); } Gdk.CairoHelper.SetSourcePixbuf(context.Context, render_pixbuf, pixbuf_area.X, pixbuf_area.Y); context.Context.Rectangle(pixbuf_area); if (!context.Opaque) { context.Context.Clip(); context.Context.PaintWithAlpha(0.5); context.Context.Restore(); } else { context.Context.Fill(); } } draw_x += ICON_SIZE; } }
public override void Render(CellContext context, /*StateType state,*/ double cellWidth, double cellHeight) { if (BoundObject == null) { return; } if (!(BoundObject is TrackInfo)) { throw new InvalidCastException("CubanoTitleCell can only bind to TrackInfo objects"); } TrackInfo track = (TrackInfo)BoundObject; context.Layout.Width = (int)((cellWidth - 8) * Pango.Scale.PangoScale); context.Layout.Ellipsize = Pango.EllipsizeMode.End; //context.Layout.FontDescription = context.Widget.PangoContext.FontDescription.Copy (); context.Layout.FontDescription.Weight = font_weight; context.Layout.SetMarkup(String.Format("<big>{0}</big> {1}", track.TrackNumber, GLib.Markup.EscapeText(track.DisplayTrackTitle))); int text_width; int text_height; context.Layout.GetPixelSize(out text_width, out text_height); context.Context.MoveTo(4, ((int)cellHeight - text_height) / 2); Cairo.Color color = context.Theme.TextMidColor; //Cairo.Color color = context.Theme.Colors.GetWidgetColor ( // context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, state); //color.A = (!context.Sensitive) ? 0.3 : 1.0; context.Context.SetSourceColor(color); Pango.CairoHelper.ShowLayout(context.Context, context.Layout); }
public override void Render(CellContext context, double cellWidth, double cellHeight) { if (BoundObject == null) { return; } if (!(BoundObject is TrackInfo)) { throw new InvalidCastException("ColumnCellAlbum can only bind to AlbumInfo objects"); } TrackInfo track = (TrackInfo)BoundObject; context.Layout.Width = (int)((cellWidth - 8) * Pango.Scale.PangoScale); context.Layout.Ellipsize = Pango.EllipsizeMode.End; context.Layout.FontDescription.Weight = font_weight; context.Layout.SetMarkup(String.Format("<b>{0}</b>\n<small><i>{1}</i></small>", GLib.Markup.EscapeText(track.DisplayTrackTitle), GLib.Markup.EscapeText(track.DisplayArtistName))); int text_width; int text_height; context.Layout.GetPixelSize(out text_width, out text_height); context.Context.MoveTo(4, ((int)cellHeight - text_height) / 2); context.Widget.StyleContext.Save(); context.Widget.StyleContext.AddClass("entry"); Gdk.RGBA rgba = context.Widget.StyleContext.GetColor(context.Selected ? StateFlags.Selected : StateFlags.Normal); Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor(rgba); context.Widget.StyleContext.Restore(); color.A = (!context.Opaque) ? 0.3 : 1.0; context.Context.SetSourceColor(color); Pango.CairoHelper.ShowLayout(context.Context, context.Layout); }
private static IEnumerable <Row.MidiNote> ParseMidiNotes(CellContext context) { //---------------------------------------------------------------------- // MIDI Notes // * Multiple MIDI Note Supported // * Column name format: // MIDI Note1 ... MIDI Note1+n // Velocity1 ... Velocity1+n //---------------------------------------------------------------------- var notes = new List <Row.MidiNote>(); for (int i = 1; i < int.MaxValue; i++) { if (!TryParseSheet(context, SpreadsheetConstants.HeaderMidiNote + i, out var noteNumberCell)) { break; } ParseSheet(context, SpreadsheetConstants.HeaderMidiVelocity + i, out var velocityCell); if (!int.TryParse(velocityCell, out var velocityValue)) { break; } var obj = new Row.MidiNote { Note = new MidiNoteNumberCell(noteNumberCell), Velocity = new MidiNoteVelocityCell(velocityValue) }; notes.Add(obj); } return(notes); }
public override void UpdateMetrics(U cell, CellContext <T> context) { MolapCell <T> mcell = (MolapCell <T>)(object) cell; foreach (var item in _metrics) { object nvalue = null; try { context.CurrentMetric = item.ID; nvalue = item.MetricExpression.Evaluate(context); } catch (Exception ex) { //to do logging error and error behavior Console.WriteLine(ex.Message); } if (nvalue != null) { if (mcell.Values.ContainsKey(item.ID)) { mcell.Values[item.ID] = (ValueType)nvalue; } else { mcell.Values.Add(item.ID, (ValueType)nvalue); } } else { mcell.Values.Remove(item.ID); } } }
/// <summary> /// Constructor /// </summary> /// <param name="cellContext"></param> /// <returns></returns> public CheckBoxStatus GetCheckBoxStatus(CellContext cellContext) { bool enableEdit = false; if (cellContext.Cell.Editor != null && cellContext.Cell.Editor.EnableEdit) { enableEdit = true; } object val = cellContext.Cell.Model.ValueModel.GetValue(cellContext); if (val == null) { return(new CheckBoxStatus(enableEdit, DevAge.Drawing.CheckBoxState.Undefined, m_Caption)); } else if (val is bool) { return(new CheckBoxStatus(enableEdit, (bool)val, m_Caption)); } else { throw new SourceGridException("Cell value not supported for this cell. Expected bool value or null."); } }
/// <summary> /// 右クリックで選択状態にする。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnMouseDown(CellContext sender, MouseEventArgs e) { base.OnMouseDown(sender, e); if (e.Button == MouseButtons.Left) { LinearGlobal.MainForm.ListForm.setFilteringText(""); SourceGrid.Grid grid = (SourceGrid.Grid)sender.Grid; LinearAudioPlayer.FilteringGridController.setRowColor( LinearAudioPlayer.FilteringGridController.LastSelectRowNo, EnuPlayType.NOPLAY); LinearAudioPlayer.FilteringGridController.setRowColor(sender.Position.Row, EnuPlayType.PLAYING); LinearAudioPlayer.GroupGridController.setRowColor(LinearAudioPlayer.GroupGridController.LastSelectRowNo, GroupGridController.EnuPlayType.NOPLAY); LinearGlobal.LinearConfig.PlayerConfig.SelectFilter = grid[sender.Position.Row, 0].Value.ToString(); LinearGlobal.FilteringMode = LinearEnum.FilteringMode.DEFAULT; //LinearGlobal.MainForm.ListForm.setGroupMode(); LinearGlobal.MainForm.ListForm.reloadDatabase(true); LinearAudioPlayer.FilteringGridController.Grid.Focus(); } }
/// <summary> /// Change the value of the cell applying the rule of the current editor. Is recommend to use this method to simulate a edit operation and to validate the cell value using the current model. /// Doesn't call the StartEdit and EndEdit but change directly the cell value. Use the CellContext.Start edit to begin an edit operation. /// </summary> /// <param name="cellContext">Cell to change the value</param> /// <param name="p_NewValue"></param> /// <returns>returns true if the value passed is valid and has been applied to the cell</returns> public virtual bool SetCellValue(CellContext cellContext, object p_NewValue) { if (EnableEdit) { if (cellContext.Cell == null) { throw new SourceGridException("Invalid CellContext, cell is null"); } ValidatingCellEventArgs l_cancelEvent = new ValidatingCellEventArgs(cellContext, p_NewValue); OnValidating(l_cancelEvent); //check if cancel == true if (l_cancelEvent.Cancel == false) { object l_PrevValue = cellContext.Cell.Model.ValueModel.GetValue(cellContext); try { cellContext.Cell.Model.ValueModel.SetValue(cellContext, ObjectToValue(l_cancelEvent.NewValue)); OnValidated(new CellContextEventArgs(cellContext)); } catch (Exception err) { OnEditException(new ExceptionEventArgs(err)); cellContext.Cell.Model.ValueModel.SetValue(cellContext, l_PrevValue); l_cancelEvent.Cancel = true; //di fatto è fallita la validazione del dato } } return(l_cancelEvent.Cancel == false); } else { return(false); } }
protected virtual void PrepareVisualElementCheckBox(CellContext context) { ElementCheckBox.AnchorArea = new DevAge.Drawing.AnchorArea(CheckBoxAlignment, false); Models.ICheckBox checkBoxModel = (Models.ICheckBox)context.Cell.Model.FindModel(typeof(Models.ICheckBox)); Models.CheckBoxStatus checkBoxStatus = checkBoxModel.GetCheckBoxStatus(context); if (context.CellRange.Contains(context.Grid.MouseCellPosition)) { //[email protected]:Readonly state is taken into acct and disabled style is displayed if (!checkBoxStatus.CheckEnable || checkBoxStatus.ReadOnly) { ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled; } else { ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Hot; } } else { if (!checkBoxStatus.CheckEnable || checkBoxStatus.ReadOnly) { ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled; } else { ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Normal; } } ElementCheckBox.CheckBoxState = checkBoxStatus.CheckState; ElementText.Value = checkBoxStatus.Caption; }
private void AutoChangeValues(CellContext sender, bool newVal) { foreach (Position pos in sender.Grid.Selection.GetSelectionRegion().GetCellsPositions()) { Cells.ICellVirtual c = sender.Grid.GetCell(pos); Models.ICheckBox check; if (c != this && c != null && (check = (Models.ICheckBox)c.Model.FindModel(typeof(Models.ICheckBox))) != null) { CellContext context = new CellContext(sender.Grid, pos, c); context.StartEdit(); try { check.SetCheckedValue(context, newVal); context.EndEdit(false); } catch (Exception) { context.EndEdit(true); throw; } } } }
public override void Render(CellContext context, double cellWidth, double cellHeight) { if (BoundObject == null) { return; } if (!(BoundObject is AlbumInfo)) { throw new InvalidCastException("ColumnCellAlbum can only bind to AlbumInfo objects"); } AlbumInfo album = (AlbumInfo)BoundObject; bool is_default = false; ImageSurface image = artwork_manager == null ? null : artwork_manager.LookupScaleSurface(album.ArtworkId, image_size, true); if (image == null) { image = default_cover_image; is_default = true; } // int image_render_size = is_default ? image.Height : (int)cellHeight - 8; int image_render_size = image_size; int x = image_spacing; int y = ((int)cellHeight - image_render_size) / 2; ArtworkRenderer.RenderThumbnail(context.Context, image, false, x, y, image_render_size, image_render_size, !is_default, context.Theme.Context.Radius); int fl_width = 0, fl_height = 0, sl_width = 0, sl_height = 0; context.Widget.StyleContext.Save(); context.Widget.StyleContext.AddClass("entry"); Cairo.Color text_color = CairoExtensions.GdkRGBAToCairoColor(context.Widget.StyleContext.GetColor(StateFlags.Selected)); context.Widget.StyleContext.Restore(); text_color.A = 0.75; Pango.Layout layout = context.Layout; layout.Width = (int)((cellWidth - cellHeight - x - 10) * Pango.Scale.PangoScale); layout.Ellipsize = Pango.EllipsizeMode.End; layout.FontDescription.Weight = Pango.Weight.Bold; // Compute the layout sizes for both lines for centering on the cell int old_size = layout.FontDescription.Size; layout.SetText(album.DisplayTitle); layout.GetPixelSize(out fl_width, out fl_height); if (!String.IsNullOrEmpty(album.ArtistName)) { layout.FontDescription.Weight = Pango.Weight.Normal; layout.FontDescription.Size = (int)(old_size * Pango.Scale.Small); layout.FontDescription.Style = Pango.Style.Italic; layout.SetText(album.ArtistName); layout.GetPixelSize(out sl_width, out sl_height); } // Calculate the layout positioning x = ((int)cellHeight - x) + 10; y = (int)((cellHeight - (fl_height + sl_height)) / 2); // Render the second line first since we have that state already if (!String.IsNullOrEmpty(album.ArtistName)) { context.Context.MoveTo(x, y + fl_height); context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); } // Render the first line, resetting the state layout.SetText(album.DisplayTitle); layout.FontDescription.Weight = Pango.Weight.Bold; layout.FontDescription.Size = old_size; layout.FontDescription.Style = Pango.Style.Normal; layout.SetText(album.DisplayTitle); context.Context.MoveTo(x, y); text_color.A = 1; context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); }
public override void OnValueChanged(CellContext sender, EventArgs e) { p.StartTimer(); }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void OnMouseLeave(CellContext sender, EventArgs e) { base.OnMouseLeave(sender, e); sender.Grid.InvalidateCell(sender.Position); }
public override void Draw(RangePaintEventArgs e) { RangeRegion region = mSelection.GetSelectionRegion(); if (region.IsEmpty()) { return; } // get visible range for scrollable area // AlanP: June 2014. Changed the call from RangeAtAreaExpanded to RangeAtArea to fix a bug that occurred on Partner/Find screen // The grid on this screen has 3 fixed columns on the left but the highlight was always applied to the cell 'behind' the last fixed column // as well as the rest of the row. This is because of getting the 'expanded' range. // To be honest I don't understand what the expanded range is for. The comment for it is not helpful (to me anyway). // It may be something to do with drawing the focus cell? If we see a problem later we could revies this code //Range visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable); Range visibleScrollableRange = mSelection.Grid.RangeAtArea(CellPositionType.Scrollable); System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor); // In OP we would like to have the rows of fixed columns highlighted as well - this seems non-standard // This code is the same as is used in the standard code below, but for the FixedLeft Range Range visibleFixedLeftRange = mSelection.Grid.RangeAtArea(CellPositionType.FixedLeft); foreach (Range rangeToLoop in region) { Range rng = visibleFixedLeftRange.Intersect(rangeToLoop); System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng); if (rectToDraw == System.Drawing.Rectangle.Empty) { continue; } System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw); e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw); } // Deal with the focus rectangle... The original grid code does not seem to support the focus being on a fixed column, which seems like a bug // but does not affect OpenPetra CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition); // get focus rectangle // clipped to visible range Range focusClippedRange = visibleScrollableRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition)); System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start); //Draw each selection range foreach (Range rangeToLoop in region) { // intersect given range with visible range // this way we ensure we don't loop through thousands // of rows to calculate rectToDraw Range rng = visibleScrollableRange.Intersect(rangeToLoop); System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng); if (rectToDraw == System.Drawing.Rectangle.Empty) { continue; } System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw); if (rectToDraw.IntersectsWith(focusRect)) { regionToDraw.Exclude(focusRect); } e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw); //Draw the border only if there isn't a editing cell // and is the range that contains the focus or there is a single range if (rng.Contains(mSelection.ActivePosition) || region.Count == 1) { if (focusContext.IsEditing() == false) { mSelection.Border.Draw(e.GraphicsCache, rectToDraw); } } } //Draw Focus System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor); e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect); }
/// <summary> /// Get char offset of current selection /// </summary> /// <param name="cellContext"></param> /// <returns></returns> public int GetSelectionCharOffset(CellContext cellContext) { return(GetRichTextBoxControl(cellContext).SelectionCharOffset); }
/// <summary> /// Get horizontal alignment of current selection /// </summary> /// <param name="cellContext"></param> /// <returns></returns> public HorizontalAlignment GetSelectionAlignment(CellContext cellContext) { return(GetRichTextBoxControl(cellContext).SelectionAlignment); }
/// <summary> /// Insert a string at the selection /// </summary> /// <param name="cellContext"></param> /// <param name="s">String to insert</param> public void InsertString(CellContext cellContext, string s) { GetRichTextBoxControl(cellContext).SelectedText = s; }
public override void OnMouseDown(CellContext sender, MouseEventArgs e) { base.OnMouseDown(sender, e); mLastButton = e.Button; }
/// <summary> /// Get font of current selection /// </summary> /// <param name="cellContext"></param> /// <returns></returns> public Font GetSelectionFont(CellContext cellContext) { return(GetRichTextBoxControl(cellContext).SelectionFont); }
/// <summary> /// Sort the current column. If the range contains all the columns this method move directly the row object otherwise move each cell. /// </summary> /// <param name="sender"></param> /// <param name="p_bAscending"></param> /// <param name="p_Comparer"></param> public void SortColumn(CellContext sender, bool p_bAscending, System.Collections.IComparer p_Comparer) { //verifico che il sort sia abilitato e che ci sia almeno una riga da ordinare oltra a quella corrente if (IsSortEnable(sender) && sender.Position.Row < (sender.Grid.Rows.Count) && sender.Grid.Columns.Count > 0) { Range l_RangeToSort; Range l_RangeHeader; if (m_RangeToSort != null) { l_RangeToSort = m_RangeToSort.GetRange(sender.Grid); } else { //the range to sort is all the grid range without the rows < of the current row l_RangeToSort = new Range(sender.Position.Row + 1, 0, sender.Grid.Rows.Count - 1, sender.Grid.Columns.Count - 1); } if (m_HeaderRange != null) { l_RangeHeader = m_HeaderRange.GetRange(sender.Grid); } else { //the range header is all the grid range with the rows <= of the current row l_RangeHeader = new Range(0, 0, sender.Position.Row, sender.Grid.Columns.Count - 1); } Models.ISortableHeader modelSortable = (Models.ISortableHeader)sender.Cell.Model.FindModel(typeof(Models.ISortableHeader)); if (sender.Grid.Rows.Count > (sender.Position.Row + 1) && sender.Grid.Columns.Count > sender.Grid.FixedColumns) { //Sort sender.Grid.SortRangeRows(l_RangeToSort, sender.Position.Column, p_bAscending, p_Comparer); if (p_bAscending) { modelSortable.SetSortMode(sender, DevAge.Drawing.HeaderSortStyle.Ascending); } else { modelSortable.SetSortMode(sender, DevAge.Drawing.HeaderSortStyle.Descending); } //Remove the image from others ColHeaderSort for (int r = l_RangeHeader.Start.Row; r <= l_RangeHeader.End.Row; r++) { for (int c = l_RangeHeader.Start.Column; c <= l_RangeHeader.End.Column; c++) { Cells.ICellVirtual tmpCell = sender.Grid.GetCell(r, c); if (tmpCell != sender.Cell && tmpCell != null && tmpCell.Model.FindModel(typeof(Models.ISortableHeader)) != null) { Models.ISortableHeader header = (Models.ISortableHeader)tmpCell.Model.FindModel(typeof(Models.ISortableHeader)); header.SetSortMode(new CellContext(sender.Grid, new Position(r, c), tmpCell), DevAge.Drawing.HeaderSortStyle.None); } } } sender.Grid.InvalidateRange(l_RangeHeader); } } }
protected override void PrepareView(CellContext context) { base.PrepareView(context); PrepareVisualElementSortIndicator(context); }