📄 splashform.cs
字号:
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;
namespace MobileDevelopersHandbook
{
public partial class SplashForm : Form
{
public SplashForm()
{
InitializeComponent();
}
private void SplashForm_Load(object sender, EventArgs e)
{
// Show full screen
this.ControlBox = false;
}
protected override void OnPaint(PaintEventArgs e)
{
using (Image backgroundImage =
new Bitmap(System.Reflection.Assembly.GetExecutingAssembly()
.GetManifestResourceStream("MobileDevelopersHandbook.Graphic.JPG")))
{
// Fill the background
e.Graphics.Clear(Color.Black);
// Draw the image, but scale it
// SourceRect is entire image
Rectangle srcRect =
new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height);
// Define the destination rectangle size as 50% of the clipping rectangle
Rectangle destRect =
new Rectangle(0, 0, e.ClipRectangle.Width / 2, e.ClipRectangle.Height / 2);
// Reposition origin to centre the image on the screen
destRect.Location = new Point(
(e.ClipRectangle.Width - destRect.Width) / 2,
(e.ClipRectangle.Height - destRect.Height) / 2);
// Draw the image
e.Graphics.DrawImage(backgroundImage, destRect, srcRect, GraphicsUnit.Pixel);
}
// Create string to draw.
string drawString = "Mobile Developers Handbook";
// Create font and brush.
SolidBrush drawBrush = new SolidBrush(Color.Yellow);
// Draw string to screen using the LogFont.
using (Font ft = CreateLogFont(90))
{
e.Graphics.DrawString(drawString,
ft,
drawBrush,
5,
this.Height - 20,
new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.NoWrap));
}
base.OnPaint(e);
}
private const float POINTS_PER_INCH = 72f;
private Font CreateLogFont(int angle)
{
// Create and define a LogFont structure.
LogFont fontStruct = new LogFont();
using (Graphics g = this.CreateGraphics())
{
// Scale 10point for the dpi of the current display
// also make it negative, means match against character
// height of available fonts
fontStruct.Height = -1 * (int)(14f * (g.DpiY / POINTS_PER_INCH));
}
// Since font width is usually dependent on the height,
// usual to set width to zero
fontStruct.Width = 0;
// Set the font angle.
// Remember to multiply by 10.
fontStruct.Escapement = angle * 10;
// The Escapement member specifies both the
// escapement and orientation. You should set
// Escapement and Orientation to the same value.
fontStruct.Orientation = fontStruct.Escapement;
// No formatting.
fontStruct.Italic = 0;
fontStruct.Underline = 0;
fontStruct.StrikeOut = 0;
// Weight: 0 = default, 400 = normal, 700 = bold
fontStruct.Weight = 0;
fontStruct.CharSet = LogFontCharSet.Default;
fontStruct.OutPrecision = LogFontPrecision.Default;
fontStruct.ClipPrecision = LogFontClipPrecision.Default;
fontStruct.Quality = LogFontQuality.Default;
fontStruct.PitchAndFamily = LogFontPitchAndFamily.Default;
fontStruct.FaceName = "Arial";
// Create the font from the LogFont structure.
return Font.FromLogFont(fontStruct);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -