/// <summary> /// SetSelection : Call Gui to set the selection on the text in the control /// </summary> /// <param name = "ctrl"> </param> /// <param name = "start"> </param> /// <param name = "end"> </param> /// <param name="caretPos"></param> public static void SetSelection(MgControlBase ctrl, int start, int end, int caretPos) { if (ctrl.isTextOrTreeEdit()) { Commands.setSelection(ctrl, ctrl.getDisplayLine(true), start, end, caretPos); } }
/// <summary> /// Constructor. /// </summary> /// <param name="dvControl"></param> /// <param name="dvDataTable"></param> internal DVControlManager(MgControlBase dvControl, DVDataTable dvDataTable) { isDataBound = false; DVDataTableObj = dvDataTable; DVControl = dvControl; DVDataTableCollection.Add(dvDataTable.DataTblObj, this); }
/// <summary> /// set the currVerifyCtrl /// </summary> /// <param name="aCtrl"></param> public void setCurrVerifyCtrl(MgControlBase aCtrl) { if (aCtrl == null || aCtrl.getField() != null) { _currVerifyCtrl = aCtrl; } }
/// <summary> /// Make copy of validation details, /// copy constructor /// </summary> public ValidationDetails(ValidationDetails vd) : this() { _oldvalue = vd.getOldValue(); _val = vd._val; _range = vd.getRange(); _control = vd.getControl(); _validationFailed = false; if (vd._pictureReal != null) { _pictureReal = new StringBuilder(vd._pictureReal.ToString()); } if (vd._pictureEnable != null) { _pictureEnable = new StringBuilder(vd._pictureEnable.ToString()); } if (vd.getDiscreteRangeValues() != null) { _discreteRangeValues = vd.CloneDiscreteRangeValues(); } if (vd.getContinuousRangeValues() != null) { _continuousRangeValues = vd.CloneContinuousRangeValues(); } _picData = vd.getPIC(); _isNull = vd.getIsNull(); }
/// <summary>To allocate and fill inner objects of the class</summary> /// <param name = "foundTagName">name of tag, of object, which need be allocated</param> /// <returns> boolean if inner tags finished</returns> private bool initInnerObjects(String foundTagName) { if (foundTagName == null) { return(false); } XmlParser parser = Manager.GetCurrentRuntimeContext().Parser; if (foundTagName.Equals(XMLConstants.MG_TAG_CONTROL)) { MgControlBase control = _mgForm.ConstructMgControl(); control.fillData(_mgForm, _controls.Count); _controls.Add(control); } else if (foundTagName.Equals('/' + XMLConstants.MG_TAG_CONTROL)) { parser.setCurrIndex2EndOfTag(); return(false); } else { return(false); } return(true); }
/// <summary>(public) /// replace the content of a marked text within an edit control /// </summary> /// <param name = "ctrl">the control to operate upon </param> /// <param name = "str">text to replace </param> /// <returns>succeed or failed </returns> public static bool MarkedTextSet(MgControlBase ctrl, String str) { if (!ctrl.isTextOrTreeEdit()) { return(false); } MgPoint selection = SelectionGet(ctrl); // return if no text is selected if (selection.x == selection.y) { return(false); } bool successful = true; if (ctrl.isRichEditControl()) { #if !PocketPC Commands.setMarkedTextOnRichEdit(ctrl, ctrl.getDisplayLine(true), str); #endif } else { successful = TextMaskEditor.MarkedTextSet(ctrl, str); } return(successful); }
/// <summary> /// applies column properties on a line mode form /// </summary> /// <param name = "tableNode"></param> /// <param name = "mgForm"></param> private void ApplyTableProp(XmlElement tableNode, MgFormBase mgForm) { // read val for all columns and set them on form if (mgForm.HasTable() && !IsTableDesignChanged(mgForm, tableNode)) { MgControlBase tableCtrl = mgForm.getTableCtrl(); int columnCount = tableNode.ChildNodes.Count; var columnData = new List <int[]>(); // {layer, width, widthForFillTablePlacement} for (int index = 0; index < columnCount; index++) { var columnElement = (XmlElement)tableNode.ChildNodes[index]; // get layer and width int colLayer = int.Parse(columnElement.GetAttribute(STR_LAYER)); int colWidth = int.Parse(columnElement.GetAttribute(STR_WIDTH)); int colWidthForFillTablePlacement; if (!int.TryParse(columnElement.GetAttribute(STR_WIDTH_FOR_FILL_TABLE_PLACEMENT), out colWidthForFillTablePlacement)) { colWidthForFillTablePlacement = colWidth; } columnData.Add(new[] { colLayer, colWidth, colWidthForFillTablePlacement }); } Commands.addAsync(CommandType.REORDER_COLUMNS, tableCtrl, 0, columnData); } }
/// <summary> /// Perform actions required when a dragged object is dropped (mouse released). /// Put actions : ACT_CTRL_HIT or ACT_HIT and MG_ACT_BEGIN_DROP. /// </summary> /// <param name="guiMgForm"></param> /// <param name="guiMgCtrl"></param> /// <param name="line"></param> protected virtual void processBeginDrop(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, int line) { MgControlBase mgControl = (MgControlBase)guiMgCtrl; MgFormBase mgForm = (guiMgForm == null) ? mgControl.getForm() : (MgFormBase)guiMgForm; bool isCtrlHit = (mgControl != null) ? true : false; // Drop occurs on a control or a form? if (isCtrlHit) { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_CTRL_HIT, line); if (mgControl.isSubform()) { Manager.EventsManager.addGuiTriggeredEvent(mgControl.GetSubformMgForm().getTask(), InternalInterface.MG_ACT_BEGIN_DROP); } else { Manager.EventsManager.addGuiTriggeredEvent(mgControl, InternalInterface.MG_ACT_BEGIN_DROP, line); } } else { // If Drop occurs on FORM. Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_HIT); Manager.EventsManager.addGuiTriggeredEvent(mgForm.getTask(), InternalInterface.MG_ACT_BEGIN_DROP); } }
/// <summary>Writes the data on the pane with the specified index.</summary> /// <param name="paneIdx">Pane index</param> /// <param name="info">Info to to shown on status bar</param> public void UpdatePaneContent(int paneIdx, string info) { if (_paneObjectsCollection.ContainsKey(paneIdx)) { //get the pane object. MgControlBase paneObj = _paneObjectsCollection[paneIdx]; if (paneObj != null) { switch (paneObj.Type) { case MgControlType.CTRL_TYPE_SB_IMAGE: //Show icon in image pane paneObj.SetAndRefreshDisplayValue(info, info == null, false); break; case MgControlType.CTRL_TYPE_SB_LABEL: //write the message to pane paneObj.setProp(PropInterface.PROP_TYPE_TEXT, info); paneObj.getProp(PropInterface.PROP_TYPE_TEXT).RefreshDisplay(true, 0); break; default: Debug.Assert(false); break; } Commands.beginInvoke(); } } }
/// <summary> /// saves table properties of a line mode form /// </summary> /// <param name = "formNode"></param> /// <param name = "mgForm"></param> private void SaveTableProp(XmlElement formNode, MgFormBase mgForm) { Debug.Assert(_xmlDoc != null); if (mgForm.isLineMode()) { // Add table column node XmlElement tableColumnNode = XmlServices.AddElement(_xmlDoc, formNode, STR_TABLECOLS); MgControlBase tableCtrl = mgForm.getTableCtrl(); List <int[]> columnsState = Commands.getColumnsState(tableCtrl); for (int idx = 0; idx < columnsState.Count; idx++) { // Add column node XmlElement columnNode = XmlServices.AddElement(_xmlDoc, tableColumnNode, STR_COLUMN); // Add layer of column int propLayer = columnsState[idx][0]; XmlServices.setAttribute(columnNode, STR_LAYER, propLayer.ToString()); // Add width of column int propWidth = columnsState[idx][1]; XmlServices.setAttribute(columnNode, STR_WIDTH, propWidth.ToString()); // Add widthForFillTablePlacement of column int propWidthForFillTablePlacement = columnsState[idx][2]; XmlServices.setAttribute(columnNode, STR_WIDTH_FOR_FILL_TABLE_PLACEMENT, propWidthForFillTablePlacement.ToString()); } } }
/// <summary> /// set the focus to the specified control /// </summary> /// <param name = "itask"></param> /// <param name = "ctrl"></param> /// <param name = "line"></param> /// <param name="activateForm">activate a form or not</param> public static void SetFocus(ITask itask, MgControlBase ctrl, int line, bool activateForm) { var task = (TaskBase)itask; if (task.isAborting()) { return; } Events.OnCtrlFocus(itask, ctrl); if (ctrl != null) { if (!ctrl.isParkable(true, false)) { return; } if (ctrl.isTreeControl()) { ctrl.TmpEditorIsShow = false; } Commands.addAsync(CommandType.SET_FOCUS, ctrl, (line >= 0 ? line : ctrl.getDisplayLine(false)), activateForm); } else { Object formObject = (task.IsSubForm ? task.getForm().getSubFormCtrl() : (Object)task.getForm()); Commands.addAsync(CommandType.SET_FOCUS, formObject, 0, activateForm); } }
/// <summary> /// set the last parked control in this task /// </summary> /// <param name = "ctrl">last focused control</param> public virtual void setLastParkedCtrl(MgControlBase ctrl) { _lastParkedCtrl = ctrl; _currParkedFld = (_lastParkedCtrl != null ? _lastParkedCtrl.getField() : null); CurrentEditingControl = ctrl; }
/// <summary> /// unSelect the text in the control /// </summary> /// <param name = "ctrl">the destination control </param> public static void SetUnselect(MgControlBase ctrl) { if (ctrl.isTextOrTreeEdit()) { Commands.addAsync(CommandType.SELECT_TEXT, ctrl, ctrl.getDisplayLine(true), (int)MarkMode.UNMARK_ALL_TEXT, 0, 0); } }
/// <summary> /// mark a specific range of characters within a control /// </summary> /// <param name="ctrl">the control to mark</param> /// <param name="startIdx">start position (0 = first char)</param> /// <param name="len">length of section to mark</param> public static void MarkText(MgControlBase ctrl, int startIdx, int len) { if (ctrl.isTextOrTreeEdit()) { int endPos = startIdx + len; SetSelection(ctrl, startIdx, endPos, endPos); } }
/// <summary> /// mark text in the control /// </summary> /// <param name = "ctrl">the destination control</param> /// <param name="start"></param> /// <param name="end"></param> internal static void SetMark(MgControlBase ctrl, int start, int end) { if (ctrl.isTextOrTreeEdit()) { Commands.addAsync(CommandType.SELECT_TEXT, ctrl, ctrl.getDisplayLine(true), (int)MarkMode.MARK_SELECTION_TEXT, start, end); } }
/// <summary>set a control to a cell in the table</summary> /// <param name = "ctrl">is the control to be added</param> /// <param name = "index">where to set the control</param> public void setControlAt(MgControlBase ctrl, int index) { // ensure that the vector size is sufficient if (_controls.Count <= index) { _controls.SetSize(index + 1); } _controls[index] = ctrl; }
/// <summary> /// Top /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildTopProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { if (AddNavigationProperties(control)) { int value = control.getProp(PropInterface.PROP_TYPE_TOP).CalcTopValue(control); String keyName = (control.Type == MgControlType.CTRL_TYPE_LINE ? Constants.WinPropY1 : Constants.WinPropTop); CreateCoordinateDesignerPropertyInfo(keyName, control, properties, value); } }
/// <summary> /// (Korean IME) Send IME Message /// </summary> /// <param name = "ctrl"> </param> /// <param name="im"></param> /// <returns> </returns> public static int SendImeMessage(MgControlBase ctrl, ImeParam im) { if (ctrl.isTextControl() && im != null) { return(Commands.sendImeMsg(ctrl, ctrl.getDisplayLine(true), im)); } return(0); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildNameProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { String value = CalculatControlName(properties, control); properties.Add(Constants.WinPropName, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = value, IsDefaultValue = false, IsNativeProperty = false }); }
/// <summary> /// Writes tool tip to the specified pane. /// </summary> /// <param name="paneIdx">Pane idx</param> /// <param name="toolTipText">tool tip text</param> public void UpdatePaneToolTip(int paneIdx, string toolTipText) { MgControlBase pane = getPane(paneIdx); if (pane != null) { pane.setProp(PropInterface.PROP_TYPE_TOOLTIP, toolTipText); pane.getProp(PropInterface.PROP_TYPE_TOOLTIP).RefreshDisplay(false); } }
/// <summary>Gets the pane for the specified pane index.</summary> /// <param name="paneIdx">Index of the pane object</param> /// <returns>pane object</returns> public MgControlBase getPane(int paneIdx) { MgControlBase pane = null; if (_paneObjectsCollection.ContainsKey(paneIdx)) { pane = _paneObjectsCollection[paneIdx]; } return(pane); }
/// <summary> /// return the selection on the control /// </summary> /// <param name = "ctrl"> </param> /// <returns> </returns> public static MgPoint SelectionGet(MgControlBase ctrl) { var point = new MgPoint(0, 0); if (ctrl != null && ctrl.isTextOrTreeEdit()) { Commands.selectionGet(ctrl, ctrl.getDisplayLine(true), point); } return(point); }
/// <summary> /// retrieve the location of the caret, within the currently selected text /// </summary> /// <param name = "ctrl">the control which is assumed to contain the selected text </param> public static int CaretPosGet(MgControlBase ctrl) { int caretPos = 0; if (ctrl.isTextOrTreeEdit()) { caretPos = Commands.caretPosGet(ctrl, ctrl.getDisplayLine(true)); } return(caretPos); }
/// <summary>returns true if this table contains the given control</summary> /// <param name = "ctrl">the control to look for</param> internal bool contains(MgControlBase ctrl) { bool contains = false; if (ctrl != null) { contains = _controls.Contains(ctrl); } return(contains); }
static bool AddNavigationProperties(MgControlBase control) { bool isNavigationEnable = true; if (control.IsFrame() || control.isFrameFormControl()) { isNavigationEnable = false; } return(isNavigationEnable); }
/// <summary> /// returns the clicked control on the task /// </summary> public MgControlBase getClickedControl() { MgControlBase clickedCtrl = Manager.GetCurrentRuntimeContext().CurrentClickedCtrl; if (clickedCtrl != null && clickedCtrl.getForm().getTask() != this) { clickedCtrl = null; } return(clickedCtrl); }
/// <summary> /// Font /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildFontProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { bool isDefaultvalue = false; int value = GetRuntimeValueAsInt(control, PropInterface.PROP_TYPE_FONT, ref isDefaultvalue); MgFont mgFont = isDefaultvalue ? null : Manager.GetFontsTable().getFont(value); properties.Add(Constants.WinPropFont, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = mgFont, IsDefaultValue = isDefaultvalue }); }
/// <summary> /// set the last focused control and the task for current window. /// </summary> /// <param name="task"></param> /// <param name="MgControlBase"></param> internal static void setLastFocusedControl(Task task, MgControlBase mgControl) { int currMgdID; currMgdID = task.getMgdID(); Debug.Assert(mgControl == null || task == mgControl.getForm().getTask()); LastFocusMgdID = currMgdID; setLastFocusedControlAt(mgControl, currMgdID); ClientManager.Instance.setLastFocusedTask(task); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildVisibleLayersListProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { MgArrayList value = control.GetTabControlChoiceLayerList(); properties.Add(Constants.WinPropVisibleLayerList, new DesignerPropertyInfo() { VisibleInPropertyGrid = false, Value = value, IsDefaultValue = false, IsNativeProperty = false, }); }
/// <summary> /// Colors /// </summary> /// <param name="control"></param> /// <param name="properties"></param> static void BuildColorsProperties(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties) { bool isDefaultvalue = false; int value = GetRuntimeValueAsInt(control, PropInterface.PROP_TYPE_COLOR, ref isDefaultvalue); if (value > 0) { MgColor color = isDefaultvalue ? null : Manager.GetColorsTable().getBGColor(value); properties.Add(Constants.WinPropBackColor, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = color, IsDefaultValue = isDefaultvalue }); if (control.Type == MgControlType.CTRL_TYPE_TEXT || control.Type == MgControlType.CTRL_TYPE_TABLE) { properties.Add(Constants.WinPropIsTransparent, new DesignerPropertyInfo() { VisibleInPropertyGrid = false, Value = color, IsDefaultValue = isDefaultvalue }); } color = isDefaultvalue ? null : Manager.GetColorsTable().getFGColor(value); properties.Add(Constants.WinPropForeColor, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = color, IsDefaultValue = isDefaultvalue }); } else { // fixed defect #:132036, 132037 // for button control set default color that we set on MgButton.cs , BtnFace\WindowText convert from ControlUtils.cs method MgColor2Color() if (control.Type == MgControlType.CTRL_TYPE_BUTTON) { MgColor colorBG = new MgColor() { IsSystemColor = true, SystemColor = MagicSystemColor.BtnFace }; properties.Add(Constants.WinPropBackColor, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = colorBG, IsDefaultValue = isDefaultvalue }); MgColor colorFG = new MgColor() { IsSystemColor = true, SystemColor = MagicSystemColor.WindowText }; properties.Add(Constants.WinPropForeColor, new DesignerPropertyInfo() { VisibleInPropertyGrid = true, Value = colorFG, IsDefaultValue = isDefaultvalue }); } } }