public void UpdateSurfaces() { mButtonUpBounds = new Rectangle(0, 0, this.Width, 25); mScrollBackgroundBounds = new Rectangle(0, mButtonUpBounds.Height, this.Width, this.Height - (mButtonUpBounds.Height * 2)); mButtonDownBounds = new Rectangle(0, mButtonUpBounds.Height + mScrollBackgroundBounds.Height, this.Width, mButtonUpBounds.Height); mScrollBarBounds = new Rectangle(0, mButtonUpBounds.Height, this.Width, (this.mMaximum / this.mValue) * 25); mBackground = new SdlDotNet.Graphics.Surface(this.Size); mButtonSurface = new SdlDotNet.Graphics.Surface(mButtonUpBounds.Size); mScrollbarBackgroundSurface = new SdlDotNet.Graphics.Surface(mScrollBackgroundBounds.Size); mScrollbarSurface = new SdlDotNet.Graphics.Surface(mScrollBarBounds.Size); mScrollbarSurface.Fill(Color.Transparent); //mScrollbarSurface.Transparent = true; mButtonSurface.Fill(mForecolor); Gfx.Primitives.Box border = new SdlDotNet.Graphics.Primitives.Box(new Point(0, 0), new Size(mScrollBackgroundBounds.Width - 2, mScrollBackgroundBounds.Height - 1)); mScrollbarBackgroundSurface.Draw(border, Color.Blue); Gfx.Primitives.Box border2 = new SdlDotNet.Graphics.Primitives.Box(new Point(0, 0), new Size(mScrollbarSurface.Width - 2, mScrollbarSurface.Height - 2)); mScrollbarSurface.Draw(border, Color.Red); mBackground.Blit(mButtonSurface); mBackground.Blit(mScrollbarBackgroundSurface, new Point(0, mButtonSurface.Height)); mBackground.Blit(mScrollbarSurface, new Point(0, mButtonSurface.Height)); mBackground.Blit(mButtonSurface, new Point(0, mButtonSurface.Height + mScrollbarBackgroundSurface.Height)); }
private void UpdateBackground() { mBackground = new SdlDotNet.Graphics.Surface(base.Size); base.Buffer.Fill(mBackColor); if (mBackColor.A != 0) { mBackground.Fill(mBackColor); } else { mBackground.Transparent = true; mBackground.TransparentColor = Color.Transparent; mBackground.Fill(Color.Transparent); } mCheckedBoxBounds = new Rectangle(new Point(2, 2), new Size(this.Height - 4, this.Height - 4)); Gfx.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(mCheckedBoxBounds.Location, mCheckedBoxBounds.Size); mBackground.Draw(box, Color.Black); if (mChecked) { Gfx.Surface filled = new SdlDotNet.Graphics.Surface(box.Size); filled.Fill(Color.Black); mBackground.Blit(filled, box.Location); filled.Close(); filled.Dispose(); } if (mText != "") { Gfx.Font font = new Gfx.Font(IO.IO.CreateOSPath("Fonts\\PMU.ttf"), this.Height); mBackground.Blit(font.Render(mText, mForeColor, mAntiAlias), new Point(20, -4)); font.Close(); } base.Buffer.Blit(mBackground, new Point(0, 0)); }
private void DrawBorder() { for (int i = 0; i < mBorderWidth; i++) { Gfx.IPrimitive border = new SdlDotNet.Graphics.Primitives.Box((short)(i), (short)(i), (short)((this.Width) - (1 + i)), (short)((this.Height - (1 + i)))); base.Buffer.Draw(border, mBorderColor); } }
void ItemsetViewer_Paint(object sender, EventArgs e) { if (vScroll != null && hScroll != null) { vScroll.BlitToScreen(base.Buffer); hScroll.BlitToScreen(base.Buffer); DrawTiles(); SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(new Point((selectedTile.X - hScroll.Value) * Constants.TILE_WIDTH, (selectedTile.Y - vScroll.Value) * Constants.TILE_HEIGHT), new Size(Constants.TILE_WIDTH, Constants.TILE_HEIGHT)); base.Buffer.Draw(box, Color.Red); base.DrawBorder(); } }
public static void DrawMiniBars(RendererDestinationData destData) { int userHPBarStartX = 40;//DrawingSupport.GetCenterX(destData.Size.Width, 100); TextRenderer.DrawText(destData, "HP:", Color.WhiteSmoke, Color.Black, new Point(userHPBarStartX - 30, 5)); SdlDotNet.Graphics.Primitives.Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userHPBarStartX - 1, destData.Location.Y + 17), new Point(destData.Location.X + userHPBarStartX + 100 + 1, destData.Location.Y + 27)); destData.Draw(hpBox, Color.Black, false, false); hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userHPBarStartX, destData.Location.Y + 17 + 1), new Point(Convert.ToInt32(destData.Location.X + userHPBarStartX + (Logic.MathFunctions.CalculatePercent(PlayerManager.MyPlayer.GetActiveRecruit().HP, PlayerManager.MyPlayer.GetActiveRecruit().MaxHP) * 0.01) * 100), destData.Location.Y + 27 - 1)); Color hpColor; if (PlayerManager.MyPlayer.GetActiveRecruit().HP < PlayerManager.MyPlayer.GetActiveRecruit().MaxHP / 5) { hpColor = Color.Red; } else if (PlayerManager.MyPlayer.GetActiveRecruit().HP < PlayerManager.MyPlayer.GetActiveRecruit().MaxHP / 2) { hpColor = Color.Yellow; } else { hpColor = Color.Green; } destData.Draw(hpBox, hpColor, false, true); int userBellyBarStartX = 205;//DrawingSupport.GetCenterX(destData.Size.Width, 100); TextRenderer.DrawText(destData, "Hunger:", Color.WhiteSmoke, Color.Black, new Point(userBellyBarStartX - 45, 5)); SdlDotNet.Graphics.Primitives.Box bellyBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userBellyBarStartX - 1, destData.Location.Y + 17), new Point(destData.Location.X + userBellyBarStartX + 100 + 1, destData.Location.Y + 27)); destData.Draw(bellyBox, Color.Black, false, false); bellyBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userBellyBarStartX, destData.Location.Y + 17 + 1), new Point(Convert.ToInt32(destData.Location.X + userBellyBarStartX + (Logic.MathFunctions.CalculatePercent(PlayerManager.MyPlayer.Belly, PlayerManager.MyPlayer.MaxBelly) * 0.01) * 100), destData.Location.Y + 27 - 1)); Color bellyColor; if (PlayerManager.MyPlayer.Belly < PlayerManager.MyPlayer.MaxBelly / 5) { bellyColor = Color.Red; } else if (PlayerManager.MyPlayer.Belly < PlayerManager.MyPlayer.MaxBelly / 2) { bellyColor = Color.Yellow; } else { bellyColor = Color.Green; } destData.Draw(bellyBox, bellyColor, false, true); }
//TODO: Check for border size and width/height public void DrawCenteredWindow(int width, int height, Surface dest) { SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(new Point((game.Width - width) / 2, (game.Height - height) / 2), new Size(width, height)); dest.Draw(box, bgColor, false, true); for (int i = Border; i < width - Border; i += Border) { dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition1), new Rectangle(2 * Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition2 - Border + 1), new Rectangle(2 * Border, Border, Border, Border)); } for (int i = Border; i < height - Border; i += Border) { dest.Blit(surface, new Point(box.XPosition1, box.YPosition1 + i), new Rectangle(3 * Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1 + i), new Rectangle(3 * Border, Border, Border, Border)); } dest.Blit(surface, new Point(box.XPosition1, box.YPosition1), new Rectangle(0, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1), new Rectangle(Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition1, box.YPosition2 - Border + 1), new Rectangle(0, Border, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition2 - Border + 1), new Rectangle(Border, Border, Border, Border)); }
private void UpdateTexture() { if (mBackcolor.A != 0) { mTexture.Fill(mBackcolor); } else { mTexture.Transparent = true; mTexture.TransparentColor = Color.Transparent; mTexture.Fill(Color.Transparent); } mBackgroundTexture.Fill(mHoverColor); mTexture.Blit(mBackgroundTexture, new Point(1, 1)); mTexture.Blit(mFont.Render(mText, mForecolor), new Point(((mTexture.Width / 2) - (mTextSize.Width / 2)) + mXOffset, ((mTexture.Height / 2) - (mTextSize.Height / 2)) + mYOffset)); for (int i = 0; i < mBorderWidth; i++) { Gfx.IPrimitive border = new Gfx.Primitives.Box((short)(i + 1), (short)(i + 1), (short)(this.Width - (2 + i)), (short)(this.Height - (2 + i))); mTexture.Draw(border, mBorderColor); } }
protected virtual void renderMiniMapViewBox(Surface s, Rectangle r) { updateMiniMapRect(r.Size); double cdw = _miniMapRect.Width / (double)_columnNum; double cdh = _miniMapRect.Height / (double)_rowNum; Point lt = new Point((int)(_xFirstIdx * cdw) + _miniMapRect.X, (int)(_yFirstIdx * cdh) + _miniMapRect.Y); Point rb = new Point((int)(_xLastIdx * cdw) + _miniMapRect.X, (int)((_yLastIdx - 1) * cdh) + _miniMapRect.Y); lt.Offset(r.Location); rb.Offset(r.Location); if (rb.Y - lt.Y > r.Height) { rb.Y = lt.Y + r.Height; } SdlDotNet.Graphics.Primitives.Box viewBox = new SdlDotNet.Graphics.Primitives.Box(lt, rb); SdlDotNet.Graphics.Primitives.Box viewBoxIn = new SdlDotNet.Graphics.Primitives.Box(new Point(lt.X + 1, lt.Y + 1), new Point(rb.X - 1, rb.Y - 1)); s.Draw(viewBox, _strongColor, true, false); s.Draw(viewBoxIn, _strongColor, true, false); }
public override void Render(int x, int y, SdlDotNet.Graphics.Surface dest) { //Code copied from Dialogs.DrawWindow int Border = dialogs.Border; Color bgColor = dialogs.bgColor; SdlDotNet.Graphics.Surface surface = dialogs.surface; SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box( new Point(x - dialogs.Margin / 2, y - dialogs.Margin / 2), size); dest.Draw(box, bgColor, false, true); for (int i = Border; i < box.Width - Border; i += Border) { dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition1), new Rectangle(2 * Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition2 - Border + 1), new Rectangle(2 * Border, Border, Border, Border)); } for (int i = Border; i < box.Height - Border; i += Border) { dest.Blit(surface, new Point(box.XPosition1, box.YPosition1 + i), new Rectangle(3 * Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1 + i), new Rectangle(3 * Border, Border, Border, Border)); } dest.Blit(surface, new Point(box.XPosition1, box.YPosition1), new Rectangle(0, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1), new Rectangle(Border, 0, Border, Border)); dest.Blit(surface, new Point(box.XPosition1, box.YPosition2 - Border + 1), new Rectangle(0, Border, Border, Border)); dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition2 - Border + 1), new Rectangle(Border, Border, Border, Border)); }
public static void DrawMiniBars(RendererDestinationData destData) { int userHPBarStartX = 40;//DrawingSupport.GetCenterX(destData.Size.Width, 100); TextRenderer.DrawText(destData, "HP:", Color.WhiteSmoke, Color.Black, new Point(userHPBarStartX - 30, 5)); SdlDotNet.Graphics.Primitives.Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userHPBarStartX - 1, destData.Location.Y + 17), new Point(destData.Location.X + userHPBarStartX + 100 + 1, destData.Location.Y + 27)); destData.Draw(hpBox, Color.Black, false, false); hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userHPBarStartX, destData.Location.Y + 17 + 1), new Point(Convert.ToInt32(destData.Location.X + userHPBarStartX + (Logic.MathFunctions.CalculatePercent(PlayerManager.MyPlayer.GetActiveRecruit().HP, PlayerManager.MyPlayer.GetActiveRecruit().MaxHP) * 0.01) * 100), destData.Location.Y + 27 - 1)); Color hpColor; if (PlayerManager.MyPlayer.GetActiveRecruit().HP < PlayerManager.MyPlayer.GetActiveRecruit().MaxHP / 5) { hpColor = Color.Red; } else if (PlayerManager.MyPlayer.GetActiveRecruit().HP < PlayerManager.MyPlayer.GetActiveRecruit().MaxHP / 2) { hpColor = Color.Yellow; } else { hpColor = Color.Green; } destData.Draw(hpBox, hpColor, false, true); int userBellyBarStartX = 205;//DrawingSupport.GetCenterX(destData.Size.Width, 100); TextRenderer.DrawText(destData, "Belly:", Color.WhiteSmoke, Color.Black, new Point(userBellyBarStartX - 45, 5)); SdlDotNet.Graphics.Primitives.Box bellyBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userBellyBarStartX - 1, destData.Location.Y + 17), new Point(destData.Location.X + userBellyBarStartX + 100 + 1, destData.Location.Y + 27)); destData.Draw(bellyBox, Color.Black, false, false); bellyBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + userBellyBarStartX, destData.Location.Y + 17 + 1), new Point(Convert.ToInt32(destData.Location.X + userBellyBarStartX + (Logic.MathFunctions.CalculatePercent(PlayerManager.MyPlayer.Belly, PlayerManager.MyPlayer.MaxBelly) * 0.01) * 100), destData.Location.Y + 27 - 1)); Color bellyColor; if (PlayerManager.MyPlayer.Belly < PlayerManager.MyPlayer.MaxBelly / 5) { bellyColor = Color.Red; } else if (PlayerManager.MyPlayer.Belly < PlayerManager.MyPlayer.MaxBelly / 2) { bellyColor = Color.Yellow; } else { bellyColor = Color.Green; } destData.Draw(bellyBox, bellyColor, false, true); }
void TilesetViewer_Paint(object sender, EventArgs e) { if (vScroll != null && hScroll != null) { vScroll.BlitToScreen(base.Buffer); hScroll.BlitToScreen(base.Buffer); DrawTiles(); SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(new Point((selectedTile.X - hScroll.Value) * Constants.TILE_WIDTH, (selectedTile.Y - vScroll.Value) * Constants.TILE_HEIGHT), new Size(Constants.TILE_WIDTH * (1 + endTile.X - selectedTile.X), Constants.TILE_HEIGHT * (1 + endTile.Y - selectedTile.Y))); base.Buffer.Draw(box, Color.Red); base.DrawBorder(); if (ParentContainer != null) { ParentContainer.RequestRedraw(); } } }
public virtual void SetAlert(bool on, string message) { _onAlert = on; if (_onAlert && string.IsNullOrEmpty(message)) _onAlert = false; if (_alertSurface != null) _alertSurface.Dispose(); if (!_onAlert) _alertSurface = null; if (_onAlert) { message += "\n\n" + Properties.Resources.Str_AlertTail; string[] lines = message.Split('\n'); Size[] sizes = Array.ConvertAll<string, Size>(lines, (l) => { return ResourceManager.SmallPFont.SizeText(l); }); int maxWidth = 0; int height = 0; foreach (Size s in sizes) { if (maxWidth < s.Width) maxWidth = s.Width; height += (int)(s.Height * Constants.LineHeight); } _alertSurface = new Surface(maxWidth + Constants.WindowPadding * 2, height + Constants.WindowPadding * 2); SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box( Point.Empty, new Size(maxWidth + Constants.WindowPadding * 2 - 1, height + Constants.WindowPadding * 2 - 1)); _alertSurface.Lock(); _alertSurface.Draw(box, Constants.Color_AlertBackground, false, true); _alertSurface.Draw(box, Constants.Color_AlertForeground, false, false); _alertSurface.Unlock(); int y = Constants.WindowPadding; int idx = 0; foreach (string l in lines) { using (Surface ts = ResourceManager.SmallPFont.Render(l, Constants.Color_AlertForeground)) { if (idx == lines.Length - 1) { _alertSurface.Blit(ts, new Point((int)(_alertSurface.Width / 2.0 - ts.Width / 2.0), y)); } else { _alertSurface.Blit(ts, new Point(Constants.WindowPadding, y)); } y += (int)(ts.Height * Constants.LineHeight); } idx++; } _alertSurface.Update(); } }
private static void draw(object sender, TickEventArgs args) { IVideoSurface.Fill(Color.Black); // flush background black Point HeaderPos = new Point(5, 5); // Point for header drawing var HeaderText = myfont.Render("JaiSeqX by XayrGA ", Color.White); // yay me. Point RAMPos = new Point(150, 5); // Point for header drawing var ramstring = string.Format("MEM: {0}MB", me.PrivateMemorySize / (1024 * 1024)); var RAMText = myfont.Render(ramstring, Color.White); // yay me. Video.Screen.Blit(RAMText, RAMPos); RAMText.Dispose(); Point bpmpos = new Point(230, 5); // Point for header drawing var bpmstring = string.Format("BPM: {0}bpm", BMSPlayer.bpm); var bpmText = myfont.Render(bpmstring, Color.White); // yay me. Video.Screen.Blit(bpmText, bpmpos); bpmText.Dispose(); Point ppqnpos = new Point(320, 5); // Point for header drawing var ppqnstring = string.Format("ppqn: {0}ppqn", BMSPlayer.ppqn); var ppqnText = myfont.Render(ppqnstring, Color.White); // yay me. Video.Screen.Blit(ppqnText, ppqnpos); ppqnText.Dispose(); Video.Screen.Blit(HeaderText, HeaderPos); // Render it to the screen HeaderText.Dispose(); // Don't need it any more. RAMText.Dispose(); for (int i = 0; i < BMSPlayer.subroutine_count; i++) { Point dest = new Point(5, (i * 35) + 30); // Position for channel indicator. Point dest2 = new Point(5, (i * 35) + 42); // Position for delay new SdlDotNet.Graphics.Primitives.Box(new Point(0, (i * 35) + 25), new Size(800, 2)).Draw(IVideoSurface, Color.White, false, true); // Long line separating voices and track indicators. Surface surfVar; Surface surfVar2 = myfont.Render("", Color.Red); if (BMSPlayer.halts[i] == true) { surfVar = myfont.Render("Track " + i + ": HALTED", Color.Red); } else if (BMSPlayer.mutes[i] == true) { surfVar = myfont.Render("Track " + i + ": MUTED", Color.Yellow); } else { var col = Color.White; if (BMSPlayer.updated[i] > 0) { BMSPlayer.updated[i]--; col = Color.Green; } var CSubState = BMSPlayer.subroutines[i].State; //var text2 = string.Format("Vel {3:X} | Note {0:X}, Bank {1:X}, Program {2:X} Delay {4} ActiveVoices {5}",CSubState.note,CSubState.voice_bank,CSubState.voice_program,CSubState.vel,CSubState.delay,BMSPlayer.ChannelManager.channels[i].ActiveVoices); var text2 = string.Format("DEL {0}", CSubState.delay); var text = string.Format("0x{0:X}", CSubState.current_address); surfVar = myfont.Render("Track " + i + " (" + text + ")", col); surfVar2 = myfont.Render(text2, col); for (int sub = 0; sub < BMSPlayer.ChannelManager.channels[i].ActiveVoices; sub++) { var sdest = dest; sdest.Offset(140 + 27 * sub, 0); var wtf = new SdlDotNet.Graphics.Primitives.Box(sdest, new Size(25, 25)); wtf.Draw(IVideoSurface, Color.Red, false, true); } } new SdlDotNet.Graphics.Primitives.Box(new Point(135, 0), new Size(2, 800)).Draw(IVideoSurface, Color.White, false, true); // Controls each line Video.Screen.Blit(surfVar, dest); Video.Screen.Blit(surfVar2, dest2); surfVar.Dispose(); surfVar2.Dispose(); } IVideoSurface.Update(); // Update the video surface. }
protected virtual void renderMiniMapViewBox(Surface s, Rectangle r) { updateMiniMapRect(r.Size); double cdw = _miniMapRect.Width / (double)_columnNum; double cdh = _miniMapRect.Height / (double)_rowNum; Point lt = new Point((int)(_xFirstIdx * cdw) + _miniMapRect.X, (int)(_yFirstIdx * cdh) + _miniMapRect.Y); Point rb = new Point((int)(_xLastIdx * cdw) + _miniMapRect.X, (int)((_yLastIdx - 1) * cdh) + _miniMapRect.Y); lt.Offset(r.Location); rb.Offset(r.Location); if (rb.Y - lt.Y > r.Height) rb.Y = lt.Y + r.Height; SdlDotNet.Graphics.Primitives.Box viewBox = new SdlDotNet.Graphics.Primitives.Box(lt, rb); SdlDotNet.Graphics.Primitives.Box viewBoxIn = new SdlDotNet.Graphics.Primitives.Box(new Point(lt.X + 1, lt.Y + 1), new Point(rb.X - 1, rb.Y - 1)); s.Draw(viewBox, _strongColor, true, false); s.Draw(viewBoxIn, _strongColor, true, false); }
public virtual void SetAlert(bool on, string message) { _onAlert = on; if (_onAlert && string.IsNullOrEmpty(message)) { _onAlert = false; } if (_alertSurface != null) { _alertSurface.Dispose(); } if (!_onAlert) { _alertSurface = null; } if (_onAlert) { message += "\n\n" + Properties.Resources.Str_AlertTail; string[] lines = message.Split('\n'); Size[] sizes = Array.ConvertAll <string, Size>(lines, (l) => { return(ResourceManager.SmallPFont.SizeText(l)); }); int maxWidth = 0; int height = 0; foreach (Size s in sizes) { if (maxWidth < s.Width) { maxWidth = s.Width; } height += (int)(s.Height * Constants.LineHeight); } _alertSurface = new Surface(maxWidth + Constants.WindowPadding * 2, height + Constants.WindowPadding * 2); SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box( Point.Empty, new Size(maxWidth + Constants.WindowPadding * 2 - 1, height + Constants.WindowPadding * 2 - 1)); _alertSurface.Lock(); _alertSurface.Draw(box, Constants.Color_AlertBackground, false, true); _alertSurface.Draw(box, Constants.Color_AlertForeground, false, false); _alertSurface.Unlock(); int y = Constants.WindowPadding; int idx = 0; foreach (string l in lines) { using (Surface ts = ResourceManager.SmallPFont.Render(l, Constants.Color_AlertForeground)) { if (idx == lines.Length - 1) { _alertSurface.Blit(ts, new Point((int)(_alertSurface.Width / 2.0 - ts.Width / 2.0), y)); } else { _alertSurface.Blit(ts, new Point(Constants.WindowPadding, y)); } y += (int)(ts.Height * Constants.LineHeight); } idx++; } _alertSurface.Update(); } }
private void UpdateItems() { this.ItemSurf = null; //this.BlockSurf.Dispose(); this.ItemSurf = new Surface(this.levelSize * this.GridSize, this.levelSize * this.GridSize); this.ItemSurf.Transparent = true; List<Item> classRef; classRef = (List<Item>)this.items; for (int i = 0; i < classRef.Count(); i++) { if (layerStatus[(int)classRef.ElementAt(i)._layer]) { IPrimitive p; p = new SdlDotNet.Graphics.Primitives.Box(0, 0, 0, 0); if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } this.ItemSurf.Draw(p, Color.YellowGreen); } } this.surfaceUpdated = 1; }
private void UpdateTemp() { /* The dispose method of Surface didn't release memory */ this.TempSurf = null; this.TempSurf = new Surface(this.levelSize * this.GridSize, this.levelSize * this.GridSize); this.TempSurf.Transparent = true; /* Add a temporary block if user is currently drawing */ if (this.isDrawingBlock) { IPrimitive p = new SdlDotNet.Graphics.Primitives.Box( (short)((original_x * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-original_y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((current_x * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-current_y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p, Color.Orange); } /* Draw Selected Blocks */ List<Block> classRef; classRef = (List<Block>)this.blocks; for (int i = 0; i < classRef.Count(); i++) { if (classRef.ElementAt(i).selected && layerStatus[(int)classRef.ElementAt(i)._layer]) { IPrimitive p; p = new SdlDotNet.Graphics.Primitives.Box(0, 0, 0, 0); if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (classRef.ElementAt(i).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (-classRef.ElementAt(i).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.Z * this.GridSize) + (classRef.ElementAt(i).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (-classRef.ElementAt(i).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (classRef.ElementAt(i).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Z * this.GridSize) + (-classRef.ElementAt(i).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } this.TempSurf.Draw(p, Color.LightGreen); } } if (this.isResizingBlock) { if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { #region ResizeXY if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeXY } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { #region ResizeZY if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeZY } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { #region ResizeXZ if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeXY } } /* Mark selected items */ List<Item> classRef2; classRef2 = (List<Item>)this.items; for (int i = 0; i < classRef2.Count(); i++) { if (classRef2.ElementAt(i).selected && layerStatus[(int)classRef2.ElementAt(i)._layer]) { IPrimitive p; p = new SdlDotNet.Graphics.Primitives.Box(0, 0, 0, 0); if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } this.TempSurf.Draw(p, Color.LightGreen); } } this.surfaceUpdated = 1; }