/// <summary> /// Combines two surfaces together. /// </summary> /// <param name="bottomImage">The surface that will be used as the background.</param> /// <param name="topImage">The surface that will be used as the foreground.</param> /// <returns>The combined surface.</returns> public static SdlDotNet.Graphics.Surface CombineImage(SdlDotNet.Graphics.Surface bottomImage, SdlDotNet.Graphics.Surface topImage) { SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(new System.Drawing.Size(System.Math.Max(bottomImage.Width, topImage.Width), System.Math.Max(bottomImage.Height, topImage.Height))); returnSurf.Blit(bottomImage, new System.Drawing.Point(0, 0)); returnSurf.Blit(topImage, new System.Drawing.Point(0, 0)); return returnSurf; }
/// <summary> /// Combines two surfaces together. /// </summary> /// <param name="bottomImage">The surface that will be used as the background.</param> /// <param name="topImage">The surface that will be used as the foreground.</param> /// <returns>The combined surface.</returns> public static SdlDotNet.Graphics.Surface CombineImage(SdlDotNet.Graphics.Surface bottomImage, SdlDotNet.Graphics.Surface topImage) { SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(new System.Drawing.Size(System.Math.Max(bottomImage.Width, topImage.Width), System.Math.Max(bottomImage.Height, topImage.Height))); returnSurf.Blit(bottomImage, new System.Drawing.Point(0, 0)); returnSurf.Blit(topImage, new System.Drawing.Point(0, 0)); return(returnSurf); }
public override void UpdateControls(SdlDotNet.Graphics.Surface dstSurf, SdlDotNet.Core.TickEventArgs e) { try { if (!mIsDisposing) { // mBuffer.Fill(SystemColors.Control); base.UpdateControls(mBuffer, e); if (mWindowed) { dstSurf.Blit(mBorderBuffer, mFullBounds.Location, new Rectangle(0, 0, this.FullBounds.Width, this.FullBounds.Height)); } dstSurf.Blit(mBuffer, mControlBounds.Location, new Rectangle(0, 0, this.ControlBounds.Width, this.ControlBounds.Height)); } } catch { } }
/// <summary> /// Crops a surface from the specified surface. /// </summary> /// <param name="surfaceToCrop">The surface to crop.</param> /// <param name="cropRectangle">The rectangle bounds to crop.</param> /// <returns>The cropped surface.</returns> public static SdlDotNet.Graphics.Surface CropImage(SdlDotNet.Graphics.Surface surfaceToCrop, System.Drawing.Rectangle cropRectangle) { SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(cropRectangle.Size); returnSurf.Transparent = surfaceToCrop.Transparent; //returnSurf.Fill(System.Drawing.Color.Transparent); //returnSurf.TransparentColor = surfaceToCrop.TransparentColor; returnSurf.Blit(surfaceToCrop, new System.Drawing.Point(0, 0), cropRectangle); return returnSurf; }
/// <summary> /// Crops a surface from the specified surface. /// </summary> /// <param name="surfaceToCrop">The surface to crop.</param> /// <param name="cropRectangle">The rectangle bounds to crop.</param> /// <returns>The cropped surface.</returns> public static SdlDotNet.Graphics.Surface CropImage(SdlDotNet.Graphics.Surface surfaceToCrop, System.Drawing.Rectangle cropRectangle) { SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(cropRectangle.Size); returnSurf.Transparent = surfaceToCrop.Transparent; //returnSurf.Fill(System.Drawing.Color.Transparent); //returnSurf.TransparentColor = surfaceToCrop.TransparentColor; returnSurf.Blit(surfaceToCrop, new System.Drawing.Point(0, 0), cropRectangle); return(returnSurf); }
private void AddBorder() { Size newSize = this.Size; switch (mWindowState) { case WindowManager.WindowState.Normal: newSize = this.Size; break; case WindowManager.WindowState.Maximized: newSize = new Size(SdlDotNet.Graphics.Video.Screen.Width, SdlDotNet.Graphics.Video.Screen.Height - Globals.GameScreen.TaskBar.Height); break; case WindowManager.WindowState.Minimized: return; } mBorderBuffer = new SdlDotNet.Graphics.Surface(AddBorderSize(newSize)); mBorderBuffer.AlphaBlending = true; mBorderBuffer.Alpha = mBorderAlpha; mTitleBarBounds = new Rectangle(0, 0, newSize.Width + 2, 20); mTitleBarSurface = new SdlDotNet.Graphics.Surface(mTitleBarBounds.Size); mTitleBarSurface.Fill(Color.Blue); if (mText != "") { mTitleBarSurface.Blit(Logic.Graphics.FontManager.TextBoxFont.Render(mText, Color.Black, false), new Point(20, 3)); } mCloseButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0), mCloseButtonSurf.Size); if (mCloseable) { mTitleBarSurface.Blit(mCloseButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0)); } mMaximizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0), mMaximizeButtonSurf.Size); if (mMaximizable) { mTitleBarSurface.Blit(mMaximizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0)); } mMinimizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0), mMinimizeButtonSurf.Size); if (mMinimizable) { mTitleBarSurface.Blit(mMinimizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0)); } mBorderBuffer.Blit(mTitleBarSurface, mTitleBarBounds.Location); }
void lblAllMoves_MouseDown(object sender, MouseButtonEventArgs e) { if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuMoveSelected") == null) { Label label = (Label)sender; SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size); dragSurf.Fill(Color.Black); dragSurf.Blit(label.Buffer, new Point(0, 0)); label.DoDragDrop(Array.IndexOf(lblAllMoves, sender), DragDropEffects.Copy, dragSurf); } }
public SdlDotNet.Graphics.Surface RenderPassword(char passwordChar) { int charWidth = mFont.SizeText(passwordChar.ToString()).Width; SdlDotNet.Graphics.Surface tempSurf = new SdlDotNet.Graphics.Surface(mMaxWidth, mFont.Height); tempSurf.Fill(Color.Transparent); tempSurf.TransparentColor = Color.Transparent; tempSurf.Transparent = true; int lastX = 0; for (int i = 0; i < mChars.Count; i++) { if (mChars[i].Char != "\n") { if (mChars[i].CharOptions != null) { mFont.Bold = mChars[i].CharOptions.Bold; mFont.Italic = mChars[i].CharOptions.Italic; mFont.Underline = mChars[i].CharOptions.Underline; } Color bltColor; if (mChars[i].CharColor == Color.Empty) { bltColor = mDefaultForeColor; } else { bltColor = mChars[i].CharColor; } SdlDotNet.Graphics.Surface charSurf = mFont.Render(passwordChar.ToString(), bltColor, false); tempSurf.Blit(charSurf, new Point(lastX, 0)); charSurf.Close(); if (mFont.Bold == true) { mFont.Bold = false; } if (mFont.Italic == true) { mFont.Italic = false; } if (mFont.Underline == true) { mFont.Underline = false; } lastX += charWidth; } } return(tempSurf); }
void lblVisibleItems_MouseDown(object sender, MouseButtonEventArgs e) { if (mode == Enums.InvMenuType.Use) { if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuItemSelected") == null) { Label label = (Label)sender; SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size); dragSurf.Fill(Color.Black); dragSurf.Blit(label.Buffer, new Point(0, 0)); label.DoDragDrop(Array.IndexOf(lblVisibleItems, sender) + 1 + (currentTen * 10), DragDropEffects.Copy, dragSurf); } } }
private void DrawTiles() { if (vScroll != null && hScroll != null & activeItemSurf != null) { int maxTilesX = System.Math.Min(activeItemSurf.Size.Width, (this.Width - vScroll.Width)) / Constants.TILE_WIDTH; int maxTilesY = System.Math.Min(activeItemSurf.Size.Height, (this.Height - hScroll.Height)) / Constants.TILE_HEIGHT; int startX = hScroll.Value; int startY = vScroll.Value; for (int y = startY; y < maxTilesY + startY; y++) { for (int x = startX; x < maxTilesX + startX; x++) { //int num = DetermineTileNumber(x, y); //if (x < (activeItemSurf.Size.Width / Constants.TILE_WIDTH) && y < (activeItemSurf.Size.Height / Constants.TILE_HEIGHT)) //{ SdlDotNet.Graphics.Surface tile = new SdlDotNet.Graphics.Surface(Constants.TILE_WIDTH, Constants.TILE_HEIGHT); tile.Blit(activeItemSurf, new Point(0, 0), new Rectangle(x * Constants.TILE_WIDTH, y * Constants.TILE_HEIGHT, Constants.TILE_WIDTH, Constants.TILE_HEIGHT)); base.Buffer.Blit(tile, new Point((x - startX) * Constants.TILE_WIDTH, (y - startY) * Constants.TILE_HEIGHT)); //} } } } }
public SdlDotNet.Graphics.Surface RenderPassword(char passwordChar) { int charWidth = mFont.SizeText(passwordChar.ToString()).Width; SdlDotNet.Graphics.Surface tempSurf = new SdlDotNet.Graphics.Surface(mMaxWidth, mFont.Height); tempSurf.Fill(Color.Transparent); tempSurf.TransparentColor = Color.Transparent; tempSurf.Transparent = true; int lastX = 0; for (int i = 0; i < mChars.Count; i++) { if (mChars[i].Char != "\n") { if (mChars[i].CharOptions != null) { mFont.Bold = mChars[i].CharOptions.Bold; mFont.Italic = mChars[i].CharOptions.Italic; mFont.Underline = mChars[i].CharOptions.Underline; } Color bltColor; if (mChars[i].CharColor == Color.Empty) bltColor = mDefaultForeColor; else bltColor = mChars[i].CharColor; SdlDotNet.Graphics.Surface charSurf = mFont.Render(passwordChar.ToString(), bltColor, false); tempSurf.Blit(charSurf, new Point(lastX, 0)); charSurf.Close(); if (mFont.Bold == true) { mFont.Bold = false; } if (mFont.Italic == true) { mFont.Italic = false; } if (mFont.Underline == true) { mFont.Underline = false; } lastX += charWidth; } } return tempSurf; }