示例#1
0
文件: Tools.cs 项目: blastboy/Client
 /// <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;
 }
示例#2
0
 /// <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);
 }
示例#3
0
        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 {
            }
        }
示例#4
0
文件: Tools.cs 项目: blastboy/Client
 /// <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;
 }
示例#5
0
 /// <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);
 }
示例#6
0
        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);
        }
示例#7
0
 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);
     }
 }
示例#8
0
        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);
        }
示例#9
0
 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);
         }
     }
 }
示例#10
0
        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));
                        //}
                    }
                }
            }
        }
示例#11
0
 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);
     }
 }
示例#12
0
        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));
                        //}
                    }
                }
            }
        }
示例#13
0
 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);
 }
示例#14
0
        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;
        }
示例#15
0
 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);
         }
     }
 }