public void Setup()
 {
     environment = new SimulationEnvironment {
         LightPosition = new Vertex(0, 10000, 0), Temperature = 22
     };
     plant                         = TestPlant.CreatePlant();
     cellFactory                   = new GenericCellFactory();
     optionsService                = PlantSimulatorOptionsHelper.CreateOptionsService();
     divider                       = new GenericCellDivider(cellFactory);
     helper                        = new GeometryHelper();
     cellSizer                     = new GenericCellSizer(helper, new LoggerAdapter <GenericCellSizer>(new NullLogger <GenericCellSizer>()));
     cellCollisionDetection        = new CellCollisionDetection(helper);
     bodySystemSolver              = new GenericCellBodySystemSolver(cellCollisionDetection, cellSizer);
     cellGrower                    = new GenericCellGrower(plant, environment, bodySystemSolver, optionsService);
     descriptorService             = new PlantDescriptorService();
     cellCreator                   = new HexagonCellCreator(cellFactory);
     gridCreator                   = new HexagonalCellGridFactory(cellCreator, CornCellTypeLocator.GetCornCellTypeLocator(), optionsService);
     plantPartCellCreator          = new PlantPartCellCreator(gridCreator);
     internodePartFactory          = new GenericInternodePartFactory(optionsService, gridCreator);
     stemPartFactory               = new GenericStemPartFactory(optionsService, internodePartFactory);
     petiolePartFactory            = new GenericPetiolePartFactory(cellFactory, optionsService);
     nodePartFactory               = new GenericNodePartFactory(optionsService, cellFactory, stemPartFactory, petiolePartFactory);
     internodePlantPartDevelopment = new InternodePartDevelopment(optionsService, nodePartFactory, cellGrower, descriptorService, internodePartFactory);
     rootFactory                   = new GenericRootPartFactory(optionsService, plantPartCellCreator);
     rootPlantPartDevelopment      = new RootPartDevelopment(optionsService, nodePartFactory, rootFactory, cellGrower, descriptorService);
     developer                     = new PlantPartDeveloper(internodePlantPartDevelopment, rootPlantPartDevelopment);
     sucroseCarrierCollection      =
         new SucroseCarrierCollection(
             new LoggerAdapter <SucroseCarrierCollection>(new NullLogger <SucroseCarrierCollection>()));
     sucroseTransporter     = new SucroseTransporter(cellCollisionDetection, helper, sucroseCarrierCollection, new LoggerAdapter <FluidTransporter <Sucrose> >(new NullLogger <FluidTransporter <Sucrose> >()));
     plantGrower            = new GenericPlantGrower(bodySystemSolver, developer, sucroseTransporter);
     runner                 = new GenericPlantRunner(plant, environment, plantGrower, new FluidsPlantCycle(plant, optionsService, sucroseCarrierCollection, new LoggerAdapter <FluidsPlantCycle>(new NullLogger <FluidsPlantCycle>())));
     RangeExtensions.Random = new Random(optionsService.Options.Simulation.RandomSeed);
 }
示例#2
0
        public SnakeObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
            : base(cellFactory, eventFactory)
        {
            _body   = new Queue <ICell>();
            _points = new Info("Points", 400, ConsoleColor.Magenta, 0, true);
            _info.Add(_points);
            _initialLifes           = int.Parse(dataProvider.Get("lifes"));
            Lifes                   = _initialLifes;
            _pointsToAdditionalLife = int.Parse(dataProvider.Get("pointsToAdditionalLife"));
            InitialLength           = int.Parse(dataProvider.Get("initialSnakeLength"));
            MaxLength               = int.Parse(dataProvider.Get("maxSnakeLength"));
            _timeToBomb             = int.Parse(dataProvider.Get("timeToBomb"));
            _bombRange              = int.Parse(dataProvider.Get("bombRange"));
            CurrentDirection        = Direction.Down;
            _stopwatch              = new Stopwatch();
            _stopwatch.Start();
            _bombCount = 0;

            _immortal = false;
            _immortalMoveStopwatch = new Stopwatch();
            _immortalMovePeriod    = int.Parse(dataProvider.Get("immortalMovePeriod"));

            _lifes = new Info("Lifes", 100, ConsoleColor.Green, Lifes, true);
            _info.Add(_lifes);
            _remainingFoods = new Info("Remaining foods", 500, ConsoleColor.Blue, MaxLength - Length, true);
            _info.Add(_remainingFoods);
            _timeToGetTimeBonus       = int.Parse(dataProvider.Get("timeGetTimeBonus"));
            _remainingTimeToTimeBonus = new Info("Time to get a timebonus", 700, ConsoleColor.Cyan, _timeToGetTimeBonus, false);
            _info.Add(_remainingTimeToTimeBonus);
            _timeToGetBomb = new Info("Time to get a bomb", 800, ConsoleColor.DarkMagenta, _timeToBomb, false);
            _info.Add(_timeToGetBomb);
            _bomb = new Info("Bombs", 900, ConsoleColor.DarkRed, _bombCount, true);
            _info.Add(_bomb);
        }
示例#3
0
 public Tissue2DFactory(ICellFactory cellFactory, IGermFactory germFactory, IShuffle shuffler)
 {
     _tissue      = ImmutableDictionary <Location, ICell> .Empty;
     _cellFactory = cellFactory ?? throw new ArgumentNullException(nameof(cellFactory));
     _germFactory = germFactory ?? throw new ArgumentNullException(nameof(germFactory));
     _shuffler    = shuffler ?? throw new ArgumentNullException(nameof(shuffler));
 }
 public void AddFactory(ICellFactory factory)
 {
     for(var i = 0; i < factory.Weighting; i++)
     {
         _factories.Add(factory);
     }
     _factories = _factories.OrderBy(x => Guid.NewGuid()).ToList();
 }
示例#5
0
 public void AddFactory(ICellFactory factory)
 {
     for (var i = 0; i < factory.Weighting; i++)
     {
         _factories.Add(factory);
     }
     _factories = _factories.OrderBy(x => Guid.NewGuid()).ToList();
 }
示例#6
0
 public GameObject(ICellFactory cellFactory, IGameEventFactory eventFactory)
 {
     _body         = new HashSet <ICell>();
     _info         = new List <IInfo>();
     _cellFactory  = cellFactory;
     _eventFactory = eventFactory;
     BePainted     = true;
 }
示例#7
0
 public BonusObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random           = new Random();
     _stopwatch        = new Stopwatch();
     _remainingTime    = int.Parse(dataProvider.Get("remainingTime"));
     _bonusPossibility = int.Parse(dataProvider.Get("bonusPossibility"));
 }
示例#8
0
 public SnowInTheAirObject(ICellFactory cellFactory, IGameEventFactory eventFactory)
     : base(cellFactory, eventFactory)
 {
     _random          = new Random();
     _direction       = Direction.Down;
     _intensity       = 1;
     _currentPosition = 0;
 }
示例#9
0
        public Board(int matrixSize, IFigureFactory figureFactory, ICellFactory cellFactory)
        {
            _figureFactory = figureFactory;
            _cellFactory   = cellFactory;

            Size = matrixSize;

            _cells = CreateCells();
        }
示例#10
0
 public FilterCellFactory(C1FlexGridFilter filter, C1FlexGrid flex)
 {
     _flex = flex;
     _gridFilter = filter;
     _baseCellFactory = flex.GetCellFactory();
     _flex.SizeChanged += _flex_ScrollPositionChanging;
     _flex.ScrollPositionChanging += _flex_ScrollPositionChanging;
     Editor = new ColumnFilterEditor();
 }
        public BoardFactory(ICellFactory cellFactory)
        {
            if (cellFactory == null)
            {
                throw new ArgumentNullException("cellFactory");
            }

            _cellFactory = cellFactory;
        }
示例#12
0
        //create playfield grid of x by y size Minimum is 4x4
        public GridPlayField(ICellFactory cellFactory, int rows, int columns)
        {
            if (rows < 4 || columns < 4)
                throw new ArgumentException("rows and columns value can't ne less than 4");

            _rows = rows;
            _columns = columns;
            _internalGrid = new AbstractCell[rows,columns];
            _cellFactory = cellFactory;
        }
示例#13
0
 public SnowOnTheGroundObject(ICellFactory cellFactory, IGameEventFactory eventFactory)
     : base(cellFactory, eventFactory)
 {
     _width            = 3;
     _meltingIntensity = 3;
     _random           = new Random();
     _currentPosition  = 0;
     //_bodyForDrawing = new List<ICell>();
     BePainted = false;
 }
 public GenericNodePartFactory(IPlantSimulatorOptionsService optionsService,
                               ICellFactory cellFactory,
                               IStemPartFactory stemFactory,
                               IPetiolePartFactory petioleFactory)
 {
     this.optionsService = optionsService;
     this.cellFactory    = cellFactory;
     this.stemFactory    = stemFactory;
     this.petioleFactory = petioleFactory;
     random = new Random(Options.Simulation.RandomSeed);
 }
示例#15
0
 public FoodObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random             = new Random();
     _stopwatch          = new Stopwatch();
     _timeFoodBeEaten    = int.Parse(dataProvider.Get("timeFoodBeEaten"));
     _remainingTimeToEat = new Info("Time to get a food", 600, ConsoleColor.DarkGreen, _timeFoodBeEaten, false);
     _info.Add(_remainingTimeToEat);
     _timeToBomb       = int.Parse(dataProvider.Get("timeToBomb"));
     _timeGetTimeBonus = int.Parse(dataProvider.Get("timeGetTimeBonus"));
 }
示例#16
0
 public WallObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random           = new Random();
     Level             = 1;
     MaxLevel          = int.Parse(dataProvider.Get("maxLevel"));
     WallSpreadDencity = int.Parse(dataProvider.Get("wallSpreadDencity"));
     MinWallLength     = int.Parse(dataProvider.Get("minWallLength"));
     MaxWallLength     = int.Parse(dataProvider.Get("maxWallLength"));
     _level            = new Info("Level", 200, ConsoleColor.DarkGray, Level, true);
     _info.Add(_level);
 }
示例#17
0
 public Scenario(string[] scenario, ICellFactory factory)
 {
     this.scenario = new Cell[scenario.Length, scenario.Max(l => l.Length)];
     for (int i = 0; i < scenario.Length; i++)
     {
         for (int j = 0; j < scenario[i].Length; j++)
         {
             this.scenario[i, j] = factory.Create(i, j, scenario[i][j]);
         }
         for (int j = scenario[i].Length; j < this.scenario.GetLength(1); j++)
         {
             this.scenario[i, j] = factory.Create(i, j, ' ');
         }
     }
 }
示例#18
0
        public void Create_Tissue2D_CorrectCellsRatiosAreCreated(int x, int y,
                                                                 [FloatAsRatio] float variableRatio,
                                                                 [Frozen(Matching.ImplementedInterfaces)]
                                                                 NullShuffle shuffler, //do not shuffle but inject when generating sut
                                                                 [Frozen] ICellFactory cellFactory,
                                                                 Tissue2DFactory sut)
        {
            var infected = variableRatio;
            var healthy  = 1 - variableRatio;

            (int expectedHealthyCells, int expectedInfectedCells, int expectedEmptyPlaces)
                = CalculateExpectations(x, y, healthy, infected);

            _ = sut.Create(x, y, healthy, infected);

            var cellFactoryMock = Mock.Get(cellFactory);

            VerifyCorrectCellCounts(cellFactoryMock, expectedHealthyCells, expectedInfectedCells, expectedEmptyPlaces);
        }
示例#19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CellMatrix"/> class.
        /// </summary>
        /// <param name="cfg">The configuration.</param>
        protected CellMatrix(ICellMatrixConfiguration cfg)
            : base(cfg.sizeX, cfg.sizeZ)
        {
            Initialize(cfg);

            if (GameServices.heightStrategy.heightMode == HeightSamplingMode.NoHeightSampling)
            {
                _cellFactory            = FlatCell.factory;
                _heightSettingsProvider = new FlatCellHeightSettingsProvider(this);
            }
            else if (GameServices.heightStrategy.useGlobalHeightNavigationSettings)
            {
                _cellFactory            = StandardCell.factory;
                _heightSettingsProvider = new StandardCellHeightSettingsProvider(this);
            }
            else
            {
                _cellFactory            = RichCell.factory;
                _heightSettingsProvider = new RichCellHeightSettingsProvider(this);
            }
        }
        private void Write(string filename)
        {
            using (var spreadSheet = SpreadsheetDocument.Open(filename, true))
            {
                _factory = new CellFactory();

                var workbookPart  = spreadSheet.WorkbookPart;
                var worksheetPart = workbookPart.WorksheetParts.First();

                var sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>();

                var startRowIndex = 2;
                foreach (DataGridViewRow dataRow in DatabaseGridView.Rows)
                {
                    var contentRow = CreateContentRow(dataRow, startRowIndex);

                    sheetData.AppendChild(contentRow);
                    startRowIndex++;
                }
            }
        }
        private void Write(string filename)
        {
            using (var spreadSheet = SpreadsheetDocument.Open(filename, true))
            {
                _factory = new CellFactory();

                var workbookPart = spreadSheet.WorkbookPart;
                var worksheetPart = workbookPart.WorksheetParts.First();

                var sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();

                var startRowIndex = 2;
                foreach (DataGridViewRow dataRow in DatabaseGridView.Rows)
                {
                    var contentRow = CreateContentRow(dataRow, startRowIndex);

                    sheetData.AppendChild(contentRow);
                    startRowIndex++;
                }
            }
        }
示例#22
0
 public GenericCellDivider(ICellFactory cellFactory)
 {
     this.cellFactory = cellFactory;
 }
示例#23
0
 public MinefieldFactory()
 {
     cellFactory            = new CellFactory();
     minePositionsGenerator = new RandomMinePositionGenerator();
 }
 public ConsoleDeskFieldGenerator()
 {
     _cellFactory = new ConsoleCellFactory();
 }
示例#25
0
 public void AddFactory(ICellFactory factory)
 {
     throw new NotImplementedException();
 }
示例#26
0
 public CellDivider(ICellFactory cellFactory)
 {
     _cellFactory = cellFactory ?? throw new ArgumentNullException(nameof(cellFactory));
 }
 public FlyweightCell(ICellFactory factory)
 {
     this.Factory    = factory;
     this.cellsInUse = new Dictionary <string, ICellObject>();
 }
示例#28
0
 public Engine(IIOHandler iOHandler, ICellFactory cellFactory)
 {
     this.iOHandler   = iOHandler;
     this.cellFactory = cellFactory;
 }
示例#29
0
 public GroundObject(ICellFactory cellFactory, IGameEventFactory eventFactory)
     : base(cellFactory, eventFactory)
 {
     _random          = new Random();
     _currentPosition = 0;
 }
示例#30
0
 public Minefield(ICellFactory cellFactory, IMinePositionsGenerator minePositionsGenerator)
 {
     this.cellFactory            = cellFactory;
     this.minePositionsGenerator = minePositionsGenerator;
     State = FieldState.NotStarted;
 }
示例#31
0
 public GenericPetiolePartFactory(ICellFactory cellCreator, IPlantSimulatorOptionsService optionsService)
 {
     this.cellCreator    = cellCreator;
     this.optionsService = optionsService;
 }
示例#32
0
 public MinefieldWithCheckFillCalled(ICellFactory cellFactory, IMinePositionsGenerator minePositionsGenerator) : base(cellFactory, minePositionsGenerator)
 {
     FillMethodCalled = false;
 }
示例#33
0
 public void AddFactory(ICellFactory factory)
 {
     throw new NotImplementedException();
 }
示例#34
0
 public HexagonCellCreator(ICellFactory cellFactory)
 {
     this.cellFactory = cellFactory;
 }
示例#35
0
 static C1FlexGrid()
 {
     //            _skipLicenseCheck = false;
     _defaultCellFactory = new CellFactory();
     _defaultGroupHeaderConverter = new GroupHeaderConverter();
     _ptEmpty = new Point(0, 0);
     _errorBorderBrush = new SolidColorBrush(Color.FromArgb(255, 220, 0, 12));
     _errorBorderBrush.Freeze();
     ItemsSourceProperty = Register("ItemsSource", typeof (IEnumerable));
     SelectedItemProperty = Register("SelectedItem", typeof (object));
     SelectedItemsProperty = Register("SelectedItems", typeof (IList));
     SelectedIndexProperty = Register("SelectedIndex", typeof (int), false, -1);
     IsSynchronizedWithCurrentItemProperty = Register("IsSynchronizedWithCurrentItem", typeof (bool), false, true);
     AutoGenerateColumnsProperty = Register("AutoGenerateColumns", typeof (bool), false, true);
     AllowMergingProperty = Register("AllowMerging", typeof (AllowMerging), true, AllowMerging.None);
     AllowSortingProperty = Register("AllowSorting", typeof (bool), false, true);
     ShowSortProperty = Register("ShowSort", typeof (bool), true, true);
     AllowAddNewProperty = Register("AllowAddNew", typeof (bool), false, false);
     NewRowPositionProperty = Register("NewRowPosition", typeof (NewRowPosition), false, NewRowPosition.Bottom);
     NewRowBackgroundProperty = Register("NewRowBackground", typeof (Brush), true);
     DeferScrollingProperty = Register("DeferScrolling", typeof (DeferScrolling), false, DeferScrolling.None);
     AllowResizingProperty = Register("AllowResizing", typeof (AllowResizing), false, AllowResizing.Columns);
     AllowDraggingProperty = Register("AllowDragging", typeof (AllowDragging), false, AllowDragging.Columns);
     KeyActionEnterProperty = Register("KeyActionEnter", typeof (KeyAction), false, KeyAction.Default);
     KeyActionTabProperty = Register("KeyActionTab", typeof (KeyAction), false, KeyAction.Default);
     ClipboardCopyModeProperty = Register("ClipboardCopyMode", typeof (ClipboardCopyMode), false, ClipboardCopyMode.IncludeColumnHeaders);
     ClipboardPasteModeProperty = Register("ClipboardPasteMode", typeof (ClipboardCopyMode), false, ClipboardCopyMode.None);
     IsReadOnlyProperty = Register("IsReadOnly", typeof (bool));
     ShowMarqueeProperty = Register("ShowMarquee", typeof (bool), true);
     ShowGroupsProperty = Register("ShowGroups", typeof (bool), false, true);
     GroupRowPositionProperty = Register("GroupRowPosition", typeof (GroupRowPosition), false, GroupRowPosition.AboveData);
     SelectionModeProperty = Register("SelectionMode", typeof (SelectionMode), false, SelectionMode.CellRange);
     KeepCurrentVisibleProperty = Register("KeepCurrentVisible", typeof (bool));
     HeadersVisibilityProperty = Register("HeadersVisibility", typeof (HeadersVisibility), false, HeadersVisibility.All);
     AreRowGroupHeadersFrozenProperty = Register("AreRowGroupHeadersFrozen", typeof (bool), false, true);
     MinColumnWidthProperty = Register("MinColumnWidth", typeof (double));
     MaxColumnWidthProperty = Register("MaxColumnWidth", typeof (double));
     MinRowHeightProperty = Register("MinRowHeight", typeof (double));
     MaxRowHeightProperty = Register("MaxRowHeight", typeof (double));
     TreeIndentProperty = Register("TreeIndent", typeof (double), false, 14.0);
     VerticalScrollBarVisibilityProperty = Register("VerticalScrollBarVisibility", typeof (ScrollBarVisibility), false, ScrollBarVisibility.Auto);
     HorizontalScrollBarVisibilityProperty = Register("HorizontalScrollBarVisibility", typeof (ScrollBarVisibility), false, ScrollBarVisibility.Auto);
     GridLinesVisibilityProperty = Register("GridLinesVisibility", typeof (GridLinesVisibility), true, GridLinesVisibility.Vertical);
     RowBackgroundProperty = Register("RowBackground", typeof (Brush), true);
     AlternatingRowBackgroundProperty = Register("AlternatingRowBackground", typeof (Brush), true);
     GridLinesBrushProperty = Register("GridLinesBrush", typeof (Brush), true);
     FrozenLinesBrushProperty = Register("FrozenLinesBrush", typeof (Brush), true);
     HeaderGridLinesBrushProperty = Register("HeaderGridLinesBrush", typeof (Brush), true);
     HeaderFontWeightProperty = Register("HeaderFontWeight", typeof (FontWeight?), true);
     ColumnHeaderBackgroundProperty = Register("ColumnHeaderBackground", typeof (Brush), true);
     ColumnHeaderForegroundProperty = Register("ColumnHeaderForeground", typeof (Brush), true);
     RowHeaderBackgroundProperty = Register("RowHeaderBackground", typeof (Brush), true);
     RowHeaderForegroundProperty = Register("RowHeaderForeground", typeof (Brush), true);
     ColumnHeaderSelectedBackgroundProperty = Register("ColumnHeaderSelectedBackground", typeof (Brush), true);
     RowHeaderSelectedBackgroundProperty = Register("RowHeaderSelectedBackground", typeof (Brush), true);
     TopLeftCellBackgroundProperty = Register("TopLeftCellBackground", typeof (Brush), true);
     BottomRightCellBackgroundProperty = Register("BottomRightCellBackground", typeof (Brush));
     GroupRowBackgroundProperty = Register("GroupRowBackground", typeof (Brush), true);
     GroupRowForegroundProperty = Register("GroupRowForeground", typeof (Brush), true);
     CursorBackgroundProperty = Register("CursorBackground", typeof (Brush), true);
     CursorForegroundProperty = Register("CursorForeground", typeof (Brush), true);
     SelectionBackgroundProperty = Register("SelectionBackground", typeof (Brush), true);
     SelectionForegroundProperty = Register("SelectionForeground", typeof (Brush), true);
     EditorBackgroundProperty = Register("EditorBackground", typeof (Brush), true);
     EditorForegroundProperty = Register("EditorForeground", typeof (Brush), true);
     GroupHeaderConverterProperty = Register("GroupHeaderConverter", typeof (IValueConverter), true);
     ChildItemsPathProperty = Register("ChildItemsPath", typeof (string));
     ShowOutlineBarProperty = Register("ShowOutlineBar", typeof (bool), true, false);
     ShowErrorsProperty = Register("ShowErrors", typeof (bool), true, true);
     AutoCompleteProperty = Register("AutoComplete", typeof (bool), false, false);
 }