/// <summary>
        /// Changes the default style of labels to generate based on
        /// </summary>
        private void btnChangeStyle_Click(object sender, EventArgs e)
        {
            LabelStyleForm styleFormForm = new LabelStyleForm(m_shapefile, m_shapefile.Labels.Options);

            if (styleFormForm.ShowDialog(this) == DialogResult.OK)
            {
                // refreshing preview
                DrawPreview();
                RefreshControlsState(null, null);
            }
            styleFormForm.Dispose();
        }
        public override void Run(LegendCommand command)
        {
            Shapefile sf    = null;
            var       layer = _legend.Layers.ItemByHandle(LayerHandle);

            if (layer != null)
            {
                sf = layer.GetObject() as Shapefile;
            }

            switch (command)
            {
            case LegendCommand.CalculateArea:
                sf.CalculateArea();
                break;

            case LegendCommand.RemoveLayer:
                LayerHelper.RemoveLayer();
                break;

            case LegendCommand.LoadLayerStyle:
                LayerHelper.LoadLayerStyle();
                break;

            case LegendCommand.SaveLayerStyle:
                LayerHelper.SaveCurrentStyle();
                break;

            case LegendCommand.ImportOgrLayer:
                LayerHelper.ImportOgrLayer();
                break;

            case LegendCommand.ZoomToLayer:
                _legend.Map.ZoomToLayer(LayerHandle);
                break;

            case LegendCommand.Labels:
            {
                using (Form form = new LabelStyleForm(_legend, sf, LayerHandle))
                {
                    form.ShowDialog(MainForm.Instance);
                    _legend.Refresh();
                }
            }
            break;

            case LegendCommand.Properties:
                LayerHelper.ShowLayerProperties(LayerHandle);
                break;
            }
        }
        /// <summary>
        /// Generating of labels
        /// </summary>
        private void btnGenerateLabels_Click(object sender, EventArgs e)
        {
            //frmGenerateLabels form = new frmGenerateLabels(m_mapWin, _shapefile, layer, LabelAction.ChangeAll);

            LabelStyleForm form = new LabelStyleForm(_legend, _shapefile, _layerHandle);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _shapefile.Labels.Visible = true;
                DrawLabelsPreview();
                RefreshControlsState(null, null);
                RedrawMap();
            }
            form.Dispose();
        }
        /// <summary>
        /// Handles the clicking on the labels for a layer
        /// </summary>
        /// <param name="Handle"></param>
        void m_legend_LayerLabelsClicked(int Handle)
        {
            if (m_legend == null || m_legend.m_Map == null)
            {
                return;
            }

            MapWinGIS.Shapefile sf = m_legend.m_Map.get_Shapefile(Handle);
            if (sf != null)
            {
                using (Form form = new LabelStyleForm(m_legend, sf, Handle))
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        m_legend.Refresh();
                    }
                }
            }
        }
        /// <summary>
        /// Changing the default style of labels
        /// </summary>
        private void btnLabelsAppearance_Click(object sender, EventArgs e)
        {
            LabelStyleForm styleFormForm = new LabelStyleForm(_legend, _shapefile, _layerHandle);

            styleFormForm.ShowDialog();

            // updating controls (even if cancel was hit, a user could have applied the options)
            MapWinGIS.LabelCategory options = _shapefile.Labels.Options;
            udLabelFontSize.Value = options.FontSize;
            clpLabelFrame.Color   = Colors.UintToColor(options.FrameBackColor);
            chkLabelFrame.Checked = options.FrameVisible;
            chkShowLabels.Checked = options.Visible;

            RefreshControlsState(null, null);

            RedrawMap();

            // refreshing preview
            DrawLabelsPreview();

            styleFormForm.Dispose();
        }