Esempio n. 1
0
 /// <summary>
 /// Raises the <see cref="VistaFileDialog.FileOk" /> event.
 /// </summary>
 /// <param name="e">A <see cref="System.ComponentModel.CancelEventArgs" /> that contains the event data.</param>
 protected override void OnFileOk(CancelEventArgs e)
 {
     // For reasons unknown, .Net puts the OFN_FILEMUSTEXIST and OFN_CREATEPROMPT flags on the save file dialog despite
     // the fact that these flags only works on open file dialogs, and then prompts manually. Similarly, the
     // FOS_CREATEPROMPT and FOS_FILEMUSTEXIST flags don't actually work on IFileSaveDialog, so we have to implement
     // the prompt manually.
     if (DownlevelDialog == null)
     {
         if (CheckFileExists && !File.Exists(FileName))
         {
             PromptUser(ComDlgResources.FormatString(ComDlgResources.ComDlgResourceId.FileNotFound, Path.GetFileName(FileName)), MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
             e.Cancel = true;
             return;
         }
         if (CreatePrompt && !File.Exists(FileName))
         {
             if (!PromptUser(ComDlgResources.FormatString(ComDlgResources.ComDlgResourceId.CreatePrompt, Path.GetFileName(FileName)), MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No))
             {
                 e.Cancel = true;
                 return;
             }
         }
     }
     base.OnFileOk(e);
 }
Esempio n. 2
0
 internal override void SetDialogProperties(IFileDialog dialog)
 {
     base.SetDialogProperties(dialog);
     if (_showReadOnly)
     {
         IFileDialogCustomize customise = (IFileDialogCustomize)dialog;
         customise.EnableOpenDropDown(_openDropDownId);
         customise.AddControlItem(_openDropDownId, _openItemId, ComDlgResources.LoadString(ComDlgResourceId.OpenButton));
         customise.AddControlItem(_openDropDownId, _readOnlyItemId, ComDlgResources.LoadString(ComDlgResourceId.ReadOnly));
     }
 }
Esempio n. 3
0
 internal override void SetDialogProperties(TylorsTech.HandyClasses.WPF.Dialogs.Interop.IFileDialog dialog)
 {
     base.SetDialogProperties(dialog);
     if (_showReadOnly)
     {
         var customize = (TylorsTech.HandyClasses.WPF.Dialogs.Interop.IFileDialogCustomize)dialog;
         customize.EnableOpenDropDown(_openDropDownId);
         customize.AddControlItem(_openDropDownId, _openItemId, ComDlgResources.LoadString(ComDlgResources.ComDlgResourceId.OpenButton));
         customize.AddControlItem(_openDropDownId, _readOnlyItemId, ComDlgResources.LoadString(ComDlgResources.ComDlgResourceId.ReadOnly));
     }
 }
        internal bool PromptUser(string text, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defaultResult)
        {
            string caption = string.IsNullOrEmpty(_title) ?
                             (this is VistaOpenFileDialog ? ComDlgResources.LoadString(ComDlgResources.ComDlgResourceId.Open) : ComDlgResources.LoadString(ComDlgResources.ComDlgResourceId.ConfirmSaveAs)) :
                             _title;
            MessageBoxOptions options = 0;

            if (System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft)
            {
                options |= MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading;
            }
            return(MessageBox.Show(_owner, text, caption, buttons, icon, defaultResult, options) == MessageBoxResult.Yes);
        }
Esempio n. 5
0
        internal bool PromptUser(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            string caption = string.IsNullOrEmpty(_title) ?
                             (this is VistaOpenFileDialog ? ComDlgResources.LoadString(ComDlgResourceId.Open) : ComDlgResources.LoadString(ComDlgResourceId.ConfirmSaveAs)) :
                             _title;
            IWin32Window      owner   = _hwndOwner == IntPtr.Zero ? null : new WindowHandleWrapper(_hwndOwner);
            MessageBoxOptions options = 0;

            if (System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft)
            {
                options |= MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading;
            }
            return(MessageBox.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1, options) == DialogResult.Yes);
        }