예제 #1
0
 public CellProperty getActiveCell(String tableName, GroupProperty group, int row, int col, String sheetName)
 {
     try
     {
         var request = new RestRequest(ResourcePath + "/cell/active/" + tableName + "/" + row + "/" + col + "/" + sheetName, Method.POST);
         System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
         serializer.MaxJsonLength = int.MaxValue;
         string json = serializer.Serialize(group);
         request.AddParameter("application/json", json, ParameterType.RequestBody);
         var response = RestClient.ExecuteTaskAsync(request);
         try
         {
             CellProperty result = RestSharp.SimpleJson.DeserializeObject <CellProperty>(response.Result.Content);
             return(result);
         }
         catch (Exception)
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         throw new BcephalException("Unable to close table : " + tableName, e);
     }
 }
        private void DisplayLoopCondition(Kernel.Domain.LoopCondition loopCondition, bool readOnly = false)
        {
            trow = false;
            this.CommentTextBlock.Text             = loopCondition.comment;
            this.OperatorComboBox.SelectedItem     = loopCondition.operatorType;
            this.OpenBracketComboBox.SelectedItem  = loopCondition.openBracket;
            this.CloseBracketComboBox.SelectedItem = loopCondition.closeBracket;
            this.Index = loopCondition.position + 1;

            if (readOnly)
            {
                SetMainPanelReadOnly(readOnly);
            }
            CellProperty cell = loopCondition.cellProperty;

            if (cell == null)
            {
                cell = new CellProperty();
            }
            this.LoopCalutedValue.ChangeEventHandler += onChange;
            this.LoopCalutedValue.periodPanel.DisplayPeriod(cell.period, false, readOnly);
            this.LoopCalutedValue.filterScopePanel.DisplayScope(cell.cellScope, false, readOnly);
            this.LoopCalutedValue.CellMeasurePanel.Display(cell.cellMeasure, readOnly);
            if (!string.IsNullOrEmpty(loopCondition.conditions))
            {
                this.LoopCalutedValue.DisplayInstructions(loopCondition.instructions, readOnly);
            }

            trow = true;
        }
예제 #3
0
        //private CellProperty GetCellProperty(int row, int col, bool update)
        //{
        //    DateTime time = DateTime.Now;

        //    CellProperty CellProperty = table.GetCellProperty(row, col, sheetName);
        //    object value = page.getInputTableForm().SpreadSheet.getValueAt(row, col, sheetName);

        //    if (CellProperty != null)
        //    {
        //        if (update) table.UpdateCellProperty(CellProperty);
        //    }
        //    else
        //    {
        //        CellProperty = new CellProperty(row.ToString(), Kernel.Util.RangeUtil.GetColumnName(col));
        //        CellProperty.nameSheet = sheetName;
        //        table.AddCellProperty(CellProperty);
        //    }
        //    CellProperty.SetDecimalMeasure(value);

        //    var duration = (DateTime.Now - time).TotalSeconds;
        //    getCellDuration += duration;
        //    Console.Out.WriteLine("Get Cell " + CellProperty.name + " : " + duration + " secondes");

        //    return CellProperty;
        //}

        /// <summary>
        /// Vérifie le type d'un objet et l'ajoute à la propriété correspondante
        /// dans le Cellproperty.
        /// </summary>
        /// <param name="cellProperty"></param>
        /// <param name="item"></param>
        private void RefreshCellProperty(CellProperty cellProperty, ObservableCollection <LineItem> lineItems)
        {
            foreach (LineItem lineItem in lineItems)
            {
                RefreshCellProperty(cellProperty, lineItem);
            }
        }
예제 #4
0
        private void slidePair()
        {
            doingRoll = true;
            if (lastMoveDir > 0)
            {
                selectedGrids[0].assignedCell.currentGrid = selectedGrids[1];   //Cell[A]   ->   Grid[2]
                CellProperty temp = selectedGrids[1].assignedCell;              //var temp  =    Cell[B]
                selectedGrids[1].assignedCell = selectedGrids[0].assignedCell;  //Grid[2]   ->   Cell[A]

                temp.currentGrid = selectedGrids[2];                            //temp      ->   Grid[3]
                CellProperty tempTwo = selectedGrids[2].assignedCell;           //var temp2 =    Cell[C]
                selectedGrids[2].assignedCell = temp;                           //Grid[3]   ->   temp

                tempTwo.currentGrid           = selectedGrids[0];
                selectedGrids[0].assignedCell = tempTwo;
            }
            else if (lastMoveDir < 0)
            {
                Debug.Log("going counterclockwise");

                selectedGrids[0].assignedCell.currentGrid = selectedGrids[2];   //Cell[A]   ->   Grid[2]
                CellProperty temp = selectedGrids[2].assignedCell;              //var temp  =    Cell[B]
                selectedGrids[2].assignedCell = selectedGrids[0].assignedCell;  //Grid[2]   ->   Cell[A]

                temp.currentGrid = selectedGrids[1];                            //temp      ->   Grid[3]
                CellProperty tempTwo = selectedGrids[1].assignedCell;           //var temp2 =    Cell[C]
                selectedGrids[1].assignedCell = temp;                           //Grid[3]   ->   temp

                tempTwo.currentGrid           = selectedGrids[0];
                selectedGrids[0].assignedCell = tempTwo;
            }

            moveRemaining--;
            gPSV.isSliding = false;
        }
        public CellProperty FillCellProperty()
        {
            CellProperty cellProperty = new CellProperty();

            cellProperty.cellMeasure = this.CellMeasurePanel.CellMeasure;
            cellProperty.cellScope   = this.filterScopePanel.Scope;
            cellProperty.period      = this.periodPanel.Period;
            return(cellProperty);
        }
예제 #6
0
        public void IsCooridnatesOutOfTable()
        {
            int[] coordinates = new int[] { 1, 11, };
            CellProperty[,] warmap = new CellProperty[2, 2];

            Scanner scanner = new Scanner();
            bool    result  = scanner.CheckCoordinatesCorrectness(coordinates, warmap);

            Assert.IsFalse(result);
        }
 public void ChangeObject(CellProperty c)
 {
     element        = c.element;
     isPushable     = c.isPushable;
     destroysObject = c.destroysObject;
     isWin          = c.isWin;
     isPlayer       = c.isPlayer;
     isStop         = c.IsStop;
     ChangeSprite();
 }
예제 #8
0
        public void IsShipDetected()
        {
            int[] coordinates = new int[] { 0, 0, };
            CellProperty[,] warmap = new CellProperty[1, 1] {
                { CellProperty.Occupied }
            };

            Scanner      scanner = new Scanner();
            CellProperty result  = scanner.CheckCellStatus(warmap, coordinates);

            Assert.AreEqual(CellProperty.Occupied, result);
        }
예제 #9
0
        public void IsCellFree()
        {
            int[] coordinates = new int[] { 0, 0, };
            CellProperty[,] warmap = new CellProperty[1, 1] {
                { CellProperty.Empty }
            };

            Scanner      scanner = new Scanner();
            CellProperty result  = scanner.CheckCellStatus(warmap, coordinates);

            Assert.AreEqual(CellProperty.Empty, result);
        }
예제 #10
0
        public void IsShipCanHit()
        {
            int[] coordinates = new int[] { 0, 0, };
            CellProperty[,] warmap = new CellProperty[1, 1] {
                { CellProperty.Occupied }
            };
            List <Ship> listofships = new List <Ship>();

            War war = new War();

            war.Shoot(coordinates, warmap, listofships);


            Assert.IsTrue(warmap[0, 0] == CellProperty.Hit);
        }
예제 #11
0
    public bool IsStop(int r, int c, Vector2 dir)
    {
        bool isPush = false;
        int  curRow = r, curCol = c;
        List <GameObject> atRC = FindObjectsAt(curRow, curCol);

        if (r >= rows || c >= cols || r < 0 || c < 0)
        {
            return(true);
        }
        foreach (GameObject g in atRC)
        {
            CellProperty currentCell = g.GetComponent <CellProperty>();

            if (currentCell.IsStop)
            {
                return(true);
            }
            else if (currentCell.IsPushable)
            {
                isPush = true;
            }
        }

        if (!isPush)
        {
            return(false);
        }

        if (dir == Vector2.right)
        {
            return(IsStop(curRow, curCol + 1, Vector2.right));
        }
        else if (dir == Vector2.left)
        {
            return(IsStop(curRow, curCol - 1, Vector2.left));
        }
        else if (dir == Vector2.up)
        {
            return(IsStop(curRow + 1, curCol, Vector2.up));
        }
        else if (dir == Vector2.down)
        {
            return(IsStop(curRow - 1, curCol, Vector2.down));
        }
        return(true);
    }
예제 #12
0
        /// <summary>
        /// Gets the parameters from the message then calls the appropriate FlexgridGetCellRange method
        /// on the correct thread storing the results in the specified datastore
        /// </summary>
        /// <param name="ptrMessage">A pointer to the message</param>
        unsafe private void FlexgridGetCellRange(Message *ptrMessage, CellProperty property)
        {
            int    row1              = GetParameterInt32(ptrMessage, 0);
            int    column1           = GetParameterInt32(ptrMessage, 1);
            int    row2              = GetParameterInt32(ptrMessage, 2);
            int    column2           = GetParameterInt32(ptrMessage, 3);
            object sourceObject      = GetObjectFromDatastore(ptrMessage->SourceStore);
            object destinationObject = null;

            if (sourceObject != null)
            {
                object[] theParameters = { sourceObject, row1, column1, row2, column2 };
                switch (property)
                {
                case CellProperty.BackColourName:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeBackColourNameDelegater, theParameters);
                    break;

                case CellProperty.ForeColourName:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeForeColourNameDelegater, theParameters);
                    break;

                case CellProperty.DataType:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeDataTypeDelegater, theParameters);
                    break;

                case CellProperty.CheckBox:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeCheckBoxDelegater, theParameters);
                    break;

                case CellProperty.Image:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeImageDelegater, theParameters);
                    break;

                case CellProperty.BackgroundImage:
                    destinationObject = ((WF.Control)tempStore0).Invoke(m_FlexgridGetCellRangeBackgroundImageDelegater, theParameters);
                    break;

                default:
                    throw new Exception("Implement support for getting cell property " + property.ToString());
                }
            }

            PutObjectInDatastore(ptrMessage->DestinationStore, destinationObject);
            CleanUpMessage(ptrMessage);
        }
예제 #13
0
        public MyGrid GenerateGrid(Vector2 newPos, int id, CellProperty newCell)
        {
            if (id == 0)
            {
                grids = new List <MyGrid>();
            }
            MyGrid newGrid = Instantiate(gridObject, newPos, Quaternion.identity).GetComponent <MyGrid>();

            newGrid.GridId             = id;
            newGrid.transform.position = newPos;

            newGrid.assignedCell     = newCell;
            newGrid.transform.parent = transform;
            newGrid.belowGrid        = GetBelowGrid();
            grids.Add(newGrid);
            return(newGrid);
        }
예제 #14
0
    public void CompileRules()
    {
        ResetData();
        for (int i = 0; i < cells.Count; i++)
        {
            if (cells[i] != null)
            {
                CellProperty currentcell = cells[i].GetComponent <CellProperty>();

                if (IsElementStartingWord(currentcell.Element))
                {
                    /*if (DoesListContainElement(FindObjectsAt(currentcell.CurrentRow + 1, currentcell.CurrentCol), ElementTypes.IsWord))
                     * {
                     *  if (DoesListContainWord(FindObjectsAt(currentcell.CurrentRow +2, currentcell.CurrentCol)))
                     *  {
                     *      Rule(currentcell.Element, ReturnWordAt(currentcell.CurrentRow + 2, currentcell.CurrentCol));
                     *  }
                     * }*/
                    if (DoesListContainElement(FindObjectsAt(currentcell.CurrentRow - 1, currentcell.CurrentCol), ElementTypes.IsWord))
                    {
                        if (DoesListContainWord(FindObjectsAt(currentcell.CurrentRow - 2, currentcell.CurrentCol)))
                        {
                            Rule(currentcell.Element, ReturnWordAt(currentcell.CurrentRow - 2, currentcell.CurrentCol));
                        }
                    }
                    if (DoesListContainElement(FindObjectsAt(currentcell.CurrentRow, currentcell.CurrentCol + 1), ElementTypes.IsWord))
                    {
                        if (DoesListContainWord(FindObjectsAt(currentcell.CurrentRow, currentcell.CurrentCol + 2)))
                        {
                            Rule(currentcell.Element, ReturnWordAt(currentcell.CurrentRow, currentcell.CurrentCol + 2));
                        }
                    }

                    /*if (DoesListContainElement(FindObjectsAt(currentcell.CurrentRow, currentcell.CurrentCol -1), ElementTypes.IsWord))
                     * {
                     *  if (DoesListContainWord(FindObjectsAt(currentcell.CurrentRow, currentcell.CurrentCol - 2)))
                     *  {
                     *      Rule(currentcell.Element, ReturnWordAt(currentcell.CurrentRow, currentcell.CurrentCol - 2));
                     *  }
                     * }*/
                }
            }
        }
    }
예제 #15
0
        public void ReturnTrueIfCoordinatesGood()
        {
            PlayerTurn pt = new PlayerTurn();

            int[] coordinatesshoot = new int[2] {
                1, 2
            };
            int[] coordinatesbuilt = new int[2] {
                0, 1
            };
            CellProperty[,] warmap = new CellProperty[10, 10];
            List <Ship> listofships = new List <Ship>()
            {
                new Ship(KindOfShip.Two, coordinatesbuilt, Direction.Left)
            };
            War war = new War();

            bool[] result = war.Shoot(coordinatesshoot, warmap, listofships);
            Assert.IsTrue(result[0]);
        }
예제 #16
0
        public void ShouldReturnModifiedBoardWhenInputIsValid()
        {
            // For
            CellProperty[,] expectedBoard = new CellProperty[10, 10];

            CellProperty[,] board = new CellProperty[10, 10];
            string coordinates = "a1";
            string direction   = "right";

            // Given
            StartGame game = new StartGame();

            game.PlaceShipOnBoard(board, coordinates, direction);

            // Assert
            for (int i = 0; i < 6; i++)
            {
                Assert.IsTrue(board[0, i] != expectedBoard[0, i]);
            }
        }
예제 #17
0
        protected void completeCell(CellProperty cellProperty)
        {
            if (cellProperty.cellScope != null)
            {
                cellProperty.cellScope.targetItemListChangeHandler.Items = cellProperty.cellScope.targetItemListChangeHandler.getItems();
                foreach (TargetItem item in cellProperty.cellScope.targetItemListChangeHandler.Items)
                {
                    if (TagFormulaUtil.isFormula(item.formula) && item.value == null)
                    {
                        System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(item.formula));
                        item.value      = new Target();
                        item.value.name = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    }
                    cellProperty.cellScope.buildName();
                }
            }

            if (cellProperty.cellMeasure != null && TagFormulaUtil.isFormula(cellProperty.cellMeasure.formula) && cellProperty.cellMeasure.measure == null)
            {
                if (TagFormulaUtil.isFormula(cellProperty.cellMeasure.formula) && cellProperty.cellMeasure.measure == null)
                {
                    System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(cellProperty.cellMeasure.formula));
                    String measureName         = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    cellProperty.cellMeasure.name = measureName;
                }
            }

            if (cellProperty.period != null)
            {
                cellProperty.period.itemListChangeHandler.Items = cellProperty.period.itemListChangeHandler.getItems();
                foreach (PeriodItem item in cellProperty.period.itemListChangeHandler.Items)
                {
                    if (TagFormulaUtil.isFormula(item.formula) && item.value == null)
                    {
                        System.Windows.Point coord = TagFormulaUtil.getCoordonne(TagFormulaUtil.getFormulaWithoutEqualSign(item.formula));
                        item.value = GetValue((int)coord.X, (int)coord.Y, cellProperty.nameSheet);
                    }
                    cellProperty.period.BuildName();
                }
            }
        }
예제 #18
0
        public void IsShipCanBeDestroy()
        {
            int[] coordinates = new int[] { 0, 1 };
            CellProperty[,] warmap = new CellProperty[1, 2];
            List <Ship> listofships = new List <Ship>()
            {
                new Ship(KindOfShip.Two, coordinates, Direction.Left)
            };

            warmap[0, 0] = CellProperty.Hit;
            warmap[0, 1] = CellProperty.Occupied;


            War war = new War();

            war.Shoot(coordinates, warmap, listofships);


            Assert.IsTrue(warmap[0, 0] == CellProperty.Destroyed);
            Assert.IsTrue(warmap[0, 1] == CellProperty.Destroyed);
        }
예제 #19
0
        public void ShouldReturnEmptyBoardWhenCoordinatesAreWrong()
        {
            // For
            StartGame game = new StartGame();

            CellProperty[,] board = new CellProperty[10, 10];
            string coordinates = "z1";
            string direction   = "up";

            // Given
            CellProperty[,] expectedBoard = game.PlaceShipOnBoard(board, coordinates, direction);

            // Assert
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Assert.IsTrue(board[i, j] == expectedBoard[i, j]);
                }
            }
        }
예제 #20
0
        private void InstantiateItem()
        {
            var itemList = GameManager.Player.Inventory.GetItemListAsReadOnly(x => x.ItemType == Sell.ItemTypes.ItemType);
            var n        = itemList.Count;

            items = new UI_Shop_Left_Sell_ItemChild[n];

            var cellProperty = new CellProperty(this);

            var currentPosition  = cellProperty.StartPosition;
            var horizontalBuffer = cellProperty.HorizontalTotal;
            var verticalLimit    = cellProperty.VerticalTotal;

            for (int i = 0; i < n; i++)
            {
                var product = Item_Product.CreateProduct(itemList[i]);
                var item    = Instantiate(prefab, RectTransform);
                item.gameObject.SetActive(true);
                item.Initialize(product, currentPosition);
                items[i] = item;

                horizontalBuffer--;
                if (horizontalBuffer == 0)
                {
                    verticalLimit--;
                    if (verticalLimit == 0)
                    {
                        break;
                    }

                    horizontalBuffer   = cellProperty.HorizontalTotal;
                    currentPosition.y -= cellProperty.n128 + cellProperty.VerticalSpace;
                    currentPosition.x  = cellProperty.StartPosition.x;
                }
                else
                {
                    currentPosition.x += cellProperty.n128 + cellProperty.HorizontalSpace;
                }
            }
        }
예제 #21
0
        /// <summary>
        /// Vérifie le type d'un objet et l'ajoute à la propriété correspondante
        /// dans le Cellproperty.
        /// </summary>
        /// <param name="cellProperty"></param>
        /// <param name="item"></param>
        private void RefreshCellProperty(CellProperty cellProperty, LineItem lineItem)
        {
            object item = lineItem.GetValue();

            if (item is Target)
            {
                Target target = (Target)item;
                if (cellProperty.cellScope == null)
                {
                    cellProperty.cellScope      = GetNewScope();
                    cellProperty.cellScope.name = target.name;
                }
                else
                {
                    cellProperty.cellScope.name += TargetItem.Operator.AND.ToString() + " " + target.name;
                }

                TargetItem targetItem = new TargetItem();
                targetItem.value        = target;
                targetItem.operatorType = TargetItem.Operator.AND.ToString();
                cellProperty.cellScope.AddTargetItem(targetItem);
            }

            if (item is Measure)
            {
                if (cellProperty.cellMeasure == null)
                {
                    cellProperty.cellMeasure = new CellMeasure();
                }
                cellProperty.cellMeasure.measure = (Measure)item;
            }

            if (!string.IsNullOrWhiteSpace(lineItem.periodFrom) && !string.IsNullOrWhiteSpace(lineItem.periodTo))
            {
                //lineItem.updatePeriod(this.periodicity);
                //cellProperty.periodFrom = lineItem.periodFrom;
                //cellProperty.periodTo = lineItem.periodTo;
            }
        }
예제 #22
0
        public void ReturnFalseIfShootMiss()
        {
            PlayerTurn pt = new PlayerTurn();

            int[] coordinatesshoot = new int[2] {
                0, 2
            };
            int[] coordinatesbuilt = new int[2] {
                0, 1
            };
            CellProperty[,] warmap = new CellProperty[1, 3];
            List <Ship> listofships = new List <Ship>()
            {
                new Ship(KindOfShip.Two, coordinatesbuilt, Direction.Left)
            };

            warmap[0, 2] = CellProperty.Empty;
            War war = new War();

            bool[] result = war.Shoot(coordinatesshoot, warmap, listofships);
            Assert.IsFalse(result[1]);
        }
예제 #23
0
        /// <summary>
        /// Retourne le CellProperty en fonction des coordonées.
        /// Si le cellProperty n'existe pas, on le crée.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        private CellProperty GetCellProperty(int row, int col, bool update)
        {
            DateTime time = DateTime.Now;

            string cellName = Kernel.Util.RangeUtil.GetCellName(row, col);

            if (update)
            {
                CellProperty cp = table.GetCellProperty(cellName, sheetName);
                if (cp != null)
                {
                    table.RemoveCellProperty(cp);
                }
            }

            CellProperty cellProperty = null;

            this.cellsDictionary.TryGetValue(cellName, out cellProperty);
            if (cellProperty != null)
            {
                return(cellProperty);
            }

            object value = page.getInputTableForm().SpreadSheet.getValueAt(row, col, sheetName);

            cellProperty           = new CellProperty(Kernel.Util.RangeUtil.GetColumnName(col) + row, row, col);
            cellProperty.nameSheet = sheetName;
            cellProperty.SetDecimalMeasure(value);

            this.cellsDictionary.Add(cellName, cellProperty);

            var duration = (DateTime.Now - time).TotalSeconds;

            getCellDuration += duration;
            Console.Out.WriteLine("Get Cell " + cellName + " : " + duration + " secondes");

            return(cellProperty);
        }
예제 #24
0
        /// <summary>
        ///Build columns
        /// </summary>
        /// <param name="range">Contains the current selected cell and the active sheet</param>
        /// <param name="coords">the number of columns and the number of lines</param>
        public void BuildColunms(Range range, System.Windows.Point coords, bool showHeader)
        {
            int  row = 1, col = 1;
            int  columnCount = (int)coords.X;
            int  rowCount    = (int)coords.Y != 0 ? (int)coords.Y : 1;
            Cell cell        = range.Cells[0];

            ObservableCollection <LineItem> centralLine = design.central.lineListChangeHandler.Items.Count > 0 &&
                                                          design.central.lineListChangeHandler.Items[0].itemListChangeHandler.Items.Count > 0 ?
                                                          design.central.lineListChangeHandler.Items[0].itemListChangeHandler.Items :
                                                          new ObservableCollection <LineItem>();

            ObservableCollection <DesignDimensionLine> Lines = new ObservableCollection <DesignDimensionLine>(design.columns.lineListChangeHandler.Items);
            int lineCount = Lines.Count;

            if (lineCount > 0)
            {
                int totalCardinality = getCartesianProductLineSize(Lines);
                row = lineCount;
                int inc = 1;
                for (int currentLineRang = lineCount; currentLineRang >= 1; currentLineRang--)
                {
                    col = design.rows.lineListChangeHandler.Items.Count > 0 ? design.rows.lineListChangeHandler.Items.Count + 1 : 2;

                    DesignDimensionLine currentLine = Lines[currentLineRang - 1];
                    int currentLineItemCount        = currentLine.GetItemCount();

                    ObservableCollection <DesignDimensionLine> AllLines = new ObservableCollection <DesignDimensionLine>(design.columns.lineListChangeHandler.Items);
                    AllLines.Remove(currentLine);
                    int cardinality = getCartesianProductLineSize(AllLines);
                    int addColIndex = 0;
                    if (currentLineRang == 1 && currentLine.GetItemCount() != 0)
                    {
                        for (int j = 1; j <= totalCardinality / currentLine.GetItemCount(); j++)
                        {
                            foreach (LineItem item in currentLine.itemListChangeHandler.Items)
                            {
                                if (showHeader)
                                {
                                    this.page.getInputTableForm().SpreadSheet.SetValueAt(cell.Row - inc, cell.Column + addColIndex, sheetName, item.GetValue().ToString(), Designer.DesignerForm.COLUMNS_COLOR);
                                    // this.page.getInputTableForm().SpreadSheet.SetValueAt(cell.Row - inc, cell.Column + addColIndex, sheetName, item.GetValue().ToString());
                                }
                                addColIndex++;
                                col++;
                            }
                        }
                    }
                    else
                    {
                        int n = totalCardinality - (currentLineItemCount * cardinality) + 1;
                        int m = cardinality;
                        if (currentLineRang != lineCount)
                        {
                            ObservableCollection <DesignDimensionLine> AllLine   = design.columns.lineListChangeHandler.Items;
                            ObservableCollection <DesignDimensionLine> UPLines   = new ObservableCollection <DesignDimensionLine>(AllLine.ToList().GetRange(0, currentLineRang - 1));
                            ObservableCollection <DesignDimensionLine> DOWNLines = new ObservableCollection <DesignDimensionLine>(AllLine.ToList().GetRange(currentLineRang, AllLine.Count - currentLineRang));

                            m = getCartesianProductLineSize(UPLines);
                            n = getCartesianProductLineSize(DOWNLines);
                        }
                        for (int j = 1; j <= n; j++)
                        {
                            foreach (LineItem item in currentLine.itemListChangeHandler.Items)
                            {
                                for (int i = 1; i <= m; i++)
                                {
                                    if (showHeader)
                                    {
                                        this.page.getInputTableForm().SpreadSheet.SetValueAt(cell.Row - inc, cell.Column + addColIndex, sheetName, item.GetValue().ToString(), Designer.DesignerForm.COLUMNS_COLOR);
                                    }
                                    for (int l = 0; l < rowCount; l++)
                                    {
                                        CellProperty cellProperty = GetCellProperty(cell.Row + l, cell.Column + addColIndex, true);
                                        RefreshCellProperty(cellProperty, centralLine);
                                        //this.page.getInputTableForm().SpreadSheet.SetColorAt(cell.Row-1;cell.Column-1,sheetName,item/
                                        RefreshCellProperty(cellProperty, item);
                                    }
                                    addColIndex++;
                                    col++;
                                }
                            }
                        }
                    }
                    inc++;
                    row--;
                }
            }
        }
예제 #25
0
        //
        //  FlexgridGetCellRange
        //

        /// <summary>
        /// Calls into the AUT to iterate over every cell in the grid returning a \t \r separated string of the
        /// required property of the cells
        /// </summary>
        /// <param name="sourceStore">The datastore which contains the grid object</param>
        /// <param name="destinationStore">The datastore to put the resultant string into</param>
        /// <param name="row1">The start row of the range</param>
        /// <param name="column1">The start column of the range</param>
        /// <param name="row2">The end row of the range</param>
        /// <param name="column2">The end column of the range</param>
        unsafe public void AddQueryMessageFlexgridGetCellRange(DataStores sourceStore, DataStores destinationStore, int row1, int column1, int row2, int column2, CellProperty property)
        {
            if (!m_DoneFind)
            {
                throw new Exception("Must locate the flexgrid before trying to use it");
            }

            Message *ptrMessage = GetPointerToNextMessage();

            ptrMessage->SourceStore      = sourceStore;
            ptrMessage->DestinationStore = destinationStore;

            switch (property)
            {
            case CellProperty.BackColourName:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeBackColourName;
                break;

            case CellProperty.ForeColourName:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeForeColourName;
                break;

            case CellProperty.DataType:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeDataType;
                break;

            case CellProperty.CheckBox:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeCheckBox;
                break;

            case CellProperty.Image:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeImage;
                break;

            case CellProperty.BackgroundImage:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeBackgroundImage;
                break;

            default:
                throw new Exception("Implement support for getting cell property " + property.ToString());
            }

            Parameter row1Parameter    = new Parameter(this, row1);
            Parameter column1Parameter = new Parameter(this, column1);
            Parameter row2Parameter    = new Parameter(this, row2);
            Parameter column2Parameter = new Parameter(this, column2);

            m_PtrMessageStore->NumberOfMessages++;
            m_DoneQuery = true;
        }
예제 #26
0
        /// <summary>
        /// Apply design lines elements as cellproperty
        /// </summary>
        /// <param name="design">Choosen design</param>
        /// <param name="table">The InputTable on which you wish to apply design template</param>
        /// <param name="range">Contains the current selected cell and the active sheet</param>
        /// <param name="coords">the number of columns and the number of lines</param>
        public void BuildRows(Range range, System.Windows.Point coords, bool showHeader)
        {
            int  row = 1, col = 1;
            int  columnCount = (int)coords.X != 0 ? (int)coords.X : 1;
            int  rowCount    = (int)coords.Y;
            Cell cell        = range.Cells[0];
            ObservableCollection <DesignDimensionLine> Lines = new ObservableCollection <DesignDimensionLine>(design.rows.lineListChangeHandler.Items);
            int lineCount = Lines.Count;

            if (lineCount > 0)
            {
                int totalCardinality = getCartesianProductLineSize(Lines);
                col = lineCount;
                int inc = 1;
                for (int currentLineRang = lineCount; currentLineRang >= 1; currentLineRang--)
                {
                    row = design.columns.lineListChangeHandler.Items.Count > 0 ? design.columns.lineListChangeHandler.Items.Count + 1 : 2;
                    if (design.concatenateColumnHearder)
                    {
                        row = 2;
                    }
                    DesignDimensionLine currentLine = Lines[currentLineRang - 1];
                    int currentLineItemCount        = currentLine.GetItemCount();

                    ObservableCollection <DesignDimensionLine> AllLines = new ObservableCollection <DesignDimensionLine>(design.rows.lineListChangeHandler.Items);
                    AllLines.Remove(currentLine);
                    int cardinality = getCartesianProductLineSize(AllLines);
                    int addRowIndex = 0;
                    if (currentLineRang == 1 && currentLine.GetItemCount() != 0)
                    {
                        for (int j = 1; j <= totalCardinality / currentLine.GetItemCount(); j++)
                        {
                            foreach (LineItem item in currentLine.itemListChangeHandler.Items)
                            {
                                if (showHeader)
                                {
                                    int colone = cell.Column - inc > 0 ? cell.Column - inc : 1;
                                    this.page.getInputTableForm().SpreadSheet.SetValueAt(cell.Row + addRowIndex, colone, sheetName, item.GetValue().ToString(), Designer.DesignerForm.ROWS_COLOR);
                                    //this.page.getInputTableForm().SpreadSheet.SetColorAt(cell.Row + addRowIndex, colone, sheetName, Designer.DesignerForm.ROWS_COLOR);
                                }
                                for (int c = 0; c < columnCount; c++)
                                {
                                    CellProperty cellProperty = GetCellProperty(cell.Row + addRowIndex, cell.Column + c, false);
                                    RefreshCellProperty(cellProperty, item);
                                }
                                addRowIndex++;
                                row++;
                            }
                        }
                    }
                    else
                    {
                        int n = totalCardinality - (currentLineItemCount * cardinality) + 1;
                        int m = cardinality;

                        if (currentLineRang != lineCount)
                        {
                            ObservableCollection <DesignDimensionLine> AllLine   = design.rows.lineListChangeHandler.Items;
                            ObservableCollection <DesignDimensionLine> UPLines   = new ObservableCollection <DesignDimensionLine>(AllLine.ToList().GetRange(0, currentLineRang - 1));
                            ObservableCollection <DesignDimensionLine> DOWNLines = new ObservableCollection <DesignDimensionLine>(AllLine.ToList().GetRange(currentLineRang, AllLine.Count - currentLineRang));

                            m = getCartesianProductLineSize(UPLines);
                            n = getCartesianProductLineSize(DOWNLines);
                        }

                        for (int j = 1; j <= n; j++)
                        {
                            foreach (LineItem item in currentLine.itemListChangeHandler.Items)
                            {
                                for (int i = 1; i <= m; i++)
                                {
                                    if (showHeader)
                                    {
                                        int colone = cell.Column - inc > 0 ? cell.Column - inc : 1;
                                        this.page.getInputTableForm().SpreadSheet.SetValueAt(cell.Row + addRowIndex, colone, sheetName, item.GetValue().ToString(), Designer.DesignerForm.ROWS_COLOR);
                                        //this.page.getInputTableForm().SpreadSheet.SetColorAt(cell.Row + addRowIndex, colone, sheetName, Designer.DesignerForm.ROWS_COLOR);
                                    }
                                    for (int c = 0; c < columnCount; c++)
                                    {
                                        CellProperty cellProperty = GetCellProperty(cell.Row + addRowIndex, cell.Column + c, false);
                                        RefreshCellProperty(cellProperty, item);
                                    }
                                    addRowIndex++;
                                    row++;
                                }
                            }
                        }
                    }
                    inc++;
                    col--;
                }
            }
        }
예제 #27
0
        public CellProperty CheckCellStatus(CellProperty[,] warmap, int[] tempcoordinates)
        {
            CellProperty answer = warmap[tempcoordinates[0], tempcoordinates[1]];

            return(answer);
        }
예제 #28
0
        /// <summary>生成Excel模板数据行</summary>
        private List <CellProperty> BuildExcelTemplateDataRow(int index, string ptFile, string ext)
        {
            var cellData = new List <CellProperty>();

            cellData.Add(new CellProperty()
            {
                Value = index + 1, Span = 1
            });
            var encoding = ExtToIndexDataTypeValueProvider.GetEncoding(ext);

            cellData.Add(new CellProperty()
            {
                Value = encoding, Span = 1
            });
            cellData.Add(new CellProperty()
            {
                Value = ptFile, Span = 1
            });
            var options = ExtToIndexDataTypeValueProvider.GetOptions(ext);

            cellData.Add(new CellProperty()
            {
                Value = options, Span = 1
            });
            var context = ptFile;

            foreach (var tag in this.Config.MetadataTags)
            {
                var property = new CellProperty()
                {
                    Span = 1
                };
                object value = null;
                if (tag.Variables != null)
                {
                    value = tag.BuildVariablesValue(context);
                }
                else if (tag.DefaultValue.Length > 0)
                {
                    value = tag.DefaultValue;
                }
                var tagType = MetadataTagType.String;
                if (!tag.Refer.Type.IsNullOrEmpty())
                {
                    tagType = tag.Refer.Type.ToEnum <MetadataTagType>();
                }
                switch (tagType)
                {
                case MetadataTagType.Date:
                case MetadataTagType.ISODate:
                    property.ValueType = typeof(DateTime);
                    if (value != null)
                    {
                        var dtValue = value.ToString().TryParseStandardString().GetValueOrDefault(DateTime.MinValue);
                        if (dtValue != DateTime.MinValue)
                        {
                            value = dtValue;
                        }
                    }
                    break;

                case MetadataTagType.Number:
                    property.ValueType = typeof(double);
                    if (value != null)
                    {
                        value = double.Parse(value.ToString());
                    }
                    break;

                default:
                    if (value == null)
                    {
                        value = string.Empty;
                    }
                    break;
                }
                property.Value = value;
                cellData.Add(property);
            }
            return(cellData);
        }
예제 #29
0
 set => SetValue(CellProperty, value);