/// <summary>
 /// Reverts changes if cancel was chosen
 /// </summary>
 private void frmChartStyle_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.DialogResult == DialogResult.Cancel)
     {
         MapWinGIS.tkSavingMode mode = _charts.SavingMode;
         _charts.SavingMode = MapWinGIS.tkSavingMode.modeNone;
         _charts.Deserialize(_initState);
         _charts.SavingMode = mode;
     }
 }
        /// <summary>
        /// Initializes a new instance of the ChartStyleForm class
        /// </summary>
        public ChartStyleForm(LegendControl.Legend legend, MapWinGIS.Shapefile sf, bool legendCall, int handle)
        {
            InitializeComponent();
            _shapefile = sf;
            _charts    = sf.Charts;
            m_legend   = legend;
            _handle    = handle;

            MapWinGIS.tkSavingMode mode = _charts.SavingMode;
            _charts.SavingMode = MapWinGIS.tkSavingMode.modeNone;
            _initState         = _charts.Serialize();
            _charts.SavingMode = mode;

            _noEvents = true;

            panelPieChart.Top  = panelBarChart.Top;
            panelPieChart.Left = panelBarChart.Left;

            foreach (FontFamily family in FontFamily.Families)
            {
                cboFontName.Items.Add(family.Name);
            }

            cboValuesStyle.Items.Clear();
            cboValuesStyle.Items.Add("Horizontal");
            cboValuesStyle.Items.Add("Vertical");

            cboChartVerticalPosition.Items.Clear();
            cboChartVerticalPosition.Items.Add("Above current layer");
            cboChartVerticalPosition.Items.Add("Above all layers");

            optBarCharts.Checked = (_charts.ChartType == MapWinGIS.tkChartType.chtBarChart);
            optPieCharts.Checked = (_charts.ChartType == MapWinGIS.tkChartType.chtPieChart);

            // initializing for list of color schemes
            icbColors.ColorSchemes = Globals.ChartColors;
            icbColors.ComboStyle   = ImageComboStyle.ColorSchemeGraduated;
            if (icbColors.Items.Count > 0)
            {
                icbColors.SelectedIndex = 0;
            }

            string[] scales = { "1",      "10",     "100",     "1000", "5000", "10000", "25000", "50000", "100000",
                                "250000", "500000", "1000000", "10000000" };
            cboMinScale.Items.Clear();
            cboMaxScale.Items.Clear();
            for (int i = 0; i < scales.Length; i++)
            {
                cboMinScale.Items.Add(scales[i]);
                cboMaxScale.Items.Add(scales[i]);
            }

            txtChartExpression.Text = sf.Charts.VisibilityExpression;

            SetChartsType();

            InitFields();

            _noEvents = false;

            Settings2GUI();

            Draw();

            RefreshControlsState();

            tabControl1.SelectedIndex = _selectedTab;
        }