Changeset 12 for Common/Prompt.cs
- Timestamp:
- Mar 14, 2020, 1:11:28 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Prompt.cs
r8 r12 3 3 using System.Linq; 4 4 using System.Text; 5 using System.IO; 5 6 using System.Threading.Tasks; 6 7 using System.Drawing; … … 162 163 }; 163 164 confirmation.Click += (sender, e) => { prompt.Close(); }; 164 ListBox listBox = new ListBox() { Left = 50, Top = 44, Width = 400, Height = dataSize, 165 ListBox listBox = new ListBox() 166 { 167 Left = 50, 168 Top = 44, 169 Width = 400, 170 Height = dataSize, 165 171 Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left 166 172 }; … … 248 254 } 249 255 } 256 257 public static class PromptOpenFile 258 { 259 public static bool ShowDialog(string fileName, string fileType, string fileExtension, out string result) 260 { 261 result = fileName; 262 OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = fileType + " (." + fileExtension + ")|*." + 263 fileExtension + "|Any file|*.*", DefaultExt = fileExtension }; 264 if (!string.IsNullOrEmpty(fileName)) 265 { 266 openFileDialog.FileName = Path.GetFileName(fileName); 267 openFileDialog.InitialDirectory = Path.GetDirectoryName(fileName); 268 } 269 270 DialogResult dialogResult = openFileDialog.ShowDialog(); 271 if (dialogResult == DialogResult.OK) 272 { 273 result = openFileDialog.FileName; 274 } 275 return dialogResult == DialogResult.OK; 276 } 277 } 278 279 public static class PromptSaveFile 280 { 281 public static bool ShowDialog(string fileName, string fileType, string fileExtension, out string result) 282 { 283 result = fileName; 284 SaveFileDialog saveFileDialog = new SaveFileDialog() 285 { 286 Filter = fileType + " (." + fileExtension + ")|*." + 287 fileExtension + "|Any file|*.*", 288 DefaultExt = fileExtension 289 }; 290 if (!string.IsNullOrEmpty(fileName)) 291 { 292 saveFileDialog.FileName = Path.GetFileName(fileName); 293 saveFileDialog.InitialDirectory = Path.GetDirectoryName(fileName); 294 } 295 296 DialogResult dialogResult = saveFileDialog.ShowDialog(); 297 if (dialogResult == DialogResult.OK) 298 { 299 result = saveFileDialog.FileName; 300 } 301 return dialogResult == DialogResult.OK; 302 } 303 } 304 305 public static class PromptOpenDir 306 { 307 public static bool ShowDialog(string dirName, out string result) 308 { 309 result = dirName; 310 FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog() { ShowNewFolderButton = true }; 311 if (!string.IsNullOrEmpty(dirName)) 312 folderBrowserDialog.SelectedPath = dirName; 313 DialogResult dialogResult = folderBrowserDialog.ShowDialog(); 314 if (dialogResult == DialogResult.OK) 315 { 316 result = folderBrowserDialog.SelectedPath; 317 } 318 return dialogResult == DialogResult.OK; 319 } 320 } 250 321 }
Note:
See TracChangeset
for help on using the changeset viewer.