Exemple #1
0
        //CalculatedFields integration
        public static Dictionary <string, List <ITrailResult> > GetTrailsResultsForActivities(IList <IActivity> activities)
        {
            var results = new Dictionary <string, List <ITrailResult> >();

            Controller.TrailController.Instance.Activities = activities;
            foreach (Trail trail in Data.TrailData.AllTrails.Values)
            {
                var activityTrail = new ActivityTrail(trail);

                List <ITrailResult> trailResults = new List <ITrailResult>();
                foreach (TrailResult tr in TrailResultWrapper.TrailResults(activityTrail.Results))
                {
                    if (!(tr is Data.PausedChildTrailResult))
                    {
                        trailResults.Add(new CFTrailResult(tr));
                    }
                }

                results.Add(trail.Name, trailResults);
            }

            return(results);
        }
Exemple #2
0
        public void RefreshChart()
        {
            if (m_showPage && this.ChartVisible)
            {
                LineChartTypes speedPaceChart       = LineChartTypes.Speed;
                LineChartTypes deviceSpeedPaceChart = LineChartTypes.DeviceSpeed;
                if (Controller.TrailController.Instance.ReferenceActivity != null &&
                    Controller.TrailController.Instance.ReferenceActivity.Category.SpeedUnits.Equals(Speed.Units.Pace))
                {
                    speedPaceChart       = LineChartTypes.Pace;
                    deviceSpeedPaceChart = LineChartTypes.DevicePace;
                }
                LineChartTypes diffChart = LineChartTypes.DiffDist;
                if (Data.Settings.XAxisValue == XAxisValue.Distance)
                {
                    diffChart = LineChartTypes.DiffTime;
                }

                bool isData = Controller.TrailController.Instance.CurrentActivityTrailIsSelected;

                IList <Data.TrailResult> selectedPresentableResults =
                    TrailResultWrapper.TrailResults(Controller.TrailController.Instance.SelectedResults);
                if (selectedPresentableResults.Count > Data.Settings.MaxChartResults)
                {
                    //Move summary first, so it is not truncated
                    for (int i = 0; i < selectedPresentableResults.Count; i++)
                    {
                        TrailResult t = selectedPresentableResults[i];
                        if (t is SummaryTrailResult)
                        {
                            selectedPresentableResults.RemoveAt(i);
                            selectedPresentableResults.Insert(0, t);
                            break;
                        }
                    }

                    ((List <Data.TrailResult>)selectedPresentableResults).RemoveRange(Data.Settings.MaxChartResults,
                                                                                      selectedPresentableResults.Count - Data.Settings.MaxChartResults);
                }

                m_multiChart.ChartTypes = new List <LineChartTypes>();
                multiChart.ShowPage     = false;
                //TODO: Temporary handling. Cleanup and decide multiple graphs and charts
                TrailLineChart updateChart = m_multiChart;
                if (!m_expanded)
                {
                    foreach (TrailLineChart chart in m_lineCharts)
                    {
                        chart.ShowPage = false;
                    }
                    m_multiChart.BeginUpdate();
                    m_multiChart.XAxisReferential = Data.Settings.XAxisValue;
                    m_multiChart.TrailResults     = selectedPresentableResults;
                    foreach (LineChartTypes t in Data.Settings.MultiChartType)
                    {
                        LineChartTypes t2 = t;
                        if (t2 == LineChartTypes.SpeedPace)
                        {
                            t2 = speedPaceChart;
                        }
                        else if (t2 == LineChartTypes.DeviceSpeedPace)
                        {
                            t2 = deviceSpeedPaceChart;
                        }
                        else if (t2 == LineChartTypes.DiffDistTime)
                        {
                            t2 = diffChart;
                        }
                        if (!m_multiChart.ChartTypes.Contains(t2) &&
                            m_multiChart.HasValues(t2))
                        {
                            m_multiChart.ChartTypes.Add(t2);
                        }
                    }
                    m_multiChart.ShowPage = true;

                    if (!m_multiChart.AnyData())
                    {
                        m_multiChart.ShowPage      = false;
                        m_multiChart.LeftChartType = speedPaceChart;
                        m_multiChart.ShowPage      = true;
                    }
                    this.ChartBanner.Text = LineChartUtil.ChartTypeString(m_multiChart.LeftChartType) + " / " +
                                            LineChartUtil.XAxisValueString(m_multiChart.XAxisReferential);
                    m_multiChart.EndUpdate(true);
                }
                else
                {
                    foreach (TrailLineChart chart in m_lineCharts)
                    {
                        bool visible = false;

                        if (m_expanded &&
                            (Data.Settings.MultiGraphType.Contains(chart.LeftChartType) ||
                             chart.LeftChartType == speedPaceChart &&
                             (Data.Settings.MultiGraphType.Contains(LineChartTypes.SpeedPace) || Data.Settings.MultiGraphType.Contains(LineChartTypes.DeviceSpeedPace)) ||
                             chart.LeftChartType == diffChart &&
                             (Data.Settings.MultiGraphType.Contains(LineChartTypes.DiffDistTime) || Data.Settings.MultiGraphType.Contains(LineChartTypes.DeviceDiffDist))) ||

                            !m_expanded &&
                            (chart.LeftChartType == Data.Settings.ChartType ||
                             chart.LeftChartType == speedPaceChart &&
                             (LineChartTypes.SpeedPace == Data.Settings.ChartType || LineChartTypes.DeviceSpeedPace == Data.Settings.ChartType) ||
                             chart.LeftChartType == diffChart &&
                             (LineChartTypes.DiffDistTime == Data.Settings.ChartType || LineChartTypes.DiffDistTime == Data.Settings.ChartType)))
                        {
                            visible = true;
                        }

                        updateChart = chart;
                        updateChart.BeginUpdate();
                        chart.ShowPage = false;
                        if (visible && isData)
                        {
                            updateChart.XAxisReferential = Data.Settings.XAxisValue;
                            updateChart.TrailResults     = selectedPresentableResults;
                            if (!m_expanded && updateChart.ChartTypes.Count == 1)
                            {
                                this.ChartBanner.Text = LineChartUtil.ChartTypeString(chart.LeftChartType) + " / " +
                                                        LineChartUtil.XAxisValueString(chart.XAxisReferential);
                            }
                            if (updateChart.HasValues(chart.LeftChartType))
                            {
                                updateChart.ShowPage = visible;
                            }
                            else
                            {
                                if (visible && !updateChart.HasValues(chart.LeftChartType))
                                {
                                    chart.ShowPage = false;
                                    //Replace empty chart
                                    if (!m_expanded && chart.LeftChartType != speedPaceChart)
                                    {
                                        foreach (TrailLineChart replaceChart in m_lineCharts)
                                        {
                                            if (replaceChart.LeftChartType == speedPaceChart)
                                            {
                                                replaceChart.BeginUpdate();
                                                replaceChart.ShowPage         = false;
                                                replaceChart.XAxisReferential = Data.Settings.XAxisValue;
                                                replaceChart.TrailResults     = selectedPresentableResults;
                                                if (!m_expanded)
                                                {
                                                    this.ChartBanner.Text = LineChartUtil.ChartTypeString(replaceChart.LeftChartType) + " / " +
                                                                            LineChartUtil.XAxisValueString(replaceChart.XAxisReferential);
                                                }
                                                replaceChart.ShowPage = visible;
                                                replaceChart.EndUpdate(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        updateChart.EndUpdate(true);
                    }
                }
                RefreshRows();
                RefreshChartMenu();
            }
        }