CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/9/2004 11:33:13 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 239 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
radelmann
Asp.Net User
Polygon HotSpot for ImageMap Custom Control3/9/2004 11:33:13 PM

0

Anyone have any ideas about how to add a polygon hotspot to the ASP.NET ImageMap Custom Control from MSPress's Developing ASP.NET Server Controls and Components.

http://www.microsoft.com/mspress/books/5728.asp.

Having a tough time with this one.

Thanks in advance.........


radelmann
Asp.Net User
Re: Polygon HotSpot for ImageMap Custom Control3/11/2004 5:58:11 PM

0

So I figured it out, here's the code if anyone's interested.

Three classes need to be added to the control: PolygonHotSpot.cs, MapPolygon.cs & and MapPolygonConverter.cs. The HotSpotCollection.cs class needs to be modified as well (not included here - pretty obvious what needs to be done though).

// PolygonHotSpot.cs

using System;
using System.ComponentModel;
using System.Web.UI;

namespace MSPress.ServerControls
{

public class PolygonHotSpot : HotSpot
{

private MapPolygon _polygon;

public PolygonHotSpot() : this(new MapPoint[0], String.Empty, String.Empty)
{
}

public PolygonHotSpot(MapPoint [] pts, string action, string toolTip) :
base(action, toolTip)
{
Pts = pts;
}

[
Category("Shape"),
DefaultValue(typeof(MapPoint), ""),
Description("The collection of points that make up the polygon"),
NotifyParentProperty(true)
]
public MapPoint []Pts
{
get
{
return ((MapPolygon)Shape).Pts;
}
set
{
((MapPolygon)Shape).Pts = value;
}
}

public override MapShape Shape
{
get
{
if (_polygon == null)
{
_polygon = new MapPolygon();
}
return _polygon;
}
}

protected override bool ShapeCreated
{
get
{
return (_polygon != null);
}
}
}
}


// MapPolygon.cs
//
//

using System;
using System.ComponentModel;

namespace MSPress.ServerControls
{
[
TypeConverter(typeof(MapPolygonConverter))
]
public class MapPolygon : MapShape
{

private MapPoint[] _pts;


public MapPolygon()
{
}

public MapPolygon(MapPoint[] pts)
{
_pts = pts;
}

[
DefaultValue(typeof(MapPoint),""),
NotifyParentProperty(true)
]
public MapPoint []Pts
{
get
{
return _pts ;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
_pts = value;
}
}

public override bool IsEmpty
{
get
{
return (_pts.Length == 0);
}
}

public override string MapCoordinates
{
get
{
string strCoordinates;
strCoordinates = string.Empty;
if (_pts.Length > 0 )
{
for (int i =0; i < _pts.Length;i++)
{
strCoordinates += _pts[i].X + "," + _pts[i].Y + "," ;
}
//Strip out last comma for the string
strCoordinates = strCoordinates.Substring(0,strCoordinates.Length -1);
return strCoordinates;
}
else
return "";
}
}

protected override MapShapeName MapShapeName
{
get
{
return MapShapeName.Polygon;
}
}

public override void LoadFromString(string value)
{
if (value.Length != 0)
{
MapPolygon p = (MapPolygon)TypeDescriptor.GetConverter(typeof(MapPolygon)).ConvertFromInvariantString(null, value);
for (int i =0; i < this._pts.Length;i++)
{
this.Pts[i] = p.Pts[i];
}

}
}

public override string SaveToString()
{
return TypeDescriptor.GetConverter(typeof(MapPolygon)).ConvertToInvariantString(this);
}
}
}


// MapPolygonConverter.cs

using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace MSPress.ServerControls
{

public class MapPolygonConverter : MapShapeConverter
{

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value == null)
{
return new MapPolygon();
}

if (value is string)
{
string s = (string)value;
if (s.Length == 0)
{
return new MapPolygon();
}

string[] parts = s.Split(culture.TextInfo.ListSeparator[0]);

if (parts.Length == 0)
{
throw new ArgumentException("Invalid MapPolygon", "value");
}

TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(Int32));

MapPoint[] pts;
pts = new MapPoint[parts.Length/2];
int j = 0;
for (int i=0; i<parts.Length/2;i++)
{
int X = (int)intConverter.ConvertFromString(context, culture, parts[j]);j++;
int Y = (int)intConverter.ConvertFromString(context, culture, parts[j]);j++;
pts[i] = new MapPoint(X,Y);
}
return new MapPolygon(pts);
}

return base.ConvertFrom(context, culture, value);
}

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value != null)
{
if (!(value is MapPolygon))
{
throw new ArgumentException("Invalid MapPolygon", "value");
}
}

if (destinationType == typeof(string))
{
if (value == null)
{
return String.Empty;
}

MapPolygon poly = (MapPolygon)value;
if (poly.IsEmpty)
{
return String.Empty;
}

TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(Int32));

int count = poly.Pts.Length;
string[] strConvert = new string[2*count];
int j = 0;
for (int i = 0;i<poly.Pts.Length;i++)
{
strConvert[j] = intConverter.ConvertToString(context, culture, poly.Pts[i].X);j++;
strConvert[j] = intConverter.ConvertToString(context, culture, poly.Pts[i].Y);j++;
}
return String.Join(culture.TextInfo.ListSeparator,strConvert);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}




2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro Asp.Net 3.5 In C# 2008: Includes Silverlight 2, 3rd Ed Authors: Matthew Macdonald, Mario Szpuszta, Pages: 1516, Published: 2009
The hidden power of Photoshop CS: advanced techniques for smarter, faster image processing Authors: Richard A. Lynch, Pages: 307, Published: 2004
Fireworks MX: inside macromedia Authors: Dan Carr, Shannon Wilder, Scott J. Wilson, Pages: 390, Published: 2003
Pro ASP.NET 3.5 in VB 2008: Includes Silverlight 2 Authors: Matthew MacDonald, Mario Szpuszta, Vidya Vrat Agarwal, Pages: 1500, Published: 2008

Web:
Polygon HotSpot for ImageMap Custom Control - ASP.NET Forums Anyone have any ideas about how to add a polygon hotspot to the ASP.NET ImageMap Custom Control from MSPress's Developing ASP. ...
DotNetSlackers: Build a custom hotspot for ImageMap Apr 11, 2005 ... . Link to full code listing. Default HotSpot Types: Circle Rectangle Polygon Custom Diamond HotSpot ...
CodeProject: ImageMap.NET 2.0. Free source code and programming help Aug 31, 2006 ... An alternative ImageMap control for ASP.NET 2.0; Author: YDreams; Section: ASP. ... I have an image that has 4 polygon hotspots. ...
How to use ImageMap Control Custom Programming · Article Sites Master List ... Similar is the case for the Polygon hot spot. Overlapping hotspots are treated with extra ... The ImageMap control enables you to specify hotspots in a couple of different ways. ...
Download Add Hotspot Image Map Source Codes, Add Hotspot Image Map ... Add Hotspot Image Map Codes and Scripts Downloads Free. ... It can create Polygon, Point 'imagemap'(HotSpot), Rectangle, Circle etc and can read either GIF or. ... NET / Visual Basic / Custom Controls/ Forms/ Menus ...

Polygon HotSpot for ImageMap Custom Control - ng.asp-net-forum ... Polygon HotSpot for ImageMap Custom Control, > ROOT > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum, Date: 3/9/2004 ...
After DNN4 install: Value cannot be null. Parameter name ... how to build a custom dropdownlist web server control · composite control simple custom property problem · polygon hotspot for imagemap custom control ...












how do you remove a module that has an error?

is dotnetnuke a good solution for an online magazine?

multi-language and sql

msde setup on local machine with dnn

help me please...

chinese ui

installation problems - could not find stored procedure 'dbo.gethostsettings".

dnn4 upgrade "nothing to install at this time"

dnn 03.01.00 install - portal failed to install

import sql 2005 express to sql 2005 server

time settings

restriced area... but see the button

creating a new portal error...

could not connect to database specified in connectionstring for sqldataprovider

creating portals

disapearing modules and content

3.0.13

tabs verses menus's

stays on home page

installation error: no documentation describing the error

rebuild from debug to release

dotnetnuke 4.02 webhost4life smtp issue

development environment

local works, remote doesn't...

admin log-in

service directory ?? where has the module gone?

adding text into dnn 2.1.2

problem with connection to sql database

open default.aspx in vs.net

'dbo.getportalaliasbyportalid' doesn't exist.

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT