dotnet / winforms Goto Github PK
View Code? Open in Web Editor NEWWindows Forms is a .NET UI framework for building Windows desktop applications.
License: MIT License
Windows Forms is a .NET UI framework for building Windows desktop applications.
License: MIT License
System.Drawing.Tests.BitmapTests.MakeTransparent_GrayscalePixelFormat_ThrowsArgumentException [FAIL]
Assert.Throws() Failure
Expected: typeof(System.Runtime.InteropServices.ExternalException)
Actual: (No exception was thrown)
Stack Trace:
at System.Drawing.Tests.BitmapTests.MakeTransparent_GrayscalePixelFormat_ThrowsArgumentException()
System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_Default_ReturnsExpected [FAIL]
System.OutOfMemoryException : Out of memory.
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Graphics.Windows.cs(119,0): at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(631,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(PageSettings pageSettings)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrinterSettingsTests.cs(476,0): at System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_Default_ReturnsExpected()
System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_Bool_ReturnsExpected [FAIL]
System.DivideByZeroException : Attempted to divide by zero.
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs(86,0): at System.Drawing.Printing.PageSettings.get_HardMarginX()
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(622,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(Boolean honorOriginAtMargins)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrinterSettingsTests.cs(491,0): at System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_Bool_ReturnsExpected()
System.Drawing.Printing.Tests.PrintDocumentTests.QueryPageSettings_SetValue_ReturnsExpected [FAIL]
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs(388,0): at System.Drawing.Printing.PageSettings.get_ExtraBytes()
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs(368,0): at System.Drawing.Printing.PageSettings.CopyToHdevmode(IntPtr hdevmode)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrintController.Windows.cs(276,0): at System.Drawing.Printing.PrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs(275,0): at System.Drawing.Printing.Tests.PrintDocumentTests.TestPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrintController.Windows.cs(117,0): at System.Drawing.Printing.PrintController.Print(PrintDocument document)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs(225,0): at System.Drawing.Printing.Tests.PrintDocumentTests.QueryPageSettings_SetValue_ReturnsExpected()
System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_Null_ThrowsNullReferenceException [FAIL]
Assert.Throws() Failure
Expected: typeof(System.NullReferenceException)
Actual: typeof(System.OutOfMemoryException): Out of memory.
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Graphics.Windows.cs(119,0): at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(631,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(PageSettings pageSettings)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(640,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(PageSettings pageSettings, Boolean honorOriginAtMargins)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrinterSettingsTests.cs(536,0): at System.Drawing.Printing.Tests.PrinterSettingsTests.<>c__DisplayClass49_0.<CreateMeasurementGraphics_Null_ThrowsNullReferenceException>b__1()
System.Drawing.Printing.Tests.PrintDocumentTests.Ctor_Default_Success [FAIL]
System.ArgumentNullException : Value cannot be null.
Parameter name: ptr
Stack Trace:
at System.Runtime.InteropServices.Marshal.StructureToPtr(Object structure, IntPtr ptr, Boolean fDeleteOld)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs(361,0): at System.Drawing.Printing.PageSettings.CopyToHdevmode(IntPtr hdevmode)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs(235,0): at System.Drawing.Printing.PageSettings.get_PrinterResolution()
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs(255,0): at System.Drawing.Printing.Tests.PrintDocumentTests.AssertDefaultPageSettings(PageSettings pageSettings)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs(44,0): at System.Drawing.Printing.Tests.PrintDocumentTests.Ctor_Default_Success()
System.Drawing.Printing.Tests.PrinterSettingsTests.IsPlotter_ReturnsExpected [FAIL]
Assert.False() Failure
Expected: False
Actual: True
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrinterSettingsTests.cs(180,0): at System.Drawing.Printing.Tests.PrinterSettingsTests.IsPlotter_ReturnsExpected()
System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_PageSettingsBool_ReturnsExpected [FAIL]
System.OutOfMemoryException : Out of memory.
Stack Trace:
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Graphics.Windows.cs(119,0): at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(631,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(PageSettings pageSettings)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs(640,0): at System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics(PageSettings pageSettings, Boolean honorOriginAtMargins)
D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrinterSettingsTests.cs(521,0): at System.Drawing.Printing.Tests.PrinterSettingsTests.CreateMeasurementGraphics_PageSettingsBool_ReturnsExpected()
cc: @danmosemsft
From @JinShil on April 29, 2017 7:47
.Net Standard 2.0 and .Net Core 2.0 have included APIs in System.ComponentModel
for building and extending the Visual Studio designer (e.g Component
class, DesignerAttribute
, TypeConverter
, etc..)
However, if one tries to use these classes in the current release of Visual Studio 2017 to create designers for their classes, Visual Studio displays errors in the designer like
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace CoreDesignerTest
{
public class Class1 : Component
{
}
}
In Visual Studio, right-click on the "Class1.cs" node and choose "View Designer".
Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
With some hacking in my .config files, I can resolve the above error, but eventually Visual Studio fails to load the .Net Core assemblies with an "Invalid Format" error.
I'm assuming this is due to the fact that Visual Studio, being a .Net Framework-based application, is trying to load a .Net Core assembly into a .Net Framework application, and therefore failing.
My question is, with the coming release of .Net Core 2.0 and .Net Standard 2.0, will there also be an accompanying Visual Studio update that will provide the ability to create designers for .Net Core 2.0 and .Net Standard 2.0 classes?
Copied from original issue: dotnet/corefx#19139
It is a commonly used type when WinForms PropertyGrid control is in use, as custom collection editor is needed to edit custom collection types.
It is not yet available in .NET Core 3.0 Preview 1.
System.Drawing.Common.Tests fails 10 tests in non-English Windows with next log:
Starting: System.Drawing.Common.Tests
System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Bold, Italic, Strikeout, gdiCharSet: 1, gdiVerticalFont: True, expectedNamePrefix: \"@\", expectedWeight: 700) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(719,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 0, gdiVerticalFont: False, expectedNamePrefix: \"\", expectedWeight: 400) [FAIL]
Assert.Equal() Failure
Expected: 0
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(719,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 10, gdiVerticalFont: False, expectedNamePrefix: \"\", expectedWeight: 400) [FAIL]
Assert.Equal() Failure
Expected: 10
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(719,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SystemDefault, expectedQuality: 0) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: AntiAlias, expectedQuality: 3) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: AntiAliasGridFit, expectedQuality: 3) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SingleBitPerPixel, expectedQuality: 3) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SingleBitPerPixelGridFit, expectedQuality: 3) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: ClearTypeGridFit, expectedQuality: 5) [FAIL]
Assert.Equal() Failure
Expected: 1
Actual: 204
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\tests\FontTests.cs(756,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint, Int32 expectedQuality)
System.Drawing.Imaging.Tests.MetafileTests.Ctor_StringIntPtrEmfType_Success(emfType: EmfPlusDual) [FAIL]
System.Runtime.InteropServices.ExternalException : A generic error occurred in GDI+.
Stack Trace:
C:\Code\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\Metafile.Windows.cs(264,0): at System.Drawing.Imaging.Metafile..ctor(String fileName, IntPtr referenceHdc, EmfType type, String description)
C:\Code\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\Metafile.Windows.cs(241,0): at System.Drawing.Imaging.Metafile..ctor(String fileName, IntPtr referenceHdc, EmfType type)
C:\Code\corefx\src\System.Drawing.Common\tests\Imaging\MetafileTests.cs(399,0): at System.Drawing.Imaging.Tests.MetafileTests.Ctor_StringIntPtrEmfType_Success(EmfType emfType)
Finished: System.Drawing.Common.Tests
On my computer font.ToLogFont(logFont);
always set logFont.lfCharSet
to 204.
Is it error in test or in implementation?
ystem.Drawing.Tests.BitmapTests.MakeTransparent_GrayscalePixelFormat_ThrowsArgumentException [FAIL]
Assert.Throws() Failure
Expected: typeof(System.Runtime.InteropServices.ExternalException)
Actual: (No exception was thrown)
Stack Trace:
D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Drawing.Common\tests\BitmapTests.cs(0,0): at System.Drawing.Tests.BitmapTests.MakeTransparent_GrayscalePixelFormat_ThrowsArgumentException()
Feedback from @danmosemsft:
Remove comments like:
///
/// [To be supplied.]
///
from ResXResourceWriter.cs and other files.
The purposes of both of these attributes is to translate from an ID known at build time to a localized value that can only be known at runtime.
As such the string they contain needs to be looked up, by calling SR.GetResourceString.
Today both of these classes are treating the ID as if it were a localized value:
Developers in WinForms Core currently have no way to set the HighDPI mode in their WinForms App. In a future version of .NET Core 3.0, this will again be possible via App.Manifest; however, a change in the settings requires then their app to be rebuilt. The previous option in the classic framework to control this setting via App.Config has been completely dropped in .NET Core. Currently, the only way to set the HighDPIMode is via P/Invoke. The Application.SetHighDpiMode
method and Application.HighDpiMode
property are an easy to apply and to discover alternative.
namespace System.Windows.Forms
{
public sealed class Application
{
// Existing methods/properties (excerpt)
public static void EnableVisualStyles();
public static bool RenderWithVisualStyles { get; }
// Proposed method/property
public static bool SetHighDpiMode(HighDpiMode highDpiMode);
public static HighDpiMode HighDpiMode { get; }
}
public enum HighDpiMode
{
DpiUnaware,
SystemAware,
PerMonitor,
PerMonitorV2,
DpiUnawareGdiScaled
}
}
Following EnableVisualStyles()
/RenderWithVisualStyles
of the Application
class, we propose the method SetHighDpiMode
which switches to the corresponding HighDPI mode, if that HighDPIMode setting a) has not been set before by other means (App.Manifest, P/Invoke before Application.Run
– in this case the value to be set is ignored), and b) that HighDPIMode
setting was set via SetHighDpiMode
before calling Application.Run
(or the first UI Element has been rendered).
Possible settings values are provided by the HighDpiMode
Enum:
DpiUnaware
SystemAware
PerMonitor
PerMonitorV2
DpiUnawareGdiScaled
If a setting is attempted to be set which is not supported by the underlying OS, SetHighDpiMode
automatically assumes the next possible setting on that OS; SetHighDpiMode never directly triggers an exception, but gives feedback as to whether the setting could be successfully set (true
) or not (false
).
In addition developers can query the actual setting of the current HighDpiMode at any time using the Application.HighDpiMode
property, which returns one of the available HighDpiMode
Enum values.
In the current implementation, we should limit the method/property to the process DpiAwareness rather than a Window DpiAwareness, and should probably think about extending this to a static method/property of the Control class to the windows DpiAwareness (@Tanya-Solyanik, thoughts?).
Every modern WinForms App uses VisualStyles to get a proper look and feel. When VisualStyles fail for an App to be activated, Apps look like running under an ancient OS like Windows 2000.
With the way the build system is currently set up, System.Windows.Forms.dll seems to be build differently compared to the internal build system we had before. On start of a WinForms app, the Application class tries to activate VisualStyles, and for that to end, passes the WinForms assembly to the method CreateActivationContext
. This method then tries to read certain resources from the WinForms assembly.
Now, when we compile the WinForms assembly System.Windows.Forms.dll with the current build setup, that does not work. CreateActCtx
inside of CreateActivationContext
return 1813 - ERROR_RESOURCE_TYPE_NOT_FOUND. If we build with the previous build system (same source code), this works.
Problem description:
I am running 3.0 winform application on linux with following command
dotnet run
But getting error
/home/owner/dotnet/sdk/3.0.100-preview-009812/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets(14,2): error MSB4019: The imported project "/home/owner/dotnet/sdk/3.0.100-preview-009812/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. [/home/owner/projects/dotnet3/dotnet3.csproj]
The build failed. Please fix the build errors and run again.
I checked my path variable as well as the Microsoft.WinFX.targets exist in the path
If you try and pack a project in WinForms like this:
You're met with the build error:
This happens both to the projects System.Windows.Forms
and System.Windows.forms.Ref
This can easily be fixed by adding <PackageProjectUrl>http://github.com/dotnet/winforms</PackageProjectUrl>
to the two project files (or as a global setting).
Feedback from EricStj:
Replace all these explicit items with a convention. Seems that you should be able to come up with a globbing convention for these and update the reading code where it doesn't align with the convention (or update items when the convention is insufficient).
I created .NET Core (2.1) console app and added reference to System.Drawing.Common nuget (4.5.1). I'm trying to run the following code from docs, but it fails on bitmap1.GetEncoderParameterList with System.OverflowException:
'Arithmetic operation resulted in an overflow.'
What is wrong with this code? Do I make something illegal?
class Program
{
public static void Main(string[] args)
{
new Program().GetSupportedParameters();
}
private void GetSupportedParameters()
{
Bitmap bitmap1 = new Bitmap(1, 1);
ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
//this one also does not work:
//Bitmap bitmap1 = new Bitmap(Image.FromFile(@"C:\temp\0\2.png"));
//ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Png);
EncoderParameters paramList = bitmap1.GetEncoderParameterList(jpgEncoder.Clsid);
EncoderParameter[] encParams = paramList.Param;
StringBuilder paramInfo = new StringBuilder();
for (int i = 0; i < encParams.Length; i++)
{
paramInfo.Append("Param " + i + " holds " + encParams[i].NumberOfValues +
" items of type " +
encParams[i].ValueType + "\r\n" + "Guid category: " + encParams[i].Encoder.Guid + "\r\n");
}
}
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
}
StackTrace:
at System.Drawing.Imaging.EncoderParameters.ConvertFromMemory(IntPtr memory)
at System.Drawing.Image.GetEncoderParameterList(Guid encoder)
at ConsoleApp16.Program.GetSupportedParameters() in Program.cs:line 19
at ConsoleApp16.Program.Main(String[] args)
in Program.cs:line 13
This one also crashes:
Bitmap bitmap1 = new Bitmap(Image.FromFile(@"C:\temp\0\2.png"));
ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Png);
With the following PR (#96 -> moved to #238) we have proposed addition of new property to the TextBox control called PlaceholderText. The property accepts string which will be drawn when the control has no text it in and is not on focus. Quite useful to indicate what is the expected input.
Currently, in order to provide guidance for the users what input is expected in a text field, the only option is to have a label next to the TextBox control. However, there are cases, where label is not appropriate and it is much more user friendly to have a placeholder text in the TextBox itself, to guide the user as to what input is expected. Think of scenarios for "Enter your username/password"
public string PlaceholderText {get; set;}
A single public property called PlaceholderText
is introduced, with no value. When the property is set, AND the TextBox
has no Text
set nor focus, the string from the PlaceholderText
will be drawn in the TextBox
control, using the SystemColors.GrayText
. Once the property value is changed the new text will be drawn, if currently visible. Once the user focuses on the control, the text disappears. Different text alignments and RightToLeft
are taken into consideration when the PlaceholderText
is being drawn. In addition, it also works in Multiline mode.
In addition AccessibilityObject
has been implemented to return the PlaceholderText
when the Text
is empty, hence screen readers read the PlaceholderText
value and guide the users to what is expected from them as input.
On the bottom left side of the image you can see a TextBox
with PlaceholderText
drawn.
The Windows Forms FolderBrowserDialog
uses an old folder picker control. Starting in Windows Vista, there is a newer COM-based control available.
My proposal is to enhance the existing FolderBrowserDialog
to use that newer control by default when running on Vista and higher.
The existing API can be used, but the newer API gives us a few new options:
Title
property. We can add that.Does .NET Core 3 support pre-Vista operating systems? Do we need to consider that, or can Vista detection code be removed? How about CAS and Security Demand code? Does that need to remain or be added for net-new code or can that be removed & omitted for .NET Core?
To avoid confusion if we support Linux/Mac or not.
This request is based on popular SO question: Close a MessageBox after several seconds (100+ votes).
When developing LOB application it is quite often needed to interact with the user via the MessageBox which automatically closes after the specific timeout. The standard MessageBox.Show
API does not provide this capability.
The new API should be based on standard Win32 MessageBox and should be compatible with corresponding .Net implementation (System.Windows.Forms.MessageBox
).
The AutoClosingMessageBox repository contains a good example of WinAPI-based wrapper on standard Win32 MessageBox compatible with the .Net System.Windows.Forms.MessageBox
.
Here how you can use the new API:
Scenario 1: Fire and forget - it about to be closed after default timeout(1000ms)
AutoClosingMessageBox.Show("Hello, you are using the AutoClosingMessageBox first time!");
Scenario 2: Wait for some result or make the default decision
var result = AutoClosingMessageBox.Show(
text: "To be or not to be?",
caption: "The question",
timeout: 2500,
buttons: MessageBoxButtons.YesNo,
defaultResult: DialogResult.Yes);
if(result == DialogResult.Yes) {
// to be
}
else {
// or not
}
Additionaly you can use the AutoClosingMessageBox.Factory
method to wrap the specific MessageBox showing. This way allows us do not provide all the AutoClosingMessageBox.Show
method overloads which associated with the corresponting System.Windows.Forms.MessageBox.Show
methods.
var toBeOrNotToBeQuestion = AutoClosingMessageBox.Factory(
showMethod: (caption, buttons) =>
MessageBox.Show(this, "To be or not to be?", caption, buttons, MessageBoxIcon.Question),
caption: "The question"
);
if(DialogResult.Yes == toBeOrNotToBeQuestion.Show(
timeout: 2500,
buttons: MessageBoxButtons.YesNo,
defaultResult: DialogResult.Yes)) {
// to be
}
else {
// or not
}
public static class AutoClosingMessageBox {
public static DialogResult Show(string text, string caption = null, int timeoutMilliseconds = 1000, MessageBoxButtons buttons = MessageBoxButtons.OK, DialogResult defaultResult = DialogResult.None);
public static DialogResult Show(IWin32Window owner, string text, string caption = null, int timeoutMilliseconds = 1000, MessageBoxButtons buttons = MessageBoxButtons.OK, DialogResult defaultResult = DialogResult.None);
}
The AutoClosingMessageBox.Factory
method (optional, but suggested):
public static class AutoClosingMessageBox {
public static IAutoClosingMessageBox Factory(Func<string, MessageBoxButtons, DialogResult> showMethod, string caption = null);
//
public interface IAutoClosingMessageBox {
DialogResult Show(int timeoutMilliseconds = 1000, MessageBoxButtons buttons = MessageBoxButtons.OK, DialogResult defaultResult = DialogResult.None);
}
}
The same bug is reproducible with .NET Framework but it seems it has no chance to be ever fixed.
But the .NET Core looks like a good place for introducing some improvements in this area.
Each instance of the System.Windows.Forms.Control
type contains a private member variable of the LayoutEventArgs
type - cachedLayoutEventArgs . And, the LayoutEventArgs
instance typically contains a reference to some specific control.
Sometimes, the cachedLayoutEventArgs
field is not cleared when the child control disposing of does not affect the layout process of the parent control due to some reasons.
Here are the minimal reproduction-steps:
Button.Click
handlers:void btnOpenView_Click(object sender, System.EventArgs e) {
var view = new Panel() { BackColor = Color.Red };
view.Name = "View";
view.Bounds = new Rectangle(100, 100, 100, 100);
view.Parent = this;
}
void btnCloseView_Click(object sender, System.EventArgs e) {
SuspendLayout();
var view = this.Controls.Find("View", false)[0];
if(view != null)
view.Dispose();
ResumeLayout(false);
}
Actual behavior:
The panel is still referencing via the System.Windows.Forms.Control.cachedLayoutEventArgs
field at the form level. As result, it can't be GC-collected properly and still in memory.
Expected behavior:
The panel should not be referenced.
It looks like we should use the WeakReference
when caching the LayoutEventArgs
.
As an alternative solution, we can validate the cachedLayoutEventArgs
value on child control removing and clear the problematical field.
There are a few pre-processor directives in S.W.F code which might not be required.
Scrub the code and keep only those which are required.
System.Drawing.Tests.GraphicsTests.CopyFromScreen_ValidRange_AffectsGraphics(sourceX: 1, sourceY: 1, destinationX: 2, destinationY: 2, width: 3, height: 3) [FAIL]
20:39:03 System.ComponentModel.Win32Exception : The handle is invalid
20:39:03 Stack Trace:
20:39:03 at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
20:39:03 at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)
I believe these tests are invalid, given that they are failing against the .NET Framework. We should give them some scrutiny, and potentially remove them.
Creating this issue to track the porting of System.Windows.Forms.DataVisualization.dll into Core.
Please add a .editorconfig file that fully specifies the conventions and naming rules for these projects.
In the following line:
The [DefaultProperty]
tag points to the property GridEditName
which doesn't exist. I'm not sure which property this was really meant to point to - especially considering this class doesn't have any properties.
Discovered as part of PR #86
Hi,
On Windows Vista and higher, the Task Dialog is available that provides many more features than a Message Box. While you can show a Message Box in WinForms and WPF, there is no "official" implementation of the Task Dialog yet in .NET WinForms/WPF.
There was an implementation in the Windows API Code Pack 1.1, but it is no longer available/updated, it did not implement all features (like navigation or modifying common/standard buttons), and I believe it had some memory management issues (like not calling Marshal.DestroyStructure()
after calling Marshal.StructureToPtr()
in order to free allocated strings for custom/radio buttons) and a few other issues.
At my company, we currently use the Task Dialog in a (commercial) WPF application to show a marquee progress bar while an operation (like database backup) is running, and then navigate it to one showing a green header to indicate the operation is finished.
Visual Studio is also using a Task Dialog:
Also, the Windows Design Guidelines (Desktop Apps) for Messages and Dialog Boxes show features of the task dialog.
Do you think a Task Dialog could also be added directly to WinForms/WPF? Thank you!
Edit:
The Windows Task Dialog (which is available since Windows Vista) has a lot of configuration options comparing to a regular Message Box, can show additional controls like a progress bar, and supports event handling. However, it has not yet been integrated officially into WinForms/WPF, so if you wanted to use it, you had to implement the native APIs yourself, or use a 3rd party library.
Implementing the Task Dialog directly in WinForms allows users to directly use the Task Dialog in any new WinForms/WPF .NET Core application, just like a MessageBox. You can then either use the simple static Show()
method (similar to a MessageBox), or you can create an instance of the TaskDialog
, configure its TaskDialogPage
and then show it.
Features of the proposed Task Dialog:
TaskDialogPage.Navigate(TaskDialogPage)
while the dialog is displayedhWnd
) through the Handle
property so that the dialog window can be further manipulated (or used as owner for another window)See also the Task Dialog Demo App for examples.
TaskDialogButton resultButton = TaskDialog.ShowDialog(new TaskDialogPage()
{
Text = "Hello World!",
Heading = "Hello Task Dialog! 👍",
Caption = "Dialog Title",
Buttons = {
TaskDialogButton.Yes,
TaskDialogButton.Cancel
},
Icon = TaskDialogIcon.ShieldSuccessGreenBar
});
if (resultButton == TaskDialogButton.Yes)
{
// Do something...
}
TaskDialogCommandLinkButton buttonRestart = new TaskDialogCommandLinkButton()
{
Text = "&Restart under different credentials",
DescriptionText = "This text will be shown in the second line.",
ShowShieldIcon = true
};
TaskDialogCommandLinkButton buttonCancelTask = new TaskDialogCommandLinkButton()
{
Text = "&Cancel the Task and return"
};
var page = new TaskDialogPage()
{
Icon = TaskDialogIcon.Shield,
Heading = "This task requires the application to have elevated permissions.",
// TODO - Hyperlinks will be possible in a future version
Text = "Why is using the Administrator or other account necessary?",
// TODO - will be possible in a future version
//EnableHyperlinks = true,
Buttons =
{
TaskDialogButton.Cancel,
buttonRestart,
buttonCancelTask
},
DefaultButton = buttonCancelTask,
// Show a expander.
Expander = new TaskDialogExpander()
{
Text = "Some expanded Text",
CollapsedButtonText = "View error information",
ExpandedButtonText = "Hide error information",
Position = TaskDialogExpanderPosition.AfterFootnote
}
};
// Show the dialog and check the result.
TaskDialogButton result = TaskDialog.ShowDialog(page);
if (result == buttonRestart)
{
Console.WriteLine("Restarting...");
}
See also: Multi-page dialog boxes
// Disable the "Yes" button and only enable it when the check box is checked.
// Also, don't close the dialog when this button is clicked.
var initialButtonYes = TaskDialogButton.Yes;
initialButtonYes.Enabled = false;
initialButtonYes.AllowCloseDialog = false;
var initialPage = new TaskDialogPage()
{
Caption = "My Application",
Heading = "Clean up database?",
Text = "Do you really want to do a clean-up?\nThis action is irreversible!",
Icon = TaskDialogIcon.ShieldWarningYellowBar,
AllowCancel = true,
Verification = new TaskDialogVerificationCheckBox()
{
Text = "I know what I'm doing"
},
Buttons =
{
TaskDialogButton.No,
initialButtonYes
},
DefaultButton = TaskDialogButton.No
};
// For the "In Progress" page, don't allow the dialog to close, by adding
// a disabled button (if no button was specified, the task dialog would
// get an (enabled) 'OK' button).
var inProgressCloseButton = TaskDialogButton.Close;
inProgressCloseButton.Enabled = false;
var inProgressPage = new TaskDialogPage()
{
Caption = "My Application",
Heading = "Operation in progress...",
Text = "Please wait while the operation is in progress.",
Icon = TaskDialogIcon.Information,
ProgressBar = new TaskDialogProgressBar()
{
State = TaskDialogProgressBarState.Marquee
},
Expander = new TaskDialogExpander()
{
Text = "Initializing...",
Position = TaskDialogExpanderPosition.AfterFootnote
},
Buttons =
{
inProgressCloseButton
}
};
var finishedPage = new TaskDialogPage()
{
Caption = "My Application",
Heading = "Success!",
Text = "The operation finished.",
Icon = TaskDialogIcon.ShieldSuccessGreenBar,
Buttons =
{
TaskDialogButton.Close
}
};
TaskDialogButton showResultsButton = new TaskDialogCommandLinkButton("Show &Results");
finishedPage.Buttons.Add(showResultsButton);
// Enable the "Yes" button only when the checkbox is checked.
TaskDialogVerificationCheckBox checkBox = initialPage.Verification;
checkBox.CheckedChanged += (sender, e) =>
{
initialButtonYes.Enabled = checkBox.Checked;
};
// When the user clicks "Yes", navigate to the second page.
initialButtonYes.Click += (sender, e) =>
{
// Navigate to the "In Progress" page that displays the
// current progress of the background work.
initialPage.Navigate(inProgressPage);
// NOTE: When you implement a "In Progress" page that represents
// background work that is done e.g. by a separate thread/task,
// which eventually calls Control.Invoke()/BeginInvoke() when
// its work is finished in order to navigate or update the dialog,
// then DO NOT start that work here already (directly after
// setting the Page property). Instead, start the work in the
// TaskDialogPage.Created event of the new page.
//
// This is because if you started it here, then when that other
// thread/task finishes and calls BeginInvoke() to call a method in
// the GUI thread to update or navigate the dialog, there is a chance
// that the callback might be called before the dialog completed
// navigation (*) (as indicated by the Created event of the
// new page), and the dialog might not be updatable in that case.
// (The dialog can be closed or navigated again, but you cannot
// change e.g. text properties of the page).
//
// If that's not possible for some reason, you need to ensure
// that you delay the call to update the dialog until the Created
// event of the next page has occured.
//
//
// (*) Background info: Although the WinForms implementation of
// Control.Invoke()/BeginInvoke() posts a new message in the
// control's owning thread's message queue every time it is
// called (so that the callback can be called later by the
// message loop), when processing the posted message in the
// control's window procedure, it calls ALL stored callbacks
// instead of only the next one.
//
// This means that even if you start the work after setting
// the Page property (which means BeginInvoke() can only be
// called AFTER starting navigation), the callback specified
// by BeginInvoke might still be called BEFORE the task dialog
// can process its posted navigation message.
};
// Simulate work by starting an async operation from which we are updating the
// progress bar and the expander with the current status.
inProgressPage.Created += async (s, e) =>
{
// Run the background operation and iterate over the streamed values to update
// the progress. Because we call the async method from the GUI thread,
// it will use this thread's synchronization context to run the continuations,
// so we don't need to use Control.[Begin]Invoke() to schedule the callbacks.
var progressBar = inProgressPage.ProgressBar;
await foreach (int progressValue in StreamBackgroundOperationProgressAsync())
{
// When we display the first progress, switch the marquee progress bar
// to a regular one.
if (progressBar.State == TaskDialogProgressBarState.Marquee)
progressBar.State = TaskDialogProgressBarState.Normal;
progressBar.Value = progressValue;
inProgressPage.Expander.Text = $"Progress: {progressValue} %";
}
// Work is finished, so navigate to the third page.
inProgressPage.Navigate(finishedPage);
};
// Show the dialog (modeless).
TaskDialogButton result = TaskDialog.ShowDialog(initialPage);
if (result == showResultsButton)
{
Console.WriteLine("Showing Results!");
}
static async IAsyncEnumerable<int> StreamBackgroundOperationProgressAsync()
{
// Note: The code here will run in the GUI thread - use
// "await Task.Run(...)" to schedule CPU-intensive operations in a
// worker thread.
// Wait a bit before reporting the first progress.
await Task.Delay(2800);
for (int i = 0; i <= 100; i += 4)
{
// Report the progress.
yield return i;
// Wait a bit to simulate work.
await Task.Delay(200);
}
}
TaskDialogButton btnCancel = TaskDialogButton.Cancel;
TaskDialogButton btnSave = new TaskDialogButton("&Save");
TaskDialogButton btnDontSave = new TaskDialogButton("Do&n't save");
var page = new TaskDialogPage()
{
Caption = "My Application",
Heading = "Do you want to save changes to Untitled?",
Buttons =
{
btnCancel,
btnSave,
btnDontSave
}
};
// Show a modal dialog, then check the result.
TaskDialogButton result = TaskDialog.ShowDialog(this, page);
if (result == btnSave)
Console.WriteLine("Saving");
else if (result == btnDontSave)
Console.WriteLine("Not saving");
else
Console.WriteLine("Canceling");
var page = new TaskDialogPage()
{
Caption = "Minesweeper",
Heading = "What level of difficulty do you want to play?",
AllowCancel = true,
Footnote = new TaskDialogFootnote()
{
Text = "Note: You can change the difficulty level later " +
"by clicking Options on the Game menu.",
},
Buttons =
{
new TaskDialogCommandLinkButton("&Beginner", "10 mines, 9 x 9 tile grid")
{
Tag = 10
},
new TaskDialogCommandLinkButton("&Intermediate", "40 mines, 16 x 16 tile grid")
{
Tag = 40
},
new TaskDialogCommandLinkButton("&Advanced", "99 mines, 16 x 30 tile grid")
{
Tag = 99
}
}
};
TaskDialogButton result = TaskDialog.ShowDialog(this, page);
if (result.Tag is int resultingMines)
Console.WriteLine($"Playing with {resultingMines} mines...");
else
Console.WriteLine("User canceled.");
var page = new TaskDialogPage()
{
Caption = "My App Security",
Heading = "Opening these files might be harmful to your computer",
Text = "Your Internet security settings blocked one or more files from " +
"being opened. Do you want to open these files anyway?",
Icon = TaskDialogIcon.ShieldWarningYellowBar,
// TODO - will be possible in a future version
//EnableHyperlinks = true,
Expander = new TaskDialogExpander("My-File-Sample.exe"),
Footnote = new TaskDialogFootnote()
{
// TODO - Hyperlinks will be possible in a future version
Text = "How do I decide whether to open these files?",
},
Buttons =
{
TaskDialogButton.OK,
TaskDialogButton.Cancel
},
DefaultButton = TaskDialogButton.Cancel
};
TaskDialogButton result = TaskDialog.ShowDialog(this, page);
if (result == TaskDialogButton.OK)
{
Console.WriteLine("OK selected");
}
const string textFormat = "Reconnecting in {0} seconds...";
int remainingTenthSeconds = 50;
var reconnectButton = new TaskDialogButton("&Reconnect now");
var cancelButton = TaskDialogButton.Cancel;
var page = new TaskDialogPage()
{
Heading = "Connection lost; reconnecting...",
Text = string.Format(textFormat, (remainingTenthSeconds + 9) / 10),
ProgressBar = new TaskDialogProgressBar()
{
State = TaskDialogProgressBarState.Paused
},
Buttons =
{
reconnectButton,
cancelButton
}
};
// Create a WinForms timer that raises the Tick event every tenth second.
using var timer = new System.Windows.Forms.Timer()
{
Enabled = true,
Interval = 100
};
timer.Tick += (s, e) =>
{
remainingTenthSeconds--;
if (remainingTenthSeconds > 0)
{
// Update the remaining time and progress bar.
page.Text = string.Format(textFormat, (remainingTenthSeconds + 9) / 10);
page.ProgressBar.Value = 100 - remainingTenthSeconds * 2;
}
else
{
// Stop the timer and click the "Reconnect" button - this will
// close the dialog.
timer.Enabled = false;
reconnectButton.PerformClick();
}
};
TaskDialogButton result = TaskDialog.ShowDialog(this, page);
if (result == reconnectButton)
Console.WriteLine("Reconnecting.");
else
Console.WriteLine("Not reconnecting.");
TODO: Which namespace to use for the types? In the PR I used System.Windows.Forms
for now.
public class TaskDialog : IWin32Window
{
// Returns the window handle while the dialog is shown, otherwise returns IntPtr.Zero.
public IntPtr Handle { get; }
// Note: The ShowDialog() methods do not return until the
// dialog is closed (similar to MessageBox.Show()), regardless of whether the
// dialog is shown modal or non-modal.
public static TaskDialogButton ShowDialog(TaskDialogPage page, TaskDialogStartupLocation startupLocation = TaskDialogStartupLocation.CenterOwner);
public static TaskDialogButton ShowDialog(IWin32Window owner, TaskDialogPage page, TaskDialogStartupLocation startupLocation = TaskDialogStartupLocation.CenterOwner);
public static TaskDialogButton ShowDialog(IntPtr hwndOwner, TaskDialogPage page, TaskDialogStartupLocation startupLocation = TaskDialogStartupLocation.CenterOwner);
// Close() will simulate a click on the "Cancel" button (but you don't
// have to add a "Cancel" button for this).
public void Close();
}
public class TaskDialogPage
{
public TaskDialogPage();
public TaskDialog? BoundDialog { get; }
// Properties "Caption", "MainInstruction", "Text", "Icon" can be set
// set while the dialog is shown, to update the dialog.
public string? Caption { get; set; }
public string? Heading { get; set; }
public string? Text { get; set; }
// Icon can either be a standard icon or a icon handle.
// (In the future, we could allow to show a resource icon.)
// Note that while the dialog is shown, you cannot switch between a
// handle icon type and a non-handle icon type.
// The same applies to the footer icon.
public TaskDialogIcon? Icon { get; set; }
public bool AllowCancel { get; set; }
public bool AllowMinimize { get; set; }
public bool RightToLeftLayout { get; set; }
public bool SizeToContent { get; set; }
public TaskDialogButtonCollection Buttons { get; set; }
public TaskDialogRadioButtonCollection RadioButtons { get; set; }
public TaskDialogButton? DefaultButton { get; set; }
// Note: When creating a TaskDialogPage instance, these four properties
// contain default/empty control instances (for better Designer support) that
// do not show up in the dialog unless you modify their properties
// (because their initial "Text" is null and initial ProgressBarState is "None" -
// however when you create a new ProgressBar instance, its default State
// is "Normal"), but you can also set them to null.
public TaskDialogVerificationCheckBox? Verification { get; set; }
public TaskDialogExpander? Expander { get; set; }
public TaskDialogFootnote? Footnote { get; set; }
public TaskDialogProgressBar? ProgressBar { get; set; }
// See section "Event Cycle" for a diagram illustrating the events.
// Raised after this TaskDialogPage is bound to a TaskDialog (and therefore
// the controls have been created): after the dialog was created (directly after event
// TaskDialog.Opened/TDN_CREATED) or navigated (in the TDN_NAVIGATED handler).
public event EventHandler? Created;
// Raised when this TaskDialogPage is about to be unbound from a TaskDialog
// (and therefore the controls are about to be destroyed): when the dialog is
// about to be destroyed (directly before event TaskDialog.Closed) or about
// to navigate.
public event EventHandler? Destroyed;
// Raised when the user presses F1 or clicks the "Help" standard button
public event EventHandler? HelpRequest;
protected internal void OnCreated(EventArgs e);
protected internal void OnDestroyed(EventArgs e);
protected internal void OnHelpRequest(EventArgs e);
}
public class TaskDialogIcon : IDisposable
{
// "Standard" icons
public static readonly TaskDialogIcon None;
public static readonly TaskDialogIcon Information;
public static readonly TaskDialogIcon Warning;
public static readonly TaskDialogIcon Error;
public static readonly TaskDialogIcon Shield;
public static readonly TaskDialogIcon ShieldBlueBar;
public static readonly TaskDialogIcon ShieldGrayBar;
public static readonly TaskDialogIcon ShieldWarningYellowBar;
public static readonly TaskDialogIcon ShieldErrorRedBar;
public static readonly TaskDialogIcon ShieldSuccessGreenBar;
public TaskDialogIcon(Bitmap image);
public TaskDialogIcon(Icon icon);
public TaskDialogIcon(IntPtr iconHandle);
// Note: This will throw (InvalidOperationException) if this is an
// instance representing a standard icon.
public IntPtr IconHandle { get; }
}
public abstract class TaskDialogControl
{
public TaskDialogPage? BoundPage { get; }
public object? Tag { get; set; }
}
public class TaskDialogButton : TaskDialogControl
{
public TaskDialogButton();
public TaskDialogButton(string? text, bool enabled = true, bool allowCloseDialog = true);
public static TaskDialogButton OK { get; }
public static TaskDialogButton Cancel { get; }
public static TaskDialogButton Abort { get; }
public static TaskDialogButton Retry { get; }
public static TaskDialogButton Ignore { get; }
public static TaskDialogButton Yes { get; }
public static TaskDialogButton No { get; }
public static TaskDialogButton Close { get; }
// Note: Clicking the "Help" button will not close the dialog, but will
// raise the TaskDialogPage.Help event.
public static TaskDialogButton Help { get; }
public static TaskDialogButton TryAgain { get; }
public static TaskDialogButton Continue { get; }
// Properties "Enabled" and "ShowShieldIcon" can be set while
// the dialog is shown.
public string? Text { get; set; }
public bool AllowCloseDialog { get; set; }
public bool Enabled { get; set; }
public bool ShowShieldIcon { get; set; }
// Setting "Visible" to false means the button will not be shown in the task dialog
// (the property cannot be set while the dialog is shown). This allows you
// to intercept button click events, e.g. "Cancel" when "AllowCancel" is true
// and the user presses ESC, without having to actually show a "Cancel" button.
public bool Visible { get; set; }
// Raised when this button is clicked while the dialog is shown (either because the
// user clicked it, or by calling PerformClick() or TaskDialog.Close()).
public event EventHandler? Click;
public override bool Equals(object? obj);
public override int GetHashCode();
public void PerformClick();
public override string ToString();
public static bool operator ==(TaskDialogButton? b1, TaskDialogButton? b2);
public static bool operator !=(TaskDialogButton? b1, TaskDialogButton? b2);
}
public sealed class TaskDialogCommandLinkButton : TaskDialogButton
{
public TaskDialogCommandLinkButton();
public TaskDialogCommandLinkButton(string? text, string? descriptionText = null, bool enabled = true, bool allowCloseDialog = true);
public string? DescriptionText { get; set; }
}
public sealed class TaskDialogRadioButton : TaskDialogControl
{
public TaskDialogRadioButton();
public TaskDialogRadioButton(string? text);
public string? Text { get; set; }
// Properties "Enabled" and "Checked" can be set while the dialog is shown
// (but "Checked" can then only be set to "true").
public bool Checked { get; set; }
public bool Enabled { get; set; }
// Raised when the "Checked" property changes while the dialog is shown (because
// the user clicked one of the radio buttons, or due to setting the "Checked"
// property of one of the radio buttons to "true").
public event EventHandler? CheckedChanged;
public override string ToString();
}
public sealed class TaskDialogVerificationCheckBox : TaskDialogControl
{
public TaskDialogVerificationCheckBox();
public TaskDialogVerificationCheckBox(string? text, bool isChecked = false);
public string? Text { get; set; }
// "Checked" can be set while the dialog is shown.
public bool Checked { get; set; }
// Raised when the "Checked" property changes while the dialog is shown (because
// the user clicked it or due to setting the "Checked" property).
public event EventHandler? CheckedChanged;
public override string ToString();
public static implicit operator TaskDialogVerificationCheckBox(string verificationText);
}
public sealed class TaskDialogExpander : TaskDialogControl
{
public TaskDialogExpander();
public TaskDialogExpander(string? text);
// "Text" can be set while the dialog is shown.
public string? Text { get; set; }
public string? ExpandedButtonText { get; set; }
public string? CollapsedButtonText { get; set; }
// Note: "Expanded" can NOT be set while the dialog is shown.
public bool Expanded { get; set; }
public TaskDialogExpanderPosition Position { get; set; }
// Raised when the "Expanded" property changes while the dialog is shown (because
// the user clicked the expando button).
public event EventHandler? ExpandedChanged;
public override string ToString();
}
public sealed class TaskDialogFootnote : TaskDialogControl
{
public TaskDialogFootnote();
public TaskDialogFootnote(string? text);
// Properties "Text", "Icon" can be set while
// the dialog is shown (see comments for TaskDialogPage.Icon).
public string? Text { get; set; }
public TaskDialogIcon? Icon { get; set; }
public override string ToString();
public static implicit operator TaskDialogFootnote(string footnoteText);
}
public sealed class TaskDialogProgressBar : TaskDialogControl
{
public TaskDialogProgressBar();
public TaskDialogProgressBar(TaskDialogProgressBarState state);
// Properties "State", "Minimum", "Maximum", "Value", "MarqueeSpeed" can
// be set while the dialog is shown.
public TaskDialogProgressBarState State { get; set; } // "Style"?
public int Minimum { get; set; }
public int Maximum { get; set; }
public int Value { get; set; }
public int MarqueeSpeed { get; set; }
}
// Note: The button order in this collection is not necessarily the same as the actual
// order of buttons displayed in the dialog. See:
// https://github.com/kpreisser/winforms/issues/5#issuecomment-584318609
public class TaskDialogButtonCollection : Collection<TaskDialogButton>
{
public TaskDialogButtonCollection();
public TaskDialogButton Add(string? text, bool enabled = true, bool allowCloseDialog = true);
protected override void ClearItems();
protected override void InsertItem(int index, TaskDialogButton item);
protected override void RemoveItem(int index);
protected override void SetItem(int index, TaskDialogButton item);
}
public class TaskDialogRadioButtonCollection : System.Collections.ObjectModel.Collection<TaskDialogRadioButton>
{
public TaskDialogRadioButtonCollection();
public TaskDialogRadioButton Add(string? text);
protected override void ClearItems();
protected override void InsertItem(int index, TaskDialogRadioButton item);
protected override void RemoveItem(int index);
protected override void SetItem(int index, TaskDialogRadioButton item);
}
public enum TaskDialogStartupLocation
{
CenterScreen = 0,
CenterOwner = 1
}
// Rename to "TaskDialogProgressBarStyle"?
public enum TaskDialogProgressBarState
{
Normal = 0,
Paused = 1,
Error = 2,
Marquee = 3,
MarqueePaused = 4,
// "None" is used for the default ProgressBar instance in the TaskDialogPage so
// that you need to set the State to a different value (or create a new ProgressBar
// instance) to actually show a progress bar in the dialog.
None = 5
}
public enum TaskDialogExpanderPosition
{
AfterText = 0,
AfterFootnote = 1
}
The events in the proposed API currently have the folowing cycle at runtime (the diagram illustrates navigating the dialog in the TaskDialogButton.Click
event):
Caller Events
TaskDialog.ShowDialog();
↓
(Calls TaskDialogIndirect())
────────────>
↓ (Window handle available now)
Callback(TDN_CREATED) ─────────> TaskDialogPage[1].Created
↓ (Window becomes visible)
↓
(...)
↓
Callback(TDN_BUTTON_CLICKED) ──> TaskDialogButton.Click
↓
TaskDialogPage.Navigate() <───────
↓
─────────────────> TaskDialogPage[1].Destroyed
↓
<──────────
↓
Callback(TDN_NAVIGATED) ───────> TaskDialogPage[2].Created
↓
(...)
↓
Callback(TDN_BUTTON_CLICKED) ──> TaskDialogButton.Click
↓ (Window closes; Dialog no longer navigable as it set a result button)
↓
Callback(TDN_DESTROYED) ───────> TaskDialogPage[2].Destroyed
↓ (Window handle no longer available)
<────────────
(TaskDialogIndirect() returns)
↓
(TaskDialog.ShowDialog() returns)
The proposed API is implemented with PR #1133.
TaskDialogContents.DoNotSetForeground
as it doesn't seem to have an effectTaskDialogControlCollection
and TaskDialogButtonCollection
TaskDialogCustomButtonCollection
and TaskDialogRadioButtonCollection
inherit from Collection
instead of KeyedCollection
TaskDialogButtons
to TaskDialogCommonButtonCollection
ResultVerificationFlagChanged
from TaskDialog
ExpandedByDefault
to Expanded
(TaskDialogExpander
) (so its value will be updated when the user clicks the expando button)imageres.dll
)TaskDialog
extends System.ComponentsModel.Component
(and is disposable)Tag
property to TaskDialogControl
TaskDialogCommonButton
now has a default constructor (like other control classes)MainInstruction
-> Instruction
, Content
-> Text
, ButtonClicked
-> Click
)TaskDialogRadioButton
and TaskDialogVerificationCheckbox
has been aligned with WinForms concepts (property Checked
, event CheckedChanged
).TaskDialogVerificationCheckbox
to TaskDialogCheckBox
(along with properties)TaskDialogProgressBarRange
to be used for the TaskDialogProgressBar.Range
property instead of (int min, int max)
for better designer supportTaskDialogContents.DoNotSetForeground
as it is actually working.TaskDialogBooleanStatusEventArgs
.TaskDialogProgressBarState
enum value MarqueeDisabled
to MarqueePaused
TaskDialogControl
abstract
TaskDialogIcon.Stop
to Error
TaskDialogProgressBar.Range
property (along with the TaskDialogProgressBarRange
struct) and instead added properties Minimum
and Maximum
directly on the TaskDialogProgressBar
and also renamed property Position
to Value
, to simplify the API and align with the WinForms ProgressBarTaskDialogContents
(FooterText
, FooterIcon
, FooterIconHandle
) into their own TaskDialogFooter
class. The reasoning for this is that a separate dialog area is added for the footer when it is used (as shown in the below image), similar to the expander (and it reduces the number of properties in TaskDialogContents
).FooterText
property, similar to the Text
property of the Expander
(which is different from the other text properties like TaskDialogContents.Text
and Instruction
that can be added later).TaskDialogFooter
class that inherits from TaskDialogControl
can thus share the behavior with taskDialogExpander
to throw an InvalidOperationException
when trying to update its Text
property but the control wasn't created because it was initially null
(or string.Empty
).TaskDialog.Closing
to Closed
and TaskDialogContents.Destroying
to Destroyed
, and added a new TaskDialog.Closing
event that is called directly after a TaskDialogButton.Click
event if the button would close the dialog, and it allows to cancel the close (similar to Form.FormClosing
event in WinForms) - see this comment (Option B).TaskDialogExpander.ExpandoButtonClicked
to ExpandedChanged
TaskDialogContents
to TaskDialogPage
and property TaskDialog.CurrentContents
to TaskDialog.Page
. This is because the documentation also talks about "navigating to a new page" - for example see Multi-page dialog boxes.TimerTick
event on TaskDialogPage
:TDN_TIMER
notification that is called every 200 ms if the TDF_CALLBACK_TIMER
flag was set in the task dialog config. The previous implementation specified the flag if the event handler has been set (like the implementation in the Windows API Code Pack did), but this means you could not add an event handler to the TimerTick
event after the dialog is displayed/navigated. Also, the interval of 200
is fixed (and a user might get the impression that the dialog can only be updated every 200 ms, which is not the case).System.Windows.Forms.Timer
. Both the Task Dialog timer and the WinForms Timer use a Windows timer (WM_TIMER
messages), so using the WinForms timer should have the same behavior as the TaskDialog timer but with more flexibility.StartupLocation
from TaskDialogPage
to TaskDialog
because it only has an effect when showing the dialog (but not when navigating it) and therefore isn't related to the page (which represents the contents of the dialog).TaskDialog.Activated
and TaskDialog.Deactivated
.TaskDialog.Shown
(similar to Form.Shown)
.TaskDialogCommonButton
to TaskDialogStandardButton
(along with collections and property names).TaskDialogPage.DoNotSetForeground
to TaskDialog
because it only has an effect when showing the dialog, but not when navigating it.Icon
+IconHandle
on TaskDialogPage
and TaskDialogFooter
into a single Icon
property use subclasses to differentiate between icon types (see #146 (comment)).imageres.dll
or the application's executable), which could also be shown using a colored bar (which is not possible when using a handle).TaskDialogPage.CommandLinkMode
to CustomButtonStyle
(along with the enum).TaskDialog
no longer inherits from System.ComponentModel.Component
which was used for trying to implement designer support, but that would require additional work. It be revisited for a future version.TaskDialogPage.Help
to HelpRequest
(and method OnHelp
to OnHelpRequest
) as discussed in #1133.TaskDialog.DoNotSetForeground
to TaskDialog.SetToForeground
(the default value is still false), as per the feedback in #1133.TaskDialog.Show
to ShowDialog
.TaskDialogPage.Instruction
to MainInstruction
(same with parameter names for the static TaskDialog.Show
methods).TaskDialogPage.Title
to Caption
(same with parameter names for the static TaskDialog.Show
methods).TaskDialogButtonClickedEventArgs
and instead added boolean property TaskDialogButton.ShouldCloseDialog
that allows to specify whether clicking the button should close the task dialog.TaskDialogStandardIcon
and TaskDialogIconHandle
, and instead added static fields on TaskDialogIcon
for the standard icons, and added a constructor taking an icon or icon handle.int
indexer to TaskDialogStandardButtonCollection
to avoid an overload resolution in the C# compiler for expressions like page.StandardButtons[0]
. See #1133 (comment)string
to TaskDialogFooter
.TaskDialogExpander.ExpandFooterArea
with Position
(using enum type TaskDialogExpanderPosition
).TaskDialogPage.BoundDialog
and TaskDialogControl.BoundPage
, so that it is possible e.g. to access the current TaskDialog
instance in a button click handler. See discussion here.SecurityShield
, SecurityShieldBlueBar
, SecurityShieldGrayBar
, SecurityWarningYellowBar
, SecurityErrorRedBar
, SecuritySuccessGreenBar
to Shield
, ShieldBlueBar
, ShieldGrayBar
, ShieldWarningYellowBar
, ShieldErrorRedBar
, ShieldSuccessGreenBar
; as the term "security" would imply that such icons will/must be used for security purposes.TaskDialogPage.CanBeMinimized
to AllowMinimize
.TaskDialogButton.ShouldCloseDialog
to AllowCloseDialog
.TaskDialogStandardButton
and TaskDialogCustomButton
constructors and to the TaskDialogStandardButtonCollection.Add
and TaskDialogCustomButtonCollection.Add
methods.TaskDialogButton.Click
from EventHandler<EventArgs>
to EventHandler
.StartupLocation
to a parameter of ShowDialog()
- see kpreisser#16TaskDialogIcon
from a Bitmap
- see kpreisser#15TaskDialogPage.MainInstruction
to Heading
- see kpreisser#6TaskDialogFooter
(and corresponding properties) to TaskDialogFootnote
- see kpreisser#8TaskDialogStartupLocation.CenterParent
to CenterOwner
TaskDialogCheckBox.Focus()
TaskDialogButton.ElevationRequired
to ShowShieldIcon
TaskDialogCheckBox
(and corresponding properties) to `TaskDialogVerificationCheckBox´ - see kpreisser#18TaskDialogPage.Width
TaskDialogProgressBarState
to TaskDialogProgressBarStyle
Tag
on TaskDialogPage
(which is already present on TaskDialogControl
)ShowDialog()
should behave. Currently, it either shows the dialog modal (when specifying an owner) or non-modal, but in both cases the method does not return until the dialog has closed (similar to Form.ShowDialog()
), which is the behavior of the native TaskDialogIndirect
function. MessageBox.Show()
; however, the MessageBox
automatically uses the current foreground window as owner when you don't specify the owner. For the Task Dialog however, it definitely should be possible to show it non-modal.TaskDialog.Show()
entry in the call stack.InvalidOperationException
(this was also the behavior of the task dialog implementation in the Windows API Code Pack). false
to the TaskDialogRadioButton.Checked
property (while the radio button is shown in a task dialog) will throw.TaskDialogButtonCollection
does not necessarily reflect the order in which the task dialog actually displays the buttons (since common buttons are specified by flags in the TASKDIALOGCONFIG
structure, whereas custom buttons are stored in an array).OK
Yes
No
Abort
Retry
Cancel
Ignore
TryAgain
Continue
Close
Help
TaskDialog.ShowDialog()
can return a TaskDialogButton
which was not added to the dialog in the following cases (which results from the native task dialog implementation):
TaskDialogButton.OK
button is returned when the user clicks it.Close()
method, or TaskDialogPage.AllowCancel
has been set and the dialog is closed by the user by pressing ESC or Alt+F4 or clicking the X button in the title bar. In these cases the TaskDialogButton.Cancel
button will be returned.Cancel
result.imageres.dll
), by initially specifying one of the Shield...Bar
icons, and when the dialog is shown, update it to a different icon:imageres.dll
) (by specifying the hInstance
field of the native TASKDIALOGCONFIG
struct), which would then allow you to show a custom icon with a colored bar.I am writing test for System.Drawing.Imaging.ImageAttributes
dotnet/runtime#22130:
private readonly Rectangle _rectangle = new Rectangle(0, 0, 64, 64);
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
public void SetColorKey_Success()
{
using (var bitmap = new Bitmap(_rectangle.Width, _rectangle.Height))
using (var graphics = Graphics.FromImage(bitmap))
using (var imageAttr = new ImageAttributes())
{
imageAttr.SetColorKey(Color.FromArgb(50, 50, 50), Color.FromArgb(150, 150, 150));
bitmap.SetPixel(0, 0, Color.FromArgb(255, 100, 100, 100));
graphics.DrawImage(bitmap, _rectangle, _rectangle.X, _rectangle.Y, _rectangle.Width, _rectangle.Height, GraphicsUnit.Pixel, imageAttr);
Assert.Equal(Color.FromArgb(0, 0, 0, 0), bitmap.GetPixel(0, 0));
}
}
Expected: Color.FromArgb(0, 0, 0, 0)
Actual: Color.FromArgb(255, 100, 100, 100)
I am running the test on netfx
and netcoreapp
and it fails on both.
Looks like transparency isn't get applied.
[EDIT] Fixed code formatting - @karelz
Here are the following that appear incorrect / incomplete:
actual:
public static Cursor HSplit {
get {
if (hSplit == null)
hSplit = new Cursor("hsplit.cur", 0);
return hSplit;
}
}
expected:
internal const string HSPLIT_CUR = "hsplit.cur"
// ...
public static Cursor HSplit {
get {
if (hSplit == null)
hSplit = new Cursor(HSPLIT_CUR , 0);
return hSplit;
}
}
In Visual Studio 2019 Preview 1, there is no project template for generating .NET Core 3 WinForms projects. If I instead run on the command line:
dotnet new winforms -o winforms_core_test
a project is created successfully. I can then open the generated .csproj file in VS2019. But the WinForms designer doesn't seem to be available. Typically the right-click context menu shows "view designer", but it is missing, and shift+f7 after opening the code doesn't work either:
On a standard WinForms project, the Designer.cs file is typically shown as a child of the form source code, and the designer is available on the context menu:
Is there any way to use the designer with .NET Core 3, or is it planned in the future?
Right now, you will get EntryPointNotFoundException's when some System.Drawing.Common tries to load some of it's PInvoke imports. We should somehow wrap these in a way that makes error messages more explicit and less confusing.
Once more advanced testing infrastructure is in-place, FolderBrowseDialog
can use additional tests.
In the following line:
The [DefaultProperty]
tag points to the property Header
which doesn't exist. I'm assuming it was meant to point to the HeaderText
property.
Discovered as part of PR #86
This will be a temporary measure for basic validation of changes until functional test are incorporated in the process. Consider covering the following points:
Got following feedback from Eric regarding Facade assemblies:
"There was one special case for these facades that you will want to check, they use the property IsRuntimeAndReferenceAssembly in order to ensure that we use the same dll in both the ref and lib folder in the package."
Unhandled Exception of Type System.ComponentModel.Win32Exception
Error in remote procedure call
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(String printer) in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterSettings.Windows.cs:line 896
at System.Drawing.Printing.PageSettings.get_ExtraBytes() in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs:line 384
at System.Drawing.Printing.PageSettings.CopyToHdevmode(IntPtr hdevmode) in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PageSettings.Windows.cs:line 368
at System.Drawing.Printing.PrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrintController.Windows.cs:line 276
at System.Drawing.Printing.Tests.PrintDocumentTests.TestPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs:line 274
at System.Drawing.Printing.PrintController.Print(PrintDocument document) in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\src\System\Drawing\Printing\PrintController.Windows.cs:line 117
at System.Drawing.Printing.Tests.PrintDocumentTests.EndPrint_SetValue_ReturnsExpected() in D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Printing\PrintDocumentTests.cs:line 182
cc @danmosemsft @safern @JeremyKuhne
Comments like the following are no longer used:
/// <internalonly />
/// <include file='doc\SystemInformation.uex' path='docs/doc[@for="SystemInformation.TerminalServerSession"]/*' />
As per feedback received from @ericstj we should avoid using IVT even for test code.
I've seen these fail multiple times in CI now, e.g.
https://mc.dot.net/#/user/dotnet-maestro-bot/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/7868028f16d0fb97037930838ec20cba5077191f/workItem/System.Drawing.Common.Tests/wilogs
2018-06-26 22:47:39,723: INFO: proc(54): run_and_log_output: Output: System.Drawing.Tests.Graphics_DrawBezierTests.DrawBezier_PointFs [FAIL]
2018-06-26 22:47:39,723: INFO: proc(54): run_and_log_output: Output: Assert.Equal() Failure
2018-06-26 22:47:39,723: INFO: proc(54): run_and_log_output: Output: Expected: Byte[] [208, 0, 8, 33, 6, ...]
2018-06-26 22:47:39,723: INFO: proc(54): run_and_log_output: Output: Actual: Byte[] [27, 206, 219, 21, 255, ...]
2018-06-26 22:47:39,737: INFO: proc(54): run_and_log_output: Output: Stack Trace:
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\DrawingTest.cs(21,0): at System.Drawing.Tests.DrawingTest.ValidateImageContent(Image image, Byte[] expectedHash)
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Graphics_DrawBezierTests.cs(59,0): at System.Drawing.Tests.Graphics_DrawBezierTests.DrawBezier_PointFs()
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: System.Drawing.Tests.Graphics_DrawLineTests.DrawLines_PointFs [FAIL]
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: Assert.Equal() Failure
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: Expected: Byte[] [142, 194, 251, 180, 222, ...]
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: Actual: Byte[] [89, 188, 96, 22, 200, ...]
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: Stack Trace:
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\DrawingTest.cs(21,0): at System.Drawing.Tests.DrawingTest.ValidateImageContent(Image image, Byte[] expectedHash)
2018-06-26 22:47:39,987: INFO: proc(54): run_and_log_output: Output: D:\j\workspace\windows-TGrou---f8ac6754\src\System.Drawing.Common\tests\Graphics_DrawLineTests.cs(32,0): at System.Drawing.Tests.Graphics_DrawLineTests.DrawLines_PointFs()
I could be wrong, but I believe I only started seeing it after dotnet/corefx#30099.
cc: @safern, @JeremyKuhne
Opened on behalf of @JiayiLi1
The test System.Drawing.Tests.FontFamilyTests/Ctor_Name(name: \"Microsoft Sans Serif\", expectedName: \"Microsoft Sans Serif\")
has failed.
System.ArgumentException : Font 'Microsoft Sans Serif' cannot be found.
Stack Trace:
at System.Drawing.FontFamily.CreateFontFamily(String name, FontCollection fontCollection)
at System.Drawing.Tests.FontFamilyTests.Ctor_Name(String name, String expectedName)
Build : Master - 20170726.01 (Core Tests)
Failing configurations:
Copied from dotnet/core#2093
Since WinForms is moving to .NET Core 3.0, I hope you upgrade the WebBrowser control to use the IE version installed on the user PC. The current WebBrowser control uses IE 7 and causes many problems. There is a workaround to solve this, but doing it in the user's PC needs permissions. See this topic for more details:
https://stackoverflow.com/questions/17922308/use-latest-version-of-internet-explorer-in-the-webbrowser-control?noredirect=1&lq=1
I have been trying to publish a plain dotnet new winforms app by following the steps here, but I end up with error: error MSB4044: The "CheckEmbeddedRootDescriptor" task was not given a value for the required parameter "AssemblyPath".
See attached image for the whole process.
I am running VS2019 Preview and have the following SDKs installed: https://www.screencast.com/t/29MbjIeY04
Instead of having separate 'ref' projects in the solution, use -refout to generate ref assemblies automatically from src assemblies.
Note that the failure occurs on Arm64 only!
The test: https://github.com/dmklementiev/corefx/blob/master/src/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs has failed with the following details:
Unhandled Exception of Type Xunit.Sdk.EqualException
Message :
Assert.Equal() Failure
Expected: {X=0,Y=0,Width=2,Height=2}
Actual: {X=0,Y=-1,Width=2,Height=2}
Stack Trace :
at System.Drawing.Drawing2D.Tests.LinearGradientBrushTests.Ctor_PointF_PointF_Color_Color(Point point1, Point point2, Color color1, Color color2, RectangleF expectedRectangle) in /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_arm64+TestOuter_false_prtest/src/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs:line 39
Exactly the same problem with another test:
Stack Trace :
at System.Drawing.Drawing2D.Tests.LinearGradientBrushTests.Ctor_Point_Point_Color_Color(Point point1, Point point2, Color color1, Color color2, RectangleF expectedRectangle) in /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_arm64+TestOuter_false_prtest/src/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs:line 68
Currently, System.Windows.Forms.Cursors has a few embedded cursors that where added for backwards compatibility with old operating systems that are not supported anymore. They should be replaced to use system cursors.
The following cursors are embedded:
618: use of obsolete code. Used probably because of legacy code, but globally surpressing the warning turns it off for new code too. Hence check if the code can be modified to avoid them. If not then add #pragmas instead of globally suppressing this warning.
649: field is never assigned. We should not ignore this warning except in the rare cases when we need to preserve an unused field for back-compat (eg: serialization). Recommend replace with pragma.
Problem description:
Crash at runtime where icon is set as follows in autogenerated form designer code
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
Actual behavior:
Following exception is thrown when running using dotnet CLI or vscode
Exception has occurred: CLR/System.InvalidCastException
An unhandled exception of type 'System.InvalidCastException' occurred in...
Expected behavior:
No crash, form icon is set. Crash does not happen and icon is set when debugging via Visual Studio 2019 preview.
Minimal repro:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.