/[cits3200i]/branches/gps-running-clean-r116/AccumulatedSummaryPlugin/Source/AccumulatedSummaryAction.cs


UCC Code Repository

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

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26