Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: obsolete/Microsoft.VisualStudio.Project/SecurityWarningDialog.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /// Copyright (c) Microsoft Corporation. All rights reserved.
2
3 using System;
4 using System.Globalization;
5 using System.IO;
6 using System.Windows.Forms;
7 using System.Windows.Forms.Design;
8 using Microsoft.VisualStudio.Shell;
9 using Microsoft.VisualStudio.Shell.Interop;
10 using Microsoft.VisualStudio;
11
12 namespace Microsoft.VisualStudio.Project
13 {
14 internal partial class SecurityWarningDialog : Form
15 {
16 #region fields
17 /// <summary>
18 /// The associated service provider
19 /// </summary>
20 private IServiceProvider serviceProvider;
21
22 /// <summary>
23 /// The dialog message to be presented when the 'More' button is pressed.
24 /// </summary>
25 private string dialogMessage;
26
27 /// <summary>
28 /// Teh full path to teh project.
29 /// </summary>
30 private string projectFullPath;
31
32 /// <summary>
33 /// The value of the ask again check box.
34 /// </summary>
35 private bool askAgainCheckBoxValue;
36
37 /// <summary>
38 /// The project load option the userwill choose on this form.
39 /// </summary>
40 private ProjectLoadOption projectLoadOption = ProjectLoadOption. DonNotLoad;
41 #endregion
42
43 #region properties
44 /// <summary>
45 /// The value of the ask again check box.
46 /// </summary>
47 internal bool AskAgainCheckBoxValue
48 {
49 get
50 {
51 return this.askAgainCheckBoxValue;
52 }
53 }
54
55 /// <summary>
56 /// The project load option the user has chosen to perform.
57 /// </summary>
58 internal ProjectLoadOption ProjectLoadOption
59 {
60 get
61 {
62 return this.projectLoadOption;
63 }
64 }
65 #endregion
66
67 #region ctors
68 /// <summary>
69 /// Overloaded ctor.
70 /// </summary>
71 /// <param name="serviceProvider">The associated service provide r.</param>
72 /// <param name="dialogMessage">The message that will be shown w hen the 'More' button is pressed.</param>
73 /// <param name="projectFullpath">The full path of the project.< /param>
74 public SecurityWarningDialog(IServiceProvider serviceProvider, s tring dialogMessage, string projectFullpath)
75 {
76 if(serviceProvider == null)
77 {
78 throw new ArgumentNullException("serviceProvider ");
79 }
80
81 if(String.IsNullOrEmpty(projectFullpath))
82 {
83 throw new ArgumentException(SR.GetString(SR.Para meterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "projectFullpath");
84 }
85
86 this.serviceProvider = serviceProvider;
87
88 this.projectFullPath = projectFullpath;
89
90 this.dialogMessage = dialogMessage;
91
92 this.InitializeComponent();
93
94 this.SetupComponents();
95 }
96 #endregion
97
98 #region helpers
99 /// <summary>
100 /// Shows the dialog if possible hosted by the IUIService.
101 /// </summary>
102 /// <returns>A DialogResult</returns>
103 internal new DialogResult ShowDialog()
104 {
105 IUIService uiService = this.serviceProvider.GetService(t ypeof(IUIService)) as IUIService;
106 if(uiService == null)
107 {
108 return this.ShowDialog();
109 }
110
111 return uiService.ShowDialog(this);
112 }
113
114 /// <summary>
115 /// Sets up the different UI elements.
116 /// </summary>
117 private void SetupComponents()
118 {
119 // Get the project name.
120 string projectName = Path.GetFileNameWithoutExtension(th is.projectFullPath);
121
122 IVsUIShell shell = this.serviceProvider.GetService(typeo f(SVsUIShell)) as IVsUIShell;
123
124 if(shell == null)
125 {
126 throw new InvalidOperationException();
127 }
128
129 String applicationName;
130
131 // Get the name of the SKU.
132 ErrorHandler.ThrowOnFailure(shell.GetAppName(out applica tionName));
133
134 // Set the dialog box caption (title).
135 this.Text = String.Format(CultureInfo.CurrentCulture, th is.Text, projectName);
136
137 // Set the text at the top of the dialog that gives a br ief description of the security
138 // implications of loading this project.
139 this.warningText.Text = String.Format(CultureInfo.Curren tCulture, this.warningText.Text, projectName, applicationName);
140
141 // Set the text that describes the "Browse" option.
142 this.browseText.Text = String.Format(CultureInfo.Current Culture, this.browseText.Text, applicationName);
143
144 // Set the text that describes the "Load" option.
145 this.loadText.Text = String.Format(CultureInfo.CurrentCu lture, this.loadText.Text, applicationName);
146
147 // The default selection is "Browse" so select that radi o button.
148 this.browseButton.Checked = true;
149
150 // Turn on the "Ask me always" checkbox by default.
151 this.askAgainCheckBox.Checked = true;
152
153 // Set the focus to the Browse button, so hitting Enter will press the OK button
154 this.browseButton.Focus();
155
156 this.CenterToScreen();
157 }
158
159 /// <summary>
160 /// The Cancel button was clicked.
161 /// </summary>
162 /// <param name="sender">The sender of the event</param>
163 /// <param name="e">An event arg Associated to the event.</param >
164 private void cancelButton_Click(object sender, EventArgs e)
165 {
166 // In case the user presses the Cancel button, we assume he never wants to see this dialog again
167 // and pretend the "Ask me every time" checkbox is unche cked even if it is really checked.
168 this.askAgainCheckBoxValue = false;
169 this.projectLoadOption = ProjectLoadOption.DonNotLoad;
170 }
171
172 /// <summary>
173 /// The OK button was clicked.
174 /// </summary>
175 /// <param name="sender">The sender of the event</param>
176 /// <param name="e">An event arg Associated to the event.</param >
177 private void okButton_Click(object sender, EventArgs e)
178 {
179 if(this.browseButton.Checked && !this.loadButton.Checked )
180 {
181 this.projectLoadOption = ProjectLoadOption.LoadO nlyForBrowsing;
182 }
183 else
184 {
185 this.projectLoadOption = ProjectLoadOption.LoadN ormally;
186 }
187
188 this.askAgainCheckBoxValue = this.askAgainCheckBox.Check ed;
189
190 this.Close();
191 }
192
193 /// <summary>
194 /// Loads a messagebox explaining in detail the security problem
195 /// </summary>
196 /// <param name="sender">The sender of the event</param>
197 /// <param name="e">An event arg Associated to the event.</param >
198 private void detailsButton_Click(object sender, EventArgs e)
199 {
200 string title = null;
201 OLEMSGICON icon = OLEMSGICON.OLEMSGICON_INFO;
202 OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK;
203 OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDE FBUTTON_FIRST;
204 VsShellUtilities.ShowMessageBox(this.serviceProvider, ti tle, this.dialogMessage, icon, buttons, defaultButton);
205 }
206
207 #endregion
208 }
209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698