-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter
committed
Mar 8, 2020
1 parent
c97cc01
commit ba2bb70
Showing
5 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Base WPF functionality for writing custom controls | ||
|
||
## Table of content | ||
[About](#about) | ||
[Sample](#sample) | ||
[Build requirements](#Build-requirements) | ||
[Structure CustomControlBaseLib Solution](#Structure-CustomControlBaseLib-Solution) | ||
[Project Status](#Project-Status) | ||
[Copyright](#Copyright) | ||
|
||
## About | ||
|
||
It can be quite a lot of work to support resizing, padding, different fonts, etc. | ||
when you write a WPF custom control. The main class in the library `CustomControlBase` | ||
provides these functionalities and also drawing directly to the screen for your | ||
custom control. | ||
A few other methods in this library are also helpful when writing | ||
WPF controls, like `GlyphDrawer` which allows to measure text length and | ||
writing text directly to a Control's DrawingContext. | ||
|
||
## Sample | ||
|
||
`CustomControlBase` can be used for any custom control. `CustomControlSample` in | ||
`CustomControlSampleLib` provides a detailed example how to add `Visuals`, | ||
`FramworkElemtens`, `Controls`, etc. and how to directly | ||
draw to the screen can be easily combined. Left in the sample is a `TextBox` and right | ||
is a code drawn ellipse with the same (!) size like the TextBox. A possible use case would | ||
be a graph together with legend. | ||
|
||
![User has changed data, cannot close window](CustomControlSample.png) | ||
|
||
One challenge here is the sizing and placing of the control's content, depending on Alignment (stretched or not), | ||
`TextBox.FontSize` and available space given by the Window. `CustomControlBase` and | ||
`CustomControlSample` also support Border and Padding. `Font` and `BackGround` are inherited in a custom | ||
control from `Control`, but they don't do anything out of the box. `CustomControlBase` adds the missing | ||
functionality. | ||
|
||
## Build requirements | ||
.Net Core 3.1 or later | ||
|
||
## Structure CustomControlBaseLib Solution | ||
|
||
### CustomControlBaseLib | ||
The only library needed to be referenced from other code, providing: | ||
* `CustomControlBase`: Base class for custom controls with functionality added for Children, Drawing, | ||
`Border`, `Padding` and `Background`. | ||
* `GlyphDrawer`: Writes text to a `DrawingContext`. Can also be used to calculate the length of text. | ||
### CustomControlSample | ||
Shows how to use `CustomControlBase` | ||
### CustomControlSampleLib | ||
Helper library for `CustomControlSample` | ||
|
||
## Project Status | ||
Completed and stable | ||
|
||
## Copyright | ||
Copyright 2020 Jürg Peter Huber, Singapore. | ||
|
||
Licensed under the [Creative Commons 0 license](COPYING.txt) | ||
|