private void AddTSBlockButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(NameTextbox.Text))
            return;

             if (!EditingTimeSeries)
             {
            foreach (TimeseriesBlock p in TimeseriesCheckedlistbox.Items)
               if (p.Name == NameTextbox.Text)
                  return;

            TimeseriesBlock newTSB = new TimeseriesBlock();
            newTSB.Name = NameTextbox.Text;
            newTSB.UseIndexes = UseIndexesCheckbox.Checked;

            newTSB.I = ITextbox.Text;
            newTSB.J = JTextbox.Text;
            newTSB.K = KTextbox.Text;

            newTSB.Latitude = LatitudeTextbox.Text;
            newTSB.Longitude = LongitudeTextbox.Text;

            newTSB.MaskID = MaskIDTextbox.Text;
            newTSB.Layer = LayerTextbox.Text;

            newTSB.X = XTextbox.Text;
            newTSB.Y = YTextbox.Text;

            TimeseriesCheckedlistbox.Items.Add(newTSB, true);
             }
             else
             {
            EditingTSB.Name = NameTextbox.Text;
            EditingTSB.UseIndexes = UseIndexesCheckbox.Checked;
            EditingTSB.I = ITextbox.Text;
            EditingTSB.J = JTextbox.Text;
            EditingTSB.K = KTextbox.Text;
            EditingTSB.Latitude = LatitudeTextbox.Text;
            EditingTSB.Longitude = LongitudeTextbox.Text;
            EditingTSB.MaskID = MaskIDTextbox.Text;
            EditingTSB.Layer = LayerTextbox.Text;
            EditingTSB.X = XTextbox.Text;
            EditingTSB.Y = YTextbox.Text;
            TimeseriesCheckedlistbox.Items[EditingTSB.Index] = EditingTSB;
            NameTextbox.Enabled = true;
            EditingTimeSeries = false;
            CancelTSEditButton.Enabled = false;
            EditTSBlockButton.Enabled = true;
            DeleteTSButton.Enabled = true;
             }
        }
        private void EditTSBlockButton_Click(object sender, EventArgs e)
        {
            if (TimeseriesCheckedlistbox.SelectedIndex > -1)
             {
            EditingTimeSeries = true;
            EditingTSB = (TimeseriesBlock)(TimeseriesCheckedlistbox.Items[TimeseriesCheckedlistbox.SelectedIndex]);
            EditingTSB.Index = TimeseriesCheckedlistbox.SelectedIndex;
            NameTextbox.Text = EditingTSB.Name;
            UseIndexesCheckbox.Checked = EditingTSB.UseIndexes;
            ITextbox.Text = EditingTSB.I;
            JTextbox.Text = EditingTSB.J;
            KTextbox.Text = EditingTSB.K;
            LatitudeTextbox.Text = EditingTSB.Latitude;
            LongitudeTextbox.Text = EditingTSB.Longitude;
            MaskIDTextbox.Text = EditingTSB.MaskID;
            LayerTextbox.Text = EditingTSB.Layer;
            XTextbox.Text = EditingTSB.X;
            YTextbox.Text = EditingTSB.Y;

            NameTextbox.Enabled = false;
            CancelTSEditButton.Enabled = true;
            EditTSBlockButton.Enabled = false;
            DeleteTSButton.Enabled = false;
             }
        }