diff --git a/example/Demo/Controls/Popover.cs b/example/Demo/Controls/Popover.cs
index 5f37156896293b1f145f96ec989169eb8cbe5c74..23bea462c74ae37dc2b9473c0d23023b56517fe6 100644
--- a/example/Demo/Controls/Popover.cs
+++ b/example/Demo/Controls/Popover.cs
@@ -16,6 +16,7 @@
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
+using Microsoft.VisualBasic.Devices;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -32,8 +33,10 @@ namespace Demo.Controls
}
private void button1_Click(object sender, EventArgs e)
+
{
- AntdUI.Popover.open(button1, "Basic Popover", "Content" + Environment.NewLine + "Content");
+
+ AntdUI.Popover.open(button1, "Basic Popover", "Content" + Environment.NewLine + "Content",MousePosition);
}
private void button2_Click(object sender, EventArgs e)
@@ -43,62 +46,62 @@ namespace Demo.Controls
private void buttonTL_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonTL, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.TL);
+ AntdUI.Popover.open(buttonTL, "Title", "Content" + Environment.NewLine + "Content",null, AntdUI.TAlign.TL);
}
private void buttonTop_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonTop, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.Top);
+ AntdUI.Popover.open(buttonTop, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.Top);
}
private void buttonTR_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonTR, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.TR);
+ AntdUI.Popover.open(buttonTR, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.TR);
}
private void buttonRT_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonRT, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.RT);
+ AntdUI.Popover.open(buttonRT, "Title", "Content" + Environment.NewLine + "Content",null, AntdUI.TAlign.RT);
}
private void buttonRight_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonRight, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.Right);
+ AntdUI.Popover.open(buttonRight, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.Right);
}
private void buttonRB_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonRB, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.RB);
+ AntdUI.Popover.open(buttonRB, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.RB);
}
private void buttonBR_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonBR, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.BR);
+ AntdUI.Popover.open(buttonBR, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.BR);
}
private void buttonBottom_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonBottom, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.Bottom);
+ AntdUI.Popover.open(buttonBottom, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.Bottom);
}
private void buttonBL_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonBL, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.BL);
+ AntdUI.Popover.open(buttonBL, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.BL);
}
private void buttonLB_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonLB, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.LB);
+ AntdUI.Popover.open(buttonLB, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.LB);
}
private void buttonLeft_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonLeft, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.Left);
+ AntdUI.Popover.open(buttonLeft, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.Left);
}
private void buttonLT_Click(object sender, EventArgs e)
{
- AntdUI.Popover.open(buttonLT, "Title", "Content" + Environment.NewLine + "Content", AntdUI.TAlign.LT);
+ AntdUI.Popover.open(buttonLT, "Title", "Content" + Environment.NewLine + "Content", null, AntdUI.TAlign.LT);
}
}
}
\ No newline at end of file
diff --git a/src/AntdUI/Controls/Popover.cs b/src/AntdUI/Controls/Popover.cs
index e49e4f6b7e4f792495daa4aa081e36254b81f490..95645a4fd9646d239f39cfa49304e091e8ef905b 100644
--- a/src/AntdUI/Controls/Popover.cs
+++ b/src/AntdUI/Controls/Popover.cs
@@ -34,21 +34,24 @@ namespace AntdUI
/// 所属控件
/// 标题
/// 内容
+ /// 自定义显示位置
/// 箭头方向
- public static Form? open(Control control, string title, string content, TAlign ArrowAlign = TAlign.Bottom)
+ public static Form? open(Control control, string title, string content, Point? customPoint = null, TAlign ArrowAlign = TAlign.Bottom)
{
- return open(new Config(control, title, content) { ArrowAlign = ArrowAlign });
+ return open(new Config(control, title, content) { ArrowAlign = ArrowAlign ,CustomPoint = customPoint });
}
+
///
/// Popover 气泡卡片
///
/// 所属控件
/// 内容
+ /// 自定义显示位置
/// 箭头方向
- public static Form? open(Control control, string content, TAlign ArrowAlign = TAlign.Bottom)
+ public static Form? open(Control control, string content, Point? customPoint = null, TAlign ArrowAlign = TAlign.Bottom)
{
- return open(new Config(control, content) { ArrowAlign = ArrowAlign });
+ return open(new Config(control, content) { ArrowAlign = ArrowAlign, CustomPoint = customPoint });
}
///
@@ -57,10 +60,11 @@ namespace AntdUI
/// 所属控件
/// 标题
/// 控件/内容
+ /// 自定义显示位置
/// 箭头方向
- public static Form? open(Control control, string title, object content, TAlign ArrowAlign = TAlign.Bottom)
+ public static Form? open(Control control, string title, object content, Point? customPoint = null, TAlign ArrowAlign = TAlign.Bottom)
{
- return open(new Config(control, title, content) { ArrowAlign = ArrowAlign });
+ return open(new Config(control, title, content) { ArrowAlign = ArrowAlign, CustomPoint = customPoint });
}
///
@@ -68,10 +72,11 @@ namespace AntdUI
///
/// 所属控件
/// 控件/内容
+ /// 自定义显示位置
/// 箭头方向
- public static Form? open(Control control, object content, TAlign ArrowAlign = TAlign.Bottom)
+ public static Form? open(Control control, object content, Point? customPoint = null, TAlign ArrowAlign = TAlign.Bottom)
{
- return open(new Config(control, content) { ArrowAlign = ArrowAlign });
+ return open(new Config(control, content) { ArrowAlign = ArrowAlign, CustomPoint = customPoint });
}
///
@@ -203,6 +208,11 @@ namespace AntdUI
/// 用户定义数据
///
public object? Tag { get; set; }
+
+ ///
+ /// 自定义位置
+ ///
+ public Point? CustomPoint { get; set; }
}
///
diff --git a/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs b/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs
index 40ebe03a5c1fd404f61f97f2d7c5f4a2be4ec83b..0175f8a0e2848f6869981370e418febfa0f65bae 100644
--- a/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs
+++ b/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs
@@ -164,11 +164,20 @@ namespace AntdUI
}
}
});
+ Point point;
+ if (config.CustomPoint != null)
+ {
+ point = config.CustomPoint.Value;
+ }
+ else
+ {
+ point = config.Control.PointToScreen(Point.Empty);
- var point = config.Control.PointToScreen(Point.Empty);
+ }
if (config.Offset is RectangleF rectf) SetLocation(config.ArrowAlign.AlignPoint(new Rectangle(point.X + (int)rectf.X, point.Y + (int)rectf.Y, (int)rectf.Width, (int)rectf.Height), TargetRect.Width, TargetRect.Height));
else if (config.Offset is Rectangle rect) SetLocation(config.ArrowAlign.AlignPoint(new Rectangle(point.X + rect.X, point.Y + rect.Y, rect.Width, rect.Height), TargetRect.Width, TargetRect.Height));
- else SetLocation(config.ArrowAlign.AlignPoint(point, config.Control.Size, TargetRect.Width, TargetRect.Height));
+ else SetLocation(config.ArrowAlign.AlignPoint(point, config.CustomPoint != null ? new Size(0, 0) : config.Control.Size, TargetRect.Width, TargetRect.Height));
+
}
public override void LoadOK()
diff --git a/src/AntdUI/Lib/Helper/Helper.RECT.cs b/src/AntdUI/Lib/Helper/Helper.RECT.cs
index aa984cea159b6fe6cd3220440cf290dcb5c82062..dbbedd854aa1683dbb359c1db084bbc9b103bde6 100644
--- a/src/AntdUI/Lib/Helper/Helper.RECT.cs
+++ b/src/AntdUI/Lib/Helper/Helper.RECT.cs
@@ -707,6 +707,8 @@ namespace AntdUI
}
}
+
+
public static Point AlignPoint(this TAlign align, Rectangle rect, Rectangle size)
{
return AlignPoint(align, rect.Location, rect.Size, size.Width, size.Height);