Example #1
0
        public static double ScrollBehavior(
            Rect bgRect,
            double contentSize,
            double viewSize,
            double viewPosition,
            int id, bool horizontal,
            out Rect gripRect,
            out bool hovered, out bool held)
        {
            GUIContext g = Form.current.uiContext;

            //grip size
            var trackSize    = horizontal ? bgRect.Width : bgRect.Height;
            var contentRatio = viewSize / contentSize;
            var gripSize     = trackSize * contentRatio;

            const double minGripSize = 20.0;

            if (gripSize < minGripSize)
            {
                gripSize = minGripSize;
            }

            if (gripSize > trackSize)
            {
                gripSize = trackSize;
            }

            //grip position
            var viewScrollAreaSize  = contentSize - viewSize;
            var viewPositionRatio   = viewPosition / viewScrollAreaSize;
            var trackScrollAreaSize = trackSize - gripSize;
            var gripPositionOnTrack = trackScrollAreaSize * viewPositionRatio;

            hovered = false;
            held    = false;

            hovered = g.IsMouseHoveringRect(bgRect);
            g.KeepAliveID(id);
            if (hovered)
            {
                g.SetHoverID(id);

                if (Mouse.Instance.LeftButtonPressed) //start track
                {
                    g.SetActiveID(id);
                }
            }
            if (g.ActiveId == id)
            {
                if (Mouse.Instance.LeftButtonState == KeyState.Down)
                {
                    var v = Mouse.Instance.MouseDelta;
                    var mousePositionDelta = horizontal ? v.X : v.Y;
                    var newGripPosition    = gripPositionOnTrack + mousePositionDelta;
                    newGripPosition = Math.Clamp(newGripPosition, 0, trackScrollAreaSize);
                    var newGripPositonRatio = newGripPosition / trackScrollAreaSize;
                    viewPosition = newGripPositonRatio * viewScrollAreaSize;
                }
                else //end track
                {
                    g.SetActiveID(0);
                }
            }

            if (g.ActiveId == id)
            {
                held = true;
            }

            if (horizontal)
            {
                gripRect = new Rect(bgRect.X + gripPositionOnTrack, bgRect.Y, gripSize, bgRect.Height);
            }
            else
            {
                gripRect = new Rect(bgRect.X, bgRect.Y + gripPositionOnTrack, bgRect.Width, gripSize);
            }

            return(viewPosition);
        }
        protected void cpnCustomFieldEditingForm_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args       = e.Parameter.Split('|');
            string   command    = args[0];
            bool     isSuccess  = false;
            string   transition = null;

            try
            {
                switch (command)
                {
                case "Create":
                    ClearForm();
                    CustomFieldId    = Guid.NewGuid();
                    GUIContext.State = new CustomFieldCreating(this);
                    transition       = command;
                    isSuccess        = true;
                    break;

                case "Edit":
                    if (args.Length > 1)
                    {
                        CustomFieldId = Guid.Parse(args[1]);
                        //Check is system type
                        NAS.DAL.CMS.ObjectDocument.CustomField customField =
                            session.GetObjectByKey <NAS.DAL.CMS.ObjectDocument.CustomField>(CustomFieldId);
                        if (customField.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_READONLY) ||
                            customField.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER_READONLY))
                        {
                            throw new Exception("Không thể chỉnh sửa trường dữ liệu được tạo ra bởi hệ thống");
                        }
                    }
                    else
                    {
                        throw new Exception("CustomFieldId cannot be null");
                    }
                    ClearForm();
                    GUIContext.State = new CustomFieldEditing(this);
                    GUIContext.Request(GetCustomFieldEditingTransition(GetSelectedCustomFieldType().Code), this);
                    transition = command;
                    isSuccess  = true;
                    break;

                case "TabChanged":
                    string editingTransition = null;
                    if (pagCustomFieldEditingForm.ActiveTabIndex == 0)
                    {
                        string customFieldEditingTransition = null;
                        editingTransition = "EDIT_FIELD";
                        //Transit to CustomFieldDataEditing state by transition 'EDIT_FIELD'
                        GUIContext.Request(editingTransition, this);
                        //Then transit to concrete CustomFieldCreating
                        customFieldEditingTransition = GetCustomFieldEditingTransition(GetSelectedCustomFieldType().Code);
                        GUIContext.Request(customFieldEditingTransition, this);
                    }
                    else if (pagCustomFieldEditingForm.ActiveTabIndex == 1)
                    {
                        editingTransition = "EDIT_DATA";
                        GUIContext.Request(editingTransition, this);
                        GUIContext.Request(GetCustomFieldDataEditingTransition(GetSelectedCustomFieldType().Code), this);
                    }
                    transition = editingTransition;
                    txtCustomFieldName.IsValid = true;
                    isSuccess = true;
                    break;

                case "DataTypeChanged":
                    string customFieldTransition = null;
                    customFieldTransition = GetCustomFieldCreatingTransition(GetSelectedCustomFieldType().Code);
                    GUIContext.Request(customFieldTransition, this);
                    transition = customFieldTransition;
                    txtCustomFieldName.IsValid = true;
                    isSuccess = true;
                    break;

                case "Next":
                    string customFieldDataCreatingTransition = null;
                    //Transit to CustomFieldDataCreating state by transition 'NEXT'
                    if (GUIContext.Request(command, this))
                    {
                        //Then transit to concrete CustomFieldDataCreating
                        customFieldDataCreatingTransition = GetCustomFieldDataCreatingTransition(GetSelectedCustomFieldType().Code);
                        GUIContext.Request(customFieldDataCreatingTransition, this);
                    }
                    isSuccess  = true;
                    transition = command;
                    break;

                default:
                    GUIContext.Request(command, this);
                    transition = command;
                    isSuccess  = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (transition != null)
                {
                    cpnCustomFieldEditingForm.JSProperties.Add("cpCallbackArgs",
                                                               String.Format("{{ \"transition\": \"{0}\", \"success\": {1} }}",
                                                                             transition, isSuccess.ToString().ToLower()));
                }
            }
        }
        protected void cpnCodeRuleDefinitionEditingForm_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string transition = null;
            bool   isSuccess  = false;

            try
            {
                string[] args = e.Parameter.Split('|');
                transition = args[0];

                if (transition.Equals("Edit"))
                {
                    if (args.Length > 1)
                    {
                        CodeRuleDefinitionId       = Guid.Parse(args[1]);
                        ParentCodeRuleDefinitionId = Guid.Empty;
                    }
                    else
                    {
                        throw new Exception();
                    }

                    GUIContext.State =
                        new ERPSystem.ArtifactCode.State.CodeRuleDefinitionForm.CodeRuleDefinitionEditing(this);
                    CodeRuleData codeRuleData =
                        codeRuleDataBO.GetCodeRuleData(session, CodeRuleDefinitionId);

                    CodeRuleDataId = codeRuleData.CodeRuleDataId;

                    transition =
                        GetTransitionByDataTypeCode(codeRuleData.CodeRuleDefinitionId.CodeRuleDataTypeId.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else if (transition.Equals("Create"))
                {
                    if (args.Length > 1)
                    {
                        CodeRuleDefinitionId = Guid.Empty;
                        Guid temp;
                        if (!Guid.TryParse(args[1], out temp))
                        {
                            temp = Guid.Empty;
                        }
                        ParentCodeRuleDefinitionId = temp;
                    }
                    else
                    {
                        throw new Exception();
                    }

                    GUIContext.State =
                        new ERPSystem.ArtifactCode.State.CodeRuleDefinitionForm.CodeRuleDefinitionCreating(this);

                    cbCodeRuleDataType.SelectedIndex = 0;
                    Guid             selectedCodeRuleDataTypeId = Guid.Parse(cbCodeRuleDataType.SelectedItem.Value.ToString());
                    CodeRuleDataType codeRuleDataType           =
                        session.GetObjectByKey <CodeRuleDataType>(selectedCodeRuleDataTypeId);
                    transition =
                        GetTransitionByDataTypeCode(codeRuleDataType.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else if (transition.Equals("ChangeDataType"))
                {
                    Guid             selectedCodeRuleDataTypeId = Guid.Parse(cbCodeRuleDataType.SelectedItem.Value.ToString());
                    CodeRuleDataType codeRuleDataType           =
                        session.GetObjectByKey <CodeRuleDataType>(selectedCodeRuleDataTypeId);
                    transition =
                        GetTransitionByDataTypeCode(codeRuleDataType.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else
                {
                    //Request change state
                    GUIContext.Request(transition, this);
                }

                isSuccess = true;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (transition != null)
                {
                    cpnCodeRuleDefinitionEditingForm.JSProperties.Add("cpCallbackArgs",
                                                                      String.Format("{{ \"transition\": \"{0}\", \"success\": {1} }}",
                                                                                    transition, isSuccess.ToString().ToLower()));
                }
            }
        }
        protected void panelInvoiceEditingForm_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[]          args              = e.Parameter.Split('|');
            string            command           = args[0];
            PurchaseInvoiceBO purchaseInvoiceBO = new PurchaseInvoiceBO();
            Bill bill = null;

            switch (command)
            {
            case "Create":
                GUIContext.State = new PurchaseInvoiceCreating(this);

                billDetails.InitState();
                break;

            case "Edit":
                if (args.Length < 2)
                {
                    throw new Exception("Invalid parameters");
                }
                BillId = Guid.Parse(args[1]);
                //Determine bill status
                hfBillId["BillId"] = BillId.ToString();
                bill = purchaseInvoiceBO.GetBillById(session, BillId);
                if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                {
                    GUIContext.State = new PurchaseInvoiceLocked(this);
                }
                else
                {
                    GUIContext.State = new PurchaseInvoiceEditing(this);
                }

                billDetails.InitState();
                break;

            case "Save":
                GUIContext.Request(command, this);

                bill = purchaseInvoiceBO.GetBillById(session, BillId);
                if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                {
                    GUIContext.State = new PurchaseInvoiceLocked(this);
                }
                break;

            case "Cancel":
                GUIContext.Request(command, this);
                panelInvoiceEditingForm.JSProperties["cpEvent"] = "Closing";
                break;

            case "Refresh":
                bill = purchaseInvoiceBO.GetBillById(session, BillId);
                if (bill.RowStatus.Equals(Utility.Constant.ROWSTATUS_BOOKED_ENTRY))
                {
                    GUIContext.State = new PurchaseInvoiceLocked(this);
                }
                else
                {
                    GUIContext.State = new PurchaseInvoiceEditing(this);
                }
                break;

            default:
                break;
            }

            uEdittingInputInventoryCommand1.SettingInit <NAS.DAL.Invoice.PurchaseInvoice>(BillId, ButtonCreateInventoryCommand);
        }
        protected void cpnReceiptVoucherEditingForm_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args      = e.Parameter.Split('|');
            string   command   = args[0];
            bool     isSuccess = false;
            ReceiptVoucherTransactionBO receiptVoucherTransactionBO;

            try
            {
                switch (command)
                {
                case "Create":
                    VoucherId = Guid.Empty;
                    //If create voucher from bill
                    if (args.Length > 1)
                    {
                        BillId = Guid.Parse(args[1]);
                    }
                    GUIContext.State         = new ReceiptVoucherCreating(this);
                    hiddenField["voucherId"] = VoucherId;
                    number = null;
                    break;

                case "Edit":
                    if (args.Length < 2)
                    {
                        throw new Exception("Invalid parameters");
                    }
                    VoucherId = Guid.Parse(args[1]);
                    hiddenField["voucherId"]    = VoucherId;
                    receiptVoucherTransactionBO = new ReceiptVoucherTransactionBO();
                    if (receiptVoucherTransactionBO.IsVoucherLockedBookingEntry(VoucherId))
                    {
                        GUIContext.State = new ReceiptVoucherLocked(this);
                    }
                    else
                    {
                        GUIContext.State = new ReceiptVoucherEditing(this);
                        UpdateBookingEntryState();
                    }
                    number = null;
                    break;

                case "ForceRefresh":
                    if (GUIContext.State is ReceiptVoucherCreating)
                    {
                        ClearFormValidation();
                        ReceiptVoucherCreating_UpdateGUI();
                        UpdateGUIByCurrency(gridlookupCurrency.GetSelectedCurrency(session));
                    }
                    else
                    {
                        receiptVoucherTransactionBO = new ReceiptVoucherTransactionBO();
                        if (receiptVoucherTransactionBO.IsVoucherLockedBookingEntry(VoucherId))
                        {
                            GUIContext.State = new ReceiptVoucherLocked(this);
                        }
                        else
                        {
                            UpdateBookingEntryState();
                        }
                    }
                    break;

                case "Cancel":
                    GUIContext.Request(command, this);
                    number = null;
                    break;

                default:
                    GUIContext.Request(command, this);
                    UpdateBookingEntryState();
                    number = null;
                    break;
                }
                isSuccess = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (command != null)
                {
                    cpnReceiptVoucherEditingForm.JSProperties.Add("cpCallbackArgs",
                                                                  String.Format("{{ \"transition\": \"{0}\", \"success\": {1} }}",
                                                                                command, isSuccess.ToString().ToLower()));
                }
            }
        }
Example #6
0
 /// <summary>
 /// Updates the state of the control as a root control.
 /// </summary>
 public void Update(GUIContext Context, double Time)
 {
     this.Update(Context.CreateRootControlContext(this, new Point(0.0, 0.0)), Time);
 }
Example #7
0
 public GUIContextRenderTargetEventArgs(GUIContext context, IRenderTarget target)
     : base(context)
 {
     renderTarget = target;
 }
Example #8
0
 protected void grdPricePolicy_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
 {
     GUIContext.Request(e.ButtonID, this);
 }
Example #9
0
        public static void ShowWindow(ref bool windowOpened)
        {
            if (!GUI.Begin(WindowName, ref windowOpened))
            {
                GUI.End();
                return;
            }

            // Basic info
            GUIContext g = GetCurrentContext();

            Text("Hello ImGui {0}##Metrics.Version", GetVersion());
            Text("Application average {0:F3} ms/frame ({1:F1} FPS)##Metrics.FPS", 1000.0f / g.fps, g.fps);
            Text("{0} vertices, {1} indices ({2} triangles)##Metrics.VI",
                 VertexNumber, IndexNumber, IndexNumber / 3);
            Text("{0} active windows ({0} visible)##Metrics.Window", ActiveWindows, RenderWindows);
            Separator("separator0");

            //Windows
            var windowManager = g.WindowManager;

            NodeWindows(windowManager.Windows.ToArray(), "Windows");

            //Internal state
            if (TreeNode("Internal state"))
            {
                var w = g.WindowManager;
                Text("HoveredWindow: '{0}'",
                     w.HoveredWindow != null ? w.HoveredWindow.Name : "null");
                Text("HoveredRootWindow: '{0}'",
                     w.HoveredRootWindow != null ? w.HoveredRootWindow.Name : "null");
                // Data is "in-flight" so depending on when the Metrics window is called we may see
                // current frame information or not
                Text("HoveredId: {0:X8}/{1:X8}, AllowOverlap: {2}",
                     g.HoverId, g.HoveredIdPreviousFrame, g.HoverIdAllowOverlap);
                Text("ActiveId: {0:X8}/{1:X8}, AllowOverlap: {2}",
                     g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdAllowOverlap);
                Text("ActiveIdWindow: '{0}'",
                     w.ActiveIdWindow != null ? w.ActiveIdWindow.Name : "null");
                Text("MovingWindow: '{0}'", w.MovingWindow != null ? w.MovingWindow.Name : "null");
                TreePop();
            }

            if (TreeNode("Tools"))
            {
                // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
                if (Button("Item Picker.."))
                {
                    lastPickedItemId = 0;
                    g.DebugStartItemPicker();
                }

                if (g.DebugItemPickerBreakID != 0)
                {
                    lastPickedItemId = g.DebugItemPickerBreakID;
                }

                if (lastPickedItemId != 0)
                {
                    //get picked node
                    Node pickedNode = null;
                    var  w          = g.WindowManager.Windows;
                    foreach (var window in w)
                    {
                        var node = window.RenderTree.GetNodeById(lastPickedItemId);
                        if (node != null)
                        {
                            pickedNode = node;
                            break;
                        }
                    }

                    DoBoxModel(pickedNode);
                }
                else if (g.HoveredIdPreviousFrame != 0)
                {
                    //get picking node
                    Node pickingNode = null;
                    var  w           = g.WindowManager.Windows;
                    foreach (var window in w)
                    {
                        var node = window.RenderTree.GetNodeById(g.HoveredIdPreviousFrame);
                        if (node != null)
                        {
                            pickingNode = node;
                            break;
                        }
                    }
                    DoBoxModel(pickingNode);
                }

                TreePop();
            }

            GUI.End();
        }
 public GUIContextEventArgs(GUIContext context)
 {
     this.context = context;
 }