public GearEditor(string title, CGear _gear, bool SpeedsEditable, bool TypeEditable)
 {
     gearpt = _gear;
     gear   = (CGear)gearpt.Clone();
     InitializeComponent();
     this.Title = title;
     TextBoxSpeeds.IsEnabled = SpeedsEditable;
     TextBoxType.IsEnabled   = TypeEditable;
 }
        public void ExportFileTr()
        {
            Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog();
            saveFileDialog1.DefaultExt       = "csv";
            saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog1.FileName         = Properties.Resources.StringTransData + ".csv";
            if (!saveFileDialog1.ShowDialog().Value)
            {
                return;
            }

            CGear  frtemp = (CGear)frnow.Clone();
            CGear  bktemp = (CGear)bknow.Clone();
            CGear  intemp = (CGear)innow.Clone();
            CWheel whtemp = (CWheel)whnow.Clone();

            //for (int i = 0; i < dataGridViewFr.Items.Count; i++)
            //    frtemp.teeth[i].teeth = ((CTeeth)dataGridViewFr.Items[i]).Teeth;
            //for (int i = 0; i < dataGridViewBk.Items.Count; i++)
            //    bktemp.teeth[i].teeth = ((CTeeth)dataGridViewBk.Items[i]).Teeth;
            //for (int i = 0; i < dataGridViewIn.Items.Count; i++)
            //    intemp.teeth[i].teeth = ((CTeeth)dataGridViewIn.Items[i]).Teeth;

            whtemp.Lenth = Whlength;
            System.IO.StreamWriter swriter;
            string _filename = saveFileDialog1.FileName;

            try
            {
                swriter = new System.IO.StreamWriter(_filename, false, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(Properties.Resources.StringUnableexp + "\r\n" + ex.Message);
                return;
            }
            swriter.WriteLine(Properties.Resources.StringTransData);
            swriter.WriteLine("");


            swriter.WriteLine(Properties.Resources.StringTire + "," + whtemp.Name + "," + whtemp.Lenth.ToString() + "mm");

            string frstr = "";

            for (int i = 0; i < frtemp.Speeds; i++)
            {
                frstr += frtemp.teeth[i].teeth.ToString() + "/";
            }
            frstr += "T";
            swriter.WriteLine(Properties.Resources.StringCranksets + "," + frtemp.Name + "," + frstr);

            string bkstr = "";

            for (int i = 0; i < bktemp.Speeds; i++)
            {
                bkstr += bktemp.teeth[i].teeth.ToString() + "/";
            }
            bkstr += "T";
            swriter.WriteLine(Properties.Resources.StringCassette + "," + bktemp.Name + "," + bkstr);

            string instr = "";

            for (int i = 0; i < intemp.Speeds; i++)
            {
                instr += intemp.teeth[i].teeth.ToString("0.00") + "/";
            }
            swriter.WriteLine(Properties.Resources.StringInternalHub + "," + intemp.Name + "," + instr);

            swriter.WriteLine("");
            string strtemp = "";

            strtemp += "No." + ",";
            strtemp += Properties.Resources.StringGear + ",";
            strtemp += Properties.Resources.StringGearTeeth + ",";
            strtemp += Properties.Resources.StringGearRatio + ",";
            strtemp += Properties.Resources.StringGI + ",";
            if (IsSpd)
            {
                strtemp += Properties.Resources.StringCAD + " rpm";
            }
            else
            {
                if (IsMPH)
                {
                    strtemp += Properties.Resources.StringSpeed + " mph";
                }
                else
                {
                    strtemp += Properties.Resources.StringSpeed + " km/h";
                }
            }
            strtemp += ",";
            strtemp += Properties.Resources.StringIncrement + ",";
            strtemp += Properties.Resources.StringRemark + ",";

            swriter.WriteLine(strtemp);

            foreach (CResult it in list.Items)
            {
                strtemp  = "";
                strtemp += it.No1.ToString() + ",";
                strtemp += it.Gear1 + ",";
                strtemp += it.GearT1 + ",";
                strtemp += it.GearRatio1.ToString("0.00") + ",";
                strtemp += it.SpeedRatio1.ToString("0.0") + ",";
                strtemp += it.Speed1.ToString("0.0") + ",";
                strtemp += it.Increment1.ToString("P2") + ",";
                strtemp += it.Remark1 + ",";
                swriter.WriteLine(strtemp);
            }
            swriter.Close();
        }