private void txtMessageChangelength() { double segmentLength = unitConverter.ConvertUnits(Segment, inUnit.pUnit, outUnit.pUnit); double perimeter = unitConverter.ConvertUnits(Total, inUnit.pUnit, outUnit.pUnit); //double area = ConvertToLength(Area, inAreaUnit.UnitName, outAreaUnit.UnitName); string areaUnit; if (outAreaUnit.UnitName == "Unkown Units") { areaUnit = outAreaUnit.UnitName; } else { areaUnit = "Square " + outAreaUnit.UnitName; } segmentLength = Math.Round(segmentLength, 6); perimeter = Math.Round(perimeter, 6); //area = Math.Round(area, 6); this.txtResultInfo.Text = "测量线" + "\r\n线段长是" + segmentLength + unitToCh(tsmiDistanceUnit) + "\r\n总长是:" + perimeter + unitToCh(tsmiDistanceUnit); //"\r\n面积是:" + area + areaUnit; }
public IIGUI() { InitializeComponent(); if (conv.ConvertUnits(pCurve.Length, mapunit, esriUnits.esriKilometers) < 100) { combox_unit.SelectedIndex = 0; } else { combox_unit.SelectedIndex = 1; } }
private void txtInput_TextChanged(object sender, System.EventArgs e) { double val; double outval; string in_unit; UnitResult res = UnitResult.NoError; res = uc.ParseUnitString(this.txtInput.Text, out val, out in_unit); if (res == UnitResult.BadUnit) { txtOutput.Text = "Bad input unit."; return; } else { if (res == UnitResult.BadValue) { txtOutput.Text = "Bad input value."; return; } } IUnitEntry out_unit = uc.GetUnitBySymbol(txtUnitTo.Text); if (out_unit == null) { txtOutput.Text = "Bad output unit."; return; } if (!uc.CompatibleUnits(in_unit, txtUnitTo.Text)) { txtOutput.Text = "Units are of different types."; return; } res = uc.ConvertUnits(val, in_unit, txtUnitTo.Text, out outval); this.txtOutput.Text = outval.ToString( ) + " " + out_unit.DefaultSymbol; }
public void frmLineDown(ref IPoint pPoint) { if (tbtnLine.Checked == true) { IPoint pPnt = pPoint; object Missing = Type.Missing; pCollection.AddPoint(pPnt, ref Missing, ref Missing); int PointCnt = pCollection.PointCount; double CntTotal; if (pCollection.PointCount > 1) { IPoint pLast = pCollection.get_Point(PointCnt - 1); IPoint pPre = pCollection.get_Point(PointCnt - 2); SegLength = Math.Sqrt(Math.Pow((pLast.X - pPre.X), 2) + Math.Pow((pLast.Y - pPre.Y), 2)); if (SegLength > 0) { LastSeg = SegLength; } TotalLength = TotalLength + SegLength; SegLength = CntUnit.ConvertUnits(SegLength, inUnit.pUnit, outUnit.pUnit); CntTotal = CntUnit.ConvertUnits(TotalLength, inUnit.pUnit, outUnit.pUnit); //单位变化 m_SegLen.value = SegLength; m_SegLen.units = outUnit.pUnit; m_TotLen.value = CntTotal; m_TotLen.units = outUnit.pUnit; SegLength = Math.Round(SegLength, 6); CntTotal = Math.Round(CntTotal, 6); double tempSumLen = SumLengths + CntTotal; UnitSumArea = tempSumLen; txtMessage.Clear(); txtMessage.Text = "测量线" + "\r\n线段的长度是:" + SegLength + outUnit.UnitName + "\r\n总长度是:" + CntTotal + outUnit.UnitName; if (tbtnSum.Checked == true) { txtMessage.Text += "\r\n" + "\r\n线段长度之和是:" + tempSumLen + outUnit.UnitName; } } } }
private void registerHandler() { #region UnitIndex Converter handler unitIndexConvertedHandler = new DelegateHandler <UnitIndexConverted>(e => { unitIndexInperiodList = e.UnitIndexInperiodList; Console.WriteLine("{0} Converted , Unit index progress finished", unitIndexInperiodList.Count); unitConverter.ConvertUnits(period, unitIndexInperiodList); }); publisher.RegisterHandler(unitIndexConvertedHandler); #endregion #region Unit Converter handler unitConvertedHandler = new DelegateHandler <UnitConverted>(e => { unitList = e.UnitList; Console.WriteLine("{0} Units converted , Unit progress finished", e.UnitList.Count); jobIndexConverter.ConvertJobIndex(period); }); publisher.RegisterHandler(unitConvertedHandler); #endregion #region JobIndex Converter handler jobIndexConvertedHandler = new DelegateHandler <JobIndexConverted>(e => { jobIndexInperiodList = e.JobIndexInperiodList; jobIndexList = e.JobIndexList; Console.WriteLine("{0} Job index converted , Job index progress finished", jobIndexInperiodList.Count); jobConverter.ConvertJobs(period, jobIndexInperiodList, jobIndexList); }); publisher.RegisterHandler(jobIndexConvertedHandler); #endregion #region Job Conveter Handler jobConvertedHandler = new DelegateHandler <JobConverted>(e => { jobList = e.JobList; Console.WriteLine("{0} Jobs Converted , Job progress finished", e.JobList.Count); jobPositionConverter.ConvertJobPositions(period, unitList, jobList); }); publisher.RegisterHandler(jobConvertedHandler); #endregion #region JobPosition Conveter Handler jobPositionConvertedHandler = new DelegateHandler <JobPositionConverted>(e => { jobPositionList = e.JobPositionList; Console.WriteLine("{0} JobPositions Converted , JobPosition progress finished", e.JobPositionList.Count); employeeConverter.ConvertEmployees(period, jobPositionList); }); publisher.RegisterHandler(jobPositionConvertedHandler); #endregion }