protected virtual ToolStripMenuItem CreateMenuStripItem(ICellElement allSelectedCellsElem) { return(new ToolStripMenuItem(allSelectedCellsElem.ToString()) { Tag = allSelectedCellsElem }); }
protected virtual void DeleteCellElement(ICellElement cellElem, Cell cell) { if (cell.Elements.Contains(cellElem)) { cell.Elements.Remove(cellElem); } this.cellElemList[cellElem].Remove(cell); }
protected virtual void AddCellElement(ICellElement cellElem) { if (!this.environmentControl.Environment.CellElements.ContainsKey(cellElem.IdToken)) { this.environmentControl.Environment.CellElements.Add(cellElem.IdToken, cellElem); } this.cellElemList[cellElem] = new HashSet <Cell>(); this.cellListBox.Items.Add(cellElem); }
protected virtual void SelectedCellsDeleteElement(ICellElement cellElement) { if (cellElement != null) { foreach (var cell in this.selectedCells) { this.DeleteCellElement(cellElement, cell); } } this.RefreshForm(false); }
public bool Equals(ICellElement cellElement) { return(cellElement is CellElement && cellElement.IdToken == this.IdToken && cellElement.Color.Equals(this.Color) && cellElement.ImagePath == this.ImagePath && ((CellElement)cellElement).Reward.Equals(this.Reward) && cellElement.Visible == this.Visible && cellElement.Walkable == this.Walkable && cellElement.HasSmell == this.HasSmell); }
protected virtual void DeleteCellElement(ICellElement cellElem) { foreach (var cell in this.cellElemList[cellElem]) { cell.Elements.Remove(cellElem); } this.environmentControl.Environment.CellElements.Remove(cellElem.IdToken); this.cellElemList.Remove(cellElem); this.cellListBox.Items.Remove(cellElem); this.RefreshForm(false); }
public virtual void MoveToElement(ICellElement element, ICellElement toElement) { if ((element == null) || (toElement == null)) { return; } var cellCloserToElement = this.GetNextCellInShortPath(element.Cell, toElement.Cell); if (cellCloserToElement != null) { element.Cell = cellCloserToElement; } }
public CellElementForm(ICellElement cellElement) { InitializeComponent(); this.CellElement = cellElement; this.LoadCellElementInfo(); this.Visible = false; this.DialogResult = DialogResult.None; this.nameTextBox.Focus(); this.selectFileDialog.Filter = Util.GetImageFilesDialogFilter(); this.selectFileDialog.FilterIndex = ImageCodecInfo.GetImageEncoders().Length; this.colorPanel.DoubleClick += this.ColorPanelDoubleClick; }
public virtual void MoveFromElement(ICellElement element, ICellElement fromElement) { if ((element == null) || (fromElement == null)) { return; } var cellFartherFromElement = this.GetNextCellToFartherFromCell(element.Cell, fromElement.Cell); if (cellFartherFromElement != null) { element.Cell = cellFartherFromElement; } }
private void LoadEnvironment(IEnvironment environment) { this.CreateEnvironmentControl(environment); this.selectedCellElem = null; this.selectedCells.Clear(); this.AddCellElements(environment); this.RefreshForm(true); //enables menus this.printToolStripMenuItem.Enabled = this.saveToolStripMenuItem.Enabled = this.saveAsToolStripMenuItem.Enabled = this.cellMenuStrip.Enabled = true; }
public virtual void MoveRandomly(ICellElement element) { if (element == null) { return; } var neighbourCells = this.GetNeighbourCells(element.Cell); var randNeighbour = neighbourCells[this.rand.Next(neighbourCells.Count)]; if ((randNeighbour != null) && this.IsWalkable(randNeighbour)) { element.Cell = randNeighbour; } }
protected virtual void ResetDots() { //puts all dots to visible foreach (var dotElement in this.dotCells.Values) { dotElement.Visible = dotElement.ForceRepaint = true; } //resets final dot (if exists) if (this.finalDot != null) { this.finalDot.IdToken = this.finalDot == this.BigDot ? BIG_DOT_ID : DOT_ID; } this.finalDot = null; }
protected virtual void AddCellElement(ICellElement cellElem, Cell cell) { if ((cell != null) && (!cell.Elements.Contains(cellElem))) { cell.Elements.Add(cellElem); } if ((cell != null) && cell.Environment.CellElements.ContainsKey(cellElem.IdToken) && !this.cellElemList[cellElem].Contains(cell)) { this.cellElemList[cellElem].Add(cell); } this.RefreshForm(false); }
protected void IdentifyFinalDot() { //checks for final dot if (this.numDotsEaten != this.numTotalDots - 1) { return; } //changes remaining dot id to final foreach (var dotElement in this.dotCells.Values.Where(dotElement => dotElement.Visible)) { //found the visible (and final) dot, mark it this.finalDot = dotElement; this.finalDot.IdToken = FINAL_DOT_ID; break; } }
protected void DrawFinishedTask(ICellElement cellElement, Graphics graphics) { if (!(cellElement is CellAgent)) { return; } //checks if agent finished task var agent = (CellAgent)cellElement; var agentFinishedTask = agent.Environment.AgentFinishedTask( agent, agent.ShortTermMemory.PreviousState, agent.ShortTermMemory.CurrentAction); if (agentFinishedTask) { graphics.DrawRectangle(new Pen(Color.Red, 10), new Rectangle(new Point(0, 0), this.Size)); } }
public Bitmap GetElementBitmap(ICellElement element) { //check new image (not loaded or path changed) if (!this._elementBitmapPaths.ContainsKey(element) || element.ImagePath != this._elementBitmapPaths[element]) { Bitmap bitmap = null; if (File.Exists(element.ImagePath)) { bitmap = (Bitmap)Image.FromFile(element.ImagePath); } if (this._elementBitmaps.ContainsKey(element) && (this._elementBitmaps[element] != null)) { this._elementBitmaps[element].Dispose(); } this._elementBitmaps[element] = bitmap; this._elementBitmapPaths[element] = element.ImagePath; } return(this._elementBitmaps[element]); }
protected void LoadCellElementInfo() { if (this.CellElement == null) { this.CellElement = new CellElement { IdToken = "new cell element" } } ; this.nameTextBox.Text = this.CellElement.IdToken; this.descTextBox.Text = this.CellElement.Description; this.imgPathTextBox.Text = this.CellElement.ImagePath; this.visibleCheckBox.Checked = this.CellElement.Visible; this.walkCheckBox.Checked = this.CellElement.Walkable; this.smellCheckBox.Checked = this.CellElement.HasSmell; this.colorPanel.BackColor = this.colorDialog.Color = this.CellElement.Color.ToColor(); this.rwdNumericUpDown.Value = (decimal)this.CellElement.Reward; if (File.Exists(this.CellElement.ImagePath)) { this.pictureBox.Load(this.CellElement.ImagePath); } }
public bool Equals(ICellElement cellElem) { return((cellElem is CellAgent) && (((CellAgent)cellElem).IdToken == this.IdToken)); }
private void CellListBoxSelectedIndexChanged(object sender, EventArgs e) { this.selectedCellElem = this.cellListBox.SelectedItem as ICellElement; }
public Cell GetFarthestCell(ICellElement fromElement) { return(fromElement.Cell != null?this.GetFarthestCell(fromElement.Cell) : null); }
public KeeperGhost(ICellElement otherElement) { this.otherElement = otherElement; }