forked from cqse/ScrumPowerTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneralOptions.cs
115 lines (95 loc) · 4.61 KB
/
GeneralOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using Microsoft.VisualStudio.Shell;
using Microsoft.Win32;
using System.Linq;
namespace ScrumPowerTools
{
public class GeneralOptions : DialogPage
{
private const string MenuItems = "Menu Items";
private const string MenuItemDescription = "Specifies if the menu item should be shown or not.";
private readonly Dictionary<Feature, Func<bool>> featureVisibilityMapping;
public GeneralOptions()
{
Review = MenuItemVisibility.Show;
ShowAffectedChangesetFiles = MenuItemVisibility.Show;
ShowChangesetsWithAffectedFiles = MenuItemVisibility.Show;
ShowCreateTaskBoardCards = MenuItemVisibility.Show;
TfsQueryShortcuts = new string[0];
TaskBoardCardsXsltFileName = "";
featureVisibilityMapping = new Dictionary<Feature, Func<bool>>
{
{Feature.ShowAffectedChangesetFiles, () => ShowAffectedChangesetFiles == MenuItemVisibility.Show},
{Feature.ShowChangesetsWithAffectedFiles, () => ShowChangesetsWithAffectedFiles == MenuItemVisibility.Show},
{Feature.Review, () => Review == MenuItemVisibility.Show},
{Feature.TaskBoardCards, () => ShowCreateTaskBoardCards == MenuItemVisibility.Show}
};
}
[Category(MenuItems)]
[DisplayName("Show affected changeset files")]
[Description(MenuItemDescription)]
public MenuItemVisibility ShowAffectedChangesetFiles { get; set; }
[Category(MenuItems)]
[DisplayName("Show changesets with affected files")]
[Description(MenuItemDescription)]
public MenuItemVisibility ShowChangesetsWithAffectedFiles { get; set; }
[Category(MenuItems)]
[DisplayName("Review")]
[Description(MenuItemDescription)]
public MenuItemVisibility Review { get; set; }
[Category(MenuItems)]
[DisplayName("Assign work item query shortcut")]
[Description(MenuItemDescription)]
public MenuItemVisibility AssignWorkItemQueryShortcut { get; set; }
[Category(MenuItems)]
[DisplayName("Show create task board cards")]
[Description(MenuItemDescription)]
public MenuItemVisibility ShowCreateTaskBoardCards { get; set; }
[Category("Task Board Cards")]
[DisplayName("Task board cards xslt file")]
[Description("Specifies which XSLT file to use for creating the task board cards, this can be a local file like c:\\somedir\\some.xslt or an TFS path like $/project/folder/some.xslt. The default xslt will be used when not specified.")]
[EditorAttribute(typeof(XsltFileNameEditor), typeof(UITypeEditor))]
public string TaskBoardCardsXsltFileName { get; set; }
internal string[] TfsQueryShortcuts { get; set; }
public bool IsEnabled(Feature feature)
{
return featureVisibilityMapping[feature]();
}
public override void SaveSettingsToStorage()
{
base.SaveSettingsToStorage();
var package = (Package)GetService(typeof(Package));
using (var registryKey = package.UserRegistryRoot)
using (var settingsKey = registryKey.OpenSubKey(SettingsRegistryPath, true))
{
settingsKey.SetValue("TfsQueryShortcuts", TfsQueryShortcuts, RegistryValueKind.MultiString);
}
}
public override void LoadSettingsFromStorage()
{
base.LoadSettingsFromStorage();
var package = (Package)GetService(typeof(Package));
using (var registryKey = package.UserRegistryRoot)
using (var settingsKey = registryKey.OpenSubKey(SettingsRegistryPath))
{
if( (settingsKey != null)
&& settingsKey.GetValueNames().Contains("TfsQueryShortcuts")
&& settingsKey.GetValueKind("TfsQueryShortcuts") == RegistryValueKind.MultiString)
{
TfsQueryShortcuts = (string[])settingsKey.GetValue("TfsQueryShortcuts", new string[0]);
}
}
}
private class XsltFileNameEditor : FileNameEditor
{
protected override void InitializeDialog(System.Windows.Forms.OpenFileDialog openFileDialog)
{
openFileDialog.Filter = "XSLT Files|*.xslt;*.xsl|All Files (*.*)|*.*";
}
}
}
}