Introduction
This is release 2.1.0 of the library. It adds methods to, and fixes bugs in, the SimpleCodeBuilder class. Note that there are incompatibilities between newer (2.x) and older (1.x) releases of the library. Refer to the History section for more details.
The SimpleWidgets2 Library is a collection of simple .NET Framework/.NET Windows Forms controls and utilities. They are primarily intended for use in more complex controls and widgets.
The SimpleWidgets2 library is compiled using .NET Framework 3.5, .NET Framework 4.6.2, and .NET 6.0.
All public and protected classes, methods and properties and fully documented using standard C# XML documentation comments. The project includes help files in both .chm and .mshc formats. Refer to the Overview section in the help file for more details on using the library.
The SimpleWidgets2_210_Demo download includes the following files:
| GAW.SimpleWidgets2.Net462.dll | | Library compiled for .NET Framework 4.6.2. |
| GAW.SimpleWidgets2.ExplorerApp.Net462.exe | | Sample app demonstrating most of the classes in the library. |
| GAW.SimpleWidgets2.ColorCircleDemoApp.Net462.exe | | Sample app for generating color circles, demonstrating the HSColor.GenerateCircle() method. |
| GAW.SimpleWidgets2.ResizerDemoApp.exe | | Sample app demonstrating the use of the Resizer class. |
The SimpleWidgets2_210_Library download includes:
| GAW.SimpleWidgets2.Net35.dll | | Library compiled for .NET Framework 3.5. |
| GAW.SimpleWidgets2.Net462.dll | | Library compiled for .NET Framework 4.6.2. |
| GAW.SimpleWidgets2.Net60 (.dll,.deps.json) | | Library compiled for .NET 6.0. |
| GAW.SimpleWidgets2.ExplorerApp.Net35.exe | | Sample app demonstrating most of the classes in the library compiled for .NET Framework 3.5. |
| GAW.SimpleWidgets2.ExplorerApp.Net462.exe | | Sample app demonstrating most of the classes in the library compiled for .NET Framework 4.6.2. |
| GAW.SimpleWidgets2.ExplorerApp.Net60 (.exe,.dll,.deps.json,.runtimeconfig.json) | | Sample app demonstrating most of the classes in the library compiled for .NET 6.0. |
| GAW_SimpleWidgets2.chm | | Help file (HTML Help format). |
| GAW_SimpleWidgets2.msha | | Help file (MS Help Viewer format). |
| GAW_SimpleWidgets2.mshc | | Help file (MS Help Viewer format). |
The SimpleWidgets2_210_Source download includes the source for all of above programs, as well as source for unit tests, and the necessary files for building the help files.
Using the Library
There are many classes in the SimpleWidgets2
library. The main classes are Filler
, Filler2
, Line
, and Polygon
. They all provide full Visual Studio Designer support (for .NET Framework projects).
Filler
The Filler
class is an area filler class. It supports the following fill types:
- Empty fills,
- Solid fills (using a single color),
- Hatched fills (using a hatch color, hatch pattern, and background color),
- Linear gradient fills (using any number of colors), and
- Path gradient fills.
Linear gradient fills have a direction, specified by an angle value. Path gradient fills radiate out from a center point, either as a rectangle or as an ellipse. For example, this is a gradient with an angle of 57 degrees:
Include a public type of Filler
in a control and it will automatically be supported by Visual Studio Designer. The following code segment shows a member of type Filler
named AreaFill
:
|
private GAW.SimpleWidgets2.Filler areaFill = new GAW.SimpleWidgets2.Filler();
public GAW.SimpleWidgets2.Filler AreaFill
{
get { return areaFill; }
set { areaFill = value; }
}
|
If such a code sample was part of a control, and that control was added to form, this property could be set within designer:
Selecting the "..." button brings up the FillerEditorDialog
.
Filler2
The Filler2
class is an area filler class similar to Filler
but with fewer options for gradient fills. It supports the following fill types:
- Empty fills,
- Solid fills (using a single color),
- Hatched fills (using a hatch color, hatch pattern, and background color), and
- Gradient fills (using any number of colors).
Filler2
is intended for use in a control where the gradient direction (if a gradient fill is chosen) is context dependent. For example, imagine a control with a spinning arrow. If a gradient fill was chosen for the arrow, and the control designer wanted the gradient to always flow in the direction the arrow was pointing, then Filler2
should be chosen as the fill over Filler
. It would not make sense for the user to be able to select a gradient direction if the control ignored the selected direction.
Line
The Line
class represents a line, of any size (thickness), color, and dash style. It is intended to be used to draw lines and/or paths using the .NET Graphics
class.
The LineEditorDialog
class implements a dialog which allows for the editing of a Line
object:
Polygon
The Polygon
class represents a polygon, either empty, or composed of any number of points. It is intended to be used to draw paths using the .NET Graphics
class.
The PolygonEditorDialog
class implements a dialog which allows for the creation and editing of a Polygon
object. The polygon is constructed by entering the X and Y coordinates for each point. Points can be added, deleted, or re-ordered:
Other Classes
The following table summarizes most, but not all, of the other classes in the SimpleWidgets
library.
WebColorPicker | A control for selecting a web color. |
| |
WebColorPickerDialog | A dialog form with a WebColorPicker control. |
| |
SystemColorPicker | A control for selecting a system color. |
| |
SystemColorPickerDialog | A dialog form with a SystemColorPicker control. |
| |
CustomColorPicker | A control for selecting any color from the RGB or HSL color spaces. |
| |
CustomColorPickerDialog | A dialog form with a CustomColorPicker control. |
| |
ComboColorPicker | A control for which combines the WebColorPicker , SystemColorPicker , and CustomColorPicker using tabs |
| |
ComboColorPickerDialog | A dialog form with a ComboColorPicker control. |
| |
ColorGradientEditor | A control for editing a color gradient. |
| |
ColorGradientEditorDialog | A dialog form with a ColorGradientEditor control. |
| |
DashStyleComboBox | A control for selecting one of the preset DashStyle values from a ComboBox control. |
| |
HatchStyleComboBox | A control for selecting one of the preset HatchStyle values from a ComboBox control. |
| |
LinearGradientModeComboBox | A control for selecting one of the preset LinearGradientMode values from a ComboBox control. |
| |
HSColor | A helper class with methods for generating HSL or HSV color circles, as well as methods for converting between RGB, HSL, and HSV color spaces. |
| |
Resizer | A helper class for controlling how the controls in a container (usually a Form or Panel ) change location and size when the container is resized. |
| |
SimpleCodeBuilder | A helper class for generating initialization source code, similar to what is generated by Visual Studio Designer. |
Unit Tests and Code Coverage
Unit tests have been added to this release using NUnit 3. Code coverage of the unit tests was measured using the Fine Code Coverage extension.
The majority of the unit tests were added to confirm that constructors, getters and setters were behaving as expected. A number of bugs were found with these simple tests! There is some code coverage of internal code (for example, the CatColorPicker.LayoutCalculator
class is covered 100%). Unfortunately, there is very little coverage of the actual GUI code - painting and responding to events. I am still searching for a satisfactory way of unit testing the GUI code.
Code coverage for the release version of the library compiled for .NET Framework 4.6.2 is at 81.9%. Branch coverage is at 56.8%. Measuring code coverage consistently works for all versions of the library.
The required packages to compile and run the unit tests in Visual Studio are:
- NUnit 3.13.2 or later.
- NUnit3TestAdapter 4.1.0 or later.
Code coverage was measured using Fine Code Coverage extension by Fortune Ngwenya
(version 1.1.188). This is an excellent free tool which I highly recommend!
Future Changes
Once the issues with Visual Studio Windows Forms Designer for .NET applications has been resolved, SimpleWidgets will be updated. Hopefully this will happen soon...
Other changes to be made for future release include:
- More refactoring of GUI code (especially that involved with layout calculation) to make it easier to unit test.
- Enhance the
PolygonEditorDialog
allowing points or groups of points to be dragged. - Allow resizing of the
GradientEditor
.
History
- December 30, 2022 - Release 2.1.0
- Added
SimpleCodeBuilder.Add
method overloads for Boolean, Size, and Point. - Fixed a bug in some
SimpleCodeBuilder.Add
method overloads where a null value being assigned might be preceded by the new keyword. - Fixed some minor documentation errors.
- December 4, 2022 - Release 2.0.0
- Added
Resizer
class. - Added XML serialization to the
Filler
, Filler2
, Line
, and Polygon
classes. - Added
SimpleCodeBuilder
class. - Added the method
Redraw
to the LinearGradientPanel
class. - Added unit tests (and fixed several minor bugs).
- Removed the
LinearGradientBrush2
class; added new method Utils.PaintWithLinearGradientBrush
to replace lost functionality. - Changed project so that the library and apps are compiled with Visual Studio 2022 for .NET Framework 3.5, .NET Framework 4.5.2, and .NET 6.0.
- Changed help files to work with Sandcastle Help File Builder 2021.11.7.0.
- Changed library name to
SimpleWidgets2
and namespace to GAW.SimpleWidgets2
to avoid conflicts with earlier versions of the library.
- January 19, 2016 - Release 1.1.1
- Fixed bug where
SetStartPosition
was positioning the form with the upper left corner at the specified point, not the center of the top edge as stated in the documentation. - Updated
SetStartPosition
and SetStartPositionBelowControl
such that the form position is adjusted to keep it in the working area of the screen. - Fixed bug where Black was missing from the list of web colors.
- September 13, 2015 - Release 1.1.0
- Fixed bug where
FillerPanel
and Filler2Panel
were using nested UserControl
s, making it impossible for mouse messages to be intercepted. - Fixed bug where
Utils.SetSetPosition()
would not always function properly on the non primary display of a multiple display system. - Added additional constructors to
FillerEditorDialog
and Filler2EditorDialog
allowing the window to be positioned immediately beneath a specified control. - Changed form border style of various dialogs from fixed dialog to fixed tool window.
- Changed titles on various dialogs.
- Changed
Line
class so that a width of zero is an empty (not visible) line. - Added alpha value selector to
CustomColorPicker
control.
- September 13, 2014 - Release 1.0.2
- Converted .csproj files to Visual Studio 2013 format.
- Converted help files to work with SandCastle Help File Builder 2014.5.31.0.
- February 5, 2014 - Release 1.0.1
- Fixed some missing documentation tags.
- February 2, 2014 - First release