Git Product home page Git Product logo

ookii-dialogs / ookii-dialogs-winforms Goto Github PK

View Code? Open in Web Editor NEW
587.0 587.0 50.0 731 KB

Awesome dialogs for Windows Desktop applications built with Microsoft .NET (WinForms)

License: BSD 3-Clause "New" or "Revised" License

C# 99.84% Batchfile 0.04% Shell 0.05% PowerShell 0.07%
common-file-dialog credential-dialog dialogs hacktoberfest input-dialog ookii progress-dialog task-dialog windows-forms windowsforms winforms

ookii-dialogs-winforms's Introduction

README.md
Ookii.Dialogs.WinForms

Ookii.Dialogs.WinForms

A class library for Windows Forms applications providing several common dialogs. Included are classes for task dialogs, credential dialog, progress dialog, input dialogs, and common file dialogs.

NuGet Version NuGet Downloads .NET Framework

Give a Star! ⭐

If you like or are using this project please give it a star. Thanks!

Getting started

Install the Ookii.Dialogs.WinForms package from NuGet:

Install-Package Ookii.Dialogs.WinForms

The included sample application Ookii.Dialogs.WinForms.Sample demonstrate the dialogs for Windows Forms. View the source of this application to see how to use the dialogs.

Windows Presentation Foundation (WPF) compatibility

If you're looking to use these common dialogs on a WPF application, check out Ookii.Dialogs.Wpf.

Included dialogs

Task dialog

Task dialogs are a new type of dialog first introduced in Windows Vista. They provide a superset of the message box functionality.

A task dialog as it appears on Windows 10

A task dialog with command links as it appears on Windows 10

The Ookii.Dialogs.WinForms.TaskDialog classe provide access to the task dialog functionality. The TaskDialog class inherits from System.ComponentModel.Component and offers full support for the Windows Forms designer and component designer of Visual Studio.

The TaskDialog class requires Windows Vista or a later version of Windows. Windows XP is not supported. Note that it is safe to instantiate the TaskDialog class and set any of its properties; only when the dialog is shown will a NotSupportedException be thrown on unsupported operating systems.

Progress dialog

Progress dialogs are a common dialog to show progress during operations that may take a long time. They are used extensively in the Windows shell, and an API has been available since Windows 2000.

A progress dialog as it appears on Windows 10

The Ookii.Dialogs.WinForms.ProgressDialog class provide a wrapper for the Windows progress dialog API. The ProgressDialog class inherits from System.ComponentModel.Component and offers full support for the Windows Forms designer and component designer of Visual Studio. The ProgressDialog class resembles the System.ComponentModel.BackgroundWorker class and can be used in much the same way as that class.

The progress dialog's behaviour of the ShowDialog function is slightly different than that of other .NET dialogs; It is recommended to use a non-modal dialog with the Show function.

The ProgressDialog class is supported on Windows XP and later versions of Windows. However, the progress dialog has a very different appearance on Windows Vista and later (the image above shows the Vista version), so it is recommended to test on both operating systems to see if it appears to your satisfaction.

When using Windows 7 or later, the ProgressDialog class automatically provides progress notification in the application's task bar button.

Credential dialog

The Ookii.Dialogs.WinForms.CredentialDialog class provide wrappers for the CredUI functionality first introduced in Windows XP. This class provides functionality for saving and retrieving generic credentials, as well as displaying the credential UI dialog. This class does not support all functionality of CredUI; only generic credentials are supported, thing such as domain credentials or alternative authentication providers (e.g. smart cards or biometric devices) are not supported.

A credential dialog as it appears on Windows 10

The CredentialDialog class inherits from System.ComponentModel.Component and offers full support for the Windows Forms designer and component designer of Visual Studio.

On Windows XP, the CredentialDialog class will use the CredUIPromptForCredentials function to show the dialog; on Windows Vista and later, the CredUIPromptForWindowsCredentials function is used instead to show the new dialog introduced with Windows Vista. Because of the difference in appearance in the two versions (the image above shows the Vista version), it is recommended to test on both operating systems to see if it appears to your satisfaction.

Input dialog

The input dialog is a dialog that can be used to prompt the user for a single piece of text. Its functionality is reminiscent of the Visual Basic InputBox function, only with a cleaner API and UI.

An input dialog as it appears on Windows 10

The Ookii.Dialogs.WinForms.InputDialog class provides the input dialog functionality for Windows Forms.

Unlike the other classes in this package, this class is not a wrapper for any existing API; the dialog uses a custom implementation in Windows Forms. This dialog is supported on Windows XP and later versions of windows; on Windows Vista and later, the visual styles API is used to draw the dialog to mimic the appearance of task dialogs, as shown in the image above.

The InputDialog class inherits from System.ComponentModel.Component and offers full support for the Windows Forms designer and component designer of Visual Studio.

Vista-style common file dialogs

Windows Vista introduced a new style of common file dialogs. As of .NET 3.5 SP1, the Windows Forms OpenFileDialog and SaveFileDialog class will automatically use the new style under most circumstances; however, some settings (such as setting ShowReadOnly to true) still cause it to revert to the old dialog. The FolderBrowserDialog still uses the old style.

The Vista-style folder browser dialog as it appears on Windows 10

The Ookii.Dialogs.WinForms.VistaOpenFileDialog, Ookii.Dialogs.WinForms.VistaSaveFileDialog and Ookii.Dialogs.WinForms.VistaFolderBrowserDialog provide these dialogs for Windows Forms (note that in the case of the OpenFileDialog and SaveFileDialog it is recommended to use the built-in .NET classes unless you hit one of the scenarios where those classes use the old dialogs).

The classes have been designed to resemble the original Windows Forms classes to make it easy to switch. When the classes are used on Windows XP, they will automatically fall back to the old style dialog.

The Vista-style file and folder dialogs classes for Windows Forms inherit from System.ComponentModel.Component and offer full support for the Windows Forms designer and component designer of Visual Studio.

Additional functionality

Three additional classes are provided in the Ookii.Dialogs.WinForms library. These classes are used to support the InputDialog (with the exception of the Aero glass functionality, which the InputDialog does not use) but are made public for your convenience.

The AdditionalVisualStyleElements class provides some visual style elements used by task dialogs on Windows Vista and later.

The Glass class provides functionality for extending Aero glass into the client area of a window on Windows Vista and later, and for drawing text on a glass surface.

The ExtendedForm class serves as an alternative base class for forms, and provides functionality to automatically use the system font (e.g. Tahoma on XP and Segoe UI on Vista and later), and easy access to some of the functionality of the Glass class.

Release History

Click on the Releases tab on GitHub.


Copyright © 2009-2021 Ookii Dialogs Contributors - Provided under the BSD 3-Clause "New" or "Revised" License.

ookii-dialogs-winforms's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ookii-dialogs-winforms's Issues

Change ProgressBarStyle

Hi,

Do you know if it's possible to start a progressBar with ProgressBarStyle = ProgressBarStyle.MarqueeProgressBar, and change later (after the number of iterations is known) to ProgressBarStyle = ProgressBarStyle.ProgressBar with percentage.

When I try, no exception is raised but the ProgressBarStyle seems locked after initialization.

Thanks

Release / binaries

Hello,

Can you please at a DLL package in addition of nuget into the releases ?
I think it would be great in case (as mine) where you need to call DLL's outside Visual studio (such as Streamer.Bot or any tool that has a C# embded compiler).

Best regards

Using [Ookii.Dialogs.WinForms.ProgressDialog] in PowerShell 7 causes an immediate crash when ProgressDialog.Show() is called.

I know this isn't the typical use-case of Ookii Dialogs Winforms, but I've had great success using all of the other dialog types in Powershell 7 by loading the assembly in my module and instantiating the various dialog classes. Input Dialog, Password Dialog, and Task Dialog all work great.

Unfortunately, I'm having some trouble diagnosing why the Ookii.Dialogs.WinForms.ProgressDialog is causing Powershell to explode.

Here is a simple repro script:

$Pdialog = [Ookii.Dialogs.WinForms.ProgressDialog]::new()
$Pdialog.Description = "Cropping SVGs..."
$Pdialog.ShowTimeRemaining = $false
$Pdialog.Text = "Cropping all queued SVGs..."
$Pdialog.WindowTitle = "SVG Crop"
$Pdialog.ProgressBarStyle = 'Marquee'

# Show the dialog
$Pdialog.Show()

Immediately when $Pdialog.Show() is called, Powershell hard terminates with the following error:

VirtualDub64_cPrTUF0OBi

An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.InvalidCastException: Unable to cast COM object of type 'Ookii.Dialogs.WinForms.Interop.ProgressDialogRCW' 
to interface type 'Ookii.Dialogs.WinForms.Interop.IProgressDialog'. This operation failed because the QueryInterface call on the COM 
component for the interface with IID '{EBBC7C04-315E-11D2-B62F-006097DF5BD4}' failed due to the following error: 
No such interface supported (0x80004002 (E_NOINTERFACE)).

at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)

at Ookii.Dialogs.WinForms.Interop.IProgressDialog.StopProgressDialog()

at Ookii.Dialogs.WinForms.ProgressDialog._backgroundWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) 
in D:\a\ookii-dialogs-winforms\ookii-dialogs-winforms\src\Ookii.Dialogs.WinForms\ProgressDialog.cs:line 774

at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action'1 callback, TState& state)

at System.Threading.QueueUserWorkItemCallback'1.Execute()

at System.Threading.ThreadPoolWorkQueue.Dispatch()

at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

I will be the first to admit, I have absolutely NO idea what the error message above means.

I did some google-fu, and found here that the CLSID {EBBC7C04-315E-11d2-B62F-006097DF5BD4} is related to the IProgressDialog interface.

The error message above reports that the casting of Ookii.Dialogs.WinForms.Interop.ProgressDialogRCW to IProgressDialog fails because, well, this: No such interface supported (0x80004002 (E_NOINTERFACE))..

No idea how to remedy this.

In one of my scripts I actually did get the Progress Dialog to work. The script was utilizing a standard winforms form, and I created the Progress Dialog instance and called its Show() method after a button click event.

All of my other scripts fail to show the dialog and crash Powershell.

I am really hoping you could shed some light on what the error message above means, and how I can fix the problem. I really like having the visual feedback in my scripts, and your dialogs are both highly polished and appear native to the OS.

Any help greatly appreciated!

And thank you for creating a great library.

Crash for SaveFileDialog when using root directory

  • Bug crash of VistaFolderBrowserDialog when using root directory path (same for VistaSaveFileDialog when directory is "C:\" and default file name is empty)
  • Need add forceDownLevel optional for FolderBrowserDialog

[Question] How to include hyperlinks in the TaskDialog?

The screenshot in the readme shows that I can use a hyperlinks. But how? Do I need to use some syntax?

readme.md seems to have not much info about this class library, just the description. Is there any documentation for this library anywhere? The documentation here is not accessible

Please add working examples

I'm trying to figure out how the Task Dialog works, but I don't know how to create a button since the example just assumes you do, and nothing online uses WinForms.

???

Can you replace windows default dialog with this ??

Create micro packages for each dialog & turn Ookii.Dialogs.WinForms into a meta package

Relates to ookii-dialogs/ookii-dialogs-wpf#28


Now that we are using the SDK-style with multi-targeting and and have a good build pipeline setup, it would be easy to generate separate NuGet packages for each of the dialogs, so that developers can have the option to cherry-pick only the dialogs they want to use in their application.

  • Ookii.Dialogs.WinForms.nupkg, depends on:
    • Ookii.Dialogs.WinForms.TaskDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.ProgressDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.CredentialDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.FolderBrowserDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.OpenFileDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.SaveFileDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)
    • Ookii.Dialogs.WinForms.InputDialog.nupkg, depends on:
      • Ookii.Dialogs.WinForms.Core.nupkg, depends on:
        • Ookii.Dialogs.Core.nupkg (no dependencies)

I'm assuming we'll have to create a Ookii.Dialogs.WinForms.Core package to share common WinForms code between the different WinForms dialog packages, as well as a Ookii.Dialogs.Core package to share common code across both the WinForms and WPF packages (#9).

Turning Ookii.Dialogs.WinForms into a meta package that depends on all other micro packages will provide the same experience that users have today where they'll get all the dialogs with one package.

希望对.net 4.5支持(Want:The lowest version supports NET 4.5)

我看到你是这样的描述的:(I saw your upgrade report)
#47 (.NET 4.6.1 EoL is April 2022 and Visual Studio 2022 no longer installs it by default.)

我们的用户使用win7系统非常多,所以我们需要对低版本net的一个支持(There are many users of Windows 7,So we need to support lower versions of NET)

辛苦作者,谢谢。(thank)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.