protected override string ValueToString(object v, string format, IFormatProvider provider)
 {
     if (provider == null)
       {
     var tc = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
     return tc.ToString((TimeSpan)v);
       }
       return string.Format(provider, format ?? "{0}", (TimeSpan)v);
 }
Exemple #2
0
 protected override string ValueToString(object v, string format, IFormatProvider provider)
 {
     if(provider == null)
       {
     var tc = new TimeConverter(TimeConverter.TimeConverterType.TimeOfDay);
     return tc.ToString(Convert.ToDateTime(v));
       }
       return string.Format(provider, format ?? "{0}", Convert.ToDateTime(v));
 }
Exemple #3
0
        private void ValidateAndFormatSmoothingIntervalLengthValue()
        {
            BeginWork();
              TimeConverter tc = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
              double? intervalLength = tc.ToNumeric(smoothingIntervalLength.Text);
              if (intervalLength.HasValue)
              {
            canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[SelectedColorCodingAttribute] = new Interval(-intervalLength.Value / 2, intervalLength.Value / 2);

            // make sure speed and pace are always the same
            if (SelectedColorCodingAttribute == WaypointAttribute.Speed)
              canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[WaypointAttribute.Pace] = new Interval(canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[SelectedColorCodingAttribute]);
            if (SelectedColorCodingAttribute == WaypointAttribute.Pace)
              canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[WaypointAttribute.Speed] = new Interval(canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[SelectedColorCodingAttribute]);

            canvas.Document.SetSessionsSmoothingIntervals();

            canvas.DrawMap(Canvas.MapDrawingFlags.Route | Canvas.MapDrawingFlags.Markers);
            CalculateLapInfo();
            CreateLapHistogram();
            DrawLapHistogram();
            CreateLineGraph();
            DrawLineGraph();
              }
              smoothingIntervalLength.Text = tc.ToString(canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[SelectedColorCodingAttribute].Length);
              EndWork();
        }
Exemple #4
0
        public void UpdateUI()
        {
            if (UpdatingUINow) return;
              updatingUINowCounter++;

              var documentOpened = (canvas.Document != null);

              // window caption
              if (documentOpened)
              {
            Text = (canvas.Document.FileName == null ? Strings.Untitled : Path.GetFileName(canvas.Document.FileName)) + " - " + Strings.QuickRoute;
              }
              else
              {
            Text = Strings.QuickRoute;
              }

              // menu
              menuFileSave.Enabled = documentOpened;
              menuFileSaveAs.Enabled = documentOpened;
              menuFileImportSessions.Enabled = documentOpened;
              menuFileExport.Enabled = documentOpened;
              menuEdit.Visible = documentOpened;
              menuEditUndo.Enabled = (undoStack.Count > 0);
              menuEditRedo.Enabled = (redoStack.Count > 0);
              menuEditSeparator1.Enabled = documentOpened;
              menuEditChangeStartTime.Enabled = documentOpened;
              menuToolsAddLapsFromExternalDataSource.Enabled = documentOpened;
              menuToolsPublishMap.Enabled = documentOpened;
              menuToolsOpenInGoogleEarth.Enabled = documentOpened;
              menuViewRightPanelVisible.Enabled = documentOpened;
              menuViewBottomPanelVisible.Enabled = documentOpened;

              // toolstrip
              toolStripSave.Enabled = documentOpened;
              toolStripUndo.Enabled = (undoStack.Count > 0);
              toolStripRedo.Enabled = (redoStack.Count > 0);
              toolStripZoom.Enabled = documentOpened;
              toolStripZoom.Text = string.Format("{0:P0}", canvas.Zoom);
              toolStripToolPointer.Visible = documentOpened;
              toolStripToolAdjustRoute.Visible = documentOpened;
              toolStripToolZoomIn.Visible = documentOpened;
              toolStripToolZoomOut.Visible = documentOpened;
              toolStripToolCut.Visible = documentOpened;
              toolStripToolLap.Visible = documentOpened;
              toolStripToolPointer.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.Pointer);
              toolStripToolAdjustRoute.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.AdjustRoute);
              toolStripToolZoomIn.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.ZoomIn);
              toolStripToolZoomOut.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.ZoomOut);
              toolStripToolCut.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.Cut);
              toolStripToolLap.Checked = (canvas.CurrentMouseTool == Canvas.MouseTool.Lap);
              tstSeparator4.Visible = documentOpened;
              toolStripOpenInGoogleEarth.Visible = documentOpened;
              toolStripPublishMap.Visible = documentOpened;
              tstToolsSeparator.Visible = documentOpened;

              // view settings
              toolStripFullScreen.Checked = (formState != null);
              menuViewFullScreen.Checked = (formState != null);
              toolStripRightPanelVisible.Visible = documentOpened;
              toolStripBottomPanelVisible.Visible = documentOpened;
              toolStripRightPanelVisible.Checked = ApplicationSettings.RightPanelVisible;
              toolStripBottomPanelVisible.Checked = ApplicationSettings.BottomPanelVisible;
              menuViewRightPanelVisible.Checked = ApplicationSettings.RightPanelVisible;
              menuViewBottomPanelVisible.Checked = ApplicationSettings.BottomPanelVisible;

              toolStripAutoAdjustColorRangeInterval.Checked = ApplicationSettings.AutoAdjustColorRangeInterval;

              // route appearance toolstrip
              routeAppearanceToolstrip.Visible = documentOpened;
              if (documentOpened && canvas.CurrentSession != null)
              {
            RouteLineSettings rls = canvas.CurrentSession.Settings.RouteLineSettingsCollection[SelectedColorCodingAttribute];
            ColorRangeIntervalSlider slider = colorRangeIntervalSlider.SliderControl;
            ColorRangeIntervalSliderSettings sliderSettings = canvas.Document.Settings.ColorRangeIntervalSliderSettings[SelectedColorCodingAttribute];

            slider.PreventRedraw = true;
            switch (SelectedColorCodingAttribute)
            {
              case WaypointAttribute.Pace:
            slider.ScaleCreator = new TimeScaleCreator(sliderSettings.MinValue, sliderSettings.MaxValue, 20, false);
            slider.NumericConverter = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
            break;
              case WaypointAttribute.Speed:
            slider.ScaleCreator = new DoubleScaleCreator(sliderSettings.MinValue, sliderSettings.MaxValue, 20, false);
            slider.NumericConverter = new NumericConverter();
            break;
              case WaypointAttribute.HeartRate:
              case WaypointAttribute.Altitude:
            slider.ScaleCreator = new DoubleScaleCreator(sliderSettings.MinValue, sliderSettings.MaxValue, 20, false);
            slider.NumericConverter = new IntConverter();
            break;
              case WaypointAttribute.DirectionDeviationToNextLap:
            slider.ScaleCreator = new DoubleScaleCreator(sliderSettings.MinValue, sliderSettings.MaxValue, 20, false);
            slider.NumericConverter = new NumericConverter { NoOfDecimals = 0 };
            break;
              case WaypointAttribute.MapReadingDuration:
            slider.ScaleCreator = new TimeScaleCreator(sliderSettings.MinValue, sliderSettings.MaxValue, 5, false);
            slider.NumericConverter = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
            break;
            }
            slider.ColorRange = rls.ColorRange;
            slider.MinValue = sliderSettings.MinValue;
            slider.MaxValue = sliderSettings.MaxValue;
            slider.AlphaAdjustment = rls.AlphaAdjustment;
            slider.PreventRedraw = false;

            SelectedColorCodingAttribute = canvas.ColorCodingAttribute;
            SelectedSecondaryColorCodingAttribute = canvas.SecondaryColorCodingAttribute;
            colorRangeStartValue.Text = FormatColorRangeValue(rls.ColorRange.StartValue);
            colorRangeEndValue.Text = FormatColorRangeValue(rls.ColorRange.EndValue);

            routeLineMaskWidth.NumericUpDownControl.Value = (decimal)rls.MaskWidth;
            routeLineWidth.NumericUpDownControl.Value = (decimal)(canvas.CurrentMouseTool == Canvas.MouseTool.AdjustRoute ? rls.MonochromeWidth : rls.Width);

            routeLineMaskVisible.Checked = rls.MaskVisible;
            routeLineMaskColorButton.Image = CreateRouteLineMaskColorImage(canvas.CurrentMouseTool == Canvas.MouseTool.AdjustRoute ? rls.MonochromeColor : rls.MaskColor);
            gradientAlphaAdjustment.TrackBarControl.Value = (int)(rls.AlphaAdjustment * 10);

            canvas.RouteLineSettings = rls;
            slider.Refresh();

            // smoothing interval length
            var tc = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
            smoothingIntervalLength.Text = tc.ToString(canvas.Document.Settings.DefaultSessionSettings.SmoothingIntervals[SelectedColorCodingAttribute].Length);

            // smoothing interval tooltip
            smoothingIntervalLength.ToolTipText = string.Format(Strings.SmoothingIntervalForX, colorCodingAttributes.Text.ToLower());

            // circle time radius
            circleTimeRadius.Text = canvas.Document.Settings.DefaultSessionSettings.CircleTimeRadius.ToString();

            // lap histogram toolstrip
            lapHistogramBinWidth.Text = slider.NumericConverter.ToString(canvas.Document.Settings.LapHistogramSettings[SelectedColorCodingAttribute].BinWidth);
              }

              // canvas
              canvas.Visible = documentOpened;

              // right panel
              rightPanel.Visible = (documentOpened && ApplicationSettings.RightPanelVisible);
              rightSplitter.Visible = (documentOpened && ApplicationSettings.RightPanelVisible);
              rightSplitter.Enabled = (documentOpened && ApplicationSettings.RightPanelVisible);
              sessionPanel.Visible = (documentOpened && canvas.Document.Sessions.Count > 1);
              rightPanelTopSplitter.Visible = (documentOpened && canvas.Document.Sessions.Count > 1);

              // dynamic help
              dynamicHelpLabel.Visible = documentOpened;
              UpdateDynamicHelp();

              // bottom panel
              bottomPanel.Visible = (documentOpened && ApplicationSettings.BottomPanelVisible);
              bottomSplitter.Visible = (documentOpened && ApplicationSettings.BottomPanelVisible);
              bottomSplitter.Enabled = (documentOpened && ApplicationSettings.BottomPanelVisible);
              switch (canvas.CurrentMouseTool)
              {
            case Canvas.MouseTool.Lap:
              lineGraph.Cursor = Canvas.GetCursor(Canvas.MouseTool.Lap);
              break;
            case Canvas.MouseTool.Cut:
              lineGraph.Cursor = Canvas.GetCursor(Canvas.MouseTool.Cut);
              break;
            default:
              lineGraph.Cursor = Cursors.Default;
              break;
              }

              // momentaneous info
              momentaneousInfoPanel.Visible = documentOpened;

              updatingUINowCounter--;
        }
Exemple #5
0
 public static string FormatTimeSpan(TimeSpan ts)
 {
     TimeConverter tc = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
       return tc.ToString(ts.TotalSeconds);
 }