/[cits3200i]/branches/gps-running-clean-r116/HighScorePlugin/Source/HighScoreAction.cs


UCC Code Repository

Contents of /branches/gps-running-clean-r116/HighScorePlugin/Source/HighScoreAction.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (show annotations) (download)
Sun Sep 5 15:48:34 2010 UTC (11 years, 3 months ago) by rvvs89
File size: 4564 byte(s)
Branching a local copy of the HEAD revision of the gps-running project on Google Code.
We will probably have to use this project as a template for our own plugins if we want to support SportTracks 2.1.
1 /*
2 Copyright (C) 2007, 2008 Kristian Bisgaard Lassen
3 Copyright (C) 2010 Kristian Helkjaer Lassen
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 using System;
20 using System.Collections.Generic;
21 using System.Text;
22 using ZoneFiveSoftware.Common.Visuals;
23 using ZoneFiveSoftware.Common.Data.Fitness;
24 using System.Windows.Forms;
25 using System.Data;
26 using GpsRunningPlugin.Properties;
27 using GpsRunningPlugin.Util;
28 #if !ST_2_1
29 using ZoneFiveSoftware.Common.Data;
30 using ZoneFiveSoftware.Common.Visuals.Fitness;
31 using ZoneFiveSoftware.Common.Visuals.Util;
32 #endif
33
34 namespace GpsRunningPlugin.Source
35 {
36 class HighScoreAction : IAction
37 {
38
39 #if !ST_2_1
40 public HighScoreAction(IDailyActivityView view)
41 {
42 this.dailyView = view;
43 }
44 public HighScoreAction(IActivityReportsView view)
45 {
46 this.reportView = view;
47 }
48 #endif
49 public HighScoreAction(IList<IActivity> activities)
50 {
51 this.activities = activities;
52 }
53
54 #region IAction Members
55
56 public bool Enabled
57 {
58 get { return activities.Count > 0; }
59 }
60
61 public bool HasMenuArrow
62 {
63 get { return false; }
64 }
65
66 public System.Drawing.Image Image
67 {
68 get { return Properties.Resources.Image_16_HighScore; }
69 }
70
71 public IList<string> MenuPath
72 {
73 get
74 {
75 return new List<string>();
76 }
77 }
78 public void Refresh()
79 {
80 }
81
82 public void Run(System.Drawing.Rectangle rectButton)
83 {
84 new HighScoreViewer(activities, activities.Count > 1, true);
85 }
86
87 public string Title
88 {
89 get
90 {
91 if (activities.Count == 1) return Resources.HS + " " + StringResources.ForOneActivity;
92 return Resources.HS + " " + String.Format(StringResources.ForManyActivities, activities.Count);
93 }
94 }
95 private bool firstRun = true;
96 public bool Visible
97 {
98 get
99 {
100 //Analyze menu must be Visible at first call, otherwise it is hidden
101 //Could be done with listeners too
102 if (true == firstRun) { firstRun = false; return true; }
103 if (activities.Count == 0) return false;
104 return true;
105 }
106 }
107
108 #endregion
109
110 #region INotifyPropertyChanged Members
111
112 #pragma warning disable 67
113 public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
114
115 #endregion
116 #if !ST_2_1
117 private IDailyActivityView dailyView = null;
118 private IActivityReportsView reportView = null;
119 #endif
120 private IList<IActivity> _activities = null;
121 private IList<IActivity> activities
122 {
123 get
124 {
125 #if !ST_2_1
126 //activities are set either directly or by selection,
127 //not by more than one
128 if (_activities == null)
129 {
130 if (dailyView != null)
131 {
132 return GpsRunningPlugin.Util.CollectionUtils.GetAllContainedItems<IActivity>(dailyView.SelectionProvider);
133 }
134 else if (reportView != null)
135 {
136 return GpsRunningPlugin.Util.CollectionUtils.GetAllContainedItems<IActivity>(reportView.SelectionProvider);
137 }
138 else
139 {
140 return new List<IActivity>();
141 }
142 }
143 #endif
144 return _activities;
145 }
146 set
147 {
148 _activities = value;
149 }
150 }
151 }
152 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26