public void NextGen_GridReturnedFromGenServiceBecomesNewState() { // Arrange var rows = Faker.RandomNumber.Next(2, 10); var cols = Faker.RandomNumber.Next(2, 10); // Create a dummy grid to be returned by the Generation service var gridToReturn = new GridBuilder() .WithCols(cols) .WithRows(rows) .Build(); // Creat a stub gen service, give it the grid to return var genService = new GenerationServiceBuilder() .NextGeneration_Returns(gridToReturn) .Build(); // Act var sut = _createSubjectUnderTest(rows, cols, genService: genService); sut.StartGame(); sut.NextGen(); // Assert Assert.AreSame(gridToReturn, sut.GameState); }
// Use this for initialization void Start() { cells = new Cell[columns, rows]; instance = this; for (int i = 0; i < columns; i++) { for (int j = 0; j < rows; j++) { GameObject go = Instantiate(cellPref, new Vector3(startPosition.x + j + cellSize, startPosition.y + i + cellSize, 0), Quaternion.identity) as GameObject; go.transform.SetParent(gameObject.transform); cells[i, j] = go.GetComponent <Cell>(); cells[i, j].AddJewel(cells[i, j].jewel.Init()); cells[i, j].position = new Cell.Position() { x = j, y = i }; } } ParseGrid(); }
public void NextGen_EmitsEventWithNewState() { // Arrange var rows = Faker.RandomNumber.Next(2, 10); var cols = Faker.RandomNumber.Next(2, 10); // Create a dummy grid to be returned by the Generation service var newGameState = new GridBuilder() .WithCols(cols) .WithRows(rows) .Build(); // Creat a stub gen service, give it the grid to return var genService = new GenerationServiceBuilder() .NextGeneration_Returns(newGameState) .Build(); // Create Event Emitter var eventEmitter = new GameEventEmitterBuilder().Build(); // Act var sut = _createSubjectUnderTest(rows, cols, genService: genService, eventEmitter: eventEmitter); sut.StartGame(); sut.NextGen(); // Assert eventEmitter .Received(1) .NewGameStateEvent(newGameState); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.LogError("OOPSALA we have an ERROR! More than one instance bein created"); Destroy(gameObject); } _mapSettings = transform.parent.GetComponent <MapSettings>(); if (_mapSettings == null) { Debug.LogError("OOPSALA we have an ERROR!"); } _nodeBuilder = transform.parent.GetComponentInChildren <NodeBuilder>(); if (_nodeBuilder == null) { Debug.LogError("OOPSALA we have an ERROR!"); } _GridLocToScriptLookup = new Dictionary <Vector3, CubeLocationScript>(); }
public static GridBuilder <T> ConfigurarGrilla <T>(this GridBuilder <T> builder, string id, Action <DataSourceBuilder <T> > dataSource, Action <GridExcelBuilder> excel, bool edicionInline = true, int tamPagina = 25, bool seleccionar = false, bool edicionMultiple = false) where T : class { return(builder .Name(id) .Sortable() .Filterable() .AutoBind(true) .Excel(excel) .Pageable(pageable => pageable .Refresh(true) .PageSizes(new[] { 10, 25, 50, 100 }) .ButtonCount(5) .Messages(mm => mm .ItemsPerPage(Txt.Kendo.ItemsPerPage) .First(Txt.Kendo.First) .Last(Txt.Kendo.Last) .Previous(Txt.Kendo.Previous) .Next(Txt.Kendo.Next))) .Selectable(c => c .Enabled(seleccionar) .Mode(edicionMultiple ? GridSelectionMode.Multiple : GridSelectionMode.Single) ) .Editable(editable => { editable.DisplayDeleteConfirmation(false); editable.Mode(GridEditMode.InLine); editable.Enabled(edicionInline); }) .DataSource(dataSource)); }
public static GridBuilder <T> DefaultSettings <T>(this GridBuilder <T> builder, ILocalizer localizer) where T : class { // builder.Scrollable(a => a.Height("auto")) builder.Pageable(a => { a.Messages(msg => { msg.Display(localizer["PageableMsg"]); msg.Empty(localizer["GridIsEmpty"]); msg.ItemsPerPage(localizer["ItemsPerPage"]); msg.Of(localizer["KendoOf"]); msg.MorePages(localizer["MorePages"]); msg.Refresh(localizer["Refresh"]); msg.Previous(localizer["Previous"]); msg.Next(localizer["Next"]); msg.Last(localizer["Last"]); msg.First(localizer["First"]); msg.Page(localizer["Page"]); }); a.AlwaysVisible(true); a.ButtonCount(5); a.Input(false); a.PreviousNext(true); a.Responsive(true); }); return(builder); }
/// <summary> /// Creates a blank grid of a given size. /// </summary> /// <param name="sizeX">The x-axis size.</param> /// <param name="sizeY">The y-axis size.</param> private void initialize(int sizeX, int sizeY) { if (_gridCellPrefab == null) { Debug.LogError("CellPrefab not assigned to GridManager.", gameObject); return; } _gridRoot = new GameObject("Root"); _gridRoot.transform.SetParent(transform, false); _grid = GridBuilder.Create(_gridRoot.transform, _gridCellPrefab, sizeX, sizeY, _cellSize, _borderWidth, _borderCellPrefab); _gridMask = new bool[sizeX, sizeY]; _emptyCellsList = new List <GridCell>(sizeX * sizeY); for (int x = 0; x < _gridSize; ++x) { for (int y = 0; y < _gridSize; ++y) { _gridMask[x, y] = false; _emptyCellsList.Add(_grid[x, y]); } } Pathfinder.Instance.Initialize(); }
// Update is called once per frame public static void Visualize() { if (IsFindingBuildingLocation()) { if (!_cachedCommander.CachedHud._mouseOverHud) { if (!GridBuilder.IsMovingBuilding) { GridBuilder.StartMove(tempStructure); } FindStructureLocation(); if (!_constructingWall) { Vector2d pos = new Vector2d(tempObject.transform.position.x, tempObject.transform.position.z); tempStructure.ValidPlacement = GridBuilder.UpdateMove(pos); if (tempStructure.ValidPlacement && SelectionManager.MousedAgent.IsNull()) { SetTransparentMaterial(tempObject, GameResourceManager.AllowedMaterial); } else { SetTransparentMaterial(tempObject, GameResourceManager.NotAllowedMaterial); } } } } }
public GridBuilderTests() { _configMock = new Mock <IOptions <AppSettings> >(MockBehavior.Strict); _shipFactoryMock = new Mock <IShipFactory>(MockBehavior.Strict); _gridMock = new Mock <IGrid>(MockBehavior.Strict); _sut = new GridBuilder(_configMock.Object, _shipFactoryMock.Object, _gridMock.Object); }
internal void InitializeForm() { InitializeComponent(); LookFeelUtil.SetLookAndFeel(contentContextMenuStrip); SetLanguage(); Form1 form = (Form1)Owner; String filename = ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage); CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); String xmlString = pageTextBox.Text; //XmlUrlResolver resolver = new XmlUrlResolver(); //resolver.Credentials = CredentialCache.DefaultCredentials; XmlDocument xmldoc = new XmlDocument(); XmlReaderSettings settings = new XmlReaderSettings { IgnoreWhitespace = true, //XmlResolver = resolver, IgnoreComments = true, DtdProcessing = DtdProcessing.Parse //ProhibitDtd = false }; StringReader reader = new StringReader(xmlString); XmlReader render = !String.IsNullOrEmpty(filename) ? XmlReader.Create(reader, settings, filename) : XmlReader.Create(reader, settings); try { xmldoc.Load(render); } catch (Exception exception) { String error = String.Format(LanguageUtil.GetCurrentLanguageString("Error", Name), exception.Message); WindowManager.ShowAlertBox(form, error); reader.Dispose(); render.Close(); return; } reader.Dispose(); render.Close(); GridBuilder builder = new GridBuilder(); GridCellGroup xmlgroup = new GridCellGroup { Flags = GroupFlags.Overlapped | GroupFlags.Expanded }; builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes); root = new GridCellGroup(); root.Table.SetBounds(1, 2); root.Table[0, 0] = new GridHeadLabel { Text = "XML" }; root.Table[0, 1] = xmlgroup; xmlGridView.Cell = root; xmlGridView.Font = pageTextBox.Font; xmlGridView.ForeColor = pageTextBox.ForeColor; xmlGridView.BackColor = pageTextBox.BackColor; }
static void Init() { // Get existing open window or if none, make a new one: GridBuilder window = (GridBuilder)EditorWindow.GetWindow(typeof(GridBuilder)); window.Show(); }
/// <summary> /// 获取标签生成器 /// </summary> protected override TagBuilder GetTagBuilder() { var builder = new GridBuilder(); Config(builder); return(builder); }
protected override Grid <VendorContact> BuildGrid() { GridBuilder.ImageButtonColumn() .ForAction <VendorContactController>(x => x.Delete(null)) .ToPerformAction(ColumnAction.Delete) .ImageName("delete.png") .ToolTip(WebLocalizationKeys.DELETE_ITEM); GridBuilder.ImageButtonColumn() .ForAction <VendorContactController>(x => x.AddEdit(null)) .ToPerformAction(ColumnAction.Edit) .ImageName("page_edit.png") .ToolTip(WebLocalizationKeys.EDIT_ITEM); GridBuilder.LinkColumnFor(x => x.FullName) .ForAction <VendorContactController>(x => x.Display(null)) .ToPerformAction(ColumnAction.Display) .IsSortable(false) .ToolTip(WebLocalizationKeys.DISPLAY_ITEM); GridBuilder.DisplayFor(x => x.Email).FormatValue(GridColumnFormatter.EMail); GridBuilder.DisplayFor(x => x.Phone); GridBuilder.DisplayFor(x => x.Address1).DisplayHeader(WebLocalizationKeys.ADDRESS); GridBuilder.DisplayFor(x => x.City); GridBuilder.DisplayFor(x => x.State); GridBuilder.DisplayFor(x => x.Fax); return(this); }
public void RoverRunsIntoObstacleAndReports() { var grid = new GridBuilder() .WithDimensions(2, 2) .WithObstacleAt(1, 0) .Build(); var startingPosition = new PositionBuilder() .OnGrid(grid) .WithCoordinates(new Coordinates(0, 0)) .Facing(DirectionEnum.West) .Build(); var rover = new RoverBuilder() .AtPosition(startingPosition) .Build(); var roverControl = new RoverControlBuilder() .ForRover(rover) .Build(); roverControl.SendCommands("f"); var detectedObstacle = roverControl.InvokeCommands(); Assert.Equal(startingPosition, rover.Position); Assert.True(detectedObstacle); Assert.Empty(roverControl.Commands); }
public static GridBuilder <T> SetDefaultSettings <T>(this GridBuilder <T> gb) where T : class { gb .Filterable(filter => { filter.Mode(GridFilterMode.Menu).Extra(false); }) .Sortable() .Pageable(pageable => pageable .Refresh(true) .PageSizes(new[] { "15", "30", "50", "100", "All" }) .ButtonCount(5)) .Selectable() .NoRecords(nr => nr.Template("<div style='padding: 5px;'>No Record Found</div>")) .DataSource(source => { source .Ajax() .PageSize(15) .Events(events => events.Error("error_handler")) .ServerOperation(true); }); return(gb); }
private Grid UseGridBuilder(int Width, int Height, int Mines) { GridBuilder gb = new GridBuilder(); Grid g = gb.BuildGrid(Width, Height, Mines); return(g); }
public static GridBuilder <T> TestGridAsync <T>(this GridBuilder <T> helper, string name, bool flag) where T : class { return(helper .Name(name) .Columns( collumns => { if (flag) { collumns.Command( commands => { commands.Edit(); }).Title("Commands").Width(200); } }) .ToolBar(toolbar => { if (flag) { toolbar.Create(); } } ) .Groupable() .Pageable() .Sortable() .Scrollable() .Filterable() .Pageable()); }
private static string CreateLeagueTableGrid(Season season) { var gridBuilder = new GridBuilder <TablePlacing>(); gridBuilder.AddColumn("#", Alignment.Right, tp => tp.Position); gridBuilder.AddColumn("Name", Alignment.Left, tp => tp.TeamName); gridBuilder.AddColumn("Pld", Alignment.Right, tp => tp.Played); gridBuilder.AddColumn("W", Alignment.Right, tp => tp.Won); gridBuilder.AddColumn("D", Alignment.Right, tp => tp.Drawn); gridBuilder.AddColumn("L", Alignment.Right, tp => tp.Lost); gridBuilder.AddColumn("GF", Alignment.Right, tp => tp.GoalsFor); gridBuilder.AddColumn("GA", Alignment.Right, tp => tp.GoalsAgainst); gridBuilder.AddColumn("GD", Alignment.Right, tp => tp.GoalDifference); gridBuilder.AddColumn("Pts", Alignment.Right, tp => tp.Points); gridBuilder.AddColumn("AS", Alignment.Right, tp => tp.AttackingStrength.ToString("N2")); gridBuilder.AddColumn("DW", Alignment.Right, tp => tp.DefensiveWeakness.ToString("N2")); gridBuilder.AddColumn( string.Empty, Alignment.Left, tp => season.League.PositionGroupings .Where(pg => pg.Contains(tp.Position)) .Select(pg => pg.LongName) .Join(", ")); return(gridBuilder.Build(season.Table)); }
/* * Create a road with minimal instructions, helper method for above functions */ Road CreateRoad(Vector2 min_array, Vector2 max_array, bool corner) { Road road_component; // if there is a corner, one straight will have size 0, if so return null if (max_array.x - min_array.x <= 0 || max_array.y - min_array.y <= 0) { return(null); } GameObject new_go = GridBuilder.CreateRectangle(min_array, max_array, this.transform.localScale.y, this.transform.parent, true); // create component, createRoad() and then update if (corner) { road_component = new_go.AddComponent <RoadCorner>(); } else { road_component = new_go.AddComponent <RoadStraight>(); } road_component.CreateRoad(this); return(road_component); }
/* * Called by UpdateConnectionsStraightToStraight() when two straights need to be * replaced by one, and the old roads deleted */ void CreateTwoStraights(RoadStraight otherRoad) { Vector2 min_array = new Vector2(Mathf.Min(grid_position_min.x, otherRoad.grid_position_min.x), Mathf.Min(grid_position_min.y, otherRoad.grid_position_min.y)); Vector2 max_array = new Vector2(Mathf.Max(grid_position_max.x, otherRoad.grid_position_max.x), Mathf.Max(grid_position_max.y, otherRoad.grid_position_max.y)); GameObject new_go = GridBuilder.CreateRectangle(min_array, max_array, this.transform.localScale.y, this.transform.parent, true); // create component, createRoad() and then update RoadStraight road_component = new_go.AddComponent <RoadStraight>(); road_component.CreateRoad(this); /* * print(this.gameObject.name + "is creating two straights"); * StartCoroutine(DelayedUpdateRoad(road_component, otherRoad)); */ road_component.UpdateRoad(this.trafficDirection); Object.Destroy(otherRoad.gameObject); Object.Destroy(this.gameObject); }
public void DataBind() { if (AutoGenerateColumns == true) { var builder = new GridBuilder(this); builder.Populate(this.DataSource); } else { foreach (Object o in this.DataSource) { var gridRow = new GridRow(); foreach (GridColumn col in this.Columns) { if (o != null) { var propertyInfo = o.GetType().GetProperty(col.PropertyName); Object propertyValue = propertyInfo.GetValue(o, null); String cellText; if (propertyValue == null) { cellText = ""; } else { cellText = propertyValue.ToString(); } gridRow.Cells.Add(new GridCell(cellText)); } } this.Rows.Add(gridRow); } } }
protected override Grid <PurchaseOrder> BuildGrid() { GridBuilder.ImageButtonColumn() .ForAction <PurchaseOrderController>(x => x.Delete(null)) .ToPerformAction(ColumnAction.Delete) .ImageName("delete.png") .ToolTip(WebLocalizationKeys.DELETE_ITEM); GridBuilder.ImageButtonColumn() .ForAction <PurchaseOrderController>(x => x.AddEdit(null)) .ToPerformAction(ColumnAction.Redirect) .ImageName("page_edit.png") .ToolTip(WebLocalizationKeys.EDIT_ITEM); GridBuilder.LinkColumnFor(x => x.DateCreated) .ForAction <PurchaseOrderController>(x => x.Display(null)) .ToPerformAction(ColumnAction.Display) .ToolTip(WebLocalizationKeys.DISPLAY_ITEM); GridBuilder.DisplayFor(x => x.Completed); GridBuilder.DisplayFor(x => x.Vendor.Company); GridBuilder.DisplayFor(x => x.SubTotal).FormatValue(GridColumnFormatter.Currency); GridBuilder.DisplayFor(x => x.Tax).FormatValue(GridColumnFormatter.Currency); GridBuilder.DisplayFor(x => x.Fees).FormatValue(GridColumnFormatter.Currency); GridBuilder.DisplayFor(x => x.Total).FormatValue(GridColumnFormatter.Currency); GridBuilder.ImageButtonColumn() .ForAction <PurchaseOrderCommitController>(x => x.PurchaseOrderCommit(null)) .ToPerformAction(ColumnAction.Redirect) .ImageName("delete.png"); return(this); }
protected override Grid <Vendor> BuildGrid() { GridBuilder.ImageButtonColumn() .ForAction <VendorController>(x => x.Delete(null)) .ToPerformAction(ColumnAction.Delete) .ImageName("delete.png") .ToolTip(WebLocalizationKeys.DELETE_ITEM); GridBuilder.ImageButtonColumn() .ForAction <VendorController>(x => x.AddEdit(null)) .ToPerformAction(ColumnAction.Edit) .ImageName("page_edit.png") .ToolTip(WebLocalizationKeys.EDIT_ITEM); GridBuilder.LinkColumnFor(x => x.Company) .ForAction <VendorController>(x => x.Display(null)) .ToPerformAction(ColumnAction.Display) .ToolTip(WebLocalizationKeys.DISPLAY_ITEM); GridBuilder.DisplayFor(x => x.Address1).DisplayHeader(WebLocalizationKeys.ADDRESS); GridBuilder.DisplayFor(x => x.City); GridBuilder.DisplayFor(x => x.State); GridBuilder.DisplayFor(x => x.Phone); GridBuilder.DisplayFor(x => x.Fax); GridBuilder.DisplayFor(x => x.Website); GridBuilder.ImageButtonColumn() .ForAction <VendorContactListController>(x => x.VendorContactList(null)) .ToPerformAction(ColumnAction.Redirect) .ImageName("delete.png"); return(this); }
private void load() { try { GridBuilder builder = new GridBuilder(); GridCellGroup root = new GridCellGroup(); //XmlDocument xmldoc = _editor.XmlEditor.Text.ToXmlDocument(); XmlDocument xmldoc = new XmlDocument(); //do this to remove #whitespace nodes xmldoc.LoadXml(_editor.XmlEditor.Text.ToXmlDocument().OuterXml); builder.ParseNodes(root, null, xmldoc.ChildNodes); _xmlGridView.Cell = root; _lblErrors.Visibility = Visibility.Collapsed; } catch (Exception ex) { _xmlGridView.Cell = null; _lblErrors.Content = "Errors in XML document: " + ex.Message; _lblErrors.Visibility = Visibility.Visible; } }
public static G Build <G>(this G grid, Action <IGridBuilder <G> > action) where G : Grid { var builder = new GridBuilder <G> (grid); action(builder); return(grid); }
public GridBuilderTests() { Mock <HtmlTextWriter> writer = new Mock <HtmlTextWriter>(TextWriter.Null); grid = GridTestHelper.CreateGrid <Customer>(writer.Object, null); builder = new GridBuilder <Customer>(grid); }
private static GridBuilder <TeamSeasonSimulationResult> CreateSimulationGridBuilder(IReadOnlyList <TeamSeasonSimulationResult> teams, IEnumerable <PositionGrouping> positionGroupings) { var gridBuilder = new GridBuilder <TeamSeasonSimulationResult>(); gridBuilder.AddColumn("#", Alignment.Right, tssr => tssr.CurrentPosition); gridBuilder.AddColumn("Name", Alignment.Left, tssr => tssr.TeamName); foreach (var position in Enumerable.Range(1, teams.Count)) { gridBuilder.AddColumn($"#{position}", Alignment.Right, tssr => CalculatePercentage(position, tssr)); } gridBuilder.AddColumn("Avg GF", Alignment.Right, tssr => tssr.GoalsFors.Average().ToString("N1")); gridBuilder.AddColumn("Avg GA", Alignment.Right, tssr => tssr.GoalsAgainsts.Average().ToString("N1")); gridBuilder.AddColumn("Avg GD", Alignment.Right, tssr => tssr.GoalDifferences.Average().ToString("N1")); gridBuilder.AddColumn("Avg Pts", Alignment.Right, tssr => tssr.Points.Average().ToString("N1")); foreach (var positionGrouping in positionGroupings) { gridBuilder.AddColumn(positionGrouping.ShortName, Alignment.Right, tssr => CalculatePercentage(positionGrouping, tssr)); } gridBuilder.AddColumn("Name", Alignment.Left, tssr => tssr.TeamName); return(gridBuilder); }
public void AnEasyBoardCanBeSolved() { var grid = GridBuilder.Easy(); var allSolvers = new AllSolvers(); var pencilMarkReducer = new PencilMarkReducer(); var success = true; while (success) { var pencilMarks = new PencilMarks(grid); var reductions = pencilMarkReducer.Reduce(grid, pencilMarks); var result = allSolvers.TryToSolveOneCell(grid, pencilMarks); if (result.ProgressMade) { grid = result.Grid; } success = result.ProgressMade; } var notValidBecause = grid.ValidateCompleteBoard(); Assert.True(string.IsNullOrWhiteSpace(notValidBecause)); }
public void RoverExecutesCommandSequenceThatLeadsIntoObstacle() { var grid = new GridBuilder() .WithDimensions(2, 2) .WithObstacleAt(1, 1) .Build(); var startingPosition = new PositionBuilder() .OnGrid(grid) .WithCoordinates(new Coordinates(0, 0)) .Facing(DirectionEnum.North) .Build(); var rover = new RoverBuilder() .AtPosition(startingPosition) .Build(); var roverControl = new RoverControlBuilder() .ForRover(rover) .Build(); roverControl.SendCommands("frf"); roverControl.InvokeCommands(); var endingPosition = new PositionBuilder() .OnGrid(grid) .WithCoordinates(new Coordinates(0, 1)) .Facing(DirectionEnum.East) .Build(); Assert.Equal(endingPosition, rover.Position); }
public void ValidBoard() { var grid = GridBuilder.Easy(); var actualResult = grid.ValidatePartialBoard(); Assert.Equal("", actualResult); }
private void OnSceneUpdate(SceneView sv) { Event e = Event.current; GridBuilder gridBuilder = (GridBuilder)target; if (e.control) { var mousePos = e.mousePosition; var ppp = EditorGUIUtility.pixelsPerPoint; mousePos.y = sv.camera.pixelHeight - mousePos.y * ppp; mousePos.x *= ppp; Ray ray = sv.camera.ScreenPointToRay(mousePos); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (e.type == EventType.MouseDown) { if (e.button == 0) { if (hit.collider.TryGetComponent(out EditorHexTile editorHexTile)) { gridBuilder.InstantiateHexTile(editorHexTile.Coords, editorHexTile.transform.position); } } } } } }
public void LoadShops(AreaInfo area, TabPage tp) { IList<ShopInfo> shops = area.AreaShops.Where(x => x.IsCenter == false).ToList(); GridBuilder<ShopInfo> g = new GridBuilder<ShopInfo>(shops, new Size(100, 100), tp, 10, 20, 20); g.OnAddItem += new GridBuilder<ShopInfo>.AddItem(g_OnAddItem); g.BuildButtons(); }
public void LoadUsers() { lbshopinfo.Text = GlobalValue.GShop.AreaInfo.AreaName + " - " + GlobalValue.GShop.ShopName; IList<UserInfo> users = GlobalValue.GShop.ShopUsers; GridBuilder<UserInfo> UserGrid = new GridBuilder<UserInfo>(users, new Size(120, 120), panel1, 3, 50, 50); UserGrid.OnAddItem += new GridBuilder<UserInfo>.AddItem(UserGrid_OnAddItem); UserGrid.BuildButtons(); }
public void Should_get_a_N_plus_1_x_N_plus_1_grid_with_primes_and_multiplications_for_first_10_primes_only() { var primes = new int[12] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}; var actualGrid = new GridBuilder().Build(primes); Assert.That(actualGrid[10][10], Is.EqualTo(841)); Assert.That(actualGrid[11][11], Is.EqualTo(0)); }
public ActionResult Index(IndexViewModel viewModel) { FillDropDowns(viewModel); var expression = viewModel.Filter.GetExpression(); var gridBuilder = new GridBuilder(viewModel.AllPosts); var posts = postRepository.Where(expression).ToList(); gridBuilder.Populate(posts); return View(viewModel); }
public void Paging() { var dataSource = this.WebLogs.GetPage(1, 1); var grid = new Grid(); var gridBuilder = new GridBuilder(grid); gridBuilder.Populate(dataSource); Assert.AreEqual(3, grid.Columns.Count); Assert.AreEqual(1, grid.Rows.Count); Assert.AreEqual(DateTime.Today.ToString(), grid.Rows[0].Cells[2].Text); Assert.AreEqual("Blog 2", grid.Rows[0].Cells[1].Text); }
public void Show_Items_In_Grid() { var dataSource = this.WebLogs.ToList(); var grid = new Grid(); var gridBuilder = new GridBuilder(grid); gridBuilder.Populate(dataSource); Assert.AreEqual(3, grid.Columns.Count); Assert.AreEqual(2, grid.Rows.Count); Assert.AreEqual(DateTime.Today.ToString(), grid.Rows[0].Cells[2].Text); Assert.AreEqual("Blog 2", grid.Rows[1].Cells[1].Text); }
public void Should_get_a_N_plus_1_x_N_plus_1_grid_with_primes_and_multiplications() { var primes = new int[4] { 2, 3, 5, 7 }; var expectedGrid = new int[5][] { new [] {0, 2, 3, 5, 7}, new [] {2, 4, 6, 10, 14}, new [] {3, 6, 9, 15, 21}, new [] {5, 10, 15, 25, 35}, new [] {7, 14, 21, 35, 49} }; var actualGrid = new GridBuilder().Build(primes); Assert.That(actualGrid, Is.EqualTo(expectedGrid)); }
public void Should_get_a_N_plus_1_x_N_plus_1_grid_with_only_the_primes() { var primes = new int[4] { 2, 3, 5, 7 }; var expectedGrid = new [] { new [] {0, 2, 3, 5, 7}, new [] {2, 0, 0, 0, 0}, new [] {3, 0, 0, 0, 0}, new [] {5, 0, 0, 0, 0}, new [] {7, 0, 0, 0, 0} }; var actualGrid = new GridBuilder().Build(primes); Assert.That(actualGrid[0][1], Is.EqualTo(2)); Assert.That(actualGrid[1][0], Is.EqualTo(2)); Assert.That(actualGrid[0][4], Is.EqualTo(7)); Assert.That(actualGrid[4][0], Is.EqualTo(7)); }
public ActionResult Index(ListViewModel viewModel) { // obj var webLogGridBuilder = new GridBuilder(viewModel.DefaultGrid); // parameters -> data source var webLogDataSource = webLogGridBuilder.GetDataSourceByParameters(WebLogs).ToList(); // data source -> grid webLogGridBuilder.Populate(webLogDataSource); // obj var postGridBuilder = new GridBuilder(viewModel.Wrapper.OutroGrid); // parameters -> data source var postDataSource = postGridBuilder.GetDataSourceByParameters(from w in WebLogs.Query() from p in w.Posts select p).ToList(); // data source -> grid postGridBuilder.Populate(postDataSource); return View(viewModel); }
private void ShowSellDetailByPageNo(bool needRefresh) { int currPage = (int)pnlselldetail.Tag; //在页面上显示! if (currPage < 0) { currPage = 0; pnlselldetail.Tag = currPage; if (!needRefresh) return; } int MaxPage = selllist.Details.Count % 18 == 0 ? selllist.Details.Count / 18 -1: selllist.Details.Count / 18 ; if (currPage > MaxPage) { currPage = MaxPage; pnlselldetail.Tag = currPage; if(!needRefresh) return; } int pagecount = 18; //一页放20个 IList<Shop_SellDetail> source = new List<Shop_SellDetail>(); for (int i = currPage * pagecount; i < currPage * pagecount + pagecount; i++) { if (i < selllist.Details.Count) { source.Add(selllist.Details[i]); } } pnlselldetail.Controls.Clear(); GridBuilder<Shop_SellDetail> g = new GridBuilder<Shop_SellDetail>(source, new Size(170, 170), pnlselldetail, 6, 10, 10); g.OnAddItem += new GridBuilder<Shop_SellDetail>.AddItem(g_OnAddItem); g.BuildButtons(); }
public void Should_add_data_key_by_name_if_bound_to_DataRowViews() { var dataRowViewGrid = GridTestHelper.CreateGrid<DataRowView>(); var dataRowViewBuilder = new GridBuilder<DataRowView>(dataRowViewGrid); const string expectedRouteValue = "CustomerId"; const string expectedFieldName = "Id"; dataRowViewBuilder.DataKeys(keys => keys.Add(expectedFieldName).RouteKey(expectedRouteValue)); var firstDataKey = dataRowViewGrid.DataKeys[0]; firstDataKey.RouteKey.ShouldEqual(expectedRouteValue); firstDataKey.Name.ShouldEqual(expectedFieldName); }
public GridBuilderTests() { Mock<HtmlTextWriter> writer = new Mock<HtmlTextWriter>(TextWriter.Null); grid = GridTestHelper.CreateGrid<Customer>(writer.Object, null); builder = new GridBuilder<Customer>(grid); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { XmlDataDocument xmldoc = new XmlDataDocument(); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; settings.ProhibitDtd = false; XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = CredentialCache.DefaultCredentials; settings.XmlResolver = resolver; XmlReader render = XmlReader.Create(dialog.FileName, settings); try { try { xmldoc.Load(render); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Parse Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } finally { render.Close(); } GridBuilder builder = new GridBuilder(); if (xmlGrid.ShowColumnHeader) { GridCellGroup xmlgroup = new GridCellGroup(); xmlgroup.Flags = GroupFlags.Overlapped | GroupFlags.Expanded; builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes); GridCellGroup root = new GridCellGroup(); root.Table.SetBounds(1, 2); root.Table[0, 0] = new GridHeadLabel(); root.Table[0, 0].Text = dialog.FileName; root.Table[0, 1] = xmlgroup; xmlGrid.Cell = root; } else { GridCellGroup root = new GridCellGroup(); builder.ParseNodes(root, null, xmldoc.ChildNodes); xmlGrid.Cell = root; } } }
/// <summary> /// Creates a web form with an <c>XmlGridView</c> rendering an <see cref="XmlDocument"/>. /// </summary> /// <param name="xmlDoc">The document to render.</param> /// <param name="width">The width of the window.</param> /// <param name="height">The height of the window.</param> /// <returns></returns> public static Form CreateForm(XmlDocument xmlDoc, int width = 300, int height = 200) { var form = new Form { Height = height, Width = width, ClientSize = new Size(width, height) }; var grid = new XmlGridView { Dock = DockStyle.Fill }; form.Controls.Add(grid); var builder = new GridBuilder(); var xmlgroup = new GridCellGroup(); xmlgroup.Flags = GroupFlags.Overlapped | GroupFlags.Expanded; builder.ParseNodes(xmlgroup, null, xmlDoc.ChildNodes); var root = new GridCellGroup(); root.Table.SetBounds(1, 2); root.Table[0, 0] = new GridHeadLabel(); root.Table[0, 0].Text = "Sample Xml"; root.Table[0, 1] = xmlgroup; grid.Cell = root; return form; }