context: namespace Steema.TeeChart.Editors
  {
      using Steema.TeeChart;
      using Steema.TeeChart.Styles;
      using System;
      using System.ComponentModel;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Windows.Forms;
  
      public class ChartGallery : Form
      {
          private Button bCancel;
          private Button bOk;
          private Chart chart;
          private CheckBox checkBox1;
          private CheckBox checkBox2;
          private Container components;
          private GalleryPanel gallery;
          private System.Windows.Forms.Panel panel1;
          private System.Windows.Forms.Panel panel2;
          private TabControl tabFuncs;
          private TabPage tabFunctions;
          private TabPage tabPage1;
          private TabControl tabPages;
          private TabPage tabSeries;
          private TabPage tabStandard;
          private TabControl tabTypes;
  
          public ChartGallery()
          {
              this.components = null;
              this.gallery = new GalleryPanel();
              this.InitializeComponent();
          }
  
          public ChartGallery(Chart c) : this()
          {
              this.chart = c;
          }
  
          private void AddTabPages(TabControl tab)
          {
              string str;
              tab.TabPages.Clear();
              if (this.tabTypes.SelectedIndex == 0)
              {
                  for (int i = 0; i < 0x2c; i++)
                  {
                      if (Utils.SeriesGalleryCount[i] > 0)
                      {
                          str = GalleryPanel.GalleryPages(Utils.SeriesGalleryPage[i]);
                          if (this.TabIndexOf(this.tabPages, str) == -1)
                          {
                              tab.TabPages.Add(new TabPage(str));
                          }
                      }
                  }
              }
              else
              {
                  for (int j = 0; j < 0x1b; j++)
                  {
                      str = GalleryPanel.GalleryPages(Utils.FunctionGalleryPage[j]);
                      if (this.TabIndexOf(this.tabFuncs, str) == -1)
                      {
                          tab.TabPages.Add(new TabPage(str));
                      }
                  }
              }
          }
  
          private void ChangedChart(object sender, EventArgs e)
          {
              this.bOk.Enabled = true;
          }
  
          public static System.Type ChangeSeriesType(Chart c, ref Series s)
          {
              Series newSeries = CreateNew(c, s);
              if (newSeries != null)
              {
                  Series.AssignDispose(ref s, newSeries);
                  return s.GetType();
              }
              return null;
          }
  
          private void ChartGallery_Load(object sender, EventArgs e)
          {
              this.gallery.OnSelectedChart += new EventHandler(this.SelectedChart);
              this.gallery.OnChangeChart += new EventHandler(this.ChangedChart);
              this.tabTypes.SelectedIndex = 0;
              this.tabTypes_SelectedIndexChanged(this, EventArgs.Empty);
          }
  
          private void checkBox1_CheckedChanged(object sender, EventArgs e)
          {
              this.gallery.View3D = this.checkBox1.Checked;
          }
  
          private void checkBox2_CheckedChanged(object sender, EventArgs e)
          {
              this.gallery.Smooth = this.checkBox2.Checked ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed;
          }
  
          private void CheckStandard(TabControl tab)
          {
              int num = this.TabIndexOf(tab, Texts.GalleryStandard);
              if (num > 0)
              {
                  TabPage page = tab.TabPages[0];
                  tab.TabPages[0] = tab.TabPages[num];
                  tab.TabPages[num] = page;
              }
          }
  
          public static Series CreateNew(Chart c, Series old)
          {
              System.Type type = null;
              System.Type aFunction = null;
              int subIndex = 0;
              if (ShowModal(c, ref type, ref aFunction, ref subIndex) == DialogResult.OK)
              {
                  return Series.CreateNewSeries(c, type, aFunction, subIndex);
              }
              return null;
          }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing && (this.components != null))
              {
                  this.components.Dispose();
              }
              base.Dispose(disposing);
          }
  
          private void InitializeComponent()
          {
              this.checkBox1 = new CheckBox();
              this.tabSeries = new TabPage();
              this.tabPages = new TabControl();
              this.tabStandard = new TabPage();
              this.tabFunctions = new TabPage();
              this.tabFuncs = new TabControl();
              this.tabPage1 = new TabPage();
              this.panel1 = new System.Windows.Forms.Panel();
              this.checkBox2 = new CheckBox();
              this.panel2 = new System.Windows.Forms.Panel();
              this.bCancel = new Button();
              this.bOk = new Button();
              this.tabTypes = new TabControl();
              this.tabSeries.SuspendLayout();
              this.tabPages.SuspendLayout();
              this.tabFunctions.SuspendLayout();
              this.tabFuncs.SuspendLayout();
              this.panel1.SuspendLayout();
              this.panel2.SuspendLayout();
              this.tabTypes.SuspendLayout();
              base.SuspendLayout();
              this.checkBox1.Checked = true;
              this.checkBox1.CheckState = CheckState.Checked;
              this.checkBox1.FlatStyle = FlatStyle.Flat;
              this.checkBox1.Location = new Point(8, 8);
              this.checkBox1.Name = "checkBox1";
              this.checkBox1.TabIndex = 0;
              this.checkBox1.Text = "View &3D";
              this.checkBox1.CheckedChanged += new EventHandler(this.checkBox1_CheckedChanged);
              this.tabSeries.Controls.Add(this.tabPages);
              this.tabSeries.Location = new Point(4, 0x16);
              this.tabSeries.Name = "tabSeries";
              this.tabSeries.Size = new Size(0x199, 0x121);
              this.tabSeries.TabIndex = 0;
              this.tabSeries.Text = "Series";
              this.tabPages.Controls.Add(this.tabStandard);
              this.tabPages.Dock = DockStyle.Fill;
              this.tabPages.HotTrack = true;
              this.tabPages.Location = new Point(0, 0);
              this.tabPages.Name = "tabPages";
              this.tabPages.SelectedIndex = 0;
              this.tabPages.Size = new Size(0x199, 0x121);
              this.tabPages.TabIndex = 0;
              this.tabPages.SelectedIndexChanged += new EventHandler(this.tabControl2_SelectedIndexChanged);
              this.tabStandard.Location = new Point(4, 0x16);
              this.tabStandard.Name = "tabStandard";
              this.tabStandard.Size = new Size(0x191, 0x107);
              this.tabStandard.TabIndex = 0;
              this.tabStandard.Text = "Standard";
              this.tabFunctions.Controls.Add(this.tabFuncs);
              this.tabFunctions.Location = new Point(4, 0x16);
              this.tabFunctions.Name = "tabFunctions";
              this.tabFunctions.Size = new Size(0x199, 0x121);
              this.tabFunctions.TabIndex = 1;
              this.tabFunctions.Text = "Functions";
              this.tabFuncs.Controls.Add(this.tabPage1);
              this.tabFuncs.Dock = DockStyle.Fill;
              this.tabFuncs.HotTrack = true;
              this.tabFuncs.Location = new Point(0, 0);
              this.tabFuncs.Name = "tabFuncs";
              this.tabFuncs.SelectedIndex = 0;
              this.tabFuncs.Size = new Size(0x199, 0x121);
              this.tabFuncs.TabIndex = 0;
              this.tabFuncs.SelectedIndexChanged += new EventHandler(this.tabFuncs_SelectedIndexChanged);
              this.tabPage1.Location = new Point(4, 0x16);
              this.tabPage1.Name = "tabPage1";
  
gt:             this.tabPage1.Size = new Size(0x191, 0x107);