gpt4 book ai didi

c# - 我可以在 system.drawing 中添加一个控件,例如一个按钮吗?

转载 作者:太空狗 更新时间:2023-10-29 23:46:03 27 4
gpt4 key购买 nike

    using System.Drawing;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication1
{
[Serializable]
public class GMapBaloonTool: GMapToolTip, ISerializable
{
public float Radius = 10f;
public GMapBaloonTool(GMapMarker marker)
: base(marker)
{
Stroke = new Pen(Color.FromArgb(140, Color.Navy));
Stroke.Width = 3;
this.Stroke.LineJoin = LineJoin.Round;
this.Stroke.StartCap = LineCap.RoundAnchor;
Fill = Brushes.Pink;
}

上面的代码,让工具提示改变了它的颜色。
enter image description here

我正在使用 gMaps.net在 winforms C# 中创建自定义谷歌地图。我正在努力添加一个标记 + onClick 事件,它将显示来自 DVR 的视频源。
唯一的问题是,内置的 GMapsToolTip 只显示字符串,尽管我有一个 activeX 作为相机的控件。
我需要的是在工具提示中显示相机(activeX)。
this在 greatmaps 的一个论坛上。创作者说我可以制作自定义工具提示。
所以我要问的是,是否可以使用此 system.drawing 命名空间创建/添加控件?
如果可能的话,请告诉我怎么做..
如果没有,如果您知道任何其他方式,请告知。

            public override void OnRender(Graphics g)
{
System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
rect.Offset(Offset.X, Offset.Y);
using (GraphicsPath objGP = new GraphicsPath())
{
objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

objGP.CloseFigure();
g.FillPath(Fill, objGP);
g.DrawPath(Stroke, objGP);
}

g.DrawString(Marker.ToolTipText, Font, Foreground, rect, Format);
g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
}

#region ISerializable Members
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Radius", this.Radius);
base.GetObjectData(info, context);
}

protected GMapBaloonTool(SerializationInfo info, StreamingContext context)
: base(info, context)
{
this.Radius = Extensions.GetStruct<float>(info, "Radius", 10f);
}
#endregion
}
}

此代码使气球呈圆形,所以我不知道如何添加我的控件以使其看起来像这样..(由 html 制作,但我需要它在 winforms 上)

enter image description here

希望有人能帮助我。哦,如果您只想将我重定向回 greatmaps 的讨论站点,请不要这样做。我从那里不太了解,所以我在这里问。

最佳答案

您可以尝试在相机控件上使用 DrawToBitmap 方法。我希望发生以下三种情况之一:

  • 你得到一个黑色的矩形
  • 在你调用 DrawToBitmap 的那一刻你得到了一帧相机
  • 您获得实时视频源(得益于叠加视频播放功能)

您最好的选择是数字 2 和 3,因为它们可用于提供您想要的功能。如果您得到第 1 个,则控件呈现不使用 Winforms 的常用呈现逻辑,因此您必须解决它。

在实践中,您可能希望更直接地访问相机渲染输出,因为每秒创建 25 个位图可能工作量太大而无用。你会到达那里:)

关于c# - 我可以在 system.drawing 中添加一个控件,例如一个按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20232754/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com