private void onSelectMap(HtmlElement_map map)
 {
     if (map != null && map != _currentMap)
     {
         _currentMap = map;
         if (map.Areas == null)
         {
             List <HtmlElement_area> areas = _webpage.GetAreas(map.id);
             map.SetAreas(areas);
         }
         mapCtrl.ReloadShapes(map.ExportShapes());
     }
 }
 private void buttonOK_Click(object sender, EventArgs e)
 {
     if (_currentMap != null)
     {
         List <HtmlElement_area> areas = new List <HtmlElement_area>();
         List <DrawingItem>      lst   = mapCtrl.ExportDrawingItems();
         if (lst != null && lst.Count > 0)
         {
             foreach (DrawingItem di in lst)
             {
                 HtmlElement_area ha   = null;
                 ClassPointer     root = _webpage.GetDevClass() as ClassPointer;
                 DrawCircle       dc   = di as DrawCircle;
                 if (dc != null)
                 {
                     ha           = new HtmlElement_area(root);
                     ha.shape     = EnumAreaShape.circle;
                     ha.coords    = new int[3];
                     ha.coords[0] = dc.CircleCenter.X;
                     ha.coords[1] = dc.CircleCenter.Y;
                     ha.coords[2] = dc.Radius;
                 }
                 else
                 {
                     DrawRect dr = di as DrawRect;
                     if (dr != null)
                     {
                         ha           = new HtmlElement_area(root);
                         ha.shape     = EnumAreaShape.rect;
                         ha.coords    = new int[4];
                         ha.coords[0] = dr.Rectangle.X;
                         ha.coords[1] = dr.Rectangle.Y;
                         ha.coords[2] = dr.Rectangle.X + dr.Rectangle.Width;
                         ha.coords[3] = dr.Rectangle.Y + dr.Rectangle.Height;
                     }
                     else
                     {
                         DrawPolygon dp = di as DrawPolygon;
                         if (dp != null)
                         {
                             ha        = new HtmlElement_area(root);
                             ha.shape  = EnumAreaShape.poly;
                             ha.coords = new int[dp.PointCount * 2];
                             for (int k = 0; k < dp.PointCount; k++)
                             {
                                 ha.coords[2 * k]     = dp.PointList[k].X;
                                 ha.coords[2 * k + 1] = dp.PointList[k].Y;
                             }
                         }
                     }
                 }
                 if (ha != null)
                 {
                     ha.SetGuid(di.DrawingId);
                     ha.SetId(di.Name);
                     areas.Add(ha);
                 }
             }
         }
         _currentMap.SetAreas(areas);
         _webpage.UpdateMapAreas(_currentMap);
         MapID             = _currentMap.id;
         this.DialogResult = DialogResult.OK;
     }
 }