private static Cell CreateCell(CellDescription cellDescription) { var cell = new Cell(DefaultSettings.RowSpan, DefaultSettings.ColumnSpan) .SetTextAlignment(TextAlignment.CENTER) .Add(new Paragraph(cellDescription.Content)); SetBorder(cell, cellDescription.CellPosition); return(cell); }
void ReleaseDesignerOutlets() { if (CellDescription != null) { CellDescription.Dispose(); CellDescription = null; } if (CellImage != null) { CellImage.Dispose(); CellImage = null; } if (CellTitle != null) { CellTitle.Dispose(); CellTitle = null; } }
public static Table CreateTable(string company, string labelContent) { var cellDescriptions = new CellDescription[] { new CellDescription(company, CellPosition.Top), new CellDescription($"Проба № {labelContent}", CellPosition.Central), new CellDescription("Проба почвы (грунта)", CellPosition.Bottom), }; var table = new Table(DefaultSettings.ColumnCount, false) .SetKeepTogether(true); foreach (var cellDescription in cellDescriptions) { var cell = CreateCell(cellDescription); table.AddCell(cell); } table.SetMarginBottom(2.5f); table.SetMarginRight(2.5f); return(table); }
/// <summary> /// Given the paramaters describing a rubric, create a /// rubric model and store it in the database. Note: the rubric is not yet /// associated with an assignment when this function returns. /// </summary> /// <param name="model"></param> /// <param name="rubricTable">List of List of strings representing the body of a rubric /// Each List of strings represents a row and contains the following: /// Index 0: performance criterion title /// Index 1: criterion weight /// Index 2-n: level description</param> /// <param name="levelTitles">A list each level title</param> /// <param name="hasGlobalComments"></param> /// <param name="hasCriteriaComments"></param> /// <returns>RubricID of the new rubric</returns> private int CreateRubricModel(List <List <string> > rubricTable, List <string> levelTitles, List <int> pointSpreads, bool hasGlobalComments, bool hasCriteriaComments, bool enableHalfStep, bool enableQuarterStep, string rubricDescription) { Rubric rubric = new Rubric(); rubric.HasGlobalComments = hasGlobalComments; rubric.HasCriteriaComments = hasCriteriaComments; rubric.EnableHalfStep = enableHalfStep; rubric.EnableQuarterStep = enableQuarterStep; rubric.Description = rubricDescription; db.Rubrics.Add(rubric); db.SaveChanges(); //Assignment.RubricID = rubric.ID; //levels int p = 1; foreach (string levelTitle in levelTitles) { Level level = new Level(); if (levelTitle == "") { //WasUpdateSuccessful = false; level.LevelTitle = "Level Title " + p.ToString(); } else { level.LevelTitle = levelTitle; } level.PointSpread = pointSpreads[p - 1]; level.RubricID = rubric.ID; db.Levels.Add(level); p++; } //Criteria p = 1; foreach (List <string> row in rubricTable) { Criterion criterion = new Criterion(); if (row[0] == "") { criterion.CriterionTitle = "Criterion " + p.ToString(); } else { criterion.CriterionTitle = row[0]; } int weight; if (int.TryParse(row[1], out weight)) { criterion.Weight = weight; } else { criterion.Weight = 1; } criterion.RubricID = rubric.ID; db.Criteria.Add(criterion); p++; } db.SaveChanges(); int i = 0; foreach (Criterion criterion in rubric.Criteria) //for each row { int n = 2; // the level titles start at index 2 in rubricTable foreach (Level level in rubric.Levels) // { CellDescription desc = new CellDescription(); desc.CriterionID = criterion.ID; desc.LevelID = level.ID; desc.RubricID = rubric.ID; if (rubricTable[i][n] == "") { desc.Description = "Description for " + level.LevelTitle; } else { desc.Description = rubricTable[i][n]; } db.CellDescriptions.Add(desc); rubric.CellDescriptions.Add(desc); n++; } i++; } return(rubric.ID); }
internal static void Init(this CellDescription[] image, AsciiColor color) { for (uint i = 0; i < image.Length; i++) image[i] = new CellDescription(' ', color); ; }
internal static void Init(this Image image, AsciiColor color) { for (uint i = 0; i < image.Size; i++) image[i] = new CellDescription(' ', color); ; }
/// <summary> /// yc: this copy the rubric information from one assignment to another. /// </summary> /// <param name="Source"></param> /// <param name="Destination"></param> /// <returns>bool for if success or fail</returns> public bool CopyRubric(Assignment Source, Assignment Destination) { try { int sid = -1; if (Source.RubricID != null) { sid = (int)Source.RubricID; //create a new reburic thats an exact copy with the same critera Rubric nr = new Rubric(); nr.HasGlobalComments = Source.Rubric.HasGlobalComments; nr.HasCriteriaComments = Source.Rubric.HasCriteriaComments; nr.EnableHalfStep = Source.Rubric.EnableHalfStep; nr.EnableQuarterStep = Source.Rubric.EnableQuarterStep; nr.Description = Source.Rubric.Description; Destination.Rubric = nr; db.Entry(Destination).State = EntityState.Modified; db.SaveChanges(); //now get all the stuff for it Dictionary <int, int> clevelHolder = new Dictionary <int, int>(); Dictionary <int, int> ccriterionHolder = new Dictionary <int, int>(); List <Level> pls = (from rl in db.Levels where rl.RubricID == sid select rl).ToList(); foreach (Level pl in pls) { Level nl = new Level(); nl.LevelTitle = pl.LevelTitle; nl.PointSpread = pl.PointSpread; nl.RubricID = nr.ID; db.Levels.Add(nl); db.SaveChanges(); clevelHolder.Add(pl.ID, nl.ID); } List <Criterion> prcs = (from rc in db.Criteria where rc.RubricID == sid select rc).ToList(); foreach (Criterion prc in prcs) //create a new criteron { Criterion nrc = new Criterion(); nrc.CriterionTitle = prc.CriterionTitle; nrc.Weight = prc.Weight; nrc.RubricID = nr.ID; db.Criteria.Add(nrc); db.SaveChanges(); ccriterionHolder.Add(prc.ID, nrc.ID); } //now descriptions //for some reason, cell descriptions do not come with this assignment so lets do a search fo rit List <CellDescription> pcds = (from cd in db.CellDescriptions where cd.RubricID == sid select cd).ToList(); foreach (CellDescription pcd in pcds) { CellDescription ncd = new CellDescription(); ncd.CriterionID = ccriterionHolder[pcd.CriterionID]; ncd.LevelID = clevelHolder[pcd.LevelID]; ncd.RubricID = nr.ID; ncd.Description = pcd.Description; db.CellDescriptions.Add(ncd); db.SaveChanges(); } } if (Source.StudentRubricID != null) { sid = (int)Source.StudentRubricID; //create a new reburic thats an exact copy with the same critera Rubric nr = new Rubric(); nr.HasGlobalComments = Source.Rubric.HasGlobalComments; nr.HasCriteriaComments = Source.Rubric.HasCriteriaComments; nr.EnableHalfStep = Source.Rubric.EnableHalfStep; nr.EnableQuarterStep = Source.Rubric.EnableQuarterStep; nr.Description = Source.Rubric.Description; db.Rubrics.Add(nr); db.SaveChanges(); Destination.StudentRubricID = nr.ID; db.Entry(Destination).State = EntityState.Modified; db.SaveChanges(); //now get all the stuff for it Dictionary <int, int> slevelHolder = new Dictionary <int, int>(); Dictionary <int, int> scriterionHolder = new Dictionary <int, int>(); List <Level> pls = (from rl in db.Levels where rl.RubricID == sid select rl).ToList(); foreach (Level pl in pls) { Level nl = new Level(); nl.LevelTitle = pl.LevelTitle; nl.PointSpread = pl.PointSpread; nl.RubricID = nr.ID; db.Levels.Add(nl); db.SaveChanges(); slevelHolder.Add(pl.ID, nl.ID); } List <Criterion> prcs = (from rc in db.Criteria where rc.RubricID == sid select rc).ToList(); foreach (Criterion prc in prcs) //create a new criteron { Criterion nrc = new Criterion(); nrc.CriterionTitle = prc.CriterionTitle; nrc.Weight = prc.Weight; nrc.RubricID = nr.ID; db.Criteria.Add(nrc); db.SaveChanges(); scriterionHolder.Add(prc.ID, nrc.ID); } //now descriptions //for some reason, cell descriptions do not come with this assignment so lets do a search fo rit List <CellDescription> pcds = (from cd in db.CellDescriptions where cd.RubricID == sid select cd).ToList(); foreach (CellDescription pcd in pcds) { CellDescription ncd = new CellDescription(); ncd.CriterionID = scriterionHolder[pcd.CriterionID]; ncd.LevelID = slevelHolder[pcd.LevelID]; ncd.RubricID = nr.ID; ncd.Description = pcd.Description; db.CellDescriptions.Add(ncd); db.SaveChanges(); } } return(true); } catch { return(false); } }
public void GenerateLevel() { Random.InitState((int)DateTime.Now.Ticks); _cells = new CellDescription[Side * Side]; var randomPresets = new CellDescription[][] { _preset1, _preset2, _preset3, _preset4, _preset5 }; var currentRandom = Random.Range(0, randomPresets.Length); var currentPreset1 = randomPresets[currentRandom]; //Debug.Log("first preset selected:"+currentRandom); currentRandom = Random.Range(0, randomPresets.Length); var currentPreset2 = randomPresets[currentRandom]; //Debug.Log("second preset selected:"+currentRandom); currentRandom = Random.Range(0, randomPresets.Length); var currentPreset3 = randomPresets[currentRandom]; //Debug.Log("third preset selected:"+currentRandom); currentRandom = Random.Range(0, randomPresets.Length); var currentPreset4 = randomPresets[currentRandom]; //Debug.Log("forth preset selected:"+currentRandom); var usedCoords = new List <int>(); TrapCoordinates = new Vector2[TrapCount]; int currentIndex = 0; for (int i = 0; i < TrapCount; i++) { var selected = false; while (!selected) { var coordinate = Random.Range(0, (Side - 2) * (Side - 2)); if (usedCoords.Contains(coordinate)) { continue; } usedCoords.Add(coordinate); selected = true; TrapCoordinates[currentIndex] = GetCoordinateByAbsoluteNumber(coordinate); currentIndex++; } } var exitSelected = false; while (!exitSelected) { var coordinate = Random.Range(0, (Side - 2) * (Side - 2)); if (usedCoords.Contains(coordinate)) { continue; } exitSelected = true; ExitCoordinate = GetCoordinateByAbsoluteNumber(coordinate); } var heroSelected = false; while (!heroSelected) { var coordinate = Random.Range(0, (Side - 2) * (Side - 2)); if (usedCoords.Contains(coordinate)) { continue; } heroSelected = true; HeroCoordinate = GetCoordinateByAbsoluteNumber(coordinate); } for (int i = 0; i < Side; i++) { for (int j = 0; j < Side; j++) { CellDescription decision = null; if (i == 0 || j == 0 || i == Side - 1 || j == Side - 1) { decision = new CellDescription(CellType.HunterPortal, 0); } else { if ( i > 0 && i <= SampleSize && j > 0 && j <= SampleSize) { var diff = 1; decision = GetByCoordinatesInternal(currentPreset1, i - diff, j - diff, SampleSize); } if ( i > 0 && i <= SampleSize && j > SampleSize && j <= SampleSize * 2) { var xdiff = 1; var ydiff = 1 + SampleSize; decision = GetByCoordinatesInternal(currentPreset2, i - xdiff, j - ydiff, SampleSize); } if ( i > SampleSize && i <= SampleSize * 2 && j > 0 && j <= SampleSize) { var xdiff = 1 + SampleSize; var ydiff = 1; decision = GetByCoordinatesInternal(currentPreset3, i - xdiff, j - ydiff, SampleSize); } if ( i > SampleSize && i <= SampleSize * 2 && j > SampleSize && j <= SampleSize * 2) { var xdiff = 1 + SampleSize; var ydiff = 1 + SampleSize; decision = GetByCoordinatesInternal(currentPreset4, i - xdiff, j - ydiff, SampleSize); } } _cells[i * Side + j] = decision; } } /*foreach (var cellDescription in _cells) * { * Debug.Log(cellDescription.Cell + ":" + cellDescription.Rotation); * }*/ }