/[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 91 - (show annotations) (download)
Tue Oct 12 21:38:57 2010 UTC (11 years, 1 month ago) by rvvs89
File size: 3298 byte(s)
Right click on map markers now displays a context menu.
Metadata can now be deleted using the context menu.
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 locationField.Text = "Range of time";
50 break;
51 case MetadataLocation.POINT:
52 locationField.Text = "Specific time";
53 break;
54 }
55 Control editorControl = editor.EditorControl;
56 splitContainer.Panel2.Controls.Clear();
57 editorControl.Width = splitContainer.Panel2.Width;
58 editorControl.Height = splitContainer.Panel2.Height;
59 editorControl.Location = new Point(0, 0);
60 editorControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
61 splitContainer.Panel2.Controls.Add(editorControl);
62 }
63
64 public bool InitialEdit
65 {
66 get { return initialEdit; }
67 set { initialEdit = value; }
68 }
69
70 public IMetadataEditor Editor
71 {
72 get { return editor; }
73 set
74 {
75 if (value == null)
76 return;
77 editor = value;
78 UpdateContent();
79 }
80 }
81
82 public void Cancel()
83 {
84 if (initialEdit)
85 {
86 MetadataRouteControlLayer.Instances[0].CurrentList.Remove(editor.Data);
87 }
88 Editor.Dispose();
89 }
90
91 private void saveButton_Click(object sender, EventArgs e)
92 {
93 initialEdit = false;
94 Editor.Commit();
95 Editor.Data.Name = nameField.Text;
96 EditMetadataDialog.Instance.Close();
97 }
98
99 private void cancelButton_Click(object sender, EventArgs e)
100 {
101 Cancel();
102 EditMetadataDialog.Instance.Close();
103 }
104 }
105 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26