Files
@ f2c2ba4ef3d4
Branch filter:
Location: seniordesign-ui/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs
f2c2ba4ef3d4
9.1 KiB
text/x-csharp
Removed unneeded code and verified use of functions. project is essentially
complete except for some live testing and cache testing/experiments
complete except for some live testing and cache testing/experiments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
namespace GMap.NET.WindowsForms
{
using System;
using System.Drawing;
using System.Runtime.Serialization;
using System.Windows.Forms;
using GMap.NET.WindowsForms.ToolTips;
/// <summary>
/// GMap.NET marker
/// </summary>
[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;
/// <summary>
/// marker position in local coordinates, internal only, do not set it manualy
/// </summary>
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();
}
}
}
}
}
}
/// <summary>
/// ToolTip position in local coordinates
/// </summary>
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;
/// <summary>
/// is marker visible
/// </summary>
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();
}
}
}
}
}
}
/// <summary>
/// if true, marker will be rendered even if it's outside current view
/// </summary>
public bool DisableRegionCheck = false;
/// <summary>
/// can maker receive input
/// </summary>
public bool IsHitTestVisible = true;
private bool isMouseOver = false;
/// <summary>
/// is mouse over marker
/// </summary>
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
/// <summary>
/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
/// <exception cref="T:System.Security.SecurityException">
/// The caller does not have the required permission.
/// </exception>
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);
}
/// <summary>
/// Initializes a new instance of the <see cref="GMapMarker"/> class.
/// </summary>
/// <param name="info">The info.</param>
/// <param name="context">The context.</param>
protected GMapMarker(SerializationInfo info, StreamingContext context)
{
this.Position = Extensions.GetStruct<PointLatLng>(info, "Position", PointLatLng.Empty);
this.Tag = Extensions.GetValue<object>(info, "Tag", null);
this.Offset = Extensions.GetStruct<Point>(info, "Offset", Point.Empty);
this.area = Extensions.GetStruct<Rectangle>(info, "Area", Rectangle.Empty);
this.ToolTip = Extensions.GetValue<GMapToolTip>(info, "ToolTip", null);
this.ToolTipMode = Extensions.GetStruct<MarkerTooltipMode>(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);
/// <summary>
/// modeof tooltip
/// </summary>
public enum MarkerTooltipMode
{
OnMouseOver,
Never,
Always,
}
}
|