上个问题
http://topic.csdn.net/u/20091027/00/59cf59f7-bd2d-44bd-8aee-942732f62ba6.html根据反馈问题的代码进行相应修改,代码如下
//// <summary>
/// 绘制实心圆
/// </summary>
/// <param name="Border">边框大小</param>
private void FillEllipse(int Border)
{
GraphicsPath GP = new GraphicsPath();
GP.AddEllipse(new Rectangle(0, 0, Border, Border)); Bitmap Bmp = new Bitmap(Border, Border);
Brush br = new SolidBrush(Properties.Settings.Default.CircleColor);
using (Graphics G = Graphics.FromImage(Bmp))
G.FillEllipse(br, new Rectangle(0, 0, Border, Border)); Panel P = new Panel();
P.Name = "P";
P.BorderStyle = BorderStyle.Fixed3D;
P.Parent = this;
if (frmPB == null) { frmPB = new Form(); }
frmPB.Name = "frmPB";
frmPB.Size = new Size(Border, Border);
frmPB.FormBorderStyle = FormBorderStyle.None;
frmPB.BackgroundImage = Bmp;
frmPB.Opacity = 0.3;
frmPB.ShowIcon = false;
frmPB.ShowInTaskbar = false;
frmPB.Region = new Region(GP);
if (!ShowOnece || frmPB == null)
{
frmPB.Show(P);
ShowOnece = true;
}
this.LocationChanged += new EventHandler(frmMain_LocationChanged); } void frmMain_LocationChanged(object sender, EventArgs e)
{
try
{
Panel P = (Panel)this.Controls.Find("P", true)[0]; if (P == null) return;
//Application.OpenForms["F"].Location = P.PointToScreen(new Point(0, 0)); Application.OpenForms["frmPB"].Location = P.PointToScreen(
new Point(panelVideo.Top + (panelVideo.Width - P.Width) / 2,
panelVideo.Left + (panelVideo.Height - P.Height) / 2));
}
catch (Exception)
{
// throw;
}
}
有两个问题:
1:P.PointToScreen()是以窗体的左上角XY为基准,需要以圆为中心进行调整
2、代码运行后首先圆不是居中的,窗体缩小后再放大就居中了,不知道是什么有因造成的
http://topic.csdn.net/u/20091027/00/59cf59f7-bd2d-44bd-8aee-942732f62ba6.html根据反馈问题的代码进行相应修改,代码如下
//// <summary>
/// 绘制实心圆
/// </summary>
/// <param name="Border">边框大小</param>
private void FillEllipse(int Border)
{
GraphicsPath GP = new GraphicsPath();
GP.AddEllipse(new Rectangle(0, 0, Border, Border)); Bitmap Bmp = new Bitmap(Border, Border);
Brush br = new SolidBrush(Properties.Settings.Default.CircleColor);
using (Graphics G = Graphics.FromImage(Bmp))
G.FillEllipse(br, new Rectangle(0, 0, Border, Border)); Panel P = new Panel();
P.Name = "P";
P.BorderStyle = BorderStyle.Fixed3D;
P.Parent = this;
if (frmPB == null) { frmPB = new Form(); }
frmPB.Name = "frmPB";
frmPB.Size = new Size(Border, Border);
frmPB.FormBorderStyle = FormBorderStyle.None;
frmPB.BackgroundImage = Bmp;
frmPB.Opacity = 0.3;
frmPB.ShowIcon = false;
frmPB.ShowInTaskbar = false;
frmPB.Region = new Region(GP);
if (!ShowOnece || frmPB == null)
{
frmPB.Show(P);
ShowOnece = true;
}
this.LocationChanged += new EventHandler(frmMain_LocationChanged); } void frmMain_LocationChanged(object sender, EventArgs e)
{
try
{
Panel P = (Panel)this.Controls.Find("P", true)[0]; if (P == null) return;
//Application.OpenForms["F"].Location = P.PointToScreen(new Point(0, 0)); Application.OpenForms["frmPB"].Location = P.PointToScreen(
new Point(panelVideo.Top + (panelVideo.Width - P.Width) / 2,
panelVideo.Left + (panelVideo.Height - P.Height) / 2));
}
catch (Exception)
{
// throw;
}
}
有两个问题:
1:P.PointToScreen()是以窗体的左上角XY为基准,需要以圆为中心进行调整
2、代码运行后首先圆不是居中的,窗体缩小后再放大就居中了,不知道是什么有因造成的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货