/[cits3200i]/trunk/UWAPlugins/PlaybackPlugin/Source/PlaybackControl.cs


UCC Code Repository

Contents of /trunk/UWAPlugins/PlaybackPlugin/Source/PlaybackControl.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Fri Sep 17 04:31:03 2010 UTC (11 years, 2 months ago) by rvvs89
File size: 5316 byte(s)
Added function to calculate GPSPoint index from total distance.
1 using PlaybackPlugin.Properties;
2 using System;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Drawing;
6 using System.Data;
7 using System.Text;
8 using System.Timers;
9 using System.Windows.Forms;
10 using ZoneFiveSoftware.Common.Data;
11 using ZoneFiveSoftware.Common.Data.Fitness;
12 using ZoneFiveSoftware.Common.Visuals.Mapping;
13 using ZoneFiveSoftware.Common.Visuals.Util;
14 using ZoneFiveSoftware.Common.Data.GPS;
15
16 namespace PlaybackPlugin.Source
17 {
18 public partial class PlaybackControl : UserControl
19 {
20 private PlaybackState state = PlaybackState.Disabled;
21 private IActivity activity = null;
22 private System.Timers.Timer timer;
23
24 public PlaybackControl()
25 {
26 InitializeComponent();
27 UpdateUI();
28 timer = new System.Timers.Timer(5000.0);
29 timer.Elapsed += new ElapsedEventHandler(PlaybackTick);
30 timer.SynchronizingObject = this;
31 }
32
33 public PlaybackControl(IActivity activity) : this()
34 {
35 this.activity = activity;
36 }
37
38 public IActivity Activity
39 {
40 get { return activity; }
41 set {
42 activity = value;
43 if (activity != null)
44 {
45 State = PlaybackState.Stopped;
46 }
47 }
48 }
49
50 public PlaybackState State
51 {
52 get { return state; }
53 set
54 {
55 state = value;
56 timer.Enabled = State == PlaybackState.Playing || State == PlaybackState.FastForwarding || State == PlaybackState.Rewinding;
57 UpdateUI();
58 }
59 }
60
61 private void UpdateUI()
62 {
63 rewindButton.Enabled = State != PlaybackState.Disabled && State != PlaybackState.Stopped;
64 fastForwardButton.Enabled = State != PlaybackState.Disabled && State != PlaybackState.Stopped;
65 playButton.Enabled = State != PlaybackState.Disabled;
66 playButton.Image = State == PlaybackState.Playing || State == PlaybackState.FastForwarding || State == PlaybackState.Rewinding ? Resources.PauseIcon : Resources.PlayIcon;
67 loopButton.Enabled = State != PlaybackState.Disabled;
68 speedLabel.Enabled = State != PlaybackState.Disabled;
69 speedSpinner.Enabled = State != PlaybackState.Disabled;
70 statusStrip.Enabled = State != PlaybackState.Disabled;
71 playbackBar.Enabled = State != PlaybackState.Disabled;
72 statusLabel.Enabled = State != PlaybackState.Disabled;
73 }
74
75 public enum PlaybackState
76 {
77 Disabled,
78 Stopped,
79 Paused,
80 Playing,
81 FastForwarding,
82 Rewinding
83 }
84
85 private void playButton_Click(object sender, EventArgs e)
86 {
87 State = State == PlaybackState.Playing || State == PlaybackState.FastForwarding || State == PlaybackState.Rewinding ? PlaybackState.Paused : PlaybackState.Playing;
88 }
89
90 private void fastForwardButton_Click(object sender, EventArgs e)
91 {
92 // TODO
93 }
94
95 private void rewindButton_Click(object sender, EventArgs e)
96 {
97 // TODO
98 }
99
100 private void loopButton_CheckedChanged(object sender, EventArgs e)
101 {
102 // TODO
103 }
104
105 private void speedSpinner_ValueChanged(object sender, EventArgs e)
106 {
107 // TODO
108 }
109
110 private void playbackBar_Scroll(object sender, EventArgs e)
111 {
112 // TODO
113 }
114
115 private static int RouteIndexFromDistance(IEnumerator<ITimeValueEntry<IGPSPoint>> route, double distance)
116 {
117 int index = 0;
118 double count = 0.0;
119 IGPSPoint prev = route.Current.Value;
120 while(route.MoveNext())
121 {
122 IGPSPoint cur = route.Current.Value;
123 count += prev.DistanceMetersToPoint(cur);
124 if(count < distance)
125 {
126 index++;
127 prev = cur;
128 } else {
129 return index;
130 }
131 }
132 return -1;
133 }
134
135 private void PlaybackTick(object source, ElapsedEventArgs args)
136 {
137 //IRouteControlSelection selection = CollectionUtils.GetSingleItemOfType<IRouteControlSelection>(PlaybackAnimationRouteControlLayer.Instance.Control.SelectedItems);
138 IRouteControlSelection selection = CollectionUtils.GetFirstItemOfType<IRouteControlSelection>(PlaybackAnimationRouteControlLayer.Selection);
139 if (selection == null)
140 {
141 // TODO
142 }
143 else
144 {
145 IList<IValueRange<DateTime>> ranges = selection.TimeRanges;
146 IGPSRoute item = selection.Item.Item.GPSRoute;
147 IList<IValueRange<double>> distanceRanges = selection.DistanceMetersRanges;
148 /*DateTime upper = range.Upper;
149 DateTime lower = range.Lower;*/
150 Console.WriteLine("Test");
151 }
152 }
153 }
154 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26