public TireEditor(string title, CWheel _item) { itempt = _item; item = (CWheel)itempt.Clone(); InitializeComponent(); this.Title = title; }
public void AddCurveNow() { CGear frtemp = frnow; CGear bktemp = bknow; CGear intemp = innow; CWheel whtemp = whnow; whtemp.Lenth = Whlength; string tempstr = ""; tempstr += pm.Axes[1].Title; tempstr += " " + frtemp.Name; tempstr += "& " + bktemp.Name; if (intemp.Speeds != 1) { tempstr += "& " + intemp.Name; } string chartname = tempstr + "& " + whtemp.Lenth.ToString() + "mm"; /* * while (Chart1.Series.FindByName(chartname) != null) * { * InputForm inputform = new InputForm(Properties.Resources.StringAddCurve, Properties.Resources.StringCurveexist + ": \r\n\"" + chartname + "\"\r\n" + Properties.Resources.StringRenameandAdd, chartname); * if (inputform.ShowDialog() == System.Windows.Forms.DialogResult.OK) * chartname = inputform.name; * else * return; * }*/ //foreach (DataPoint dp in lineSeriesCurrent..Points) dp.MarkerSize = 4; InputWindow inputform = new InputWindow(Properties.Resources.StringAddCurve, Properties.Resources.StringInputCName, chartname); if (inputform.ShowDialog().Value) { chartname = inputform.name; } else { return; } LineSeries temp = new LineSeries(); //temp.Color = OxyColors.SkyBlue; //temp.MarkerFill = OxyColors.SkyBlue; temp.MarkerSize = 4; temp.MarkerStroke = OxyColors.White; temp.MarkerStrokeThickness = 2; temp.MarkerType = MarkerType.Circle; temp.Title = chartname; foreach (DataPoint dp in lineSeriesCurrent.Points) { temp.Points.Add(new DataPoint(dp.X, dp.Y)); } pm.Series.Add(temp); chart.InvalidatePlot(true); }
public void CalculateWheelLenth() { //if (checkBox2 == null) return; if (IsISO) { try { if (TireISO1 <= 5) { Whlength = Convert.ToInt32((TireISO1 * 25.4 * 2 + TireISO2) * Math.PI); } else { Whlength = Convert.ToInt32((TireISO1 * 2.0 + TireISO2) * Math.PI); } } catch { } } else { CWheel temp = whnow; if (temp != null) { Whlength = temp.Lenth; } } }
private void ButtonAdd_Click(object sender, RoutedEventArgs e) { CWheel newitem = new CWheel("", 1590); TireEditor geditor = new TireEditor(this.Title, newitem); if (geditor.ShowDialog() != true) { return; } data.wheelList.Add(newitem); ButtonSave.IsEnabled = true; LoadData(); }
public void CopyTo(CWheel pt) { pt.Lenth = lenth; pt.Name = name; }
public object Clone() { CWheel p = new CWheel(Name, Lenth); return(p); }
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(); }
public void Calculate() { if (!ready) { return; } pm.Axes[0].MinorStep = double.NaN; pm.Axes[0].MajorStep = double.NaN; CGear frtemp = frnow; CGear bktemp = bknow; CGear intemp = innow; CWheel whtemp = (CWheel)whnow.Clone(); whtemp.Lenth = Whlength; list.Items.Clear(); lineSeriesCurrent.Points.Clear(); double toothratemax = 0; double toothratemin = 0; int num = 1; NaNNumber.Clear(); for (int i = 0; i < frtemp.Speeds; i++) { for (int k = 0; k < intemp.Speeds; k++) { for (int j = 0; j < bktemp.Speeds; j++) { CResult resulttemp = new CResult(); resulttemp.No1 = num; num++; resulttemp.Gear1 = ""; resulttemp.GearT1 = ""; if (frtemp.Speeds != 1) { resulttemp.Gear1 += (i + 1).ToString(); resulttemp.GearT1 += frtemp.teeth[i].teeth.ToString() + "T"; } if (bktemp.Speeds != 1) { if (resulttemp.Gear1 != "") { resulttemp.Gear1 += "x"; resulttemp.GearT1 += "x"; } resulttemp.Gear1 += (j + 1).ToString(); resulttemp.GearT1 += bktemp.teeth[j].teeth.ToString() + "T"; } if (intemp.Speeds != 1) { if (resulttemp.Gear1 != "") { resulttemp.Gear1 += "x"; resulttemp.GearT1 += "x"; } resulttemp.Gear1 += (k + 1).ToString(); resulttemp.GearT1 += intemp.teeth[k].Teeth.ToString("0.00"); } double toothrateout = (double)frtemp.teeth[i].teeth / (double)bktemp.teeth[j].teeth; double toothrate = toothrateout * intemp.teeth[k].teeth; if (toothratemin == 0) { toothratemin = toothrate; } if (toothratemax == 0) { toothratemax = toothrate; } if (toothrate < toothratemin) { toothratemin = toothrate; } if (toothrate > toothratemax) { toothratemax = toothrate; } resulttemp.GearRatio1 = toothrate; resulttemp.SpeedRatio1 = toothrate * whtemp.Lenth / 3.1415926535 / 25.4; if (IsSpd) { if (IsMPH) { resulttemp.Speed1 = Cad * 1.609344 / 2.0 * 1000000.0 / 60.0 / whtemp.Lenth / toothrate; } else { resulttemp.Speed1 = Cad / 2.0 * 1000000.0 / 60.0 / whtemp.Lenth / toothrate; } } else { if (IsMPH) { resulttemp.Speed1 = toothrate * Cad * whtemp.Lenth * 60 / 1000000.0 * 0.6213712; } else { resulttemp.Speed1 = toothrate * Cad * whtemp.Lenth * 60 / 1000000.0; } } if (num >= 3) { resulttemp.Increment1 = toothrate / toothrateold - 1.0; } toothrateold = toothrate; resulttemp.Remark1 = ""; if (frtemp.Speeds != 1 && bktemp.Speeds != 1) { if (i == frtemp.Speeds - 1 && j == 0) { resulttemp.Remark1 += Properties.Resources.StringLFLB; } if (i == 0 && j == bktemp.Speeds - 1) { resulttemp.Remark1 += Properties.Resources.StringSFSB; } } if (intemp.Speeds != 1) { if (toothrateout < 1.5) { resulttemp.Remark1 += Properties.Resources.StringTorque; } } results.Add(resulttemp); list.Items.Add(resulttemp); double tempx = 0; double tempy = 0; switch (CurveX) { case 0: //不分支 tempx = num - 1; break; case 1: //按牙盘 tempx = bktemp.Speeds * k + j + 1; break; case 2: //按飞轮 tempx = i * frtemp.Speeds + k + 1; break; case 3: //按内变速 tempx = i * bktemp.Speeds + j + 1; break; } switch (CurveY) { case 1: //走距速比 tempy = toothrate * whtemp.Lenth / 1000.0; break; case 2: //GI速比 tempy = toothrate * whtemp.Lenth / 3.1415926535 / 25.4; break; case 3: //齿比 tempy = toothrate; break; case 4: //车速踏频 tempy = resulttemp.Speed1; break; } if (lineSeriesCurrent.Points.Count >= 2) { if (lineSeriesCurrent.Points[lineSeriesCurrent.Points.Count - 2].X != double.NaN) { if (tempx - lineSeriesCurrent.Points[lineSeriesCurrent.Points.Count - 2].X <= 0) { lineSeriesCurrent.Points.Add(new DataPoint(double.NaN, double.NaN)); NaNNumber.Add(num - 1); } } } lineSeriesCurrent.Points.Add(new DataPoint(tempx, tempy)); } } } switch (CurveX) { case 0: //不分支 pm.Axes[0].Title = Properties.Resources.StringGear + " No."; break; case 1: //按牙盘 pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchfr + ")"; break; case 2: //按飞轮 pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchbk + ")"; break; case 3: //按内变速 pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchin + ")"; break; } switch (CurveY) { case 1: //走距速比 pm.Axes[1].Title = Properties.Resources.StringSpdRatio; break; case 2: //GI速比 pm.Axes[1].Title = Properties.Resources.StringGI; break; case 3: //齿比 pm.Axes[1].Title = Properties.Resources.StringGearRatio; break; case 4: //车速踏频 pm.Axes[1].Title = (IsSpd ? Properties.Resources.StringCAD + "(rpm)" : (Properties.Resources.StringSpeed + (IsMPH ? "(mph)" : "(km/h)"))); break; } label0.Content = Properties.Resources.StringTotaldiff + ": " + (Convert.ToDouble(toothratemax / toothratemin * 100.0)).ToString("F0") + "%"; label1.Content = Properties.Resources.StringTotalCap + ": " + (frtemp.teeth[frtemp.Speeds - 1].teeth - frtemp.teeth[0].teeth - bktemp.teeth[bktemp.Speeds - 1].teeth + bktemp.teeth[0].teeth).ToString() + "T"; chart.ResetAllAxes(); chart.InvalidatePlot(true); pm.Axes[1].Minimum = 0; //if (pm.Axes[0].ActualMinorStep < 0.9 && pm.Axes[0].MinorStep == double.NaN) pm.Axes[0].MinorStep = 1; //if (pm.Axes[0].ActualMajorStep < 0.9 && pm.Axes[0].MajorStep == double.NaN) pm.Axes[0].MajorStep = 1; //Chart1.InvalidatePlot(true); }