📄 main.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
namespace AlphaBlendTest
{
public partial class main : Form
{
string path = "";
Bitmap backImage;
Bitmap topBar;
Bitmap topLock;
Bitmap battery;
Bitmap signal;
// Bitmap slideAni;
Font timeFont = new Font("Tahoma", 32, FontStyle.Regular);
Font dateFont;
string time = "";
Graphics gxBuffer;
Bitmap offBitmap;
bool showPins = true;
string date = "";
Brush whiteBrush;
private ImageButton buttonOne;
private ImageButton buttonTwo;
private ImageButton buttonThree;
private ImageButton buttonFour;
private ImageButton buttonFive;
public main()
{
InitializeComponent();
path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
backImage = new Bitmap(path + @"\img\icegirl.bmp");
topBar = new Bitmap(path + @"\img\topbar.bmp");
topLock = new Bitmap(path + @"\img\toplock.bmp");
battery = new Bitmap(path + @"\img\battery.bmp");
signal = new Bitmap(path + @"\img\signal.bmp");
dateFont = new Font("Tahoma", 9, FontStyle.Regular);
whiteBrush = new SolidBrush(Color.White);
time = DateTime.Now.ToString("hh:mm");
date = DateTime.Now.DayOfWeek.ToString() + ", " + DateTime.Now.ToString("MMMM") + " " + DateTime.Now.Day.ToString();
offBitmap = new Bitmap(this.Width, this.Height);
gxBuffer = Graphics.FromImage(offBitmap);
//buttonOne = new ImageButton(this, new Point(14, 20));
//buttonOne.Image = new Bitmap(path + @"\img\camera.bmp");
//buttonOne.ImageDown = new Bitmap(path + @"\img\camera_p.bmp");
//buttonTwo = new ImageButton(this, new Point(56, 20));
//buttonTwo.Image = new Bitmap(path + @"\img\map.bmp");
//buttonTwo.ImageDown = new Bitmap(path + @"\img\map_p.bmp");
//buttonThree = new ImageButton(this, new Point(98, 20));
//buttonThree.Image = new Bitmap(path + @"\img\camera.bmp");
//buttonThree.ImageDown = new Bitmap(path + @"\img\camera_p.bmp");
//buttonFour = new ImageButton(this, new Point(140, 20));
//buttonFour.Image = new Bitmap(path + @"\img\map.bmp");
//buttonFour.ImageDown = new Bitmap(path + @"\img\map_p.bmp");
// buttonFive = new ImageButton(this, new Point(182, 20));
// buttonFive.Image = new Bitmap(path + @"\img\camera.bmp");
// buttonFive.ImageDown = new Bitmap(path + @"\img\camera_p.bmp");
}
protected override void OnPaint(PaintEventArgs e)
{
gxBuffer.Clear(this.BackColor);
//先绘制背景
gxBuffer.DrawImage(backImage, 0, 0);
DrawTransp.DrawAlpha(gxBuffer, signal, 200, 0, 0);
DrawTransp.DrawAlpha(gxBuffer, topLock, 200, signal.Width, 0);
DrawTransp.DrawAlpha(gxBuffer, battery, 200, topLock.Width + signal.Width, 0);
DrawTransp.DrawAlpha(gxBuffer, topBar, 170, 0, 250);
SizeF size = gxBuffer.MeasureString(time, timeFont);
int x = this.Width / 2 - (int)size.Width / 2;
DrawTransp.DrawTime(time, gxBuffer, x,252);
size = gxBuffer.MeasureString(date, dateFont);
x = this.Width / 2 - (int)size.Width / 2;
gxBuffer.DrawString(date, dateFont, whiteBrush, x, 300);
//buttonOne.Paint(gxBuffer);
//buttonTwo.Paint(gxBuffer);
//buttonThree.Paint(gxBuffer);
//buttonFour.Paint(gxBuffer);
//buttonFive.Paint(gxBuffer);
e.Graphics.DrawImage(offBitmap, 0, 0);
}
private void timer1_Tick(object sender, EventArgs e)
{
if (showPins)
{
time = DateTime.Now.ToString("hh:mm:ss");
}
else
{
time = DateTime.Now.ToString("hh:mm:ss");
}
showPins = !showPins;
this.Invalidate(new Rectangle(0, 20, 240, 70));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -