A ProEssentials v10 WPF .NET 8 demonstration of two advanced PesgoWpf
features: intelligent logarithmic axes that restructure intelligently on zoom,
and a live drag measurement tool built with the Quick Annotation mechanism.
| Feature | How to See It |
|---|---|
| Log-Log axes | Scroll the mouse wheel — watch grid lines restructure at decade boundaries as you zoom through orders of magnitude |
| Quick Annotation drag measure | Left-click and drag — a live measurement rectangle appears showing X and Y deltas, updated every MouseMove with no chart rebuild |
Both axes use ScaleControl.Log. ProEssentials selects intelligent
logarithmic grid numbers automatically at any zoom level, always landing on
clean powers of ten and their subdivisions:
Pesgo1.PeGrid.Configure.XAxisScaleControl = ScaleControl.Log;
Pesgo1.PeGrid.Configure.YAxisScaleControl = ScaleControl.Log;Mouse wheel zooms both axes simultaneously:
Pesgo1.PeUserInterface.Allow.Zooming = AllowZooming.None; // left-drag reserved for measurement
Pesgo1.PeUserInterface.Scrollbar.MouseWheelFunction = MouseWheelFunction.HorizontalVerticalZoom;
Pesgo1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 8;Quick annotations are graph annotations that render via an optimized overlay
path, avoiding full chart rebuilds. They are ideal for transient UI that
updates every MouseMove.
In WPF, PesgoWpf automatically manages the CacheBmp2 secondary buffer
and improved cursor rendering — these properties are not exposed on the WPF
interface and require no explicit setup.
The only mouse wheel zoom requirement is pairing MouseWheelFunction with
the matching scrollbar flags:
Pesgo1.PeUserInterface.Scrollbar.ScrollingHorzZoom = true;
Pesgo1.PeUserInterface.Scrollbar.ScrollingVertZoom = true;
Pesgo1.PeUserInterface.Scrollbar.MouseWheelFunction = MouseWheelFunction.HorizontalVerticalZoom;MouseWheelFunction.HorizontalVerticalZoom requires both flags set explicitly —
without them the wheel cannot zoom out and only one axis responds.
Any GraphAnnotationType value becomes a quick annotation by negating it:
// Normal annotation — baked into cached image, requires ResetImage to change:
Graph.Type[i] = (int)GraphAnnotationType.TopLeft;
// Quick annotation — overlay only, no chart rebuild needed:
Graph.Type[i] = ((int)GraphAnnotationType.TopLeft + 1) * -1;When ShowingQuickAnnotations = true, only negative-type annotations are
rendered, drawn on top of the primary cached chart image.
| Index | Type | Purpose |
|---|---|---|
| [0] | TopLeft (negative) |
Top-left bound of the selection rectangle |
| [1] | BottomRight (negative) |
Bottom-right bound |
| [2] | RoundRectFill (negative) |
Semi-transparent filled background |
| [3] | RoundRectMedium (negative) |
White border outline |
| [4] | NoSymbol + |c text (negative) |
X-delta label, centered horizontally |
| [5] | NoSymbol + |D text (negative) |
Y-delta label, centered vertically (right edge) |
// MouseMove — trigger overlay redraw (no chart rebuild):
Pesgo1.PeAnnotation.ShowingQuickAnnotations = true;
Pesgo1.Invalidate();
Pesgo1.Refresh();
// MouseUp — clear overlay:
Pesgo1.PeAnnotation.ShowingQuickAnnotations = false;
Pesgo1.PeAnnotation.HidingQuickAnnotations = true;
Pesgo1.Invalidate();
Pesgo1.Refresh();On log axes the visual center of a span is the geometric mean, not the arithmetic mean. Delta labels use geometric centering so they appear visually centered within the selection at any zoom level:
double centeredXLog = (Math.Log10(fX) + Math.Log10(_dragStartX)) / 2.0;
double centeredX = Math.Pow(10.0, centeredXLog);| Code | Meaning |
|---|---|
|c |
Centered horizontally, bottom anchor (text above the point) |
|D |
Centered vertically on right side — 90° rotated text, right edge |
Mouse pixel positions are converted to data-unit coordinates using
ConvPixelToGraph, then clamped to the visible axis extents:
int nA = 0, nX = (int)pt.X, nY = (int)pt.Y;
double fX = 0, fY = 0;
Pesgo1.PeFunction.ConvPixelToGraph(ref nA, ref nX, ref nY,
ref fX, ref fY, false, false, false);
// Clamp to current visible range
fX = Math.Max(Pesgo1.PeGrid.Configure.ManualMinX,
Math.Min(Pesgo1.PeGrid.Configure.ManualMaxX, fX));ManualMinX/MaxX/MinY/MaxY are only valid after the chart has rendered
its first image — never read them during initialization.
| Input | Action |
|---|---|
| Mouse wheel | Zoom both axes (log-scale aware, smooth) |
| Left-click drag | Live drag measurement overlay |
| Right-click | Context menu — export, print, customize |
- Visual Studio 2022
- .NET 8 SDK
1. Clone this repository
2. Open LogLogDragMeasure.sln in Visual Studio 2022
3. Build → Rebuild Solution (NuGet restore is automatic)
4. Press F5
References
ProEssentials.Chart.Net80.x64.Wpf.
Package restore is automatic on build.
- WPF Multi-Axis Layout Explorer
- WPF Mouse Interaction Hotspots
- All Examples — GigasoftInc on GitHub
- Full Evaluation Download
- gigasoft.com
Example code is MIT licensed. ProEssentials requires a commercial license for continued use.
