Inheritance: UnityEngine.ScriptableObject
    public async Task Spreadsheet_AddRow_MixedBoldStyleCells(bool firstCellBold, Type type)
    {
        // Arrange
        const string firstCellValue = "First";
        const string secondCellValue = "Second";
        using var stream = new MemoryStream();
        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var style = new Style();
            style.Font.Bold = true;
            var styleId = spreadsheet.AddStyle(style);

            var firstCell = CellFactory.Create(type, firstCellValue, firstCellBold ? styleId : null);
            var secondCell = CellFactory.Create(type, secondCellValue, firstCellBold ? null : styleId);

            // Act
            await spreadsheet.AddRowAsync(new[] { firstCell, secondCell });
            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var workbook = new XLWorkbook(stream);
        var worksheet = workbook.Worksheets.Single();
        var actualFirstCell = worksheet.Cell(1, 1);
        var actualSecondCell = worksheet.Cell(1, 2);
        Assert.Equal(firstCellValue, actualFirstCell.Value);
        Assert.Equal(secondCellValue, actualSecondCell.Value);
        Assert.Equal(firstCellBold, actualFirstCell.Style.Font.Bold);
        Assert.Equal(!firstCellBold, actualSecondCell.Style.Font.Bold);
    }
    public async Task Spreadsheet_AddRow_FillColorCellWithStringValue(Type type)
    {
        // Arrange
        const string cellValue = "Color test";
        var color = Color.Brown;
        using var stream = new MemoryStream();
        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var style = new Style();
            style.Fill.Color = color;
            var styleId = spreadsheet.AddStyle(style);
            var styledCell = CellFactory.Create(type, cellValue, styleId);

            // Act
            await spreadsheet.AddRowAsync(styledCell);
            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var workbook = new XLWorkbook(stream);
        var worksheet = workbook.Worksheets.Single();
        var actualCell = worksheet.Cell(1, 1);
        Assert.Equal(cellValue, actualCell.Value);
        Assert.Equal(color, actualCell.Style.Fill.BackgroundColor.Color);
    }
    public async Task Spreadsheet_AddRow_FontNameCellWithStringValue(string? fontName, Type type)
    {
        // Arrange
        const string cellValue = "Font name test";
        using var stream = new MemoryStream();
        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var style = new Style();
            style.Font.Name = fontName;
            var styleId = spreadsheet.AddStyle(style);
            var styledCell = CellFactory.Create(type, cellValue, styleId);

            // Act
            await spreadsheet.AddRowAsync(styledCell);
            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var workbook = new XLWorkbook(stream);
        var worksheet = workbook.Worksheets.Single();
        var actualCell = worksheet.Cell(1, 1);
        Assert.Equal(cellValue, actualCell.Value);
        Assert.Equal(fontName ?? "Calibri", actualCell.Style.Font.FontName);
    }
Exemplo n.º 4
0
    public void RemoveRoom(RoomCell roomCell)
    {
        var cellsToReplace = new List <Cell>();

        for (int i = 0; i < roomCell.roomInfo.size; i++)
        {
            cellsToReplace.Add(CellFactory.CreateCell(roomCell.id + i, roomCell.transform.position - Vector3.right * roomCell.size * 0.5f * Cell.defaultCellWidth + Vector3.right * i * Cell.defaultCellWidth + Vector3.right * Cell.defaultCellWidth * 0.5f, 1, CellState.Corridor));
            //Setting neighbours
            if (i > 0)
            {
                cellsToReplace[i - 1].rightNeighbour = cellsToReplace[i];
                cellsToReplace[i].leftNeighbour      = cellsToReplace[i - 1];
            }
        }
        cellsToReplace[0].leftNeighbour = roomCell.leftNeighbour;
        cellsToReplace[roomCell.roomInfo.size - 1].rightNeighbour = roomCell.rightNeighbour;
        cells.Remove(roomCell);
        cells.InsertRange(roomCell.id, cellsToReplace);
        foreach (var o in cellsToReplace)
        {
            o.UpdateView();
        }
        UpdateCellIds();
        Destroy(roomCell.gameObject);
    }
Exemplo n.º 5
0
        static Program()
        {
            var configFactory = new ConfigFactory();
            var cellFactory   = new CellFactory();
            var figureFactory = new FigureFactory();
            var boardFactory  = new BoardFactory(figureFactory, cellFactory);
            var linesFactory  = new LinesFactory();

            Console = new ConcreteConsole();
            var consoleInputProvider = new ConsoleInputProvider(Console);

            var playerRegisterManager = new PlayerRegisterManager(consoleInputProvider, Console);

            PreparationService = new GamePreparationService(configFactory, playerRegisterManager, consoleInputProvider, Console);
            var inputManager = new GameInputProvider(consoleInputProvider, Console);

            PartyFinishedProvider = new PartyFinishProvider(consoleInputProvider);

            GameFactory = new GameFactory(boardFactory, linesFactory, inputManager);

            var figureDrawerFactory  = new FigureDrawerFactory(Console);
            var figureDrawerProvider = new FigureDrawerProvider(figureDrawerFactory);

            BoardDrawer = new BoardDrawer(Console, figureDrawerProvider);
        }
    public async Task Spreadsheet_AddRow_CellWithIntegerValue(int?value, Type type)
    {
        // Arrange
        using var stream = new MemoryStream();
        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var cell = CellFactory.Create(type, value);

            // Act
            await spreadsheet.AddRowAsync(cell);

            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var actual = SpreadsheetDocument.Open(stream, true);
        var sheetPart  = actual.WorkbookPart !.WorksheetParts.Single();
        var actualCell = sheetPart.Worksheet.Descendants <OpenXmlCell>().Single();

        Assert.Equal(CellValues.Number, actualCell.GetDataType());
        Assert.Equal(value?.ToString() ?? string.Empty, actualCell.InnerText);
    }
    public async Task Spreadsheet_AddRow_CellWithVeryLongStringValue(int length, Type type)
    {
        // Arrange
        var value = new string('a', length);

        using var stream = new MemoryStream();
        var options = new SpreadCheetahOptions {
            BufferSize = SpreadCheetahOptions.MinimumBufferSize
        };

        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream, options))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var cell = CellFactory.Create(type, value);

            // Act
            await spreadsheet.AddRowAsync(cell);

            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var actual = SpreadsheetDocument.Open(stream, true);
        var sheetPart  = actual.WorkbookPart !.WorksheetParts.Single();
        var actualCell = sheetPart.Worksheet.Descendants <OpenXmlCell>().Single();

        Assert.Equal(CellValues.InlineString, actualCell.DataType?.Value);
        Assert.Equal(value, actualCell.InnerText);
    }
    public async Task Spreadsheet_AddRow_CellWithStringValue(string?value, Type type)
    {
        // Arrange
        using var stream = new MemoryStream();
        await using (var spreadsheet = await Spreadsheet.CreateNewAsync(stream))
        {
            await spreadsheet.StartWorksheetAsync("Sheet");

            var cell = CellFactory.Create(type, value);

            // Act
            await spreadsheet.AddRowAsync(cell);

            await spreadsheet.FinishAsync();
        }

        // Assert
        SpreadsheetAssert.Valid(stream);
        using var actual = SpreadsheetDocument.Open(stream, true);
        var        sheetPart        = actual.WorkbookPart !.WorksheetParts.Single();
        var        actualCell       = sheetPart.Worksheet.Descendants <OpenXmlCell>().Single();
        CellValues?expectedDataType = value is null ? null : CellValues.InlineString;

        Assert.Equal(expectedDataType, actualCell.DataType?.Value);
        Assert.Equal(value ?? string.Empty, actualCell.InnerText);
    }
Exemplo n.º 9
0
        public static CellMatrix Python(
            [Parameter("The Python Code")] CellMatrix PythonCode,
            [Parameter("The Parameters ")] CellMatrix TheParameters
            )
        {
            if (PythonCode.ColumnsInStructure != 1)
            {
                throw new Exception("The Python code should  be one column of strings");
            }
            string theCode = "";

            for (int i = 0; i < PythonCode.RowsInStructure; ++i)
            {
                if (!PythonCode[i, 0].IsEmpty)
                {
                    theCode = theCode + PythonCode[i, 0].StringValue() + "\n";
                }
            }
            CellFactory theFactory = new CellFactory();

            scope.SetVariable("Input", TheParameters);
            scope.SetVariable("CellFactory", theFactory);
            ScriptSource source = engine.CreateScriptSourceFromString(theCode, SourceCodeKind.Statements);

            source.Execute(scope);
            return((CellMatrix)scope.GetVariable("Output"));
        }
Exemplo n.º 10
0
 public override Tree <Cell> Parse(CellFactory factory, Settings settings)
 {
     return(new TextTables(
                new TextTableScanner(content, c => c == CharacterType.Letter),
                factory.MakeEmptyCell)
            .Parse());
 }
Exemplo n.º 11
0
        public async Task EntryCellDisposed()
        {
            var text1 = "Foo";
            var text2 = "Bar";
            var model = new _5560Model()
            {
                Text = text1
            };

            for (int m = 0; m < 3; m++)
            {
                var entryCell = new EntryCell();
                entryCell.SetBinding(EntryCell.TextProperty, new Binding("Text"));
                entryCell.SetBinding(EntryCell.BindingContextProperty, new Binding("BindingContext"));
                entryCell.BindingContext = model;
                CellFactory.GetCell(entryCell, null, null, Context, null);

                if (m == 1)
                {
                    GC.Collect();
                }

                model.Text = model.Text == text1 ? text2 : text1;
            }

            await model.WaitForTestToComplete().ConfigureAwait(false);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Places mines on the field
        /// </summary>
        public void PlaceMines()
        {
            if (cells == null)
            {
                throw new ArgumentNullException("Error: playfiled array cannot be null (not initialized)");
            }

            int totalCellsCount = this.PlayfieldSize * this.PlayfieldSize;

            //CellView cellView;
            int fifteenPercentCellsCount = (int)Math.Floor(totalCellsCount * 0.15);
            int thirtyPercentCellsCount  = (int)Math.Floor(totalCellsCount * 0.30);

            int minesCount = RandomGenerator.GetRandomNumber(fifteenPercentCellsCount, thirtyPercentCellsCount + 1);

            for (int i = 0; i < minesCount; i++)
            {
                int mineRowPosition = RandomGenerator.GetRandomNumber(0, PlayfieldSize);
                int mineColPosition = RandomGenerator.GetRandomNumber(0, PlayfieldSize);

                ICell bombCell = CellFactory.CreateCell(CellType.Bomb);
                bombCell.X = mineRowPosition;
                bombCell.Y = mineColPosition;
                this.cells[mineRowPosition, mineColPosition] = bombCell;
                //Console.WriteLine(this.playfield[mineRowPosition, mineColPosition].CellView);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 지정된 위치에 적합한 Cell 객체를 생성한다.
        /// </summary>
        /// <param name="nRow"></param>
        /// <param name="nCol"></param>
        /// <returns></returns>
        Cell SpawnCellForStage(int nRow, int nCol)
        {
            Debug.Assert(m_StageInfo != null);
            Debug.Assert(nRow < m_StageInfo.row && nCol < m_StageInfo.col);

            return(CellFactory.SpawnCell(m_StageInfo, nRow, nCol));
        }
Exemplo n.º 14
0
    public static void LoadInfo(InfoContainer info)
    {
        if (info != null)
        {
            AllCells           = info.AllCells.ToList();
            GameScore          = info.GameScore;
            GameHighScore      = info.GameHighScore;
            PreviousScore      = info.PreviousScore;
            isUndone           = info.IsUndone;
            GameField          = info.GameField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            PreviousMoveField  = info.PreviousMoveField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            TemporaryMoveField = info.TemporaryMoveField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            CellFactory.Load(info.CurrentId);
            for (int i = 0; i < Config.FieldHeight; i++)
            {
                for (int j = 0; j < Config.FieldWidth; j++)
                {
                    if (GameField[i, j] != null)
                    {
                        GameField[i, j] = AllCells.Find(c => GameField[i, j].id == c.id);
                    }
                }
            }

            foreach (var cell in AllCells)
            {
                cell.isNew = true;
            }
        }
        //GarbageCollect();
    }
Exemplo n.º 15
0
 private void OnDestoy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="convertView">The convert view.</param>
        /// <param name="parent">The parent.</param>
        /// <returns>Android.Views.View.</returns>
        public global::Android.Views.View GetCell(int position, global::Android.Views.View convertView, ViewGroup parent)
        {
            var item           = this.Element.ItemsSource.Cast <object>().ElementAt(position);
            var viewCellBinded = (Element.ItemTemplate.CreateContent() as ViewCell);

            viewCellBinded.BindingContext = item;
            return(CellFactory.GetCell(viewCellBinded, convertView, parent, Context, Element));
            //var view =  Xamarin.Forms.Platform.Android.Platform.CreateRenderer(viewCellBinded.View);
            //// Platform.SetRenderer (viewCellBinded.View, view);
            //view.ViewGroup.LayoutParameters = new  Android.Widget.GridView.LayoutParams (Convert.ToInt32(this.Element.ItemWidth), Convert.ToInt32(this.Element.ItemHeight));
            //view.ViewGroup.SetBackgroundColor (global::Android.Graphics.Color.Blue);
            //return view.ViewGroup;


            //                this.AddView (this.view.ViewGroup);

            //            GridViewCellRenderer render = new GridViewCellRenderer ();
            //
            //            return render.GetCell (viewCellBinded, convertView, parent, this.Context);;
            //          //  view.LayoutParameters = new GridView.LayoutParams (this.Element.ItemWidth,this.Element.ItemHeight);
            //            return view;
            //            ImageView imageView;
            //
            //            if (convertView == null) {  // if it's not recycled, initialize some attributes
            //                imageView = new ImageView (Forms.Context);
            //                imageView.LayoutParameters = new GridView.LayoutParams (85, 85);
            //                imageView.SetScaleType (ImageView.ScaleType.CenterCrop);
            //                imageView.SetPadding (8, 8, 8, 8);
            //            } else {
            //                imageView = (ImageView)convertView;
            //            }
            //            var imageBitmap = GetImageBitmapFromUrl("http://xamarin.com/resources/design/home/devices.png");
            //            imageView.SetImageBitmap(imageBitmap);
            //            return imageView;
        }
Exemplo n.º 17
0
    public void Awake()
    {
        //Scaling size for 2k, 4k
        float ScreenScaleX = Camera.main.scaledPixelWidth / 3840.0f;
        float ScreenScaleY = Camera.main.scaledPixelHeight / 2160.0f;

        transform.localScale = new Vector3(1.2f * ScreenScaleX, 1.2f * ScreenScaleY, 1);

        CF = null;
        Transform SemiTarget = null;

        //Getting access to the CellFactory without .Find
        foreach (Transform trans in Camera.main.GetComponentsInChildren <Transform>())
        {
            if (trans.gameObject.name == "Canvas")
            {
                SemiTarget = trans;
            }
        }
        foreach (Transform trans in Camera.main.GetComponentsInChildren <Transform>())
        {
            if (trans.gameObject.name == "CellFactory")
            {
                SemiTarget = trans;
            }
        }
        CF = SemiTarget.GetComponent <CellFactory>();
    }
Exemplo n.º 18
0
 /// <summary>
 /// CellFactory method checks if their is an already created
 /// CellFactory instance and returns it. If the instance is 
 /// already create it returns it anyway.
 /// </summary>
 /// <returns>The existing CellFactory instance.</returns>
 public static CellFactory Instance()
 {
     if (instance == null)
     {
         instance = new CellFactory();
     }
     return instance;
 }
Exemplo n.º 19
0
        public global::Android.Views.View GetCell(int position, global::Android.Views.View convertView, ViewGroup parent)
        {
            var item           = this.Element.ItemsSource.Cast <object>().ElementAt(position);
            var viewCellBinded = (Element.ItemTemplate.CreateContent() as ViewCell);

            viewCellBinded.BindingContext = item;
            return(CellFactory.GetCell(viewCellBinded, convertView, parent, Context, Element));
        }
Exemplo n.º 20
0
 protected override Cell[,] CreateMatrix(Color color, CellFactory cellFactory)
 {
     Cell[,] matrix = new Cell[3, 3];
     cellFactory.PositionNewCell(color, matrix, Cells, 0, 0);
     cellFactory.PositionNewCell(color, matrix, Cells, 1, 1);
     cellFactory.PositionNewCell(color, matrix, Cells, 2, 2);
     return(matrix);
 }
Exemplo n.º 21
0
 public void Awake()
 {
     instance = this;
     foreach (var o in cellPrefabsBase)
     {
         cellPrefabs.Add(o.state, o.viewBuilder);
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Generates the output
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string GenerateOutput(string input)
        {
            List <Minefield> minefields = new List <Minefield>();
            Minefield        minefield  = null;
            StringBuilder    output     = new StringBuilder();

            string[] delimiter = { Environment.NewLine };
            string[] words     = input.Split(delimiter, StringSplitOptions.None);

            foreach (string s in words)
            {
                if (MinefieldValidator.IsHeader(s))
                {
                    minefield = MinefieldFactory.Create(minefields.Count + 1, s);
                    minefields.Add(minefield);
                }
                else if (MinefieldValidator.isFooter(s))
                {
                    break;
                }
                else
                {
                    foreach (char c in s.ToCharArray())
                    {
                        if (CellValidator.isMineOrSafe(c.ToString()))
                        {
                            minefield.Cells.Add(CellFactory.Create(c));
                        }
                        else
                        {
                            ErroMessage = "Your input data is not valid.";
                            return(output.ToString());
                        }
                    }
                }
            }
            try
            {
                foreach (Minefield field in minefields)
                {
                    MinesweeperConverter converter = new MinesweeperConverter();
                    converter.ConvertMinefield(field);
                    //header
                    output.Append(String.Format(MinefieldValidator.headerOutput, field.Id));
                    output.Append(Environment.NewLine);
                    //result
                    output.Append(converter.output);
                    output.Append(Environment.NewLine);
                }
            }
            catch
            {
                ErroMessage = "Your input data is not valid.";
                return(output.ToString());
            }

            return(output.ToString());
        }
Exemplo n.º 23
0
        void BindContentView(ContentViewHolder holder, Cell formsCell, int position)
        {
            AView nativeCell = null;
            AView layout     = holder.ItemView;

            holder.SectionIndex = CellCaches[position].SectionIndex;
            holder.RowIndex     = CellCaches[position].RowIndex;

            nativeCell = holder.Body.GetChildAt(0);
            if (nativeCell != null)
            {
                holder.Body.RemoveViewAt(0);
            }

            nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView);

            if (position == _selectedIndex)
            {
                DeselectRow();
                nativeCell.Selected = true;

                _preSelectedCell = nativeCell;
            }

            var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight);

            //it is neccesary to set both
            layout.SetMinimumHeight(minHeight);
            nativeCell.SetMinimumHeight(minHeight);

            if (!_settingsView.HasUnevenRows)
            {
                //if not Uneven, set the larger one of RowHeight and MinRowHeight.
                layout.LayoutParameters.Height = minHeight;
            }
            else if (formsCell.Height > -1)
            {
                //if the cell itself was specified height, set it.
                layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height);
            }
            else
            {
                layout.LayoutParameters.Height = -2; //wrap_content
            }

            if (!CellCaches[position].IsLastCell || _settingsView.ShowSectionTopBottomBorder)
            {
                holder.Border.SetBackgroundColor(_settingsView.SeparatorColor.ToAndroid());
            }
            else
            {
                holder.Border.SetBackgroundColor(Android.Graphics.Color.Transparent);
            }

            holder.Body.AddView(nativeCell, 0);
        }
Exemplo n.º 24
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            indexPath = NSIndexPath.FromRowSection(indexPath.Row, 0);

            var cell = CellFactory.GetCell(tableView, indexPath, CellId, NibName, (cellId, idxPath) => NewListCell(cellId, idxPath));

            UpdateCell(cell, indexPath);

            return(cell);
        }
Exemplo n.º 25
0
        public void CreateCell()
        {
            ICellFactory            factory   = new CellFactory();
            IMinePositionsGenerator generator = Substitute.For <IMinePositionsGenerator>();
            IMinefield field = new Minefield(factory, generator);

            ICell cell = factory.CreateCell(field, 0, 0);

            Assert.AreEqual(new Cell(field, 0, 0), cell);
        }
Exemplo n.º 26
0
    public static Cell CreateAndSetCell(int _x, int _y, int value, bool doAnimate)
    {
        GameField[_y, _x]   = CellFactory.CreateCell(value, doAnimate);
        GameField[_y, _x].x = _x;
        GameField[_y, _x].y = _y;

        RegisterCell(GameField[_y, _x]);

        return(GameField[_y, _x]);
    }
Exemplo n.º 27
0
 internal void GenerateSea()
 {
     for (var i = 0; i < size; i++)
     {
         for (var j = 0; j < size; j++)
         {
             field[i].Add(CellFactory.Create(CellType.Water, i, j));
         }
     }
 }
Exemplo n.º 28
0
 protected override Cell[,] CreateMatrix(Color color, CellFactory cellFactory)
 {
     Cell[,] matrix = new Cell[4, 4];
     cellFactory.PositionNewCell(color, matrix, Cells, 0, 0);
     cellFactory.PositionNewCell(color, matrix, Cells, 1, 0);
     cellFactory.PositionNewCell(color, matrix, Cells, 2, 0);
     cellFactory.PositionNewCell(color, matrix, Cells, 2, 1);
     cellFactory.PositionNewCell(color, matrix, Cells, 2, 2);
     return matrix;
 }
        void BindContentView(ContentBodyViewHolder holder, int position)
        {
            var   formsCell  = holder.RowInfo.Cell;
            AView nativeCell = null;
            AView layout     = holder.ItemView;

            holder.RowInfo = _proxy[position];

            nativeCell = holder.Body.GetChildAt(0);
            if (nativeCell != null)
            {
                holder.Body.RemoveViewAt(0);
            }

            nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView);

            if (position == _selectedIndex)
            {
                DeselectRow();
                nativeCell.Selected = true;

                _preSelectedCell = nativeCell;
            }

            var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight);

            //it is neccesary to set both
            layout.SetMinimumHeight(minHeight);
            nativeCell.SetMinimumHeight(minHeight);

            if (!_settingsView.HasUnevenRows)
            {
                // if not Uneven, set the larger one of RowHeight and MinRowHeight.
                layout.LayoutParameters.Height = minHeight;
            }
            else if (formsCell.Height > -1)
            {
                // if the cell itself was specified height, set it.
                layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height);
            }
            else if (formsCell is ViewCell viewCell)
            {
                // if used a viewcell, calculate the size and layout it.
                var size = viewCell.View.Measure(_settingsView.Width, double.PositiveInfinity);
                viewCell.View.Layout(new Rectangle(0, 0, size.Request.Width, size.Request.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(size.Request.Height);
            }
            else
            {
                layout.LayoutParameters.Height = -2; //wrap_content
            }

            holder.Body.AddView(nativeCell, 0);
        }
Exemplo n.º 30
0
    private void Awake()
    {
        if (Instance)
        {
            Debug.LogWarning("Already created instance of CellFactory");
            Destroy(this);
            return;
        }

        Instance = this;
    }
Exemplo n.º 31
0
        public Grid Update(Grid g)
        {
            Grid newgrid = GridFactory.GetGrid(g.Size);

            for (uint i = 1; i < g.Size - 1; ++i)
            {
                for (uint j = 1; j < g.Size - 1; ++j)
                {
                    int nbAlive = 0;
                    if (g.Cells[i - 1, j - 1].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i - 1, j].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i - 1, j + 1].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i, j - 1].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i, j + 1].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i + 1, j - 1].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i + 1, j].Alive)
                    {
                        nbAlive++;
                    }
                    if (g.Cells[i + 1, j + 1].Alive)
                    {
                        nbAlive++;
                    }

                    if (0 < nbAlive && nbAlive < 3)
                    {
                        newgrid.Cells[i, j] = CellFactory.GetAlive();
                    }
                    if (nbAlive > 5 || nbAlive == 0)
                    {
                        newgrid.Cells[i, j] = CellFactory.GetDead();
                    }
                }
            }
            return(newgrid);
        }
Exemplo n.º 32
0
    //Main method of this class.
    //Create the board using the Factory design pattern with the CellFactory class.
    public Cell[] createBoard(int composition)
    {
        CellType[] listTypeCell = ComposeBoard(composition);
        int        ncells       = listTypeCell.GetLength(0);

        Cell[] Board = new Cell[listTypeCell.GetLength(0)];
        for (int pos = 0; pos < ncells; pos++)
        {
            Board[pos] = CellFactory.GetCell(listTypeCell[pos], list_names[pos]);
        }
        return(Board);
    }
Exemplo n.º 33
0
 public Grid(int size)
 {
     Cells     = new Cell[size, size];
     this.Size = size;
     for (uint i = 0; i < size; ++i)
     {
         for (uint j = 0; j < size; ++j)
         {
             Cells[i, j] = CellFactory.GetDead();
         }
     }
 }
Exemplo n.º 34
0
 public void Generate(CellType cellType, int times)
 {
     times = times > playableArea.Count
         ? playableArea.Count
         : times;
     for (var i = 0; i < times; i++)
     {
         var cell    = GetPlayableCell();
         var newType = CellFactory.Create(cellType, cell.Position.Column, cell.Position.Row);
         newType.Field = this;
         Draw(newType);
     }
 }
Exemplo n.º 35
0
 protected override Cell[,] CreateMatrix(System.Windows.Media.Color color, CellFactory cellFactory)
 {
     string[] lines = Picture.Split('/');
     int height = lines.Length;
     int width = lines[0].Length;
     Cell[,] matrix = new Cell[width, height];
     for (int row = 0; row < height; row++)
     {
         if (lines[row].Length != width)
         {
             throw new FormatException(string.Format("Each line must be the same length ({0})", width));
         }
         for (int col = 0; col < width; col++)
         {
             char ch = lines[row][col];
             if (ch == '1')
             {
                 cellFactory.PositionNewCell(color, matrix, Cells, col, row);
             }
         }
     }
     return matrix;
 }
Exemplo n.º 36
0
 public static CellMatrix Python(
                 [Parameter("The Python Code")] CellMatrix PythonCode,
                 [Parameter("The Parameters ")] CellMatrix TheParameters
                     )
 {
     if (PythonCode.ColumnsInStructure != 1)
     {
         throw new Exception("The Python code should  be one column of strings");
     }
     string theCode = "";
     for (int i = 0; i < PythonCode.RowsInStructure; ++i)
     {
         if (!PythonCode[i, 0].IsEmpty)
         {
             theCode = theCode + PythonCode[i, 0].StringValue() + "\n";
         }
     }
     CellFactory theFactory = new CellFactory();
     scope.SetVariable("Input", TheParameters);
     scope.SetVariable("CellFactory", theFactory);
     ScriptSource source = engine.CreateScriptSourceFromString(theCode, SourceCodeKind.Statements);
     source.Execute(scope);
     return (CellMatrix)scope.GetVariable("Output");
 }
Exemplo n.º 37
0
 protected abstract Cell[,] CreateMatrix(Color color, CellFactory cellFactory);