/[cits3200i]/trunk/UWAPlugins/MetadataPlugin/Source/EditMetadataControl.cs


UCC Code Repository

Contents of /trunk/UWAPlugins/MetadataPlugin/Source/EditMetadataControl.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (show annotations) (download)
Wed Oct 13 01:51:32 2010 UTC (11 years, 1 month ago) by rvvs89
File size: 3725 byte(s)
Merging metadata-branch-rvvs89.
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 UpdateContent();
27 }
28
29 public void UpdateContent()
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 if (editor == null)
39 {
40 return;
41 }
42 nameField.Text = editor.Data.Name;
43 switch(editor.Data.Location)
44 {
45 case MetadataLocation.TRACK:
46 locationField.Text = "Entire Track";
47 break;
48 case MetadataLocation.RANGE:
49 TimeSpan startOff = editor.Data.Point - activity.StartTime;
50 TimeSpan endOff = editor.Data.End - activity.StartTime;
51 locationField.Text = String.Format("{0}:{1:00}:{2:00} - {3}:{4:00}:{5:00}", startOff.Hours, startOff.Minutes, startOff.Seconds, endOff.Hours, endOff.Minutes, endOff.Seconds);
52 break;
53 case MetadataLocation.POINT:
54 TimeSpan off = editor.Data.Point - activity.StartTime;
55 locationField.Text = String.Format("{0}:{1:00}:{2:00}", off.Hours, off.Minutes, off.Seconds);
56 break;
57 }
58 Control editorControl = editor.EditorControl;
59 splitContainer.Panel2.Controls.Clear();
60 editorControl.Width = splitContainer.Panel2.Width;
61 editorControl.Height = splitContainer.Panel2.Height;
62 editorControl.Location = new Point(0, 0);
63 editorControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
64 splitContainer.Panel2.Controls.Add(editorControl);
65 }
66
67 public bool InitialEdit
68 {
69 get { return initialEdit; }
70 set { initialEdit = value; }
71 }
72
73 public IMetadataEditor Editor
74 {
75 get { return editor; }
76 set
77 {
78 if (value == null)
79 return;
80 editor = value;
81 UpdateContent();
82 }
83 }
84
85 public void Cancel()
86 {
87 if (initialEdit)
88 {
89 MetadataRouteControlLayer.Instances[0].CurrentList.Remove(editor.Data);
90 }
91 Editor.Dispose();
92 }
93
94 private void saveButton_Click(object sender, EventArgs e)
95 {
96 initialEdit = false;
97 Editor.Commit();
98 Editor.Data.Name = nameField.Text;
99 EditMetadataDialog.Instance.Close();
100 }
101
102 private void cancelButton_Click(object sender, EventArgs e)
103 {
104 Cancel();
105 EditMetadataDialog.Instance.Close();
106 }
107 }
108 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26