public void AddTabPage(string key, int index)
 {
     string[] temp = key.Split(' ');
     if (temp[0] == "SERIES")
     {
         VariableTabPage seriesTabPage = new VariableTabPage();
         int             listIndex     = VariableFinder.FindVariableIndex(data.SeriesVariables, temp[1]);
         seriesTabPage.SetData(data.SeriesVariables[listIndex], data);
         seriesTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, seriesTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
     else if (temp[0] == "GROUP")
     {
         GroupTabPage groupTabPage = new GroupTabPage();
         int          listIndex    = GroupFinder.FindGroupIndex(data.SeriesGroups, temp[1]);
         groupTabPage.SetData(data.SeriesGroups[listIndex], data);
         groupTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, groupTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
     else if (temp[0] == "STOCK")
     {
         StockTabPage stockTabPage = new StockTabPage();
         int          listIndex    = StockFinder.FindStockIndex(data.SeriesStocks, temp[1]);
         stockTabPage.SetData(data.SeriesStocks[listIndex], data);
         stockTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, stockTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
 }
 public void AddTabPage(SeriesDataList.Item selectedItem)
 {
     if (selectedItem.Type == SeriesDataList.Type.Series)
     {
         string key = "SERIES " + data.SeriesVariables[selectedItem.ListIndex].VariableName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             VariableTabPage seriesTabPage = new VariableTabPage();
             seriesTabPage.SetData(data.SeriesVariables[selectedItem.ListIndex], data);
             seriesTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(seriesTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
     else if (selectedItem.Type == SeriesDataList.Type.Group)
     {
         string key = "GROUP " + data.SeriesGroups[selectedItem.ListIndex].GroupName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             GroupTabPage groupTabPage = new GroupTabPage();
             groupTabPage.SetData(data.SeriesGroups[selectedItem.ListIndex], data);
             groupTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(groupTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
     else if (selectedItem.Type == SeriesDataList.Type.Stock)
     {
         string key = "STOCK " + data.SeriesStocks[selectedItem.ListIndex].StockName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             StockTabPage stockTabPage = new StockTabPage();
             stockTabPage.SetData(data.SeriesStocks[selectedItem.ListIndex], data);
             stockTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(stockTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
 }
 private void cmdSpreadsheet_Click(object sender, EventArgs e)
 {
     this.cmdSpreadSheet.BackgroundImage = zaitun.Properties.Resources.button_selected_view_pane2;
     if (this.variableViewCollection.SelectedTab.Name.Contains("SERIES "))
     {
         VariableTabPage vtp = (VariableTabPage)this.variableViewCollection.SelectedTab;
         vtp.ShowDataGrid();
     }
     else if (this.variableViewCollection.SelectedTab.Name.Contains("GROUP "))
     {
         GroupTabPage gtp = (GroupTabPage)this.variableViewCollection.SelectedTab;
         gtp.ShowDataGrid();
     }
     else if (this.variableViewCollection.SelectedTab.Name.Contains("STOCK "))
     {
         StockTabPage stp = (StockTabPage)this.variableViewCollection.SelectedTab;
         stp.ShowDataGrid();
     }
 }
 public void AddTabPage(SeriesDataList.Item selectedItem)
 {
     if (selectedItem.Type == SeriesDataList.Type.Series)
     {
         string key = "SERIES " + data.SeriesVariables[selectedItem.ListIndex].VariableName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             VariableTabPage seriesTabPage = new VariableTabPage();
             seriesTabPage.SetData(data.SeriesVariables[selectedItem.ListIndex], data);
             seriesTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(seriesTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
     else if (selectedItem.Type == SeriesDataList.Type.Group)
     {
         string key = "GROUP " + data.SeriesGroups[selectedItem.ListIndex].GroupName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             GroupTabPage groupTabPage = new GroupTabPage();
             groupTabPage.SetData(data.SeriesGroups[selectedItem.ListIndex], data);
             groupTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(groupTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
     else if (selectedItem.Type == SeriesDataList.Type.Stock)
     {
         string key = "STOCK " + data.SeriesStocks[selectedItem.ListIndex].StockName;
         if (this.variableViewCollection.TabPages.ContainsKey(key))
         {
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.IndexOfKey(key);
         }
         else
         {
             StockTabPage stockTabPage = new StockTabPage();
             stockTabPage.SetData(data.SeriesStocks[selectedItem.ListIndex], data);
             stockTabPage.ShowDataGrid();
             this.variableViewCollection.TabPages.Add(stockTabPage);
             this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
         }
     }
 }
 public void AddTabPage(string key, int index)
 {
     string[] temp = key.Split(' ');
     if (temp[0] == "SERIES")
     {
         VariableTabPage seriesTabPage = new VariableTabPage();
         int listIndex = VariableFinder.FindVariableIndex(data.SeriesVariables, temp[1]);
         seriesTabPage.SetData(data.SeriesVariables[listIndex], data);
         seriesTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, seriesTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
     else if (temp[0] == "GROUP")
     {
         GroupTabPage groupTabPage = new GroupTabPage();
         int listIndex = GroupFinder.FindGroupIndex(data.SeriesGroups, temp[1]);
         groupTabPage.SetData(data.SeriesGroups[listIndex], data);
         groupTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, groupTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
     else if (temp[0] == "STOCK")
     {
         StockTabPage stockTabPage = new StockTabPage();
         int listIndex = StockFinder.FindStockIndex(data.SeriesStocks, temp[1]);
         stockTabPage.SetData(data.SeriesStocks[listIndex], data);
         stockTabPage.ShowDataGrid();
         this.variableViewCollection.TabPages.Insert(index, stockTabPage);
         this.variableViewCollection.SelectedIndex = this.variableViewCollection.TabPages.Count - 1;
     }
 }