/[cits3200i]/branches/metadata-branch-rvvs89/UWAPlugins/MetadataPlugin/Source/EditMetadataControl.cs


UCC Code Repository

Contents of /branches/metadata-branch-rvvs89/UWAPlugins/MetadataPlugin/Source/EditMetadataControl.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90 - (show annotations) (download)
Tue Oct 12 21:18:41 2010 UTC (11 years, 1 month ago) by rvvs89
File size: 3420 byte(s)
Attaching metadata now works.
Saving metadata now works.
Loading metadata now works.
Editing metadata and cancelling your changes now works.
MetadataList now only commits on change.
Icons appear on the track when metadata is added.
Icons can be double clicked to launch the editor.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
6 using System.Text;
7 using System.Windows.Forms;
8 using ZoneFiveSoftware.Common.Visuals.Util;
9 using ZoneFiveSoftware.Common.Data.Fitness;
10
11 namespace MetadataPlugin.Source
12 {
13 public partial class EditMetadataControl : UserControl
14 {
15 private IMetadataEditor editor;
16 private bool initialEdit = false;
17
18 public EditMetadataControl()
19 {
20 InitializeComponent();
21 if (MetadataActivityReportPages.View == null)
22 {
23 // don't break the editor
24 return;
25 }
26 Update();
27 }
28
29 public void Update()
30 {
31 IActivity activity = CollectionUtils.GetSingleItemOfType<IActivity>(MetadataActivityReportPages.View.SelectionProvider.SelectedItems);
32 if (activity == null)
33 {
34 // this really shouldn't happen
35 return;
36 }
37 routeField.Text = activity.Name;
38 UpdateSpecific();
39 }
40
41 public void UpdateSpecific()
42 {
43 // TODO: be more specific with times
44 if (editor == null)
45 {
46 return;
47 }
48 nameField.Text = editor.Data.Name;
49 switch(editor.Data.Location)
50 {
51 case MetadataLocation.TRACK:
52 locationField.Text = "Entire Track";
53 break;
54 case MetadataLocation.RANGE:
55 locationField.Text = "Range of time";
56 break;
57 case MetadataLocation.POINT:
58 locationField.Text = "Specific time";
59 break;
60 }
61 Control editorControl = editor.EditorControl;
62 splitContainer.Panel2.Controls.Clear();
63 editorControl.Width = splitContainer.Panel2.Width;
64 editorControl.Height = splitContainer.Panel2.Height;
65 editorControl.Location = new Point(0, 0);
66 editorControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
67 splitContainer.Panel2.Controls.Add(editorControl);
68 }
69
70 public bool InitialEdit
71 {
72 get { return initialEdit; }
73 set { initialEdit = value; }
74 }
75
76 public IMetadataEditor Editor
77 {
78 get { return editor; }
79 set
80 {
81 if (value == null)
82 return;
83 editor = value;
84 Update();
85 }
86 }
87
88 public void Cancel()
89 {
90 if (initialEdit)
91 {
92 MetadataRouteControlLayer.Instances[0].CurrentList.Remove(editor.Data);
93 }
94 Editor.Dispose();
95 }
96
97 private void saveButton_Click(object sender, EventArgs e)
98 {
99 initialEdit = false;
100 Editor.Commit();
101 Editor.Data.Name = nameField.Text;
102 EditMetadataDialog.Instance.Close();
103 }
104
105 private void cancelButton_Click(object sender, EventArgs e)
106 {
107 Cancel();
108 EditMetadataDialog.Instance.Close();
109 }
110 }
111 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26