private DlgBox() {}	// To remove the constructor from the documentation!

		///////////////////////////////////////////////////////////////////////
		// CommonDialog

		/// <summary>
		/// Show a command dialog box at the center of the active window.
		/// </summary>
		public static DialogResult ShowDialog(CommonDialog dlg)
		{
			CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
			DialogResult dlgResult = dlg.ShowDialog();
			centerWindow.Dispose();
			return dlgResult;
		}
 public FileDialog(MainWindow window, FileChooserAction action)
 {
     if (action == FileChooserAction.Open)
         _dialog = new OpenFileDialog ();
     else
         _dialog = new FolderBrowserDialog ();
 }
        public static void AddDialog(CommonDialog dlg)
        {
            Debug.Assert(dlg != null);
            if(dlg == null) throw new ArgumentNullException("dlg");

            m_vDialogs.Add(dlg);
        }
		/// <summary>
		/// Show a command dialog box at the center of the owner window.
		/// </summary>
		public static DialogResult ShowDialog(CommonDialog dlg, IWin32Window owner)
		{
			IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
			CenterWindow centerWindow = new CenterWindow(handle);
			DialogResult dlgResult = dlg.ShowDialog();
			centerWindow.Dispose();
			return dlgResult;
		}
 public DialogResult ShowDialog(CommonDialog commonDialog)
 {
     if (commonDialog == null)
     {
         throw new ArgumentNullException("commonDialog");
     }
     return this.ShowDialog(null, new ShowDialogCallback(commonDialog.ShowDialog));
 }
Exemple #6
0
			internal DialogForm(CommonDialog owner) {
				this.owner = owner;
				ControlBox = true;
				MinimizeBox = false;
				MaximizeBox = false;
				ShowInTaskbar = false;
				FormBorderStyle = FormBorderStyle.Sizable;
				StartPosition = FormStartPosition.CenterScreen;
			}
 internal DialogForm(CommonDialog owner)
 {
     this.owner      = owner;
     ControlBox      = true;
     MinimizeBox     = false;
     MaximizeBox     = false;
     ShowInTaskbar   = false;
     FormBorderStyle = FormBorderStyle.Sizable;
     StartPosition   = FormStartPosition.CenterScreen;
 }
        protected DialogResult ShowDialog(CommonDialog dialog)
        {
            if (InvokeRequired)
            {
                ShowDialogCallback d = ShowDialog;
                return (DialogResult)Invoke(d, new Object[] { dialog });
            }

            return dialog.ShowDialog(this);
        }
Exemple #9
0
        public DialogRunner(System.ComponentModel.Component dialog)
        {
            commonDialog = dialog as SWF.CommonDialog;
            if (commonDialog == null)
            {
                threadExceptionDialog = dialog as SWF.ThreadExceptionDialog;
            }
            if (commonDialog == null && threadExceptionDialog == null)
            {
                throw new ArgumentException("Unsupported dialog type: " + dialog);
            }

            Show();
        }
Exemple #10
0
 private void GetPath(CommonDialog dialog, Control textControl)
 {
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         textControl.Text = openFileDialog.FileName;
     }
 }
 /// <summary>
 /// Shows a common dialog.
 /// </summary>
 /// <param name="commonDialog">The common dialog to show.</param>
 /// <returns>The common dialog result.</returns>
 public DialogResult ShowDialog(CommonDialog commonDialog)
 {
     if (commonDialog == null) throw new ArgumentNullException("commonDialog");
     return commonDialog.ShowDialog(Owner);
 }
 /// <summary>
 /// Returns an observable sequence wrapping the HelpRequest event on the CommonDialog instance.
 /// </summary>
 /// <param name="instance">The CommonDialog instance to observe.</param>
 /// <returns>An observable sequence wrapping the HelpRequest event on the CommonDialog instance.</returns>
 public static IObservable <EventPattern <EventArgs> > HelpRequestObservable(this CommonDialog instance)
 {
     return(Observable.FromEventPattern <EventHandler, EventArgs>(
                handler => instance.HelpRequest += handler,
                handler => instance.HelpRequest -= handler));
 }
        private void ExportAsXml()
        {
            if(ReportList.SelectedItems.Count <= 0) {
                return;
            }

            CommonDialog dialog = new CommonDialog();
            dialog.Filter.Add(new FilterEntry("XML file", "*.xml"));
            dialog.Title = "Export Report";

            if(dialog.ShowSave()) {
                WipeReport report = reportManager.LoadReport((ReportInfo)ReportList.SelectedItems[0].Tag);
                if(report == null) {
                    return;
                }

                ReportExporter.ExportAsXml(report, dialog.FileName);
            }
        }
Exemple #14
0
		public DialogRunner (System.ComponentModel.Component dialog)
		{
			commonDialog = dialog as SWF.CommonDialog;
			if (commonDialog == null)
				threadExceptionDialog = dialog as SWF.ThreadExceptionDialog;
			if (commonDialog == null && threadExceptionDialog == null)
				throw new ArgumentException ("Unsupported dialog type: " + dialog);

			Show ();
		}
Exemple #15
0
 public static DialogResult ShowModalDialog(Form parent, CommonDialog dialog)
 {
     parent.Enabled = false;
     DialogResult r = dialog.ShowDialog();
     parent.Enabled = true;
     dialog.Dispose();
     return r;
 }
 public FolderDialogHelper(CommonDialog host) : base(host)
 {
     this.CanChooseFiles       = false;
     this.CanChooseDirectories = true;
 }
Exemple #17
0
        protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
        {
            if (msg == 0x4e)
            {
                this.dialogHWnd = System.Windows.Forms.UnsafeNativeMethods.GetParent(new HandleRef(null, hWnd));
                try
                {
                    System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY structure = (System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY)System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(lparam, typeof(System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY));
                    switch (structure.hdr_code)
                    {
                    case -606:
                        if (this.ignoreSecondFileOkNotification)
                        {
                            if (this.okNotificationCount != 0)
                            {
                                break;
                            }
                            this.okNotificationCount = 1;
                        }
                        goto Label_0171;

                    case -604:
                        this.ignoreSecondFileOkNotification = true;
                        this.okNotificationCount            = 0;
                        goto Label_01CF;

                    case -602:
                    {
                        System.Windows.Forms.NativeMethods.OPENFILENAME_I openfilename_i = (System.Windows.Forms.NativeMethods.OPENFILENAME_I)System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(structure.lpOFN, typeof(System.Windows.Forms.NativeMethods.OPENFILENAME_I));
                        int num = (int)System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.dialogHWnd), 0x464, IntPtr.Zero, IntPtr.Zero);
                        if (num > openfilename_i.nMaxFile)
                        {
                            try
                            {
                                int size = num + 0x800;
                                System.Windows.Forms.UnsafeNativeMethods.CharBuffer buffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(size);
                                IntPtr ptr = buffer.AllocCoTaskMem();
                                Marshal.FreeCoTaskMem(openfilename_i.lpstrFile);
                                openfilename_i.lpstrFile = ptr;
                                openfilename_i.nMaxFile  = size;
                                this.charBuffer          = buffer;
                                Marshal.StructureToPtr(openfilename_i, structure.lpOFN, true);
                                Marshal.StructureToPtr(structure, lparam, true);
                            }
                            catch
                            {
                            }
                        }
                        this.ignoreSecondFileOkNotification = false;
                        goto Label_01CF;
                    }

                    case -601:
                        CommonDialog.MoveToScreenCenter(this.dialogHWnd);
                        goto Label_01CF;

                    default:
                        goto Label_01CF;
                    }
                    this.ignoreSecondFileOkNotification = false;
                    System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                    return(System.Windows.Forms.NativeMethods.InvalidIntPtr);

Label_0171:
                    if (!this.DoFileOk(structure.lpOFN))
                    {
                        System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                        return(System.Windows.Forms.NativeMethods.InvalidIntPtr);
                    }
                }
                catch
                {
                    if (this.dialogHWnd != IntPtr.Zero)
                    {
                        System.Windows.Forms.UnsafeNativeMethods.EndDialog(new HandleRef(this, this.dialogHWnd), IntPtr.Zero);
                    }
                    throw;
                }
            }
Label_01CF:
            return(IntPtr.Zero);
        }
Exemple #18
0
        private void SaveSessionAs()
        {
            CommonDialog dialog = new CommonDialog();
            dialog.Handle = this.Handle;
            dialog.Title = "Save Session";
            dialog.Filter.Add(new FilterEntry("SecureDelete Session", "*.sds"));

            if(dialog.ShowSave()) {
                SaveSessionTo(dialog.FileName);
            }
        }
 /// <summary>
 /// Shows the given dialog on top of all other windows, even from within PPT.
 /// </summary>
 /// <param name="dialog">a non-null dialog to display</param>
 /// <returns>the returned result of the dialog itself</returns>
 public static DialogResult ShowDialog(CommonDialog dialog)
 {
     return Wrapper.InternalShowDialog(dialog);
 }
        private DialogResult InternalShowDialog(CommonDialog dialog)
        {
            if (dialog == null)
                throw new ArgumentNullException("dialog");

            this.PrepareForDialog();
            try
            {
                return dialog.ShowDialog(this);
            }
            finally
            {
                this.DecomissionFromDialog();
            }
        }
 public DialogResult ShowDialog(CommonDialog dialog, IWin32Window owner)
 {
     return dialog.ShowDialog(owner);
 }
Exemple #22
0
 public DialogResult ShowDialog(CommonDialog commonDialog)
 {
     this.InitializeConsoleDialogHost();
     return this._dialogHost.ShowDialog(commonDialog);
 }
 public FileDialogHelper(CommonDialog host)
 {
     Host = host;
     this.CanChooseFiles       = true;
     this.CanChooseDirectories = false;
 }
 private DialogResult ShowDialog(CommonDialog commonDialog)
 {
     return commonDialog.ShowDialog();
 }
Exemple #25
0
        private void LoadSettings()
        {
            CommonDialog dialog = new CommonDialog();
            dialog.Filter.Add(new FilterEntry("Plugin settings file", "*.sdp"));

            if(dialog.ShowOpen()) {
                _plugin.PluginSettings.SettingsFile = dialog.FileName;
                _plugin.PluginSettings.LoadSettings();
            }

            PluginList.SelectedIndices.Clear();

            if(PluginList.Items.Count > 0) {
                PluginList.SelectedIndices.Add(0);
                PluginList.Select();
            }
        }
Exemple #26
0
        public static void RemoveDialog(CommonDialog dlg)
        {
            Debug.Assert(dlg != null);
            if(dlg == null) throw new ArgumentNullException("dlg");

            Debug.Assert(m_vDialogs.IndexOf(dlg) >= 0);
            m_vDialogs.Remove(dlg);
        }
Exemple #27
0
        private string _ShowFolderDialogOrFileDialogAndGetPath(CommonDialog dialog)
        {
            switch (dialog.ShowDialog())
            {
                case DialogResult.OK:
                    return dialog is FolderBrowserDialog
                        ? ((FolderBrowserDialog) dialog).SelectedPath
                        : ((FileDialog) dialog).FileName;
                case DialogResult.Cancel:
                    return null;
            }

            return null;
        }
		public FolderDialogHelper(CommonDialog host) : base(host)
		{
			this.CanChooseFiles = false;
			this.CanChooseDirectories = true;
		}
Exemple #29
0
 public DialogResult ShowDialog(CommonDialog commonDialog)
 {
     return this._dialogHost.ShowDialog(commonDialog);
 }
		public FileDialogHelper (CommonDialog host)
		{
			Host = host;
			this.CanChooseFiles = true;
			this.CanChooseDirectories = false;
		}
 /// <summary>
 ///  Runs a common dialog box with the owner defined in this class. 
 /// </summary>
 /// <param name="dlg">Dialog to show.</param>
 /// <returns>One of the <see cref="T:System.Windows.Forms.DialogResult"/> values.</returns>
 /// <exception cref="ArgumentNullException">dlg is null.</exception>
 protected DialogResult ShowDialog(CommonDialog dlg)
 {
     if (dlg == null) throw new ArgumentNullException("dlg");
     return dlg.ShowDialog(Owner);
 }
Exemple #32
0
 public Invoker(CommonDialog dialog)
 {
     InvokeDialog = dialog;
     InvokeThread = new Thread(new ThreadStart(InvokeMethod));
     InvokeThread.SetApartmentState(ApartmentState.STA);
     InvokeResult = DialogResult.None;
 }
Exemple #33
-1
        private void LoadSession()
        {
            CommonDialog dialog = new CommonDialog();
            dialog.Handle = this.Handle;
            dialog.Title = "Open Session";
            dialog.Filter.Add(new FilterEntry("SecureDelete Session", "*.sds"));

            if(dialog.ShowOpen()) {
                LoadSessionFrom(dialog.FileName);
            }
        }
Exemple #34
-1
        private void ExportAsHTML()
        {
            if(ReportList.SelectedItems.Count <= 0) {
                return;
            }

            CommonDialog dialog = new CommonDialog();
            dialog.Filter.Add(new FilterEntry("HTML file", "*.htm"));
            dialog.Title = "Export Report";

            if(dialog.ShowSave()) {
                WipeReport report = reportManager.LoadReport((ReportInfo)ReportList.SelectedItems[0].Tag);

                if(report == null) {
                    return;
                }

                // set style
                string style = "";

                if(_options.CustomReportStyle) {
                    try {
                        style = File.ReadAllText(_options.CustomStyleLocation);
                    }
                    catch(Exception ex) {
                        Debug.ReportError("Style could not be loaded. Exception: {0}", ex.Message);
                        MessageBox.Show("Style file could not be found.", "SecureDelete",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else {
                    style = WebReportStyle.HTMLReportStyle;
                }

                ReportExporter.ExportAsHtml(report, dialog.FileName, style);
            }
        }
Exemple #35
-1
        private void SaveSettings()
        {
            CommonDialog dialog = new CommonDialog();
            dialog.Filter.Add(new FilterEntry("Plugin settings file", "*.sdp"));

            if(dialog.ShowSave()) {
                _plugin.PluginSettings.SettingsFile = dialog.FileName;
                _plugin.PluginSettings.SaveSettings();
            }
        }