public int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            Width   = BitConverter.ToUInt32(Buffer, cursor);
            cursor += TypeSizes.INT;

            Height  = BitConverter.ToUInt32(Buffer, cursor);
            cursor += TypeSizes.INT;

            XOffset = BitConverter.ToInt32(Buffer, cursor);
            cursor += TypeSizes.INT;

            YOffset = BitConverter.ToInt32(Buffer, cursor);
            cursor += TypeSizes.INT;

            byte HotSpotCount = Buffer[cursor];

            cursor++;

            HotSpots.Clear();
            HotSpots.Capacity = HotSpotCount;
            for (int i = 0; i < HotSpotCount; i++)
            {
                BgfBitmapHotspot hotspot = new BgfBitmapHotspot(Buffer, cursor);
                cursor += hotspot.ByteLength;

                HotSpots.Add(hotspot);
            }

            isCompressed = BitConverter.ToBoolean(Buffer, cursor);
            cursor++;

            CompressedLength = BitConverter.ToInt32(Buffer, cursor);
            cursor          += TypeSizes.INT;

            if (IsCompressed)
            {
                PixelData = new byte[CompressedLength];
                Array.Copy(Buffer, cursor, PixelData, 0, CompressedLength);
                cursor += CompressedLength;
            }
            else
            {
                PixelData = new byte[UncompressedLength];
                Array.Copy(Buffer, cursor, PixelData, 0, UncompressedLength);
                cursor += UncompressedLength;
            }
            return(ByteLength);
        }
        protected override void OnClick(ImageMapEventArgs e)
        {
            string[] args = e.PostBackValue.Split(':');
            CurrentDepth     = Convert.ToInt32(args[0]);
            CurrentCounty    = String.Empty;
            CurrentCommunity = String.Empty;

            if (CurrentDepth == 0)
            {
                ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway.Fylker.jpg");
                loadCountiesHotSpots();
            }
            else if (CurrentDepth == 1)
            {
                CurrentCounty = args[1];
                ImageUrl      = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway." + CurrentCounty + ".jpg");
                loadCountyHotSpots();

                // The back hotspot
                PolygonHotSpot phs = new PolygonHotSpot();
                phs.PostBackValue = "0";
                phs.Coordinates   = "0,0 20,0 20,20 0,20";
                HotSpots.Add(phs);
            }
            else
            {
                CurrentCounty    = args[1];
                CurrentCommunity = args[2];

                ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway." + CurrentCounty + ".jpg");
                loadCountyHotSpots();

                // The back hotspot
                PolygonHotSpot phs = new PolygonHotSpot();
                phs.PostBackValue = "1:" + CurrentCounty;
                phs.Coordinates   = "0,0 20,0 20,20 0,20";
                HotSpots.Add(phs);
            }

            base.OnClick(e);
        }
        protected void loadCountiesHotSpots()
        {
            HotSpots.Clear();

            string hotSpotsXml = Page.ClientScript.GetWebResourceUrl(this.GetType(), "HotSpotMapNorway.HotSpots.xml");

            hotSpotsXml = GetAbsolutePath(hotSpotsXml);

            XmlDocument hotSpots = new XmlDocument();

            hotSpots.Load(hotSpotsXml);

            XmlNodeList nodes = hotSpots.SelectNodes("//county");

            foreach (XmlElement node in nodes)
            {
                PolygonHotSpot phs = new PolygonHotSpot();
                phs.PostBackValue = "1:" + node.GetAttribute("name");
                phs.Coordinates   = node.FirstChild.InnerText;
                HotSpots.Add(phs);
            }
        }