c语言main声明主体未标记,新建的类,说我的类必须声明主体,未标记abstruct,extern或partial...

这篇博客详细介绍了GMap.NET Windows Forms库中GMapMarker类的实现,包括其属性、方法和事件。GMapMarker是地图标记的基础抽象类,支持位置、可见性、工具提示等功能,并提供了自定义渲染的接口。博客内容涵盖了如何设置和操作地图标记,以及与地图交互的相关机制。
摘要由CSDN通过智能技术生成

这个是父类

using GMap.NET.WindowsForms.ToolTips;

namespace GMap.NET.WindowsForms

{

using System;

using System.Drawing;

using System.Runtime.Serialization;

using System.Windows.Forms;

///

/// GMap.NET marker

///

[Serializable]

#if !PocketPC

public abstract class GMapMarker : ISerializable, IDisposable

#else

public class GMapMarker: IDisposable

#endif

{

#if PocketPC

static readonly System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();

static GMapMarker()

{

attr.SetColorKey(Color.White, Color.White);

}

#endif

GMapOverlay overlay;

public GMapOverlay Overlay

{

get

{

return overlay;

}

internal set

{

overlay = value;

}

}

private PointLatLng position;

public PointLatLng Position

{

get

{

return position;

}

set

{

if(position != value)

{

position = value;

if(IsVisible)

{

if(Overlay != null && Overlay.Control != null)

{

Overlay.Control.UpdateMarkerLocalPosition(this);

}

}

}

}

}

public object Tag;

Point offset;

public Point Offset

{

get

{

return offset;

}

set

{

if(offset != value)

{

offset = value;

if(IsVisible)

{

if(Overlay != null && Overlay.Control != null)

{

Overlay.Control.UpdateMarkerLocalPosition(this);

}

}

}

}

}

Rectangle area;

///

/// marker position in local coordinates, internal only, do not set it manualy

///

public Point LocalPosition

{

get

{

return area.Location;

}

set

{

if(area.Location != value)

{

area.Location = value;

{

if(Overlay != null && Overlay.Control != null)

{

if(!Overlay.Control.HoldInvalidation)

{

Overlay.Control.Core.Refresh.Set();

}

}

}

}

}

}

///

/// ToolTip position in local coordinates

///

public Point ToolTipPosition

{

get

{

Point ret = area.Location;

ret.Offset(-Offset.X, -Offset.Y);

return ret;

}

}

public Size Size

{

get

{

return area.Size;

}

set

{

area.Size = value;

}

}

public Rectangle LocalArea

{

get

{

return area;

}

}

internal Rectangle LocalAreaInControlSpace

{

get

{

Rectangle r = area;

if(Overlay != null && Overlay.Control != null)

{

r.Offset((int)Overlay.Control.Core.renderOffset.X, (int)overlay.Control.Core.renderOffset.Y);

}

return r;

}

}

public GMapToolTip ToolTip;

public MarkerTooltipMode ToolTipMode = MarkerTooltipMode.OnMouseOver;

string toolTipText;

public string ToolTipText

{

get

{

return toolTipText;

}

set

{

if(ToolTip == null)

{

#if !PocketPC

ToolTip = new GMapRoundedToolTip(this);

#else

ToolTip = new GMapToolTip(this);

#endif

}

toolTipText = value;

}

}

private bool visible = true;

///

/// is marker visible

///

public bool IsVisible

{

get

{

return visible;

}

set

{

if(value != visible)

{

visible = value;

if(Overlay != null && Overlay.Control != null)

{

if(visible)

{

Overlay.Control.UpdateMarkerLocalPosition(this);

}

{

if(!Overlay.Control.HoldInvalidation)

{

Overlay.Control.Core.Refresh.Set();

}

}

}

}

}

}

///

/// if true, marker will be rendered even if it's outside current view

///

public bool DisableRegionCheck = false;

///

/// can maker receive input

///

public bool IsHitTestVisible = true;

private bool isMouseOver = false;

///

/// is mouse over marker

///

public bool IsMouseOver

{

get

{

return isMouseOver;

}

internal set

{

isMouseOver = value;

}

}

public GMapMarker(PointLatLng pos)

{

this.Position = pos;

}

public virtual void OnRender(Graphics g)

{

//

}

#if PocketPC

protected void DrawImageUnscaled(Graphics g, Bitmap inBmp, int x, int y)

{

g.DrawImage(inBmp, new Rectangle(x, y, inBmp.Width, inBmp.Height), 0, 0, inBmp.Width, inBmp.Height, GraphicsUnit.Pixel, attr);

}

#endif

#if !PocketPC

#region ISerializable Members

///

/// Populates a with the data needed to serialize the target object.

///

/// The to populate with data.

/// The destination (see ) for this serialization.

///

/// The caller does not have the required permission.

///

public void GetObjectData(SerializationInfo info, StreamingContext context)

{

info.AddValue("Position", this.Position);

info.AddValue("Tag", this.Tag);

info.AddValue("Offset", this.Offset);

info.AddValue("Area", this.area);

info.AddValue("ToolTip", this.ToolTip);

info.AddValue("ToolTipMode", this.ToolTipMode);

info.AddValue("ToolTipText", this.ToolTipText);

info.AddValue("Visible", this.IsVisible);

info.AddValue("DisableregionCheck", this.DisableRegionCheck);

info.AddValue("IsHitTestVisible", this.IsHitTestVisible);

}

///

/// Initializes a new instance of the class.

///

/// The info.

/// The context.

protected GMapMarker(SerializationInfo info, StreamingContext context)

{

this.Position = Extensions.GetStruct(info, "Position", PointLatLng.Empty);

this.Tag = Extensions.GetValue(info, "Tag", null);

this.Offset = Extensions.GetStruct(info, "Offset", Point.Empty);

this.area = Extensions.GetStruct(info, "Area", Rectangle.Empty);

this.ToolTip = Extensions.GetValue(info, "ToolTip", null);

this.ToolTipMode = Extensions.GetStruct(info, "ToolTipMode", MarkerTooltipMode.OnMouseOver);

this.ToolTipText = info.GetString("ToolTipText");

this.IsVisible = info.GetBoolean("Visible");

this.DisableRegionCheck = info.GetBoolean("DisableregionCheck");

this.IsHitTestVisible = info.GetBoolean("IsHitTestVisible");

}

#endregion

#endif

#region IDisposable Members

bool disposed = false;

public virtual void Dispose()

{

if(!disposed)

{

disposed = true;

Tag = null;

if(ToolTip != null)

{

toolTipText = null;

ToolTip.Dispose();

ToolTip = null;

}

}

}

#endregion

}

public delegate void MarkerClick(GMapMarker item, MouseEventArgs e);

public delegate void MarkerEnter(GMapMarker item);

public delegate void MarkerLeave(GMapMarker item);

///

/// modeof tooltip

///

public enum MarkerTooltipMode

{

OnMouseOver,

Never,

Always,

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值