当前位置: 首页>>代码示例>>C#>>正文


C# Distance.ToString方法代码示例

本文整理汇总了C#中Distance.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.ToString方法的具体用法?C# Distance.ToString怎么用?C# Distance.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Distance的用法示例。


在下文中一共展示了Distance.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DlgFavoritesAddTo

        // closest is SortedList of string (name) by key=double (distance meters)
        public DlgFavoritesAddTo(CamPos camPos, SortedList closest, MenuItem parentMenuItem, EventHandler eventHandler)
        {
            m_camPos = camPos;
            m_parentMenuItem = parentMenuItem;
            m_eventHandler = eventHandler;

            InitializeComponent();

            GeoCoord loc = new GeoCoord(m_camPos);

            Distance camHD = new Distance(m_camPos.H);
            int unitsCompl = camHD.UnitsCompl;
            locationLabel.Text = "Location: " + loc.ToString() + " / Camera at " + camHD.ToString(unitsCompl);
            nameComboBox.Text = m_camPos.Name;
            for(int i=0; i < closest.Count && i < 20 ;i++)
            {
                string name = ((LiveObject)closest.GetByIndex(i)).Name;
                nameComboBox.Items.Add(name);
            }
            Project.setDlgIcon(this);
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:22,代码来源:DlgFavoritesAddTo.cs

示例2: toStringPopup

        /// <summary>
        /// returns a formatted string suitable for popups
        /// </summary>
        /// <returns></returns>
        public string toStringPopup()
        {
            StringBuilder builder = new StringBuilder();
            string speedLbl = null;
            string odometerLbl = null;
            string timeTraveledLbl = null;
            string timeThisLegLbl = null;
            string timeRemainingLbl = null;

            if(m_wptFrom.TrackId != -1)
            {
                Track trk = (Track)Project.mainCommand.getTrackById(m_wptFrom.TrackId);
                Distance dOdometer;

                if(trk != null)
                {
                    int i = trk.Trackpoints.IndexOfValue(this);
                    builder.Append("Leg : " + m_wptFrom.Name + " --> " + m_wptTo.Name);
                    builder.Append("\nof " + (trk.isRoute ? "Route" : "Track") + m_wptFrom.TrackId + " : " + trk.Name + "\n");

                    if(HasSpeed)
                    {
                        Speed dSpeed = new Speed(this.Speed);				// meters per hour
                        speedLbl = dSpeed.ToString();
                    }

                    TimeSpan ts = m_wptFrom.DateTime - trk.Start;
                    timeTraveledLbl = Project.TimeSpanToString(ts);

                    timeThisLegLbl = Project.TimeSpanToString(m_duration);

                    ts = trk.End - m_wptTo.DateTime;
                    timeRemainingLbl = Project.TimeSpanToString(ts);

                    dOdometer = new Distance(m_wptFrom.Odometer);	// meters
                    odometerLbl = dOdometer.ToString() + " plus this leg: " + Dist.ToString();
                }
            }
            builder.Append(m_wptFrom.Location.toString00(false, Project.coordStyle));
            Distance dElev = new Distance(m_wptFrom.Location.Elev);
            if(dElev.Meters != 0.0d)
            {
                builder.Append("  elev: " + dElev.ToStringCompl() + "\n");
            }

            if(m_wptFrom.DateTime.Ticks > minDateTimeTicks)
                // waypoint times are added to to avoid duplicates, we need to compare with tolerance
            {
                builder.Append("\n  " + Project.zuluToLocal(m_wptFrom.DateTime));
            }
            if(odometerLbl != null)
            {
                builder.Append((speedLbl == null ? "\n" : "  ") +  "odometer: " + odometerLbl);
            }
            if(speedLbl != null)
            {
                builder.Append("\n  speed: " + speedLbl);
            }
            builder.Append("\n time");
            if(timeTraveledLbl != null)
            {
                builder.Append(" traveled: " + timeTraveledLbl);
            }
            builder.Append(" this leg: " + timeThisLegLbl);
            if(timeRemainingLbl != null)
            {
                builder.Append("   remaining: " + timeRemainingLbl);
            }

            addCourseData(builder, false);

            return builder.ToString();
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:77,代码来源:Leg.cs

示例3: Paint

        public override void Paint(Graphics graphics, IDrawingSurface layer, ITile iTile, int offsetX, int offsetY)
        {
            if(!m_enabled)
            {
                return;
            }

            //LibSys.StatusBar.Trace("Earthquake::Paint()  - " + Location + " - " + Magn + " : " + m_doName + m_labelBoundingRect);

            int x, y, w, h;

            x = m_imageBoundingRect.X + 1 + offsetX;
            y = m_imageBoundingRect.Y + 1 + offsetY;
            w = m_imageBoundingRect.Width-2;
            h = m_imageBoundingRect.Height-2;

            switch (Project.earthquakeStyle)
            {
                case STYLE_DOT:		// small dot
                    //g.setColor(color(3));
                    graphics.DrawEllipse(Project.earthquakePen, x, y, w, h);
                    break;
                case STYLE_TRIANGLE:
                {
                    // triangle pointing down to epicenter; the deeper the quake,
                    // the more narrow the triangle is:
                    // m_triWidth is actually half of the upper side of the triangle.
                    //g.setColor(color(3));
                    graphics.DrawLine(Project.earthquakePen, x+w/2-m_triWidth, y, x+w/2+m_triWidth, y);
                    graphics.DrawLine(Project.earthquakePen, x+w/2-m_triWidth, y, x+w/2, y+h);
                    graphics.DrawLine(Project.earthquakePen, x+w/2+m_triWidth, y, x+w/2, y+h);

                    if(h > 15 && Project.displayEqDepth && m_doName)
                    {
                        double depthMeters = Math.Max(0.0, -Location.Z);
                        Distance dist = new Distance(depthMeters);
                        string sDist = dist.ToString();
                        if(m_triWidth > 50)
                        {
                            sDist += " deep";
                        }

                        // other threads can throw "invalid argument" exception in graphics.MeasureString:
                        SizeF size = graphics.MeasureString(sDist, mm_font);
                        int depthLabelWidth = (int)(size.Width * 0.95d);
                        int depthLabelHeight = (int)(size.Height * 0.85d);
                        //if(depthLabelWidth > m_triWidth*5/6)
                        //{
                        //	depthLabelWidth = m_triWidth*5/6;
                        //}
                        int xx = x+w/2-depthLabelWidth/2;
                        int yy = y + 2; //-depthLabelHeight-2;
                        if(Project.earthquakeUseShadow)
                        {
                            //g.setColor(PrjColor.palette[Project.earthquakeColorShadowIndex]);
                            graphics.DrawString(sDist, mm_font, Project.earthquakeBackgroundBrush, xx,   yy);
                            graphics.DrawString(sDist, mm_font, Project.earthquakeBackgroundBrush, xx+2, yy);
                            graphics.DrawString(sDist, mm_font, Project.earthquakeBackgroundBrush, xx,   yy-2);
                            graphics.DrawString(sDist, mm_font, Project.earthquakeBackgroundBrush, xx+2, yy-2);
                        }
                        //g.setColor(color(3));
                        graphics.DrawString(sDist, mm_font, Project.earthquakeFontBrush, xx+1, yy-1);
                    }
                }
                    break;
                case STYLE_SQUARES:
                    // Cyan looks like a good contrast color on the map, very suitable for border around filled circles and squares.
                    // g.setColor(PrjColor.palette[PrjColor.COLOR_CYAN]);
                    //g.setColor(color(3));
                    graphics.DrawRectangle(Project.earthquakePen, x, y, w, h);
                    break;
                case STYLE_FILLSQUARES:
                    if(m_doFill)
                    {
                        graphics.FillRectangle(brushByDepth(), x, y, w, h);
                    }
                    if(w > 6)
                    {
                        //g.setColor(color(3));   // PrjColor.palette[PrjColor.COLOR_CYAN]);
                        graphics.DrawRectangle(Project.earthquakePen, x, y, w, h);
                    }
                    break;
                case STYLE_CIRCLES:
                    //g.setColor(color(3));
                    graphics.DrawEllipse(Project.earthquakePen, x, y, w, h);
                    break;
                case STYLE_FILLCIRCLES:
                    if(m_doFill)
                    {
                        graphics.FillEllipse(brushByDepth(), x, y, w, h);
                    }
                    if(w > 6)
                    {
                        //g.setColor(color(3));   // PrjColor.palette[PrjColor.COLOR_CYAN]);
                        graphics.DrawEllipse(Project.earthquakePen, x, y, w, h);
                    }
                    break;
                case STYLE_CONCENTRICCIRCLES:
                default:
                    // Oval drawn without "+1" would go beyond the bounding rectangle
//.........这里部分代码省略.........
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:101,代码来源:Earthquake.cs

示例4: addKmlCoords

        private void addKmlCoords(StringBuilder builder)
        {
            string sep = "<br/>";

            int coordStyle = Project.coordStyle;
            if(Project.coordStyle == 3)
            {
                coordStyle = 1;
            }
            builder.Append("<b>Loc:</b> " + this.Location.toString00(false, coordStyle) + sep);
            builder.Append("<b>UTM:</b> " + this.Location.toString0(false, 3) + sep);

            Distance dElev = new Distance(-this.Location.Elev);
            double depthKm = Math.Round(-this.Location.Elev / 1000.0d, 1);

            builder.Append("<b>Depth:</b> " + dElev.ToString() + " (" + string.Format("{0:F1}", depthKm) + " Km)");
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:17,代码来源:Earthquake.cs

示例5: OnPaintOffScreen

        /// <inheritdocs/>
        protected override void OnPaintOffScreen(PaintEventArgs e)
        {
            PolarGraphics f = CreatePolarGraphics(e.Graphics);

            // What altitude are we drawing?

            Distance altitudeToRender = new Distance(_valueInterpolator[_interpolationIndex], _altitude.Units);

            // There are 100 tick marks in 360 degrees.   3.6° per tick mark
            const double conversionFactor = 3.6;
            // Draw tick marks
            if (_minorTickPen != null)
            {
                for (double alt = 0; alt < 100; alt += 1)
                {
                    // Convert the speed to an angle
                    Angle angle = new Angle(alt * conversionFactor);
                    // Get the coordinate of the line's start
                    PolarCoordinate start = new PolarCoordinate(95, angle, Azimuth.North, PolarCoordinateOrientation.Clockwise);
                    PolarCoordinate end = new PolarCoordinate(100, angle, Azimuth.North, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    f.DrawLine(_minorTickPen, start, end);
                }
            }
            // Draw tick marks
            if (_majorTickPen != null)
            {
                for (double alt = 0; alt < 100; alt += 10)
                {
                    // Convert the speed to an angle
                    Angle angle = new Angle(alt * conversionFactor);
                    // Get the coordinate of the line's start
                    PolarCoordinate start = new PolarCoordinate(94, angle, Azimuth.North, PolarCoordinateOrientation.Clockwise);
                    PolarCoordinate end = new PolarCoordinate(100, angle, Azimuth.North, PolarCoordinateOrientation.Clockwise);
                    // And draw a line
                    f.DrawLine(_majorTickPen, start, end);
                    // And also a string
                    string s = Convert.ToString(alt * 0.1, CultureInfo.CurrentCulture);
                    f.DrawCenteredString(s, _altitudeLabelFont, _altitudeLabelBrush,
                        new PolarCoordinate(85, angle, Azimuth.North, PolarCoordinateOrientation.Clockwise));
                }
            }
            // Calculate all needle values
            double pTensOfThousandsValue = altitudeToRender.Value / 1000.0;
            double pThousandsValue = altitudeToRender.Value / 100.0;
            double pValue = altitudeToRender.Value / 10.0;

            // Now draw the tens-of-thousands needle
            // Rotate the needle to the right place
            PolarCoordinate[] needle1 = new PolarCoordinate[_tensOfThousandsNeedle.Length];
            for (int index = 0; index < needle1.Length; index++)
                needle1[index] = _tensOfThousandsNeedle[index].Rotate(pTensOfThousandsValue * conversionFactor);

            // Now draw the tens-of-thousands needle
            // Rotate the needle to the right place
            PolarCoordinate[] needle2 = new PolarCoordinate[_thousandsNeedle.Length];
            for (int index = 0; index < needle2.Length; index++)
            {
                needle2[index] = _thousandsNeedle[index].Rotate(pThousandsValue * conversionFactor);
            }

            // Now draw the tens-of-Hundreds needle
            // Rotate the needle to the right place
            PolarCoordinate[] needle3 = new PolarCoordinate[_hundredsNeedle.Length];
            for (int index = 0; index < needle3.Length; index++)
            {
                needle3[index] = _hundredsNeedle[index].Rotate(pValue * conversionFactor);
            }

            string altitudeString = altitudeToRender.ToString(_valueFormat, CultureInfo.CurrentCulture);
            //SizeF FontSize = f.Graphics.MeasureString(AltitudeString, pValueFont);

            f.DrawRotatedString(altitudeString, _valueFont,
                _valueBrush, new PolarCoordinate(45.0f, Angle.Empty, Azimuth.North, PolarCoordinateOrientation.Clockwise));

            // Draw an ellipse at the center
            f.DrawEllipse(_centerPen, PolarCoordinate.Empty, 10);

            f.Graphics.TranslateTransform(_needleShadowSize.Width, _needleShadowSize.Height, MatrixOrder.Append);

            f.FillPolygon(_needleShadowBrush, needle1);
            f.FillPolygon(_needleShadowBrush, needle2);
            f.FillPolygon(_needleShadowBrush, needle3);

            f.Graphics.ResetTransform();

            f.FillPolygon(_tensOfThousandsBrush, needle1);
            f.DrawPolygon(_tensOfThousandsPen, needle1);
            f.FillPolygon(_thousandsBrush, needle2);
            f.DrawPolygon(_thousandsPen, needle2);
            f.FillPolygon(_hundredsBrush, needle3);
            f.DrawPolygon(_hundredsPen, needle3);

            // Draw an ellipse at the center
            f.FillEllipse(_hundredsBrush, PolarCoordinate.Empty, 7);
            f.DrawEllipse(_hundredsPen, PolarCoordinate.Empty, 7);
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:98,代码来源:Altimeter.cs

示例6: realtimeCallback

        private void realtimeCallback( GpsRealTimeData rtData )
        {
            if(!closing)
            {
                this.timeLabel.Text = rtData.time.Equals(DateTime.MinValue) ? "" : ("" + Project.zuluToLocal(rtData.time));
                this.fixLabel.Text = rtData.fixStr;
                this.statusLabel.Text = "PC: " + DateTime.Now.ToLongTimeString() + " - " + rtData.comment;
                switch (rtData.fix)
                {
                    case 0:
                    case 1:
                    case -1:
                        this.positionLabel.Text = "No GPS fix";
                        this.altLabel.Text = "";
                        this.accuracyLabel.Text = "";
                        this.speedLabel.Text = "";
                        this.magnHeadingLabel.Text = "";
                        this.trueHeadingLabel.Text = "";
                        this.slopeLabel.Text = "";
                        lastFixLoc = null;
                        gpsBasicsGroupBox.BackColor = Color.Pink;
                        gpsBasicsGroupBox.Text = "";
                        break;
                    default:
                        if(rtData.location != null)
                        {
                            string sLoc = rtData.location.ToString();		// alt not included
                            this.positionLabel.Text = sLoc.Replace(" ", "   ");
                            //LibSys.StatusBar.Trace2(sLoc);
                            Distance dAlt = new Distance(rtData.location.Elev);
                            this.altLabel.Text = "" + dAlt.ToString(Distance.UNITS_DISTANCE_FEET);
                        }
                        else
                        {
                            this.positionLabel.Text = "";
                            this.altLabel.Text = "";
                            //LibSys.StatusBar.Trace2("GPS: no fix");
                        }
                        Distance dAccH = new Distance(rtData.posErrorH);
                        Distance dAccV = new Distance(rtData.posErrorV);
                        this.accuracyLabel.Text =
                            (rtData.posErrorH > 0 ? (dAccH.ToString(Distance.UNITS_DISTANCE_FEET) + "(Horiz)") : "") + "   "
                            + (rtData.posErrorV > 0 ? (dAccV.ToString(Distance.UNITS_DISTANCE_FEET) + "(Vert)") : "");

                        double variation = Math.Round(rtData.location.magneticVariation());
                        string variationDir = variation > 0.0d ? "W" : "E";

                        bool hasHeading = false;
                        double headingTrue = 0.0d;
                        double headingMagn = 0.0d;
                        string slopeInfo = "";

                        if(lastFixLoc != null)
                        {
                            headingTrue = Math.Round(lastFixLoc.bearing(rtData.location) * 180.0d / Math.PI, 1);
                            headingMagn = (headingTrue + variation + 360.0d) % 360.0d;
                            hasHeading = true;

                            double dAlt = rtData.location.Elev - lastFixLoc.Elev;	// meters
                            double dDist = rtData.location.distanceFrom(lastFixLoc).Meters;
                            double dSlope = Math.Atan(dAlt / dDist) * 180.0d / Math.PI;
                            double dTimeMs = (DateTime.Now - lastFixDateTime).TotalMilliseconds + 1.0d;		// 1.0d to avoid 0
                            double fpm = dAlt / dTimeMs / Distance.METERS_PER_FOOT * 1000.0d * 60.0d;
                            string fpmFormat = Math.Abs(fpm) > 20.0d ? "1:F0" : "1:F1";

                            if(fpm > 1.0d || dSlope >= 0.1d)
                            {
                                slopeInfo = String.Format("slope: {0:F1}° (up) - climbing at {" + fpmFormat + "} fpm", dSlope, fpm);
                            }
                            else if(fpm < -1.0d || dSlope <= -0.1d)
                            {
                                slopeInfo = String.Format("slope: {0:F1}° (down) - descending at {" + fpmFormat + "} fpm", -dSlope, -fpm);
                            }
                        }

                        Speed dSpeed = new Speed(rtData.velocity * 3600.0d);		// rtData.velocity is in meters/sec, Speed requires meters/hr
                        if(dSpeed.Meters < 300)
                        {
                            this.speedLabel.Text = "0";
                            this.magnHeadingLabel.Text = "";
                            this.trueHeadingLabel.Text = "";
                        }
                        else
                        {
                            this.speedLabel.Text = dSpeed.ToString();
                        }

                        this.magnHeadingLabel.Text = (hasHeading ? String.Format("{0:000}°", Math.Round(headingMagn)) : "");
                        this.trueHeadingLabel.Text = (hasHeading ? String.Format("true heading: {0:000}°", Math.Round(headingTrue)) : "") + String.Format("  variation {0:F0}{1}", Math.Abs(variation), variationDir);

                        this.slopeLabel.Text = slopeInfo;

                        lastFixLoc = new GeoCoord(rtData.location);
                        lastFixDateTime = DateTime.Now;
                        gpsBasicsGroupBox.BackColor = Color.LightGreen;
                        gpsBasicsGroupBox.Text = "";
                        break;
                }
            }
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:100,代码来源:DlgGpsManager.cs

示例7: graphInfoString

        /// <summary>
        /// short info string about the trackpoint for elevation graph
        /// </summary>
        /// <returns></returns>
        public string graphInfoString()
        {
            string tmp = "";

            string speedLbl = null;
            string odometerLbl = null;

            Track trk = (Track)Project.mainCommand.getTrackById(this.TrackId);
            if(trk != null)
            {
                if(trk.isRoute)
                {
                    tmp += "Route " + this.TrackId + ": " + trk.Name;
                    if(HasOdometer)
                    {
                        Distance dOdometer = new Distance(this.Odometer);	// meters
                        odometerLbl = dOdometer.ToString();
                    }
                }
                else
                {
                    tmp += "Track " + this.TrackId + ": " + trk.Name;
                    if(HasSpeed)
                    {
                        Speed dSpeed = new Speed(this.Speed);				// meters per hour
                        speedLbl = dSpeed.ToString();
                    }
                    if(HasOdometer)
                    {
                        Distance dOdometer = new Distance(this.Odometer);	// meters
                        odometerLbl = dOdometer.ToString();
                    }
                }
            }

            Distance dElev = new Distance(this.Location.Elev);
            string elevLbl = dElev.ToStringCompl();

            tmp += "       elevation: " + elevLbl;

            if(speedLbl != null)
            {
                tmp += "  speed: " + speedLbl;
            }
            if(odometerLbl != null)
            {
                tmp += "  odometer: " + odometerLbl;
            }

            return tmp;
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:55,代码来源:Waypoint.cs

示例8: ToStringProfile

        public string ToStringProfile()
        {
            StringBuilder builder = new StringBuilder();
            Waypoint nextWpt = null;
            string speedLbl = null;
            string odometerLbl = null;
            string timeTraveledLbl = null;
            string timeRemainingLbl = null;

            bool doTime = true;
            if(this.Desc != null && this.Desc.Length > 0 && !this.Desc.Equals(this.Name))
            {
                builder.Append(this.Desc.Trim() + "  ");
            }
            if(this.TrackId != -1)
            {
                Track trk = (Track)Project.mainCommand.getTrackById(this.TrackId);
                if(trk != null)
                {
                    int i = trk.Trackpoints.IndexOfValue(this);
                    nextWpt = (i < trk.Trackpoints.Count-1) ? (Waypoint)trk.Trackpoints.GetByIndex(i+1) : null;
                    string name = this.Name;
                    if(trk.isRoute)
                    {
                        builder.Append(name + " | ");
                        doTime = false;
                        if(HasOdometer)
                        {
                            Distance dOdometer = new Distance(this.Odometer);	// meters
                            odometerLbl = dOdometer.ToString();
                        }
                    }
                    else
                    {
                        builder.Append(name + " | ");
                        if(HasSpeed)
                        {
                            Speed dSpeed = new Speed(this.Speed);				// meters per hour
                            speedLbl = dSpeed.ToString();
                        }
                        TimeSpan ts = this.DateTime - trk.Start;
                        timeTraveledLbl = Project.TimeSpanToString(ts);

                        ts = trk.End - this.DateTime;
                        timeRemainingLbl = Project.TimeSpanToString(ts);
                    }
                    if(HasOdometer)
                    {
                        Distance dOdometer = new Distance(this.Odometer);	// meters
                        odometerLbl = dOdometer.ToString();
                    }
                }
            }
            builder.Append(this.Location.toString00(false, Project.coordStyle));
            Distance dElev = new Distance(this.Location.Elev);
            if(dElev.Meters != 0.0d)
            {
                builder.Append("  elev: " + dElev.ToStringCompl() + " ");
            }

            if(doTime && this.DateTime.Ticks > minDateTimeTicks)
                // waypoint times are added to to avoid duplicates, we need to compare with tolerance
            {
                builder.Append(" " + Project.zuluToLocal(this.DateTime));
            }
            if(speedLbl != null)
            {
                builder.Append("  speed: " + speedLbl);
            }
            if(odometerLbl != null)
            {
                builder.Append("  odometer: " + odometerLbl);
            }
            if(timeTraveledLbl != null)
            {
                builder.Append("  time traveled: " + timeTraveledLbl);
            }
            if(timeRemainingLbl != null)
            {
                builder.Append("  time remaining: " + timeRemainingLbl);
            }
            if(nextWpt != null && !this.Location.sameAs(nextWpt.Location))
            {
                addCourseData(builder, nextWpt, false);
            }
            if(this.WptName != null && this.WptName.Length > 0)
            {
                builder.Append(" Name: " + this.WptName.Trim());
            }
            if(this.TrackId == -1 && this.LiveObjectType == LiveObjectTypes.LiveObjectTypeGeocache && this.DateTime.Ticks > minDateTimeTicks)
            {
                builder.Append("      Hidden: " + Project.zuluToLocal(this.DateTime).ToShortDateString());
            }
            if(this.UrlName != null && this.UrlName.Length > 0)
            {
                builder.Append(" Url Name: " + this.UrlName.Trim());
            }
            if(this.Comment != null && this.Comment.Length > 0)
            {
                builder.Append(" Comment: " + this.Comment.Trim());
//.........这里部分代码省略.........
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:101,代码来源:Waypoint.cs

示例9: toStringPopup

        /// <summary>
        /// returns a formatted string suitable for popups
        /// </summary>
        /// <returns></returns>
        public string toStringPopup()
        {
            StringBuilder builder = new StringBuilder();
            Waypoint nextWpt = null;
            string speedLbl = null;
            string odometerLbl = null;
            //Waypoint prevWpt = null;
            string timeTraveledLbl = null;
            string timeRemainingLbl = null;

            bool doTime = this.DateTime.Ticks > minDateTimeTicks;

            if(this.Desc != null && this.Desc.Length > 0)
            {
                builder.Append(this.Desc.Trim() + "\n\n");
            }
            if(this.Url != null && this.Url.Length > 0)
            {
                builder.Append(Project.serverAvailable ? "[click waypoint or label to browse]\n\n" : "[can't browse offline]\n\n");
            }
            if(this.TrackId != -1)
            {
                Track trk = (Track)Project.mainCommand.getTrackById(this.TrackId);
                if(trk != null)
                {
                    int i = trk.Trackpoints.IndexOfValue(this);
                    nextWpt = (i < trk.Trackpoints.Count-1) ? (Waypoint)trk.Trackpoints.GetByIndex(i+1) : null;
                    string name = " : " + this.Name;
                    if(name.Length > 7)
                    {
                        name = "";
                    }

                    if(builder.Length == 0)
                    {
                        builder.Append("Waypoint on ");
                    }

                    builder.Append((trk.isRoute ? "Route " : "Track ") + this.TrackId + ": " + trk.Name + name + "\n");

                    if(HasSpeed)
                    {
                        Speed dSpeed = new Speed(this.Speed);				// meters per hour
                        speedLbl = dSpeed.ToString();
                    }
                    TimeSpan ts = this.DateTime - trk.Start;
                    timeTraveledLbl = Project.TimeSpanToString(ts);

                    ts = trk.End - this.DateTime;
                    timeRemainingLbl = Project.TimeSpanToString(ts);

                    if(HasOdometer)
                    {
                        Distance dOdometer = new Distance(this.Odometer);	// meters
                        odometerLbl = dOdometer.ToString();
                    }
                }
            }
            builder.Append(this.Location.toString00(false, Project.coordStyle));
            Distance dElev = new Distance(this.Location.Elev);
            if(dElev.Meters != 0.0d)
            {
                builder.Append("  elev: " + dElev.ToStringCompl() + "\n");
            }

            if(this.TrackId == -1)
            {
                string strLoType = this.LiveObjectTypeToString();
                builder.Append("Type: (" + strLoType + (this.Found ? " - FOUND" : "") + ")");
            }
            if(m_wptType.Length > 0)
            {
                builder.Append(" (" + m_wptType + (this.Found ? " - FOUND" : "") + ")");
            }
            if(doTime && this.DateTime.Ticks > minDateTimeTicks)
                // waypoint times are added to to avoid duplicates, we need to compare with tolerance
            {
                builder.Append("\n  " + Project.zuluToLocal(this.DateTime));
            }
            if(speedLbl != null)
            {
                builder.Append("\n  speed: " + speedLbl);
            }
            if(odometerLbl != null)
            {
                builder.Append((speedLbl == null ? "\n" : "  ") +  "odometer: " + odometerLbl);
            }
            if(timeTraveledLbl != null)
            {
                builder.Append("\n time traveled: " + timeTraveledLbl);
            }
            if(timeRemainingLbl != null)
            {
                builder.Append("  time remaining: " + timeRemainingLbl);
            }
            if(nextWpt != null && !this.Location.sameAs(nextWpt.Location))
//.........这里部分代码省略.........
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:101,代码来源:Waypoint.cs

示例10: toStringKmlDescr


//.........这里部分代码省略.........
                {
                    builder.Append(this.Desc.Replace("\n","<br/>\n").Trim() + "<br/>\n");
                }
                if(this.Url != null && this.Url.Length > 0)
                {
                    builder.Append(String.Format("<a href=\"{0}\">{0}</a><br/>\n", this.Url));
                }
                if(this.TrackId != -1)
                {
                    Track trk = (Track)Project.mainCommand.getTrackById(this.TrackId);
                    if(trk != null)
                    {
                        int i = trk.Trackpoints.IndexOfValue(this);
                        nextWpt = (i < trk.Trackpoints.Count-1) ? (Waypoint)trk.Trackpoints.GetByIndex(i+1) : null;
                        string pointOfLabel = "<b>Point:</b> " + (i+1) + " of " + trk.Trackpoints.Count + "<br/>\n";

                        if(trk.isRoute)
                        {
                            builder.Append("<b>Route:</b> " + trk.Name + "<br/>\n");
                            builder.Append(pointOfLabel);
                        }
                        else
                        {
                            builder.Append("<b>Track:</b> " + trk.Name + "<br/>\n");
                            builder.Append(pointOfLabel);
                            if(this.DateTime.Ticks > minDateTimeTicks)
                                // waypoint times are added to to avoid duplicates, we need to compare with tolerance
                            {
                                builder.Append("<b>Time:</b> " + Project.zuluToLocal(this.DateTime) + "<br/>\n");
                            }
                            if(HasSpeed)
                            {
                                Speed dSpeed = new Speed(this.Speed);				// meters per hour
                                speedLbl = dSpeed.ToString();
                            }
                            TimeSpan ts = this.DateTime - trk.Start;
                            timeTraveledLbl = Project.TimeSpanToString(ts);

                            ts = trk.End - this.DateTime;
                            timeRemainingLbl = Project.TimeSpanToString(ts);
                        }
                        if(HasOdometer)
                        {
                            Distance dOdometer = new Distance(this.Odometer);		// meters
                            odometerLbl = dOdometer.ToString() + " of " + (new Distance(trk.Odometer)).ToString() + "<br/>";
                        }
                    }
                }

                addKmlCoords(builder, true);

                if(nextWpt != null && !this.Location.sameAs(nextWpt.Location))
                {
                    addCourseData(builder, nextWpt, true);
                }

                if(this.TrackId != -1)
                {
                    builder.Append(m_endTr);
                    builder.Append(m_startTr2);

                    if(speedLbl != null)
                    {
                        builder.Append("<b>Speed:</b> " + speedLbl + "<br/>");
                    }
                    if(odometerLbl != null)
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:67,代码来源:Waypoint.cs

示例11: makeRoutesDS


//.........这里部分代码省略.........
            myDataColumn.Unique = true;
            routesTable.Columns.Add(myDataColumn);

            // Create name column.
            myDataColumn = new DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.String");
            myDataColumn.ColumnName = "name";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "Name";
            myDataColumn.ReadOnly = false;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            // Create source column.
            myDataColumn = new DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.String");
            myDataColumn.ColumnName = "source";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "Source";
            myDataColumn.ReadOnly = true;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            // Create "legs" column.
            myDataColumn = new DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.Int32");
            myDataColumn.ColumnName = "legs";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "Legs";
            myDataColumn.ReadOnly = true;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            // Create start column.
            myDataColumn = new DataColumn();
            myDataColumn.DataType = sortableDateTime.GetType();
            myDataColumn.ColumnName = "start";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "Start";
            myDataColumn.ReadOnly = true;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            // Create end column.
            myDataColumn = new DataColumn();
            myDataColumn.DataType = sortableDateTime.GetType();
            myDataColumn.ColumnName = "end";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "End";
            myDataColumn.ReadOnly = true;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            myDataColumn = new DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.Boolean");
            myDataColumn.ColumnName = "displayed";
            myDataColumn.AutoIncrement = false;
            myDataColumn.Caption = "Display";
            myDataColumn.ReadOnly = false;
            myDataColumn.Unique = false;
            routesTable.Columns.Add(myDataColumn);

            // Make the ID column the primary key column.
            DataColumn[] PrimaryKeyColumns = new DataColumn[1];
            PrimaryKeyColumns[0] = routesTable.Columns["id"];
            routesTable.PrimaryKey = PrimaryKeyColumns;

            // Add the new DataTable to the DataSet.
            m_routesDS = new DataSet();
            m_routesDS.Tables.Add(routesTable);

            routesTable = m_routesDS.Tables[0];
            // Create DataRow objects and add them to the DataTable
            DataRow myDataRow;
            for (int i = 0; i < WaypointsCache.TracksAll.Count; i++)
            {
                Track route = (Track)WaypointsCache.TracksAll[i];
                if(route.isRoute)
                {
                    myDataRow = routesTable.NewRow();
                    myDataRow["id"] = route.Id;

                    Distance dOdometer = new Distance(route.Odometer);	// meters

                    myDataRow["name"] = route.Name;
                    myDataRow["source"] = "" + dOdometer.ToString() + "      source: " + route.Source;
                    myDataRow["legs"] = route.Trackpoints.Count - 1;
                    myDataRow["start"] = new SortableDateTime(route.Start, DateTimeDisplayMode.ConvertToLocal);
                    myDataRow["end"] = new SortableDateTime(route.End, DateTimeDisplayMode.ConvertToLocal);
                    myDataRow["displayed"] = route.Enabled;
                    routesTable.Rows.Add(myDataRow);
                }
            }

            // now make sure the event handlers are in place:
            routesTable.ColumnChanging += new DataColumnChangeEventHandler(this.routes_ColumnChanging);
            routesTable.RowDeleting += new DataRowChangeEventHandler(this.routes_RowDeleting);

            rebuildingRoutes = false;
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:101,代码来源:DlgWaypointsManager.cs


注:本文中的Distance.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。