using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace thinger.com.Pro1
{
public partial class Frmlogin : Form
{
public Frmlogin()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//获取画布
Graphics g = e.Graphics;
Rectangle rec = new Rectangle(0,0,this.Width, this.Height);
LinearGradientBrush brush = new LinearGradientBrush(
rec, Color.FromArgb(225, 101, 127), Color.FromArgb(93, 127, 124),
LinearGradientMode.BackwardDiagonal);
g.FillRectangle(brush, rec);
}
private void label1_Click(object sender, EventArgs e)
{
}
//无边框拖动,一个事件可以被很多事件引用,比如其他字框也可以引用
//lal_title_MouseDown与lal_title_MouseMove
private Point mpoint;
private void lal_title_MouseDown(object sender, MouseEventArgs e)
{
mpoint = e.Location;
}
private void lal_title_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = new Point(this.Location.X + e.X - mpoint.X,
this.Location.Y + e.Y - mpoint.Y);//+上鼠标移动的距离:e.X,减去原来的距离mpoint.X
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace thinger.com.Pro1
{
static class Program
{
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Frmlogin frm = new Frmlogin();
DialogResult dr = frm.ShowDialog();
if (dr == DialogResult.OK)
{
Application.Run(new Frmlogin());
}
//Application.Run(new Frmlogin());
}
}
}