Ejemplo n.º 1
0
        private void gridViewWaste_BeforeEnterEditMode(object sender, CancelEventArgs e)
        {
            //   Use the BeforeEnterEditMode event to position the edit controls
            UltraGridCell objCell = this.gridViewWaste.ActiveCell;

            //   This should be impossible, but its good practice to check
            //   to make sure there is an active cell before continuing
            if (objCell == null)
            {
                return;
            }
            //   Get the UIElement associated with the active cell, which we will
            //   need so we can get the size and location of the cell
            if (objCell.IsDataCell)
            {
                CellUIElement objCellUIElement = (CellUIElement)objCell.GetUIElement(this.gridViewWaste.ActiveRowScrollRegion, this.gridViewWaste.ActiveColScrollRegion);
                if (objCellUIElement == null)
                {
                    return;
                }
                //   Get the size and location of the cell
                int left   = objCellUIElement.RectInsideBorders.Location.X + this.gridViewWaste.Location.X;
                int top    = objCellUIElement.RectInsideBorders.Location.Y + this.gridViewWaste.Location.Y;
                int width  = objCellUIElement.RectInsideBorders.Width;
                int height = objCellUIElement.RectInsideBorders.Height;
                //   The edit control we will use depends on which column we are editing
                //   The values of the identity fields are not very useful to the end user.
                //   Let's display the name in these columns instead,
                //   using the intrisic ComboBox control
                if (objCell.Column.Key == "FoodTypeID")
                {
                    /*
                     * //   Set the combobox's size and location equal to the active cell's size and location
                     * this.cboFoodName.SetBounds(left, top, width, height);
                     * //   Using the cell's value, select the appropriate item in the combobox
                     * this.cboFoodName.SelectedValue = objCell.Value;
                     * //   Show the combobox control over the cell, and give it focus
                     * cboFoodName.Visible = true;
                     * cboFoodName.Focus();
                     * cboFoodName.BringToFront();
                     *
                     * //   Set the Cancel parameter to true so we don't actually go into edit mode
                     * //e.Cancel = true; */
                }
                else
                if (objCell.Column.Key == "Timestamp")
                {
                    //   Set the date picker's size and location equal to the active cell's size and location
                    this.dtpStamp.SetBounds(left, top, dtpStamp.Width, dtpStamp.Height);
                    //   Set the value
                    DateTime temp = DateTime.Parse(objCell.Value.ToString());
                    this.dtpStamp.Value   = temp;
                    this.dtpStamp.Visible = true;
                    this.dtpStamp.Focus();
                    this.dtpStamp.BringToFront();
                    //   Set the Cancel parameter to true so we don't actually go into edit mode
                    //e.Cancel = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void ultraGrid1_BeforeEnterEditMode(object sender, CancelEventArgs e)
        {
            //   Use the BeforeEnterEditMode event to position the edit controls
            UltraGridCell objCell = this.ultraGrid1.ActiveCell;

            //   This should be impossible, but its good practice to check
            //   to make sure there is an active cell before continuing
            if (objCell == null)
            {
                return;
            }
            //   Get the UIElement associated with the active cell, which we will
            //   need so we can get the size and location of the cell
            if (objCell.IsDataCell)
            {
                CellUIElement objCellUIElement = (CellUIElement)objCell.GetUIElement(this.ultraGrid1.ActiveRowScrollRegion, this.ultraGrid1.ActiveColScrollRegion);
                if (objCellUIElement == null)
                {
                    return;
                }
                //   Get the size and location of the cell
                int left   = objCellUIElement.RectInsideBorders.Location.X + this.ultraGrid1.Location.X;
                int top    = objCellUIElement.RectInsideBorders.Location.Y + this.ultraGrid1.Location.Y;
                int width  = objCellUIElement.RectInsideBorders.Width;
                int height = objCellUIElement.RectInsideBorders.Height;
                //   The edit control we will use depends on which column we are editing
                //   The values of the identity fields are not very useful to the end user.
                //   Let's display the name in these columns instead,
                //   using the intrisic ComboBox control
                if (Regex.IsMatch(objCell.Column.Key, "TypeID"))
                {
                    //   Set the date picker's size and location equal to the active cell's size and location
                    this.ucTreeView1.SetBounds(left, top, ucTreeView1.Width, ucTreeView1.Height);
                    //   Set the value
                    this.ucTreeView1.InitTreeView(VWA4Common.GlobalSettings.CurrentTypeCatalogID.ToString(),
                                                  Regex.Replace(objCell.Column.Key, "TypeID", ""),
                                                  objCell.Value.ToString());
                }
                else if (objCell.Column.Key == "FoodCostDiscount")
                {
                    decimal value = cellValue(objCell.Value.ToString());
                    if (value != 0)
                    {
                        objCell.Value = value * 100m;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void mClickAtGrid(string strMethodName, object objRowNumber, object objColumnName, MOUSE_BUTTON clickButton, int iClickTimes = 1)
        {
            Logger.logBegin(strMethodName);
            PrepareForReplay();
            string strErr = "";

            try
            {
                if ((objRowNumber == null) || (objColumnName == null))
                {
                    this.ReplayReportStep(strMethodName, EventStatus.EVENTSTATUS_FAIL,
                                          new object[] {
                        strErr = string.Format("parameter should not be null. Parameters:Row-[{0}], ColumnName-[{1}]", objRowNumber == null?"null":objRowNumber.ToString(),
                                               objColumnName == null?"null":objColumnName.ToString())
                    }
                                          );
                    this.ReplayThrowError(string.Format(strErr));
                    return;
                }
                int    iNumber   = Int32.Parse(objRowNumber.ToString());
                string strColumn = objColumnName.ToString();

                UltraGrid objGrid = (UltraGrid)SourceControl;
                if (iNumber > objGrid.Rows.Count)
                {
                    strErr = string.Format("Row number [{0}] is larger than the current Grid contains :[{1}]", iNumber, objGrid.Rows.Count);
                    ReportError(strMethodName, strErr);
                    return;
                }
                if (objGrid.Rows.Count == 0)
                {
                    strErr = "Row number is Zero, can't rightClick on Content. ";
                    ReportError(strMethodName, strErr);
                    return;
                }
                UltraGridRow       objRow       = objGrid.Rows[iNumber];
                Mars_RowColumnInfo objRowInfo   = new Mars_RowColumnInfo(objRowNumber),
                                   objColunInfo = new Mars_RowColumnInfo(objColumnName);
                UltraGridCell objCell           = this.mFindCellByRowAndColumnInfo(objRow, objColunInfo);
                if (objCell == null)
                {
                    strErr = string.Format("No such Column can be found on the table:[{0}]", strColumn);
                    ReportError(strMethodName, strErr);
                    return;
                }
                UIElement objUIElement = objCell.GetUIElement();
                Thread.Sleep(200);
                if (objUIElement == null)
                {
                    strErr = string.Format("Can't get UIElement: Cell is invisible,no such cell or exceptions? \r\n\tRow:[{0}]\r\n\tColumn:[{1}]", iNumber, strColumn);
                    ReportError(strMethodName, strErr);
                    return;
                }
                Rectangle rect = objUIElement.Rect;
                Point     pt   = rect.Location;
                if (iClickTimes != 1)
                {
                    base.MouseDblClick(pt.X + rect.Width / 2, pt.Y + rect.Height / 2, clickButton);
                }
                else
                {
                    base.MouseClick(pt.X + rect.Width / 2, pt.Y + rect.Height / 2, clickButton);
                }

                this.ReplayReportStep(strMethodName, EventStatus.EVENTSTATUS_GENERAL, new object[] { "Passed" });
            }
            catch (Exception e)
            {
                strErr = string.Format("Can't continue to RightClick, Exceptions :[{0}]", e.Message);
                Logger.Error(strMethodName, strErr, e);
                this.ReplayReportStep("RightClick", EventStatus.EVENTSTATUS_FAIL,
                                      new Object[] { strErr });
                this.ReplayThrowError(string.Format(strErr));
            }
        }
Ejemplo n.º 4
0
        /**  **/
        public void MarsTigerActiveCell(params object[] arrRC)
        {
            Logger.logBegin("MarsTigerActiveCell");
            if (arrRC.Length != 2)
            {
                Logger.Error("MarsTigerActiveCell", "Only two parameters are accepted. ");
                return;
            }
            PrepareForReplay();

            object    oRow = arrRC[0], oColumn = arrRC[1];
            UltraGrid objGrid  = (UltraGrid)SourceControl;
            string    strError = "";

            Mars_RowColumnInfo oRowInfo = new Mars_RowColumnInfo(oRow),
                               oColInfo = new Mars_RowColumnInfo(oColumn);

            try
            {
                if ((objGrid.Rows == null ? -1 : objGrid.Rows.Count) <= 0)
                {
                    base.ReplayReportStep("MarsTigerActiveCell", EventStatus.EVENTSTATUS_FAIL, new object[] { oRow, oColumn, "RowCount is 0" });
                    return;
                }

                if (oRowInfo.CurrentDataType == E_RowColumnType.eType_String)
                {
                    // the first column of the row with fixed caption, which should be implement later
                    throw new NotImplementedException();
                }
                /** find cells **/
                UltraGridRow objRow = mFindRowByRowNumber(oRowInfo.convertData2Int(), objGrid);
                if (objRow == null)
                {
                    strError = string.Format("no such row number [{0}] is availble, row number stars 0", objRow);
                    base.ReplayReportStep("MarsTigerActiveCell", EventStatus.EVENTSTATUS_FAIL, new object[] { oRow, oColumn, strError });
                    return;
                }
                /** find cells by oColumn, int or header **/
                UltraGridCell objCell = mFindCellByRowAndColumnInfo(objRow, oColInfo);
                if (objCell == null)
                {
                    strError = string.Format("Can't find sepecial cell. \r\n\tRow:[{0}]\r\n\tColumn:[{1}]", oRow, oColumn);
                    base.ReplayReportStep("MarsTigerActiveCell", EventStatus.EVENTSTATUS_FAIL, new object[] { oRow, oColumn, strError });
                    return;
                }
                /** 获得 cell的rectangle, 然后调用mouse事件 **/
                UIElement objUIElement = objCell.GetUIElement();
                Thread.Sleep(200);
                if (objUIElement == null)
                {
                    strError = string.Format("Can't get UIElement: Cell is invisible,no such cell or exceptions? \r\n\tRow:[{0}]\r\n\tColumn:[{1}]", oRow, oColumn);
                    base.ReplayReportStep("MarsTigerActiveCell", EventStatus.EVENTSTATUS_FAIL, new object[] { oRow, oColumn, strError });
                    return;
                }
                Rectangle rect = objUIElement.Rect;
                Point     pt   = rect.Location;
                base.MouseClick(pt.X + rect.Width / 2, pt.Y + rect.Height / 2, MOUSE_BUTTON.LEFT_MOUSE_BUTTON);

                //LeftMouseClick(pt.X, pt.Y);
            }
            finally
            {
                Logger.logEnd("MarsTigerActiveCell");
            }
        }