public override void Project(GameTime gameTime, int x, int y, IRender render) { render.Begin(); render.DrawRect(new Rectangle(x, y, Width, Height), BackgroundColor); Font.DrawString(Text, new Point(x, y), FontColor, render); render.End(); }
void DrawHorizontalColors(int posX, int posY, int width, int height, List <Color> colors, IRender render) { int colorWidth = width / colors.Count; foreach (var color in colors) { render.DrawRect(new Rectangle(posX, posY, colorWidth, height), color); posX += colorWidth; } }
void DrawOpen(GameTime gameTime, ViewRect viewRect) { if (IsClosed || !IsInitialized || !Activated || Hidden) { return; } viewRect.Add(MasterBoundaries); IRender render = GraphicsManager.GetRender(); int x = RealX; int y = RealY; render.AddViewRect(new ViewRect(x, y + TextFieldHeight, TextFieldWidth, OpenHeight - TextFieldHeight)); render.Begin(); render.DrawRect(new Rectangle(x, y + TextFieldHeight, TextFieldWidth, OpenHeight - TextFieldHeight), OpenBackgroundColor); //DrawSprite items int drawY = y + TextFieldHeight - ItemPositionY + itemMargin; foreach (string line in Items) { Rectangle area = new Rectangle(x, drawY, TextFieldWidth, Font.CharHeight + Font.VerticalSpace); if (IsMouseInRect(area)) { render.DrawRect(area, MouseOverElementColor); } Font.DrawString(line, new Point(x + itemMargin, drawY), OpenFontColor, render); drawY += Font.CharHeight + Font.VerticalSpace; } render.End(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { if (!DrawBorder) { return; } render.Begin(); render.DrawLine(new Vector2(x + borderPosition, y), new Vector2(x + borderPosition, y + Height), OuterBorderColor); render.DrawLine(new Vector2(x + borderPosition + BorderSize - 1, y), new Vector2(x + borderPosition + BorderSize - 1, y + Height), OuterBorderColor); render.DrawRect(new Rectangle(x + borderPosition, y, BorderSize - 2, Height), InnerBorderColor); render.End(); }
int DrawGenes(int posX, int posY, IList geneList, IRender render, int geneWidth, int geneHeight) { foreach (var gene in geneList) { string geneType = gene.GetType().Name; switch (geneType) { case "DoubleGene": var dGene = (DoubleGene)gene; float val = (float)((dGene.Value - dGene.Min) / (dGene.Max - dGene.Min)); var color = new Color(val, val, val); render.DrawRect(new Rectangle(posX, posY, geneWidth, geneHeight), color); break; case "RMP_NeuronGene": var nGene = (RMP_NeuronGene)gene; var colorList = new List <Color>(); colorList.Add(GetColorFromDouble(nGene.Bias.Value)); foreach (var c in nGene.Connections) { colorList.Add(GetColorFromDouble(c.Weight.Value)); } DrawHorizontalColors(posX, posY, geneWidth, geneHeight, colorList, render); break; } posY += geneHeight; } return(posY); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { ViewRect orig = render.GetViewRect(); render.Begin(); ISprite iconUpSignInUse = UpIsPressed ? IconUpSignPressed : IconUpSign; ISprite iconInsideInUse = UpIsPressed ? IconInsidePressed : IconInside; // /-------\ // | /|\ | // | / | \ | // | | | // \-------/ render.DrawSprite(IconTop, new Vector2(x, y), Color.White); render.DrawSprite(IconLeft, new Rectangle(x, y + IconTop.Height, IconLeft.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconRight, new Rectangle(x + IconTop.Width - IconRight.Width, y + IconTop.Height, IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconBottom, new Vector2(x, y + UpperFieldHeight - IconBottom.Height), Color.White); render.DrawSprite(iconInsideInUse, new Rectangle(x + IconLeft.Width, y + IconTop.Height, IconTop.Width - IconLeft.Width - IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconUpSign, new Vector2(x + IconLeft.Width + ((IconTop.Width - IconLeft.Width - IconRight.Width) / 2) - (IconUpSign.Width / 2), y + (UpperFieldHeight / 2) - (IconUpSign.Height / 2)), Color.White); //UPPER FIELD: //Top render.DrawSprite(TopBorder, new Rectangle(x + IconTop.Width, y, Width - IconTop.Width - TopRightCorner.Width, TopBorder.Height), Color.White); //TopRight render.DrawSprite(TopRightCorner, new Vector2(x + Width - TopRightCorner.Width, y), Color.White); //Right render.DrawSprite(RightBorder, new Rectangle(x + Width - RightBorder.Width, y + TopRightCorner.Height, RightBorder.Width, UpperFieldHeight - TopRightCorner.Height - UpperFieldBottomRightCorner.Height), Color.White); //BottomRight render.DrawSprite(UpperFieldBottomRightCorner, new Vector2(x + Width - UpperFieldBottomRightCorner.Width, y + UpperFieldHeight - UpperFieldBottomRightCorner.Height), Color.White); //Bottom render.DrawSprite(BottomBorder, new Rectangle(x + IconTop.Width, y + UpperFieldHeight - BottomBorder.Height, Width - IconTop.Width - TopRightCorner.Width, BottomBorder.Height), Color.White); //Inside render.DrawSprite(Inside, new Rectangle(x + IconTop.Width, y + TopBorder.Height, Width - IconTop.Width - RightBorder.Width, UpperFieldHeight - TopBorder.Height - BottomBorder.Height), Color.White); //LOWER FIELD: //Middle render.DrawSprite(MiddleBorder, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, MiddleBorder.Height), Color.White); //Right render.DrawSprite(RightBorder, new Rectangle(x + LowerFieldWidth - RightBorder.Width, y + UpperFieldHeight, RightBorder.Width, LowerFieldHeight - BottomRightCorner.Height), Color.White); //BottomRight render.DrawSprite(BottomRightCorner, new Vector2(x + LowerFieldWidth - BottomRightCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomRightCorner.Height), Color.White); //Bottom render.DrawSprite(BottomBorder, new Rectangle(x + BottomLeftCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomBorder.Height, LowerFieldWidth - BottomLeftCorner.Width - BottomRightCorner.Width, BottomBorder.Height), Color.White); //BottomLeft render.DrawSprite(BottomLeftCorner, new Vector2(x, y + UpperFieldHeight + LowerFieldHeight - BottomLeftCorner.Height), Color.White); //Left render.DrawSprite(LeftBorder, new Rectangle(x, y + UpperFieldHeight, LeftBorder.Width, LowerFieldHeight - BottomLeftCorner.Height), Color.White); //Inside render.DrawSprite(Inside, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight + MiddleBorder.Height, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, LowerFieldHeight - MiddleBorder.Height - BottomBorder.Height), Color.White); render.End(); render.SetViewRect(orig.AddGet(new ViewRect(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin, Width - IconTop.Width - RightBorder.Width - TextMargin * 2, UpperFieldHeight - TopBorder.Height - MiddleBorder.Height - TextMargin * 2))); render.Begin(); string textToDraw = Text; if (HasFocus) { textToDraw = Text.Insert(CursorPosition, "|"); } Font.DrawString(textToDraw, new Point(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin), FontColor, render); render.End(); render.SetViewRect(orig.AddGet(new ViewRect(selectorX, selectorY, selectorWidth, selectorHeight))); render.Begin(); int drawX = selectorX + textAreaOriginX; int drawY = selectorY + textAreaOriginY; //DrawSprite filedir Font.DrawString(CurrentDirectory.FullName, new Point(drawX, drawY), FontColor, render); drawY += TextMargin + Font.CharHeight; render.DrawLine(new Vector2(drawX, drawY), new Vector2(selectorX + selectorWidth, drawY), SeparatorColor); drawY += 1 + TextMargin; foreach (DirectoryInfo d in directoryList) { if (selectedDirectories.Contains(d)) { render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor); } render.DrawSprite(FolderSign, new Vector2(drawX, drawY), Color.White); Font.DrawString(d.Name, new Point(drawX + FolderSign.Width + TextMargin, drawY), FontColor, render); drawY += Font.CharHeight + Font.VerticalSpace; } foreach (FileInfo f in fileList) { if (selectedFiles.Contains(f)) { render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor); } Font.DrawString(f.Name, new Point(drawX, drawY), FontColor, render); drawY += Font.CharHeight + Font.VerticalSpace; } render.End(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { render.Begin(); render.DrawRect(new Rectangle(x, y, Width, Height), BackgroundColor); render.End(); }
public override void Project(Microsoft.Xna.Framework.GameTime gameTime, int x, int y, IRender render) { base.Project(gameTime, x, y, render); const int geneHeight = 3; render.Begin(); render.DrawRect(new Rectangle(x, y, Width, Height), Color.White); //Genome1 if (Genome == null) { render.End(); return; } var geneDict = Genome.NetChromosome.GetGeneInfo(); int headerX = x + 5; int posY = y + 5; int genome2PosY = posY; foreach (var geneListKey in geneDict.Keys) { var geneList = geneDict[geneListKey]; int stringWidth = Font.MeasureString(geneListKey).X; Font.DrawString(geneListKey, new Point(headerX, posY), Color.Black, render); genome2PosY = Math.Max(DrawGenes(headerX, posY + Font.CharHeight + 2, geneList, render, stringWidth, geneHeight), genome2PosY); headerX += stringWidth + 4; } //Genome2 if (Genome2 == null) { render.End(); return; } geneDict = Genome2.NetChromosome.GetGeneInfo(); headerX = x + 5; posY = genome2PosY += 5; foreach (var geneListKey in geneDict.Keys) { var geneList = geneDict[geneListKey]; int stringWidth = Font.MeasureString(geneListKey).X; Font.DrawString(geneListKey, new Point(headerX, posY), Color.Black, render); genome2PosY = Math.Max(DrawGenes(headerX, posY + Font.CharHeight + 2, geneList, render, stringWidth, geneHeight), genome2PosY); headerX += stringWidth + 4; } //ChildGenome if (ChildGenome == null) { render.End(); return; } geneDict = ChildGenome.NetChromosome.GetGeneInfo(); headerX = x + 5; posY = genome2PosY += 5; foreach (var geneListKey in geneDict.Keys) { var geneList = geneDict[geneListKey]; int stringWidth = Font.MeasureString(geneListKey).X; Font.DrawString(geneListKey, new Point(headerX, posY), Color.Black, render); genome2PosY = Math.Max(DrawGenes(headerX, posY + Font.CharHeight + 2, geneList, render, stringWidth, geneHeight), genome2PosY); headerX += stringWidth + 4; } render.End(); }
void DrawMenu(GameTime gameTime, ViewRect viewRect) { if (IsClosed || !IsInitialized || !Activated || Hidden) { return; } viewRect.Add(MasterBoundaries); IRender render = GraphicsManager.GetRender(); int x = RealX; int y = RealY; int posX = x + menuItemMarginX; int posY = y + Height / 2 - Font.CharHeight / 2; int count = 0; foreach (var item in MenuItems) { int strinW = Font.MeasureString(item.Name).X; if (count == SelectedMenuItem && ItemIsOpen) { render.Begin(); Color color = count == SelectedMenuItem && item.Enabled ? FontHighlightColor : FontColor; render.DrawHorizontalLine(new Point(posX, y + menuItemMarginY), strinW, DropdownBorder); render.DrawVerticalLine(new Point(posX, y + menuItemMarginY), Height - menuItemMarginY + toolbarDropdownMargin, DropdownBorder); render.DrawVerticalLine(new Point(posX + strinW, y + menuItemMarginY), Height - menuItemMarginY + toolbarDropdownMargin, DropdownBorder); render.DrawRect(new Rectangle(posX + 1, y + menuItemMarginY + 1, strinW - 2, Height - menuItemMarginY + toolbarDropdownMargin - 2), DropdownBody); Font.DrawString(item.Name, new Point(posX + 1, posY), color, render); //DropdownMenu int top = y + Height + toolbarDropdownMargin - 1; render.DrawHorizontalLine(new Point(posX + strinW, top), dropdownMenuWidth - strinW, DropdownBorder); render.DrawHorizontalLine(new Point(posX, top + dropdownMenuHeight), dropdownMenuWidth, DropdownBorder); render.DrawVerticalLine(new Point(posX, top), dropdownMenuHeight, DropdownBorder); render.DrawVerticalLine(new Point(posX + dropdownMenuWidth - 1, top), dropdownMenuHeight, DropdownBorder); render.DrawRect(new Rectangle(posX + 1, top + 1, dropdownMenuWidth - 3, dropdownMenuHeight - 2), DropdownBody); int elemX = posX; int elemY = top + menuElemMarginY; var selectedItem = MenuItems[SelectedMenuItem]; int c = 0; foreach (var elem in selectedItem.Elements) { int elemH; if (elem.Name != null) { elemH = Font.MeasureString(elem.Name).Y + menuElemMarginY; } else { elemH = separatorHeight; } if (c == SelectedMenuElement && item.Enabled && elem.Enabled) { render.DrawRect(new Rectangle(elemX + 1, elemY - menuElemMarginY + 2, dropdownMenuWidth - 3, elemH - 2), ElementHighlightColor); } if (elem.IsSeparator) { render.DrawLine(new Vector2(elemX + separatorMargin, elemY + separatorHeight / 2), new Vector2(elemX + dropdownMenuWidth - separatorMargin, elemY + separatorHeight / 2), SeparatorColor); } else { Font.DrawString(elem.Name, new Point(elemX + menuElemMarginX, elemY), FontColor, render); } elemY += elemH; c += 1; } render.End(); } posX += strinW + menuItemMarginX; count += 1; } render.Reset(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { if (drawFpsList.Count == meanFloor) { drawFpsList.RemoveAt(0); } double add = 1 / gameTime.ElapsedGameTime.TotalSeconds; if (!double.IsInfinity(add)) { drawFpsList.Add(1 / gameTime.ElapsedGameTime.TotalSeconds); } DrawFps = 0; foreach (double fps in drawFpsList) { DrawFps += fps; } DrawFps /= drawFpsList.Count; render.Begin(); Color background = BackgroundColor; Color fontColor = FontColor; Color bumpColor = BumpColor; const float transparencyFactor = 0.3F; if (CheckIfUnderMouse()) { background.R = Convert.ToByte(BackgroundColor.R * transparencyFactor); background.G = Convert.ToByte(BackgroundColor.G * transparencyFactor); background.B = Convert.ToByte(BackgroundColor.B * transparencyFactor); background.A = Convert.ToByte(BackgroundColor.A * transparencyFactor); fontColor.R = Convert.ToByte(FontColor.R * transparencyFactor); fontColor.G = Convert.ToByte(FontColor.G * transparencyFactor); fontColor.B = Convert.ToByte(FontColor.B * transparencyFactor); fontColor.A = Convert.ToByte(FontColor.A * transparencyFactor); bumpColor.R = Convert.ToByte(bumpColor.R * transparencyFactor); bumpColor.G = Convert.ToByte(bumpColor.G * transparencyFactor); bumpColor.B = Convert.ToByte(bumpColor.B * transparencyFactor); bumpColor.A = Convert.ToByte(bumpColor.A * transparencyFactor); } render.DrawRect(new Rectangle(x, y, Width, Height), background); //Draw bump render.DrawLine(new Vector2(x + bumpX, Height), new Vector2(x + bumpX, 0), bumpColor); //Move bump if (bumpX + speed > Width || bumpX + speed < 0) { speed = -speed; } bumpX += speed; if (ShowUpdateFps) { Font.DrawString("DrawFps: " + UpdateFps.ToString(), new Point(x, y), fontColor, render); } if (ShowDrawFps) { Font.DrawString("UpdateFps: " + DrawFps.ToString(), new Point(x, y + Font.CharHeight + margin), fontColor, render); } render.End(); }
public override void Project(Microsoft.Xna.Framework.GameTime gameTime, int x, int y, IRender render) { render.Begin(); int n = 0; int drawX = x + textMargin; foreach (string name in columnNames) { bool pressed = n == pressedColumnButton; int size = columnSizes[n]; bool quit = false; if (drawX + columnSizes[n] >= RealX + Width) { size = RealX + Width - drawX; quit = true; } DrawButton(drawX, y, render, name, size, pressed); if (quit) { break; } drawX += columnSizes[n]; n += 1; } y += HeaderSize; render.DrawSprite(TopLeftCorner, new Vector2(x, y), Color.White); render.DrawSprite(TopRightCorner, new Vector2(x + Width - TopRightCorner.Width, y), Color.White); render.DrawSprite(BottomLeftCorner, new Vector2(x, y + Height - HeaderSize - BottomLeftCorner.Height), Color.White); render.DrawSprite(BottomRightCorner, new Vector2(x + Width - BottomRightCorner.Width, y + Height - HeaderSize - BottomRightCorner.Height), Color.White); render.DrawSprite(TopBorder, new Rectangle(x + TopLeftCorner.Width, y, Width - TopLeftCorner.Width - TopRightCorner.Width, TopBorder.Height), Color.White); render.DrawSprite(BottomBorder, new Rectangle(x + BottomLeftCorner.Width, y + Height - HeaderSize - BottomBorder.Height, Width - BottomLeftCorner.Width - BottomRightCorner.Width, BottomBorder.Height), Color.White); render.DrawSprite(LeftBorder, new Rectangle(x, y + TopLeftCorner.Height, LeftBorder.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height), Color.White); render.DrawSprite(RightBorder, new Rectangle(x + Width - RightBorder.Width, y + TopLeftCorner.Height, RightBorder.Width, Height - HeaderSize - TopRightCorner.Height - BottomRightCorner.Height), Color.White); render.DrawSprite(Inside, new Rectangle(x + TopLeftCorner.Width, y + TopLeftCorner.Height, Width - BottomLeftCorner.Width - BottomRightCorner.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height), Color.White); render.End(); //DrawSprite list items: render.AddViewRect(new ViewRect(RealX + TopLeftCorner.Width, RealY + TopLeftCorner.Height + HeaderSize, Width - TopLeftCorner.Width - TopRightCorner.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height)); render.Begin(); int rowX = RealX + TopLeftCorner.Width + textMargin; int rowY = RealY + TopLeftCorner.Height + HeaderSize + textMargin; int rowNumber = 0; foreach (ListBoxRow row in Values) { if (rowNumber == rowUnderMouse) { render.DrawRect(new Rectangle(rowX, rowY, Width - TopLeftCorner.Width - TopRightCorner.Width, Font.CharHeight + textMargin), ElementUnderMouseColor); } if (row == SelectedRow) { render.DrawRect(new Rectangle(rowX, rowY, Width - TopLeftCorner.Width - TopRightCorner.Width, Font.CharHeight + textMargin), SelectedElementColor); } int index = 0; foreach (object val in row.Values) { string valStr = val == null ? "NULL" : val.ToString(); Font.DrawString(valStr, new Point(rowX, rowY), ListElementColor, render); rowX += ColumnSizes[index]; index += 1; } rowX = RealX + TopLeftCorner.Width + textMargin; rowY += Font.CharHeight + textMargin; rowNumber += 1; } render.End(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { render.Begin(); render.DrawRect(new Rectangle(x, y, DrawSpaceWidth, DrawSpaceHeight), BackColor); int drawX = x; int drawY = y; for (int iy = 0; iy < BufferHeight; iy++) { for (int ix = 0; ix < BufferWidth; ix++) { if (display[ix, iy] != '\0') { Font.DrawChar(display[ix, iy], new Point(drawX, drawY), FontColor, render); } drawX += Font.CharWidth + Font.HorizontalSpace; } drawX = x - OriginX; drawY += Font.CharHeight + Font.VerticalSpace; } if (TerminalMode && drawCursor) { int sum = 0; int cursorY = Lines.Count - OriginY; int cursorX = OriginX; List <string> currentLineParts = new List <string>(); AddCurrentLineParts(currentLineParts); string lastPart = ""; bool partIsFullSize = false; foreach (string part in currentLineParts) { lastPart = part; sum += part.Length; if (inputMachine.Cursor <= sum) { partIsFullSize = part.Length == BufferWidth && sum == inputMachine.Cursor; break; } cursorY += 1; } if (partIsFullSize) { cursorX = OriginX; cursorY += 1; } else { cursorX = inputMachine.Cursor - sum + lastPart.Length; } int cursorHeight = (int)Math.Round(Font.CharHeight * CursorSize, 0); render.DrawRect(new Rectangle(cursorX * (Font.CharWidth + Font.HorizontalSpace) + x, cursorY * (Font.CharHeight + Font.VerticalSpace) + Font.CharHeight - cursorHeight + y, Font.CharWidth, cursorHeight), FontColor); } render.End(); }