| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- namespace TSZ.DotNetDll.WinForms
- {
- using System;
- using System.IO;
- using System.Windows.Forms;
- using TSZ.DotNetDll;
- public class SaveFileDialogEx : IDisposable
- {
- private bool __Disposed;
- private SaveFileDialog dialog;
- private string flagGuid;
- public SaveFileDialogEx() : this(null)
- {
- }
- public SaveFileDialogEx(string flagGuid)
- {
- this.flagGuid = flagGuid;
- this.dialog = new SaveFileDialog();
- try
- {
- string keyValue = RegistryHelper.GetKeyValue(this.REGISTRYKEYFLAG);
- if (!string.IsNullOrEmpty(keyValue) && Directory.Exists(keyValue))
- {
- this.dialog.InitialDirectory = keyValue;
- }
- }
- catch
- {
- }
- }
- public void Dispose()
- {
- if (!this.__Disposed)
- {
- this.dialog.Dispose();
- this.__Disposed = true;
- }
- }
- public void Reset()
- {
- this.dialog.Reset();
- }
- public DialogResult ShowDialog()
- {
- return this.dialog.ShowDialog();
- }
- public DialogResult ShowDialog(IWin32Window owner)
- {
- return this.dialog.ShowDialog(owner);
- }
- public bool CheckFileExists
- {
- get
- {
- return this.dialog.CheckFileExists;
- }
- set
- {
- this.dialog.CheckFileExists = value;
- }
- }
- public string DefaultExt
- {
- get
- {
- return this.dialog.DefaultExt;
- }
- set
- {
- this.dialog.DefaultExt = value;
- }
- }
- public string FileName
- {
- get
- {
- string fileName = this.dialog.FileName;
- string directoryName = Path.GetDirectoryName(fileName);
- if (!string.IsNullOrEmpty(directoryName))
- {
- try
- {
- RegistryHelper.SetKeyValue(this.REGISTRYKEYFLAG, directoryName);
- }
- catch
- {
- }
- }
- return fileName;
- }
- set
- {
- this.dialog.FileName = value;
- }
- }
- public string Filter
- {
- get
- {
- return this.dialog.Filter;
- }
- set
- {
- this.dialog.Filter = value;
- }
- }
- private string REGISTRYKEYFLAG
- {
- get
- {
- if (string.IsNullOrEmpty(this.flagGuid))
- {
- return "FileSaveDialogSelectedPath";
- }
- return (@"SaveFilePaths\" + this.flagGuid);
- }
- }
- public object Tag
- {
- get
- {
- return this.dialog.Tag;
- }
- set
- {
- this.dialog.Tag = value;
- }
- }
- public string Title
- {
- get
- {
- return this.dialog.Title;
- }
- set
- {
- this.dialog.Title = value;
- }
- }
- }
- }
|