/// <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> /// 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> /// 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> /// 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 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> /// (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> /// 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> /// 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> /// If current control becomes invisible/disabled/non parkable, then put MG_ACT_TBL_NXTFLD into queue. /// </summary> /// <param name="ctrl">control whose property is changed.</param> internal void OnNonParkableLastParkedCtrl(GuiMgControl ctrl) { MgControlBase mgControl = (MgControlBase)ctrl; //If task is already in exiting edit state, do not add MG_ACT_TBL_NXTFLD. (Defect 67647) if (ClientManager.Instance.EventsManager.getForceExit() != ForceExit.Editing) { RunTimeEvent rtEvt = new RunTimeEvent((MgControl)mgControl, mgControl.getDisplayLine(false), false); rtEvt.setInternal(InternalInterface.MG_ACT_TBL_NXTFLD); ClientManager.Instance.EventsManager.addToTail(rtEvt); } }
/// <summary> /// write the clipData string to the clipboard /// if ctrl was passed, use it : copy will be done from selected area on the control to the clip. /// if a String was passed, set it to the clipboard. /// </summary> /// <param name = "ctrl"> </param> /// <param name = "clipData"> </param> public static void ClipboardWrite(MgControlBase ctrl, String clipData) { // both null, do nothing. if (ctrl == null && string.IsNullOrEmpty(clipData)) { return; } // set currRow in any case. int currRow = (ctrl == null ? 0 : ctrl.getDisplayLine(true)); Commands.clipboardWrite(ctrl, currRow, clipData); _clipboardData = ""; }
/// <summary> /// Set read only for controls /// </summary> /// <param name = "ctrl">the control to change its property </param> /// <param name = "isReadOnly">boolean </param> internal static void SetReadOnlyControl(MgControlBase ctrl, bool isReadOnly) { if (ctrl.isTextOrTreeControl() || ctrl.isRichEditControl() || ctrl.isRichText() || ctrl.IsRepeatable) // Defect 131802: Set ReadOnly for Rich Text control in Table Header and defect 131704: in general for Rich Text. { // JPN: IME support (enable IME in query mode) if (UtilStrByteMode.isLocaleDefLangDBCS() && !ctrl.isTreeControl() && !ctrl.isMultiline()) { if (ctrl.getForm().getTask().checkProp(PropInterface.PROP_TYPE_ALLOW_LOCATE_IN_QUERY, false)) { return; } } Commands.addAsync(CommandType.PROP_SET_READ_ONLY, ctrl, ctrl.getDisplayLine(false), isReadOnly); Commands.beginInvoke(); } }
/// <summary> /// update the display /// </summary> public void updateDisplay(String displayValue, bool isNull, bool calledFromEditSet) { MgControlBase ctrl; MgControlBase ctrlValue = null; String defaultValue = "" + GuiConstants.DEFAULT_VALUE_INT; String savedValue = null; String savePrevValue = null; bool savedIsNull = false; bool savePrevIsNull = false; if (_controls != null) { MgControlBase firstControlValue = null; bool foundControlValue = false; MgControlBase savedControlToFocus = ControlToFocus; for (int i = 0; i < _controls.getSize(); i++) { ctrl = _controls.getCtrl(i); if (calledFromEditSet) { savedValue = ctrl.Value; savePrevValue = ctrl.getPrevValueInArray(ctrl.getDisplayLine(true)); savedIsNull = ctrl.IsNull; savePrevIsNull = ctrl.getPrevIsNullsInArray(); } if (!ctrl.getForm().inRefreshDisplay()) { ctrl.resetPrevVal(); // force update of the display ctrl.SetAndRefreshDisplayValue(displayValue, isNull, false); // Even if the control that contains the correct value is found we don't break the loop because: // (1) we need to refresh all the controls // (2) the last control that was focus with the correct value is the one that should be checked if (!ctrl.isRadio()) { if (ctrlValue == null || ctrl.Value != null && !ctrl.Value.Equals(defaultValue) && (ctrl == savedControlToFocus)) { ctrlValue = ctrl; } } else { //Fixed bug#:780359, for radio control select the correct control //if not found any ctrlvalue(the control that was in focuse) //select the first control with the correct value if not exist select the first control. //a. save the first control (with or without the correct value) if (firstControlValue == null) { firstControlValue = ctrl; } if (ctrl.Value != null && !ctrl.Value.Equals(defaultValue)) { //b. save the first control with the correct value if (!foundControlValue) { firstControlValue = ctrl; foundControlValue = true; } //c.save the control that belong to the focus control if (ctrl == savedControlToFocus) { ctrlValue = ctrl; } else if (ctrlValue == null) { ctrlValue = firstControlValue; } } } } if (calledFromEditSet) { ctrl.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull); } } // if there was a control that had the correct value and this field is linked to more than one // control then it means that the control that contained the correct value might have been reset by // one of its siblings so there is a need to refresh its value again. if (ctrlValue != null) { if (calledFromEditSet) { savedValue = ctrlValue.Value; savePrevValue = ctrlValue.getPrevValueInArray(ctrlValue.getDisplayLine(true)); savedIsNull = ctrlValue.IsNull; savePrevIsNull = ctrlValue.getPrevIsNullsInArray(); } //save the control that belong to the value on the field. ControlToFocus = ctrlValue; if (_controls.getSize() > 1) { ctrlValue.resetPrevVal(); // force update of the display ctrlValue.SetAndRefreshDisplayValue(displayValue, isNull, false); } if (calledFromEditSet) { ctrlValue.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull); ctrlValue.getForm().getTask().setLastParkedCtrl(ctrlValue); Manager.SetFocus(ctrlValue, -1); } //Fixed bug#:465616, when the control is the current focus control then refresh his focus control if (ctrlValue.isRadio() && ctrlValue == ctrlValue.getForm().getTask().getLastParkedCtrl()) { Manager.SetFocus(ctrlValue, -1); } } } }
/// <summary> /// returns the current value of the control /// </summary> /// <param name = "ctrl">control to get value </param> /// <returns> value of the control </returns> public static String GetCtrlVal(MgControlBase ctrl) { // QCR #745117: Make sure that if the contents of a control were changed // then the changes are applied before examining its value. return(Commands.getValue(ctrl, ctrl.getDisplayLine(true))); }
/// <summary> /// close the task, if the wide is open, then close is before close the task /// </summary> /// <param name = "form"> </param> /// <param name="mainPrgTask"></param> public static void Abort(MgFormBase form, TaskBase mainPrgTask) { ApplicationMenus menus = MenuManager.getApplicationMenus(mainPrgTask); MgFormBase topMostForm = form.getTopMostForm(); if (topMostForm.wideIsOpen()) { topMostForm.closeWide(); } // Context menu will not automatically dispose when form is dispose. we need to dispose it menually. if (menus != null) { menus.disposeFormContexts(form); } // remove the instantiatedToolbar as this is not removed from Dispose handler. MgMenu mgMenu = form.getPulldownMenu(); if (mgMenu != null) { mgMenu.removeInstantiatedToolbar(form); } if (form.getSubFormCtrl() == null) { // if the closing form is 'opened as a modal' then decrement the modal count on its frame window. if (form.isDialog()) { MgFormBase topMostFrameForm = form.getTopMostFrameForm(); if (topMostFrameForm != null) { topMostFrameForm.UpdateModalFormsCount(form, false); } } #if !PocketPC // If the form was added into WindowMenu then remove it from list before closing it. if (form.IsValidWindowTypeForWidowList) { Property prop = form.GetComputedProperty(PropInterface.PROP_TYPE_SHOW_IN_WINDOW_MENU); if (prop != null && prop.GetComputedValueBoolean()) { MenuManager.WindowList.Remove(form); } } #endif Commands.addAsync(CommandType.CLOSE_FORM, form); // QCR# 307199/302197: When a task closes, its form is closed, where it activates topmost form of // ParentForm. If Print Preview is activated, this is not required. Instead Print Preview form // should be activated. if (!PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused) { /* QCR #939802. This bug is since 1.9 after the check-in of version 41 of GuiCommandsQueue.cs */ /* From that version onwards, we started to set the owner of the Floating window. */ /* Now, when we close a form, the .Net Framework activates the form which spawned this form. */ /* But in this special case of the QCR, while closing the 3rd form, framework activated the */ /* 1st form instead of the 2nd. */ /* So, when pressing Esc, the 1st form got closed (and of course, because of this all forms got */ /* closed. */ /* The solution is to explicitly activate the parent form when a form is closed. */ // If interactive offline task calls, non interactive non offline task, after closing the parent task // focus is not switched back to caller task, but it is set on MDI Frame. To avoid this, activate parent // form only if called task's form is opened. MgFormBase formToBeActivated = form.ParentForm; if (form.FormToBoActivatedOnClosingCurrentForm != null) { formToBeActivated = form.FormToBoActivatedOnClosingCurrentForm; } if (formToBeActivated != null && form.getTask() != null && !form.getTask().IsParallel && //not for parallel !MgFormBase.isMDIChild(form.ConcreteWindowType) && //not for mdi children Defect 128265 form.Opened) { Commands.addAsync(CommandType.ACTIVATE_FORM, formToBeActivated.getTopMostForm()); if (form.ConcreteWindowType == WindowType.ChildWindow) { TaskBase task = formToBeActivated.getTask(); MgControlBase mgControl = task.getLastParkedCtrl(); if (mgControl != null) { Commands.addAsync(CommandType.SET_FOCUS, mgControl, mgControl.getDisplayLine(false), true); } } } } } else { // Defect 115062. For frames remove controls also from frame control. if (form.getContainerCtrl() != null) { Commands.addAsync(CommandType.REMOVE_SUBFORM_CONTROLS, form.getContainerCtrl()); } Commands.addAsync(CommandType.REMOVE_SUBFORM_CONTROLS, form.getSubFormCtrl()); } Commands.beginInvoke(); Thread.Sleep(10); }
/// <summary> /// Insert text to a text control at a given position /// </summary> /// <param name="ctrl"></param> /// <param name="startPosition"></param> /// <param name="textToInsert"></param> public static void InsertEditText(MgControlBase ctrl, int startPosition, String textToInsert) { Commands.insertEditText(ctrl, ctrl.getDisplayLine(true), startPosition, textToInsert); }
/// <summary> /// Used to put the text on a text control /// </summary> /// <param name = "ctrl"> </param> /// <param name = "text"> </param> public static void SetEditText(MgControlBase ctrl, String text) { Commands.setEditText(ctrl, ctrl.getDisplayLine(true), text); }