/// <summary> /// creates controland coordinator according to the type /// </summary> /// <param name = "commandType"></param> /// <param name = "mgControl"></param> /// <param name = "containerControl"></param> /// <returns></returns> internal static LogicalControl createControl(CommandType commandType, GuiMgControl guiMgControl, Control containerControl, int mgRow, int mgColumn) { LogicalControl lg = createControl(commandType, guiMgControl, containerControl); lg._mgRow = mgRow; lg._mgColumn = mgColumn; ContainerManager containerManager = GuiUtilsBase.getContainerManager(containerControl); if (containerManager is TableManager) { TableCoordinator tableCoordinator = new TableCoordinator((TableManager)containerManager, lg, mgColumn); lg._coordinator = tableCoordinator; lg._editorProvider = tableCoordinator; } else if (containerManager is BasicControlsManager) { EditorSupportingCoordinator editorSupportingCoordinator = new EditorSupportingCoordinator(lg); lg._coordinator = editorSupportingCoordinator; lg._editorProvider = editorSupportingCoordinator; } else // tree { Debug.Assert(false); } return(lg); }
/// <summary> /// coordinater for controls on the form /// </summary> /// <param name = "lg"></param> internal EditorSupportingCoordinator(LogicalControl lg) : base(lg, ((BasicControlsManager)lg.ContainerManager).LogicalControlsContainer) { _staticControlsManager = (BasicControlsManager)lg.ContainerManager; lg.StyleChanged += lg_OnStyleChanged; lg.BorderTypeChanged += lg_OnBorderTypeChanged; }
/// <summary>link control to the editor</summary> /// <param name="staticControl"></param> /// <param name="editor"></param> /// <param name="create"></param> internal void linkControlToEditor(LogicalControl lg, StaticControlEditor editor, bool create) { Control control; if (create) { if (editor.Control != null) { GuiUtilsBase.ControlToDispose = editor.Control; } control = toControl(lg.GuiMgControl); control.Size = new Size(); } else { control = editor.Control; } ControlsMap.getInstance().setMapData(lg.GuiMgControl, lg._mgRow, control); editor.Control = control; lg.setProperties(control); editor.BoundsComputer = (BoundsComputer)lg.Coordinator; editor.Layout(); lg.setPasswordToControl(control); }
public override void PaintControl(PlacementDrivenLogicalControl lg, Rectangle cellRect, Graphics g, bool isRowMarked, bool isSelected, ColumnsManager columnsManager) { base.PaintControl(lg, cellRect, g, isRowMarked, isSelected, columnsManager); LogicalControl logicalControl = (LogicalControl)lg; // paint controls if (GuiUtilsBase.isOwnerDrawControl(logicalControl.GuiMgControl)) { var tableCoordinator = (TableCoordinator)lg.Coordinator; ILogicalColumn lgColumn = columnsManager.getLgColumnByMagicIdx(lg._mgColumn); if (lg.Visible && lgColumn.Visible && tableCoordinator.getEditorControl() == null) { bool keepColor; //calculate background color Color controlBgColor = computeControlBgColor((LogicalControl)lg, columnsManager, null, isRowMarked, false, OnGetGuiRowIndex(lg._mgRow), true, out keepColor); Rectangle displayRect = tableCoordinator.getDisplayRect(cellRect, false); //calculate foreground color Color fgColor = computeControlFgColor(isSelected, isRowMarked, (LogicalControl)lg); //paint the control logicalControl.paint(g, displayRect, controlBgColor, fgColor, keepColor); } } }
/// <summary> /// Gets logical control cell rect in table /// </summary> /// <param name="lg"></param> /// <returns></returns> public override Rectangle GetCellRect(PlacementDrivenLogicalControl lg) { LogicalControl logicalControl = (LogicalControl)lg; TableCoordinator tableCoordinator = (TableCoordinator)lg.Coordinator; return(tableCoordinator.GetCellRect(lg._mgColumn, logicalControl._mgRow)); }
/// <summary>finds static control on point</summary> /// <param name="pt"></param> point /// <param name="findExact"></param> - not relevant for this implementation /// <param name="checkEnabled"></param> check if statuc control is enabled /// <returns></returns> internal override MapData HitTest(Point pt, bool findExact, bool checkEnabled) { Point offset = ContainerOffset(); pt.Offset(-offset.X, -offset.Y); if (LogicalControls != null) { for (int i = LogicalControls.Count - 1; i >= 0; i--) { LogicalControl lg = (LogicalControl)LogicalControls[i]; if (lg.canHit(checkEnabled) && ((EditorSupportingCoordinator)lg.Coordinator).Contains(pt)) { return(new MapData(lg.GuiMgControl)); } } } return(null); }
/// <summary> open temporary editor for tree child create a text control for the editor</summary> /// <param name="child"></param> /// <returns></returns> internal Control showTmpEditor(LogicalControl lg) { GuiUtils.SetTmpEditorOnTagData(GuiUtils.FindForm(mainControl), tmpEditor); //When the focus passed from control with hint to control without hint (and vise versa) or between two controls with hint, the control should be created. bool shouldCreate = GuiUtils.ShouldCreateControl(tmpEditor.Control, lg); linkControlToEditor(lg, tmpEditor, (tmpEditor.Control == null || shouldCreate) && !lg.isLastFocussedControl()); #if !PocketPC // The RightToLeft causes a select all. but sometimes the outcome has a problem. // so, deselect all. after that we have our own set selection anyway. if (tmpEditor.Control is TextBox && tmpEditor.Control.RightToLeft == RightToLeft.Yes) { ((TextBox)tmpEditor.Control).DeselectAll(); } #endif return(tmpEditor.Control); }
/// <summary> /// Placement Data of object /// </summary> /// <param name="obj"></param> /// <returns></returns> protected override PlacementData PlacementData(Object obj) { PlacementData placementData = null; if (obj is Control) { Control control = (Control)obj; if (control.Tag != null) { placementData = ((TagData)control.Tag).PlacementData; } } else { if (obj is LogicalControl) { LogicalControl staticControl = (LogicalControl)obj; placementData = staticControl.PlacementData; } } return(placementData); }
/// <summary> /// /// </summary> /// <param name="tableManager"></param> /// <param name="logicalControl"></param> /// <param name="mgColumn"></param> internal TableCoordinator(TableManager tableManager, LogicalControl logicalControl, int mgColumn) : base(tableManager, logicalControl, mgColumn) { }
/// <summary> /// insert rows into table control /// </summary> /// <param name="rowStart">the index at which to begin insert</param> /// <param name="rowsToInsert">number of rows to be inserted</param> internal override void InsertRows(int rowStart, int rowsToInsert, bool manipulateEditors) { if (rowStart < 0 || rowsToInsert <= 0) { return; } _mgCount += rowsToInsert; for (int idx = rowStart; idx < rowStart + rowsToInsert; idx++) { _tableControl.InsertItem(getGuiRowIndex(rowStart)); } if (manipulateEditors) { // if allowTesting, do not perform insert, use shiftrows instead. if (GuiUtils.AccessTest) { ShiftEditors(rowStart, rowsToInsert); } else { InsertEditorsForVisibleColumns(rowStart, rowsToInsert); } } // move rows after rowStart in controlsMap for (int i = 0; i < _children.Count; i++) { if (!_children[i].IsTableHeaderChild) { ArrayList arrayControl = controlsMap.object2WidgetArray(_children[i], GuiConstants.ALL_LINES); if (arrayControl == null) { break; } if (rowStart <= arrayControl.Count) { for (int idx = rowStart; idx < rowStart + rowsToInsert; idx++) { arrayControl.Insert(rowStart, null); } } for (int j = rowStart + rowsToInsert; j < arrayControl.Count; j++) { LogicalControl lg = (LogicalControl)arrayControl[j] ?? null; if (lg != null) { lg._mgRow = j; ((TableCoordinator)lg.Coordinator).MgRow = j; TableEditor editor = getTableEditor(lg); // reapply properties on the editor if (editor != null && editor.Control != null) { TagData tagData = (TagData)(((Control)editor.Control).Tag); if (tagData.MapData is MapData) { MapData mapData = (MapData)tagData.MapData; int row = mapData.getIdx(); row = j; mapData.setIdx(row); } } } } } } }
/// <summary> /// remove rows from table control /// </summary> /// <param name="rowStart">the index at which to begin remove</param> /// <param name="rowsToRemove">number of rows to remove</param> internal override void RemoveRows(int rowStart, int rowsToRemove, bool manipulateEditors) { int numOfRows = _tableControl.getItemsCount(); if (rowStart < 0 || rowStart >= numOfRows && rowsToRemove <= 0) { return; } if (rowStart + rowsToRemove > numOfRows) { rowsToRemove = numOfRows - rowStart; } _mgCount -= rowsToRemove; for (int idx = rowStart; idx < rowStart + rowsToRemove; idx++) { _tableControl.RemoveItem(getGuiRowIndex(rowStart)); } if (manipulateEditors) { // if allowTesting, do not perform remove, use shiftrows instead. if (GuiUtils.AccessTest) { ShiftEditors(rowStart, -rowsToRemove); } else { RemoveEditorsForVisibleColumns(rowStart, rowsToRemove); } } // update controlsMap for (int i = 0; i < _children.Count; i++) { if (!_children[i].IsTableHeaderChild) { ArrayList arrayControl = controlsMap.object2WidgetArray(_children[i], GuiConstants.ALL_LINES); // lg.Dispose() can remove entries from controlsMap and hence arrayControl can be null. // In that case no need to continue even for other columns in same row. if (arrayControl == null) { break; } for (int idx = 0; idx < rowsToRemove && rowStart < arrayControl.Count; idx++) { long entriesBeforeDispose = arrayControl.Count; LogicalControl lg = (LogicalControl)arrayControl[rowStart] ?? null; if (lg != null) { // As we delete entries from arrayControl, we should adjust _mgRow in // logical controls. _mgRow is used as index to remove Control from map lg._mgRow = rowStart; lg.Dispose(); } // LogicalControl.Dispose removes entry from the map only all entries after current // entry are null. If Dispose has not removed the entry, then remove it. if (entriesBeforeDispose == arrayControl.Count) { arrayControl.RemoveAt(rowStart); } } for (int j = rowStart; j < arrayControl.Count; j++) { LogicalControl lg = (LogicalControl)arrayControl[j] ?? null; if (lg != null) { lg._mgRow = j; ((TableCoordinator)lg.Coordinator).MgRow = j; TableEditor editor = getTableEditor(lg); // reapply properties on the editor if (editor != null && editor.Control != null) { TagData tagData = (TagData)(((Control)editor.Control).Tag); if (tagData.MapData is MapData) { MapData mapData = (MapData)tagData.MapData; int row = mapData.getIdx(); row = j; mapData.setIdx(row); } } } } } } // remove from _rowsToRefresh for (int idx = rowStart; idx < rowStart + rowsToRemove; idx++) { if (_rowsToRefresh.Contains(getGuiRowIndex(rowStart))) { _rowsToRefresh.Remove(getGuiRowIndex(rowStart)); } } }
/// <summary> /// return control of tableChild /// </summary> /// <param name="child"></param> /// <returns></returns> internal Control getEditorControl(LogicalControl child) { return(child.getEditorControl()); }