diff --git a/README-zh.md b/README-zh.md index 451d2b68..3d33005d 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,3 +1,65 @@ +
+ WPFDevelopers +

WPFDevelopers

+

面向 WPF 应用的开源控件与主题库,帮助你更轻松地构建现代 Windows 桌面界面。

+

+ 快速开始 · + MapView 指南 · + GitHub · + AtomGit · + Gitee +

+

+ NuGet version + NuGet downloads + GitHub stars + AtomGit stars + Gitee stars + Visual Studio 2026 + .NET Framework 4.0–.NET 10 +

+
+ +## 项目简介 + +WPFDevelopers 为 WPF 项目提供常用控件、统一主题和丰富的交互示例。项目覆盖 .NET Framework 4.0 至 .NET 10;各目标框架与环境要求请查看[快速开始文档](docs/zh/getting-started.md)。 + +| 主题与样式 | 常用控件 | 示例与扩展 | +| --- | --- | --- | +| Light / Dark 主题及主题色配置 | 按钮、输入、导航、图表、窗口等控件 | 配套示例项目,便于查看实现与组合方式 | + +## 快速开始 + +从 NuGet 安装稳定版: + +```powershell +Install-Package WPFDevelopers +``` + +体验最新功能可安装预览版: + +```powershell +Install-Package WPFDevelopers -Pre +``` + +随后按[快速开始文档](docs/zh/getting-started.md)配置 `App.xaml`,并查看主题选项、控件用法和环境说明。 + +## 文档与资源 + +- [快速开始与 .NET 支持范围](docs/zh/getting-started.md) +- [MapView 地图控件指南](docs/zh/mapview.md) +- [示例项目源码](src/WPFDevelopers.Samples.Shared/ExampleViews/) +- [GitHub 仓库](https://github.com/WPFDevelopersOrg/WPFDevelopers) · [AtomGit](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers) · [Gitee](https://gitee.com/WPFDevelopersOrg/WPFDevelopers) + +## 控件预览 + +![WPFDevelopers 控件预览](https://gitee.com/WPFDevelopersOrg/MarkDownBlog/raw/master/resources/WPFDevelopersResource/BasicControls.png) + +完整控件与效果示例仍保留在下方图集中。示例中标注为 `DEMO` 的内容可能是示例专属实现或组合效果,不一定是库内置控件,请以对应源码为准。 + +
+展开完整示例图集及社区信息 +
[English](https://github.com/WPFDevelopersOrg/WPFDevelopers/blob/master/README.md) @@ -6,15 +68,13 @@ nuget-version nuget-version - [![Github stars](https://img.shields.io/github/stars/yanjinhuagood/WPFDevelopers)](https://github.com/yanjinhuagood/WPFDevelopers/stargazers) [![AtomGIt Star](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers/star/badge.svg)](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers)![Downloads](https://img.shields.io/nuget/dt/WPFDevelopers?color=%23409EF) - .NET6VSIX - + [![Github stars](https://img.shields.io/github/stars/yanjinhuagood/WPFDevelopers)](https://github.com/yanjinhuagood/WPFDevelopers/stargazers) [![AtomGIt Star](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers/star/badge.svg)](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers)![Downloads](https://img.shields.io/nuget/dt/WPFDevelopers?color=%23409EF) ## Welcome to WPFDevelopers -# __最新请使用 Nuget 预览版包__ |[下载可执行程序EXE](https://foruda.gitee.com/attach_file/1688956477367725173/net40.zip?token=71326e788298fd73e4e1dfd46558a23e&ts=1688956652&attname=net40.zip) |[项目模板下载VSIX](resources/WPFDevelopersResource/WPFDevelopers.vsix) +# 最新请使用 NuGet 预览版包 # [最新 WPFDevelopers .Net4.5 至 Net10.0 版本如何编译 👀](https://mp.weixin.qq.com/s/M8as_AsVAFsiImDhaX7TKQ) @@ -28,6 +88,8 @@ ### [ 文档中心 → 快速开始](docs/zh/getting-started.md) +示例导航中的蓝灰色 `DEMO` 标识表示示例专属实现或组合效果,并非 WD 内置控件,请参考示例源码。`DEMO` 与表示更新状态的 `NEW / UPDATE` 独立,同一项可以同时显示两类标识。 + ### 此项目包含了 微信公众号 《 WPF开发者》 日常开发分享,欢迎Star。 ### 运行环境 Visual Studio 2026 @@ -66,7 +128,7 @@ ### 支持者 -Conscientious loridoo yaunchen 王菅物 清梦 zhangjingcheng dotnet9 罗海钧 +Conscientious loridoo yaunchen 王菅物 清梦 zhangjingcheng dotnet9 罗海钧 左全 ### 贡献者 ChisterWu @@ -514,7 +576,7 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- -### CropControl(WPF实现图片切成九宫格控件) +### ImageCrop(WPF实现图片九宫格分块效果) @@ -683,7 +745,7 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- -### WpfPieControl(WPF实现统计图(饼图仿LiveCharts)) +### PieSegment(WPF实现分段饼图示例) @@ -764,4 +826,4 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- - ~~底线~~ +
diff --git a/README.md b/README.md index d6d39299..798bd720 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,67 @@ +
+ WPFDevelopers +

WPFDevelopers

+

An open-source control and theme library for building modern WPF desktop applications.

+

+ Quick start · + MapView guide · + GitHub · + AtomGit · + Gitee · + 中文 +

+

+ NuGet version + NuGet downloads + GitHub stars + AtomGit stars + Gitee stars + Visual Studio 2026 + .NET Framework 4.0–.NET 10 +

+
+ +## About + +WPFDevelopers provides reusable controls, application-wide themes, and interactive samples for WPF projects. It supports target frameworks from .NET Framework 4.0 through .NET 10. See the [quick start guide](docs/en/getting-started.md) for framework and environment details. + +| Themes | Controls | Samples | +| --- | --- | --- | +| Light / Dark themes and customizable accent colors | Buttons, inputs, navigation, charts, windows, and more | Sample applications with implementation and composition examples | + +## Quick start + +Install the stable NuGet package: + +```powershell +Install-Package WPFDevelopers +``` + +To try the latest features, install the preview package: + +```powershell +Install-Package WPFDevelopers -Pre +``` + +Then follow the [quick start guide](docs/en/getting-started.md) to configure `App.xaml` and use the controls. + +## Documentation and resources + +- [Quick start and supported .NET versions](docs/en/getting-started.md) +- [MapView guide](docs/en/mapview.md) +- [Sample project source](src/WPFDevelopers.Samples.Shared/ExampleViews/) +- [GitHub](https://github.com/WPFDevelopersOrg/WPFDevelopers) · [AtomGit](https://atomgit.com/WPFDevelopersOrg/WPFDevelopers) · [Gitee](https://gitee.com/WPFDevelopersOrg/WPFDevelopers) +- [中文 README](README-zh.md) + +## Control preview + +![WPFDevelopers control preview](https://gitee.com/WPFDevelopersOrg/MarkDownBlog/raw/master/resources/WPFDevelopersResource/BasicControls.png) + +The full collection of control demos and animated previews is preserved below. Items marked `DEMO` may be sample-only implementations or compositions rather than built-in WD controls; refer to the corresponding source. + +
+Show the full demo gallery and community information +
[中文](https://gitee.com/WPFDevelopersOrg/WPFDevelopers/blob/master/README-zh.md) @@ -26,6 +90,8 @@ ### [Documentation Center → Quick Start](docs/en/getting-started.md) +The sample navigation marks sample-only implementations and composed effects with a blue-gray `DEMO` badge. These are not built-in WD controls; refer to the sample source. `DEMO` is independent of `NEW` / `UPDATE`, so both badges can appear on the same item. + ### Visual Studio 2026

System Design

@@ -65,7 +131,7 @@ If you think our open source software is helpful to you, please scan the QR code ### Backers Conscientious loridoo yaunchen 王菅物 清梦 zhangjingcheng dotnet9 - 罗海钧 + 罗海钧 左全 ### Contributors ChisterWu @@ -487,7 +553,7 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- -### CropControl +### ImageCrop @@ -663,7 +729,7 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- -### WpfPieControl +### PieSegment @@ -744,5 +810,4 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ---------- - ~~end~~ - +
diff --git a/docs/en/getting-started.md b/docs/en/getting-started.md index 85dc650c..6a87eda4 100644 --- a/docs/en/getting-started.md +++ b/docs/en/getting-started.md @@ -17,8 +17,6 @@ WPFDevelopers covers the full spectrum from .NET Framework 4.0 to .NET 10: - Visual Studio 2026 - .NET Framework 4.0 or later / .NET Core 3.0 or later ---- - ## MapView Guide If you need to use the map control, start with: @@ -108,6 +106,107 @@ Then use WD controls: ``` +### ColorPicker Usage + +`ColorPicker` remains an inline panel. Its format dropdown selects RGB, HSL, or HEX directly; set `ColorType` to choose the initial format. + +```xml + +``` + +Set `DisplayMode="Popup"` on the same `ColorPicker` to show a clickable swatch that opens the panel. The default, `DisplayMode="Inline"`, preserves the existing inline display: + +```xml + + +``` + +- `SelectedColor` is a `Color` and binds two-way by default. Changes are applied immediately, without confirmation. +- `ShowColorText` defaults to `False`. Enable it to display HEX beside the swatch: `#RRGGBB` for opaque colors, or `#AARRGGBB` otherwise. +- `SwatchSize` is the swatch side length, defaulting to 18. Use positive values such as 24 or 32; trigger dimensions also include padding and borders. +- `IsDropDownOpen` supports two-way binding. Click outside or press Esc to close; F4 or Alt+Down toggles the popup. Space opens it when the trigger has focus. +- Mouse activation opens the panel on release so the popup can capture outside clicks. Outside-click dismissal remains available after changing formats. +- `ShowColorText`, `SwatchSize`, and `IsDropDownOpen` apply to Popup mode; Inline mode cannot open a popup. Switching `DisplayMode` at runtime closes the popup and preserves the color and format. +- `SelectedColorChanged` is a bubbling color-change event. Both modes share the color panel and theme resources. In Popup mode, `Width`, `Height`, and `Padding` configure the trigger, not the inner panel. + +### GridSplitter Usage + +`GridSplitter` is a standard WPF control and does not require the `wd:` prefix. After configuring the theme above, its default style has a transparent background and a centered three-dot grip. Hovering hides the dots and highlights the splitter with the theme color; leaving restores the grip. + +> The three-dot grip requires a library version containing this change. Earlier NuGet packages may not include this style. + +#### Vertical Splitter: Side-by-Side Panes + +Place the splitter in a dedicated `Auto` column and set `Width` and `ResizeDirection="Columns"`: + +```xml + + + + + + + + + + + + + + +``` + +#### Horizontal Splitter: Stacked Panes + +Place the splitter in a dedicated `Auto` row and set `Height` and `ResizeDirection="Rows"`. The three-dot grip rotates to a horizontal arrangement: + +```xml + + + + + + + + + + + + + + +``` + +Configuration notes: + +- Set `ResizeDirection` explicitly: `Columns` resizes adjacent columns; `Rows` resizes adjacent rows. The current grip style rotates through the `Rows` trigger, not through the effective direction inferred by `Auto`. +- `ResizeBehavior="PreviousAndNext"` resizes the rows or columns on either side of the splitter, matching the dedicated row/column layouts above. +- `ShowsPreview="True"` previews the resize and applies it on release; `False` resizes immediately. Preview mode requires an `AdornerLayer` in the visual tree, which standard WPF windows normally provide. +- Set `MinWidth` / `MinHeight` on content columns/rows to prevent panes from becoming too small. +- `Margin="2,0"` adds 2 DIPs on each side; `Margin="0,2"` adds 2 DIPs above and below. Margins on neighboring containers add to this spacing, so prefer configuring the gap on the splitter alone. The transparent background remains hit-testable for dragging. +- `Foreground` controls the dot color; the hover background uses the theme resource `WD.PrimaryBrush`. + +Find the interactive demo under **Basic → GridSplitter** in the sample application. See [GridSplitterExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Basics/GridSplitterExample.xaml) for the source. + ### MarkdownViewer Usage `wd:MarkdownViewer` renders Markdown content as rich text in WPF, which is ideal for README files, help documentation, changelogs, and in-app knowledge content. It supports common Markdown elements such as headings, lists, blockquotes, code blocks, tables, links, and images. @@ -239,6 +338,35 @@ If you need to display a README, help document, release notes, or internal docum ``` +#### Back-to-top and back-to-bottom + +Set `ScrollViewerBehavior.IsBackToTopEnabled` and/or `ScrollViewerBehavior.IsBackToBottomEnabled` to `True` on a scrollable control. The corresponding button appears at the bottom-right while the pointer or keyboard focus is within the control, and hides when the content reaches its destination. + +```xml + + + + + + + + + +``` + +The behavior can also be set directly on `ScrollViewer`, `WDScrollViewer`, or `TreeView`. For a `Panel`, set it on the containing `ScrollViewer` because panels do not provide scrolling themselves. It does not replace the `ItemsPanel`, so list virtualization is preserved. + +Open the **Attached Properties** menu in the sample application to see an interactive example. + ### 3. Static Resource Styles ```xml @@ -280,7 +408,9 @@ WD provides a set of theme resources you can reference in XAML: ## Complete Control Catalog -> **Important**: Controls marked 🟡 Sample-only are defined in `WPFDevelopers.Samples.Shared/Controls/` and are **NOT** part of the NuGet package (`wd:` namespace). They are only available in the sample project. All other controls can be used directly via the `wd:` prefix after NuGet installation. +> **Important**: Implementations marked 🟡 Sample-only live in the sample project's `Controls/` or `ExampleViews/` folders and are not shipped as built-in WD controls in the NuGet package. They may compose native WPF controls with WD styles, controls, or helpers. + +The sample navigation identifies these implementations and composed effects with a blue-gray `DEMO` badge. Hover for an explanation; the tooltip follows the selected language. `NEW` and `UPDATE` remain independent change-status badges and can appear alongside `DEMO`; for example, ActivityFeed can show both `DEMO` and `UPDATE`. Ordinary usage samples for built-in WD controls and helpers do not receive `DEMO`. ### Windows & Navigation @@ -338,11 +468,11 @@ WD provides a set of theme resources you can reference in XAML: | `wd:IPEditBox` | NuGet | [IPEditBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml) | IP address input | | `wd:MultiSelectComboBox` | NuGet | [MultiSelectComboBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectComboBoxExample.xaml) | Multi-select combo box | | 🟡 MultiSelectSearchComboBox | Sample-only | [MultiSelectSearchComboBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml) | Searchable multi-select combo box | -| `wd:Password` | NuGet | [PasswordExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Passwrod/PasswordExample.xaml) | Password show/hide toggle | +| 🟡 Password | Sample-only | [PasswordExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Passwrod/PasswordExample.xaml) | Composed password show/hide sample | | `wd:VerifyCode` | NuGet | [VerifyCodeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/VerifyCodeExample.xaml) | CAPTCHA drawing | | 🟡 RoundPicker | Sample-only | [RoundPickerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RoundPickerExample.xaml) | Circular color picker | -| `wd:RulerControl` | NuGet | [RulerControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml) | Ruler control | -| 🟡 Selector | Sample-only | [SelectorExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SelectorExample.xaml) | Selector control | +| `wd:RulerControl` | NuGet | [RulerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml) | Ruler control | +| `wd:ScrollIntoView` | NuGet | [SelectorExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SelectorExample.xaml) | List positioning helper | | `wd:Dial` | NuGet | [DialExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DialExample.xaml) | Dial pad | | `wd:GestureUnlock` | NuGet | [GestureUnlockExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/GestureUnlockExample.xaml) | Gesture pattern unlock | | `wd:SvgViewer` | NuGet | [SvgViewerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SvgViewerExample.xaml) | SVG viewer | @@ -369,14 +499,14 @@ WD provides a set of theme resources you can reference in XAML: | `wd:ChartLine` | NuGet | [ChartLineExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml) | Line chart | | `wd:ChartPie` | NuGet | [ChartPieExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml) | Pie chart | | 🟡 Dashboard | Sample-only | [DashboardExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DashboardExample.xaml) | Dashboard gauge (tick marks follow progress) | -| 🟡 PieControl | Sample-only | [PieControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml) | Pie chart statistics | +| 🟡 PieSegment | Sample-only | [PieSegmentExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml) | Segmented pie chart sample (distinct from `wd:ChartPie`) | | `wd:Gauge` | NuGet | [GaugeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/GaugeExample.xaml) | Gauge control | | 🟡 LineChart | Sample-only | [LineChartExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/LineChartExample.xaml) | Line chart (alternate implementation) | | `wd:CircleProgressBar` | NuGet | [CircleProgressBarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CircleProgressBarExample.xaml) | Circular progress bar | | `wd:Step` | NuGet | [StepExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/StepExample.xaml) | Step wizard | | `wd:BreadCrumbBar` | NuGet | [BreadCrumbBarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BreadCrumbBarExample.xaml) | Breadcrumb navigation | | `wd:Pagination` | NuGet | [PaginationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml) | Pagination control | -| 🟡 TimeLineControl | Sample-only | [TimeLineExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/TimeLineExample.xaml) | Timeline (Gitee-style) | +| 🟡 ActivityFeed | Sample-only | [ActivityFeedExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ActivityFeedExample.xaml) | Activity feed (Gitee-style) | | `wd:Thermometer` | NuGet | [ThermometerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml) | Thermometer | | `wd:DataGridFilter` | NuGet | [DataGridFilterExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DataGridFilterExample.xaml) | DataGrid column filter engine | @@ -390,14 +520,64 @@ WD provides a set of theme resources you can reference in XAML: | `wd:CircleMenu` | NuGet | [CircleMenuExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CircleMenuExample.xaml) | Circular menu | | `wd:SixGridView` | NuGet | [SixGirdViewExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml) | Six-column grid layout | | `wd:WaterfallPanel` | NuGet | [WaterfallPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml) | Waterfall / masonry panel | +| `wd:WaterfallItemsControl` | NuGet | [WaterfallPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml) | Masonry items control with a scrolling template | | `wd:VirtualizingWrapPanel` | NuGet | [VirtualizingWrapPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/VirtualizingWrapPanelExample.xaml) | Virtualizing WrapPanel | | 🟡 TransformLayout | Sample-only | [TransformLayoutExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/TransformLayoutExample.xaml) | Draggable, resizable, rotatable control | | `wd:DrapView` | NuGet | [DrapViewExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml) | Drag-and-drop view | | `wd:Spacing` (attached) | NuGet | [SpacingExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml) | Panel child spacing | | `wd:PanningItems` | NuGet | [PanningItemsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PanningItemsExample.xaml) | Panning control (touch swipe) | -| 🟡 ScrollViewerAnimation | Sample-only | [ScrollViewerAnimationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml) | Animated scrollbar | +| `wd:WDScrollViewer` / `wd:ScrollViewerBehavior` | NuGet | [ScrollViewerAnimationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml) | Animated scrolling and back-to-top helper | | `wd:IconicThumbnail` | NuGet | [IconicThumbnailExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/IconicThumbnailExample.xaml) | Iconic thumbnail | +#### WaterfallPanel: responsive columns and virtualization + +Scrolling reuses cached item positions and uses per-column binary searches to select nearby items. +Positions are rebuilt when width, data, or measured realized-item heights change. +`WDScrollViewer` retains smooth scrolling: consecutive wheel input accumulates its target, +while direction changes restart from the current offset. Animations last 250ms without a fixed +40 FPS cap. Actual smoothness depends on item templates and hardware. +These changes use APIs available in .NET Framework 4.0. Windows 7 requires a compatible +.NET Framework build; this does not imply Windows 7 support for modern .NET targets. + +For data binding, use `WaterfallItemsControl` without an outer `ScrollViewer`: + +```xml + + + + + + + +``` + +It inherits `ItemsSource`, `ItemTemplate`, and `ItemTemplateSelector`, enables recycling by default, +and exposes `Columns`, `MinColumnWidth`, `Spacing`, and `EstimatedItemHeight`. +Use `ScrollViewer.VerticalScrollBarVisibility` to control the scrollbar. +A finite host height is still required for virtualization. Use `WaterfallPanel` for direct XAML +children or custom hosts. + +`Columns` defaults to 3. `MinColumnWidth` defaults to 0 (fixed columns). +A positive `MinColumnWidth` selects `max(1, floor((availableWidth + Spacing) / (MinColumnWidth + Spacing)))` +columns. A narrow container still has one column, which may be narrower than the minimum. +`ActualColumns` reports the selected count. With infinite available width, `Columns` is used, +and the widest natural item width (at least `MinColumnWidth`) determines the column width. + +The same panel supports direct XAML children and `ItemsControl.ItemsSource`. +For UI virtualization, give the host a finite viewport and use an `ItemsControl` template containing +`ScrollViewer CanContentScroll="True"` with an `ItemsPresenter` as its content. +Set `VirtualizingStackPanel.IsVirtualizing="True"` and `VirtualizingStackPanel.VirtualizationMode="Recycling"` +on the `ItemsControl`, and use `WaterfallPanel` as its `ItemsPanel`. +Do not wrap this host in a vertical `StackPanel` or an outer scroller providing infinite height. +Without a finite scrolling viewport the panel generates all containers; setting `IsVirtualizing="False"` +also generates all containers. + +Unmeasured items use `EstimatedItemHeight` (default 200). Actual measurements update positions and +the scroll extent, so distant jumps and asynchronously loaded images may cause layout shifts. +Reserve a suitable initial height for asynchronous content. +This is UI, not data, virtualization: metadata storage is O(item count), and layout calculation is +O(item count × columns). The example includes XAML, MVVM, and a 5000-card virtualization tab. + ### Animation & Effects | Control | Source | Example File | Description | @@ -407,7 +587,7 @@ WD provides a set of theme resources you can reference in XAML: | `wd:EdgeLight` | NuGet | [EdgeLightExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml) | Edge marquee light | | 🟡 RainbowButtons | Sample-only | [RainbowButtonsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml) | Rainbow buttons | | `wd:Shake` | NuGet | [ShakeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ShakeExample.xaml) | Window shake | -| 🟡 BubblleControl | Sample-only | [BubblleControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml) | Bubble animation | +| 🟡 BubbleSelection | Sample-only | [BubbleSelectionExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BubbleSelectionExample.xaml) | Bubble selection sample | | `wd:StarrySky` | NuGet | [StarrySkyExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/StarrySkyExample.xaml) | Starry sky animation | | 🟡 SnowCanvas | Sample-only | [SnowCanvasExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SnowCanvasExample.xaml) | Christmas tree & snow canvas | | 🟡 SpeedRockets | Sample-only | [SpeedRocketsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SpeedRockets/SpeedRocketsExample.xaml) | Speed rocket animation | @@ -435,7 +615,7 @@ WD provides a set of theme resources you can reference in XAML: | `wd:ScreenCut` | NuGet | [ScreenCutExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScreenCutExample.xaml) | Screen capture (pen / arrow annotation) | | `wd:CropImage` | NuGet | [CropImageExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropImageExample.xaml) | Image cropping | | `wd:CropAvatar` | NuGet | [CropAvatarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropAvatar/CropAvatarExample.xaml) | Avatar cropping selector | -| 🟡 CropControl | Sample-only | [CropControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropControlExample.xaml) | Image nine-grid cutter | +| 🟡 ImageCrop | Sample-only | [ImageCropExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml) | Image nine-grid tiling effect sample | | 🟡 CutImage | Sample-only | [CutImageExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml) | User avatar cropping solution | | `wd:Magnifier` | NuGet | [MagnifierExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml) | Magnifier | @@ -455,7 +635,7 @@ WD provides a set of theme resources you can reference in XAML: | Control | Source | Example File | Description | |---------|--------|-------------|-------------| | 🟡 ZooSemy | Sample-only | [ZooSemyExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ZooSemy/ZooSemyExample.xaml) | Skeuomorphic rotary knob (volume) | -| 🟡 OtherControl | Sample-only | [OtherControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml) | Torch & other fun controls | +| 🟡 Flame | Sample-only | [FlameExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/FlameExample.xaml) | Flame animation | | 🟡 Desktop | Sample-only | [DesktopBackground.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Desktop/DesktopBackground.xaml) | Dynamic desktop wallpaper | | 🟡 AMap | Sample-only | [BingAMapExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml) | Map integration (Bing / AutoNavi) | | 🟡 LoginWindow | Sample-only | [LoginExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/LoginWindow/LoginExample.xaml) | Login window template | diff --git a/docs/zh/getting-started.md b/docs/zh/getting-started.md index 69d4ef40..307a14b8 100644 --- a/docs/zh/getting-started.md +++ b/docs/zh/getting-started.md @@ -17,8 +17,6 @@ WPFDevelopers 覆盖从 .NET Framework 4.0 到 .NET 10 的完整版本线: - Visual Studio 2026 - .NET Framework 4.0 或更高 / .NET Core 3.0 或更高 ---- - ## MapView 专题文档 如果你要使用地图控件,建议直接阅读: @@ -108,6 +106,107 @@ xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers" ``` +### ColorPicker 使用方式 + +`ColorPicker` 保留内嵌面板用法,底部下拉框可直接选择 RGB、HSL 或 HEX,支持通过 `ColorType` 设置初始格式。 + +```xml + +``` + +同一个 `ColorPicker` 设置 `DisplayMode="Popup"` 后,提供点击色块打开面板的用法;默认 `DisplayMode="Inline"` 保留现有内嵌展示: + +```xml + + +``` + +- `SelectedColor` 为 `Color`,默认双向绑定,修改颜色时立即同步,无需确认。 +- `ShowColorText` 默认为 `False`;启用后在色块右侧显示 HEX,不透明颜色为 `#RRGGBB`,带透明度颜色为 `#AARRGGBB`。 +- `SwatchSize` 为色块边长,默认为 18,可设置为 24、32 等正数;触发器总尺寸还包含 `Padding` 和边框。 +- `IsDropDownOpen` 支持双向绑定;点击外部或按 Esc 关闭,F4 或 Alt+下箭头切换打开状态,也可通过聚焦触发器后按空格打开。 +- 鼠标点击触发器时,在松开后展开面板,以保证外部点击关闭所需的鼠标捕获;切换格式后仍可点击外部关闭。 +- `ShowColorText`、`SwatchSize` 和 `IsDropDownOpen` 用于 Popup 模式,Inline 模式不会打开弹窗。运行时切换 `DisplayMode` 会关闭弹窗并保留颜色和格式。 +- `SelectedColorChanged` 为颜色改变时触发的冒泡事件。两种模式共用取色逻辑及主题资源,控件的 `Width`、`Height` 和 `Padding` 在 Popup 模式下设置触发器尺寸,不影响内部面板。 + +### GridSplitter 使用方式 + +`GridSplitter` 是标准 WPF 控件,不需要 `wd:` 前缀。完成上述主题配置后即可使用默认样式:背景透明、居中显示三个圆点,鼠标进入时隐藏圆点并显示主题色分隔条,移出后恢复。 + +> 三点手柄样式需要使用包含此改动的控件库版本;较早的 NuGet 包可能尚未包含该样式。 + +#### 垂直分隔条:左右分栏 + +使用独立的 `Auto` 列放置分隔条,设置 `Width` 和 `ResizeDirection="Columns"`: + +```xml + + + + + + + + + + + + + + +``` + +#### 水平分隔条:上下分栏 + +使用独立的 `Auto` 行放置分隔条,设置 `Height` 和 `ResizeDirection="Rows"`;此时三个圆点会旋转为水平排列: + +```xml + + + + + + + + + + + + + + +``` + +配置要点: + +- 显式设置 `ResizeDirection`:`Columns` 调整左右列宽,`Rows` 调整上下行高。当前手柄样式通过 `Rows` 触发器旋转三点,不会根据 `Auto` 的实际拖动方向自动旋转。 +- `ResizeBehavior="PreviousAndNext"` 调整分隔条两侧的行或列,适合上述独立行/列布局。 +- `ShowsPreview="True"` 拖动时显示预览,松开后应用尺寸;`False` 则实时调整。预览模式需要所在的可视树中存在 `AdornerLayer`,标准 WPF 窗口通常已提供。 +- 为内容行/列设置 `MinWidth` / `MinHeight`,避免拖动后内容区过小。 +- `Margin="2,0"` 表示左右各留 2 DIP;`Margin="0,2"` 表示上下各留 2 DIP。相邻容器的外边距会叠加,建议统一在分隔条上配置间距。透明背景仍保留拖动命中区域。 +- `Foreground` 控制圆点颜色;悬停背景使用主题资源 `WD.PrimaryBrush`。 + +交互示例位于示例程序的 **基础控件 → GridSplitter(网格分隔条)**,源码参见 [GridSplitterExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Basics/GridSplitterExample.xaml)。 + ### MarkdownViewer 使用方式 `wd:MarkdownViewer` 用于将 Markdown 文本渲染为 WPF 中的富文本展示,适合展示说明文档、README、日志、知识库内容等。它支持标题、列表、引用、代码块、表格、链接、图片等常见 Markdown 语法。 @@ -243,6 +342,35 @@ public string MarkdownText { get; } = "# WPFDevelopers\n\n- 支持标题\n- 支 ``` +#### 回到顶部和回到底部 + +在可滚动控件上将 `ScrollViewerBehavior.IsBackToTopEnabled` 和/或 `ScrollViewerBehavior.IsBackToBottomEnabled` 设置为 `True`。当光标或键盘焦点进入控件时,对应按钮会显示在控件右下角;到达目标位置后自动隐藏。 + +```xml + + + + + + + + + +``` + +该附加属性也可直接用于 `ScrollViewer`、`WDScrollViewer` 和 `TreeView`。`Panel` 本身不提供滚动能力,应将属性设置在包裹它的 `ScrollViewer` 上。该行为不会修改 `ItemsPanel`,因此不会影响列表虚拟化。 + +示例程序中可打开 **附加属性** 菜单查看交互示例。 + ### 3. 静态资源样式 ```xml @@ -284,7 +412,9 @@ WD 提供了一套主题资源,可在 XAML 中引用: ## 控件全览 -> **重要说明**:以下列表中带有 🟡 示例专属 标记的控件定义在 `WPFDevelopers.Samples.Shared/Controls/` 目录中,**不**属于 NuGet 包(`wd:` 命名空间),仅在示例项目中可用。其余控件均可通过 NuGet 安装后以 `wd:` 前缀直接使用。 +> **重要说明**:以下列表中带有 🟡 示例专属 标记的实现位于示例项目的 `Controls/` 或 `ExampleViews/` 中,不作为 WD 内置控件随 NuGet 包提供。示例可能组合使用 WPF 原生控件及 WD 样式、控件或辅助功能。 + +示例导航使用蓝灰色 `DEMO` 标识这些示例专属实现或组合效果。悬停可查看说明,中英文切换时提示同步更新。`NEW`(新增)和 `UPDATE`(更新)仍只表示更新状态,与 `DEMO` 独立,可同时显示;例如“活动记录”可以同时显示 `DEMO` 和 `UPDATE`。WD 内置控件及辅助功能的常规用法示例不加 `DEMO`。 ### 窗口与导航 @@ -342,11 +472,11 @@ WD 提供了一套主题资源,可在 XAML 中引用: | `wd:IPEditBox` | NuGet | [IPEditBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml) | IP 地址输入框 | | `wd:MultiSelectComboBox` | NuGet | [MultiSelectComboBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectComboBoxExample.xaml) | 下拉多选框 | | 🟡 MultiSelectSearchComboBox | 示例专属 | [MultiSelectSearchComboBoxExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml) | 下拉搜索多选框 | -| `wd:Password` | NuGet | [PasswordExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Passwrod/PasswordExample.xaml) | 密码显示/隐藏切换 | +| 🟡 Password | 示例专属 | [PasswordExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Passwrod/PasswordExample.xaml) | 密码显示/隐藏组合示例 | | `wd:VerifyCode` | NuGet | [VerifyCodeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/VerifyCodeExample.xaml) | 验证码绘制 | | 🟡 RoundPicker | 示例专属 | [RoundPickerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RoundPickerExample.xaml) | 圆形颜色选择器 | -| `wd:RulerControl` | NuGet | [RulerControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml) | 刻度尺控件 | -| 🟡 Selector | 示例专属 | [SelectorExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SelectorExample.xaml) | 选择器控件 | +| `wd:RulerControl` | NuGet | [RulerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml) | 刻度尺控件 | +| `wd:ScrollIntoView` | NuGet | [SelectorExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SelectorExample.xaml) | 列表定位辅助功能 | | `wd:Dial` | NuGet | [DialExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DialExample.xaml) | 拨号盘控件 | | `wd:GestureUnlock` | NuGet | [GestureUnlockExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/GestureUnlockExample.xaml) | 手势解锁 | | `wd:SvgViewer` | NuGet | [SvgViewerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SvgViewerExample.xaml) | SVG 查看器 | @@ -373,14 +503,14 @@ WD 提供了一套主题资源,可在 XAML 中引用: | `wd:ChartLine` | NuGet | [ChartLineExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml) | 折线图 | | `wd:ChartPie` | NuGet | [ChartPieExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml) | 饼图 | | 🟡 Dashboard | 示例专属 | [DashboardExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DashboardExample.xaml) | 仪表盘(刻度跟随进度) | -| 🟡 PieControl | 示例专属 | [PieControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml) | 统计饼图 | +| 🟡 PieSegment | 示例专属 | [PieSegmentExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml) | 分段饼图示例(区别于 `wd:ChartPie`) | | `wd:Gauge` | NuGet | [GaugeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/GaugeExample.xaml) | 仪表盘 | | 🟡 LineChart | 示例专属 | [LineChartExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/LineChartExample.xaml) | 折线图(另一实现) | | `wd:CircleProgressBar` | NuGet | [CircleProgressBarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CircleProgressBarExample.xaml) | 环形进度条 | | `wd:Step` | NuGet | [StepExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/StepExample.xaml) | 步骤条向导 | | `wd:BreadCrumbBar` | NuGet | [BreadCrumbBarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BreadCrumbBarExample.xaml) | 面包屑导航栏 | | `wd:Pagination` | NuGet | [PaginationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PaginationExample.xaml) | 分页控件 | -| 🟡 TimeLineControl | 示例专属 | [TimeLineExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/TimeLineExample.xaml) | 时间轴(仿 Gitee) | +| 🟡 ActivityFeed | 示例专属 | [ActivityFeedExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ActivityFeedExample.xaml) | 活动记录(仿 Gitee) | | `wd:Thermometer` | NuGet | [ThermometerExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ThermometerExample.xaml) | 温度计 | | `wd:DataGridFilter` | NuGet | [DataGridFilterExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DataGridFilterExample.xaml) | DataGrid 列过滤引擎 | @@ -394,14 +524,80 @@ WD 提供了一套主题资源,可在 XAML 中引用: | `wd:CircleMenu` | NuGet | [CircleMenuExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CircleMenuExample.xaml) | 圆形菜单 | | `wd:SixGridView` | NuGet | [SixGirdViewExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml) | 六宫格布局 | | `wd:WaterfallPanel` | NuGet | [WaterfallPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml) | 瀑布流面板 | +| `wd:WaterfallItemsControl` | NuGet | [WaterfallPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/WaterfallPanelExample.xaml) | 内置滚动模板的瀑布流集合控件 | | `wd:VirtualizingWrapPanel` | NuGet | [VirtualizingWrapPanelExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/VirtualizingWrapPanelExample.xaml) | 虚拟化 WrapPanel | | 🟡 TransformLayout | 示例专属 | [TransformLayoutExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/TransformLayoutExample.xaml) | 可拖拽旋转缩放控件 | | `wd:DrapView` | NuGet | [DrapViewExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/DrapView/DrapViewExample.xaml) | 拖拽视图控件 | | `wd:Spacing`(附加属性) | NuGet | [SpacingExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml) | 面板子元素间距 | | `wd:PanningItems` | NuGet | [PanningItemsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/PanningItemsExample.xaml) | 平移控件 | -| 🟡 ScrollViewerAnimation | 示例专属 | [ScrollViewerAnimationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml) | 带动画的滚动条 | +| `wd:WDScrollViewer` / `wd:ScrollViewerBehavior` | NuGet | [ScrollViewerAnimationExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml) | 动画滚动视图与回到顶部辅助功能 | | `wd:IconicThumbnail` | NuGet | [IconicThumbnailExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/IconicThumbnailExample.xaml) | 图标缩略图 | +#### WaterfallPanel:响应式列数与虚拟化 + +瀑布流滚动复用项目位置缓存,并通过列内二分查找选择视口附近的项目; +宽度、数据或已实现项目的测量高度变化时才重建位置。 +`WDScrollViewer` 保留平滑滚动,连续同向滚轮输入累计目标位置,反向输入从当前位置开始, +动画时长为 250ms,不再固定限制为 40 FPS。实际流畅度取决于项目模板和设备性能。 +这些优化只使用 .NET Framework 4.0 已有 API;Win7 应选择兼容的 .NET Framework 构建, +不能因此认为现代 .NET 目标也支持 Win7。 + +数据绑定场景推荐使用 `WaterfallItemsControl`,不需要再套外层 `ScrollViewer`: + +```xml + + + + + + + +``` + +它继承 `ItemsControl` 的 `ItemsSource`、`ItemTemplate`、`ItemTemplateSelector`, +默认启用容器回收,并提供 `Columns`、`MinColumnWidth`、`Spacing`、`EstimatedItemHeight`。 +通过 `ScrollViewer.VerticalScrollBarVisibility` 控制滚动条,仍需由父布局提供有限高度才能虚拟化。 +直接 XAML 子项或自行配置宿主时继续使用 `WaterfallPanel`。 + +`Columns` 默认为 3;`MinColumnWidth` 默认为 0,保留固定列数。 +设置 `MinColumnWidth="200"` 后,列数按 `floor((可用宽度 + Spacing) / (MinColumnWidth + Spacing))` +计算,最少一列。容器不足最小列宽时,单列会缩小到容器宽度;`ActualColumns` 可读取当前列数。 +无限宽度下使用 `Columns`,按子项最大自然宽度(且不小于 `MinColumnWidth`)计算列宽。 + +同一个 `WaterfallPanel` 支持直接 XAML 子元素和 `ItemsControl.ItemsSource`。 +真正的 UI 虚拟化需要有限视口,并由 `ScrollViewer` 通过 `CanContentScroll="True"` +将滚动交给面板。例如: + +```xml + + + + + + + + + + + + + + + +``` + +不要将该虚拟化宿主放入垂直 `StackPanel` 或另一个提供无限高度的外层滚动容器; +缺少有限视口或滚动协作时会退回全部容器布局。`IsVirtualizing="False"` 也会生成全部容器。 +未测量项使用 `EstimatedItemHeight`(默认 200),测得真实高度后会修正布局与滚动范围, +因此远距离跳转、图片异步加载时位置可能变化。异步内容应预留合理高度。 +这是容器虚拟化,不是数据虚拟化:布局元数据仍随项目数增长,布局计算为 O(项目数 × 列数)。 +示例包含 XAML、MVVM 和 5000 个不同高度卡片的虚拟化演示。 + ### 动画与特效 | 控件名 | 来源 | 示例文件 | 说明 | @@ -411,7 +607,7 @@ WD 提供了一套主题资源,可在 XAML 中引用: | `wd:EdgeLight` | NuGet | [EdgeLightExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/EdgeLightExample.xaml) | 边框跑马灯 | | 🟡 RainbowButtons | 示例专属 | [RainbowButtonsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml) | 彩虹按钮 | | `wd:Shake` | NuGet | [ShakeExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ShakeExample.xaml) | 窗体抖动 | -| 🟡 BubblleControl | 示例专属 | [BubblleControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BubblleControlExample.xaml) | 泡泡动画控件 | +| 🟡 BubbleSelection | 示例专属 | [BubbleSelectionExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/BubbleSelectionExample.xaml) | 气泡选择示例 | | `wd:StarrySky` | NuGet | [StarrySkyExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/StarrySkyExample.xaml) | 星空动画 | | 🟡 SnowCanvas | 示例专属 | [SnowCanvasExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SnowCanvasExample.xaml) | 圣诞树雪花 Canvas | | 🟡 SpeedRockets | 示例专属 | [SpeedRocketsExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/SpeedRockets/SpeedRocketsExample.xaml) | 加速火箭动画 | @@ -439,7 +635,7 @@ WD 提供了一套主题资源,可在 XAML 中引用: | `wd:ScreenCut` | NuGet | [ScreenCutExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ScreenCutExample.xaml) | 截屏工具(画笔/箭头标注) | | `wd:CropImage` | NuGet | [CropImageExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropImageExample.xaml) | 图片裁剪 | | `wd:CropAvatar` | NuGet | [CropAvatarExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropAvatar/CropAvatarExample.xaml) | 头像裁剪选择器 | -| 🟡 CropControl | 示例专属 | [CropControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CropControlExample.xaml) | 图片切九宫格控件 | +| 🟡 ImageCrop | 示例专属 | [ImageCropExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml) | 图片九宫格分块效果示例 | | 🟡 CutImage | 示例专属 | [CutImageExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/CutImageExample.xaml) | 用户头像裁剪方案 | | `wd:Magnifier` | NuGet | [MagnifierExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/MagnifierExample.xaml) | 放大镜 | @@ -459,7 +655,7 @@ WD 提供了一套主题资源,可在 XAML 中引用: | 控件名 | 来源 | 示例文件 | 说明 | |--------|------|----------|------| | 🟡 ZooSemy | 示例专属 | [ZooSemyExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/ZooSemy/ZooSemyExample.xaml) | 拟物旋转按钮(音量旋钮) | -| 🟡 OtherControl | 示例专属 | [OtherControlExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml) | 火炬等趣味控件 | +| 🟡 Flame | 示例专属 | [FlameExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/FlameExample.xaml) | 火苗动画 | | 🟡 Desktop | 示例专属 | [DesktopBackground.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Desktop/DesktopBackground.xaml) | 动态桌面壁纸(视频播放) | | 🟡 AMap | 示例专属 | [BingAMapExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml) | 地图集成(Bing/高德) | | 🟡 LoginWindow | 示例专属 | [LoginExample.xaml](../../src/WPFDevelopers.Samples.Shared/ExampleViews/LoginWindow/LoginExample.xaml) | 登录窗口模板 | diff --git a/src/Microsoft.Windows.Shell/WindowChromeWorker.cs b/src/Microsoft.Windows.Shell/WindowChromeWorker.cs index ec9b940b..5f0a5d6d 100644 --- a/src/Microsoft.Windows.Shell/WindowChromeWorker.cs +++ b/src/Microsoft.Windows.Shell/WindowChromeWorker.cs @@ -319,13 +319,13 @@ private IntPtr _HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, out bool { Point point = new Point((double)Utility.GET_X_LPARAM(lParam), (double)Utility.GET_Y_LPARAM(lParam)); Rect deviceRectangle = this._GetWindowRect(); - HT ht = this._HitTestNca(DpiHelper.DeviceRectToLogical(deviceRectangle), DpiHelper.DevicePixelsToLogical(point)); + Point windowOrigin = this._window.PointFromScreen(deviceRectangle.TopLeft); + Point windowEnd = this._window.PointFromScreen(deviceRectangle.BottomRight); + Point logicalPoint = this._window.PointFromScreen(point); + HT ht = this._HitTestNca(new Rect(windowOrigin, windowEnd), logicalPoint); if (ht != HT.CLIENT) { - Point point2 = point; - point2.Offset(-deviceRectangle.X, -deviceRectangle.Y); - point2 = DpiHelper.DevicePixelsToLogical(point2); - IInputElement inputElement = this._window.InputHitTest(point2); + IInputElement inputElement = this._window.InputHitTest(logicalPoint); if (inputElement != null && WindowChrome.GetIsHitTestVisibleInChrome(inputElement)) { ht = HT.CLIENT; @@ -578,7 +578,7 @@ private void _SetRoundingRegion(WINDOWPOS? wp) try { double num3 = Math.Min(size.Width, size.Height); - double num4 = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.CornerRadius.TopLeft, 0.0)).X; + double num4 = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.CornerRadius.TopLeft, 0.0)).X; num4 = Math.Min(num4, num3 / 2.0); if (WindowChromeWorker._IsUniform(this._chromeInfo.CornerRadius)) { @@ -587,17 +587,17 @@ private void _SetRoundingRegion(WINDOWPOS? wp) else { intPtr = WindowChromeWorker._CreateRoundRectRgn(new Rect(0.0, 0.0, size.Width / 2.0 + num4, size.Height / 2.0 + num4), num4); - double num5 = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.CornerRadius.TopRight, 0.0)).X; + double num5 = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.CornerRadius.TopRight, 0.0)).X; num5 = Math.Min(num5, num3 / 2.0); Rect region = new Rect(0.0, 0.0, size.Width / 2.0 + num5, size.Height / 2.0 + num5); region.Offset(size.Width / 2.0 - num5, 0.0); WindowChromeWorker._CreateAndCombineRoundRectRgn(intPtr, region, num5); - double num6 = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.CornerRadius.BottomLeft, 0.0)).X; + double num6 = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.CornerRadius.BottomLeft, 0.0)).X; num6 = Math.Min(num6, num3 / 2.0); Rect region2 = new Rect(0.0, 0.0, size.Width / 2.0 + num6, size.Height / 2.0 + num6); region2.Offset(0.0, size.Height / 2.0 - num6); WindowChromeWorker._CreateAndCombineRoundRectRgn(intPtr, region2, num6); - double num7 = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.CornerRadius.BottomRight, 0.0)).X; + double num7 = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.CornerRadius.BottomRight, 0.0)).X; num7 = Math.Min(num7, num3 / 2.0); Rect region3 = new Rect(0.0, 0.0, size.Width / 2.0 + num7, size.Height / 2.0 + num7); region3.Offset(size.Width / 2.0 - num7, size.Height / 2.0 - num7); @@ -661,8 +661,8 @@ private void _ExtendGlassFrame() return; } this._hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; - Point point = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.GlassFrameThickness.Left, this._chromeInfo.GlassFrameThickness.Top)); - Point point2 = DpiHelper.LogicalPixelsToDevice(new Point(this._chromeInfo.GlassFrameThickness.Right, this._chromeInfo.GlassFrameThickness.Bottom)); + Point point = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.GlassFrameThickness.Left, this._chromeInfo.GlassFrameThickness.Top)); + Point point2 = this._hwndSource.CompositionTarget.TransformToDevice.Transform(new Point(this._chromeInfo.GlassFrameThickness.Right, this._chromeInfo.GlassFrameThickness.Bottom)); MARGINS margins = new MARGINS { cxLeftWidth = (int)Math.Ceiling(point.X), diff --git a/src/Package.props b/src/Package.props index 54a1ca80..615f3c1a 100644 --- a/src/Package.props +++ b/src/Package.props @@ -7,9 +7,9 @@ true snupkg Copyright © WPFDevelopersOrg 2026 - 0.3.0.0 - 0.3.0.0 - 0.3.0.0 + 0.4.0.0 + 0.4.0.0 + 0.4.0.0 https://github.com/WPFDevelopersOrg/WPFDevelopers Debug;Release;Debug-.NET40;Release-.NET40 diff --git a/src/Resources.props b/src/Resources.props index b41fbb04..7fdeed8c 100644 --- a/src/Resources.props +++ b/src/Resources.props @@ -80,6 +80,9 @@ Resources\Svg\%(Filename)%(Extension) + + Resources\MenuIcons\%(Filename)%(Extension) + WPFDevelopers.Samples diff --git a/src/WPFDevelopers.Net40/Themes/Theme.xaml b/src/WPFDevelopers.Net40/Themes/Theme.xaml index db40b038..20177e00 100644 --- a/src/WPFDevelopers.Net40/Themes/Theme.xaml +++ b/src/WPFDevelopers.Net40/Themes/Theme.xaml @@ -56,6 +56,7 @@ M0.99999994,0.99999994 L0.99999994,9 9,9 9,0.99999994 z M0,0 L10,0 10,10 0,10 z M1,3 L1,9 7,9 7,3 z M3,0.99999994 L3,2 8,2 8,7 9,7 9,0.99999994 z M2,0 L10,0 10,8 8,8 8,10 0,10 0,2 2,2 z M 1301 69.6875 L 1305.3049 74 L 1300.9375 78.5313 L 1301.6324 79.2263 L 1306 74.735 L 1310.4263 79.2613 L 1311.1563 78.5313 L 1306.7 74 L 1310.9375 69.6875 L 1310.2075 68.9575 L 1306 73.265 L 1301.6949 68.9925 L 1301 69.6875 Z + M10,31 C10,31 1.8,21.6 1.8,13.2 C1.8,7.1 5.3,3.2 10,3.2 C14.7,3.2 18.2,7.1 18.2,13.2 C18.2,21.6 10,31 10,31 Z M 426 726 L 810 342 L 750 280 L 426 666 L 274 514 L 214 574 Z M 512 86 C 748 86 938 276 938 512 C 938 748 748 938 512 938 C 276 938 86 748 86 512 C 86 276 276 86 512 86 Z M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512-230.4 512-512 512zM576 128h-128v128h128v-128zM576 320h-128v448h128v-448z M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512-230.4 512-512 512zM576 128h-128v448h128v-448zM576 640h-128v128h128v-128z @@ -101,6 +102,11 @@ M13 2h-1v1.5c0 .28-.22.5-.5.5h-2c-.28 0-.5-.22-.5-.5V2H6v1.5c0 .28-.22.5-.5.5h-2c-.28 0-.5-.22-.5-.5V2H2c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 12H2V5h11v9zM5 3H4V1h1v2zm6 0h-1V1h1v2zM6 7H5V6h1v1zm2 0H7V6h1v1zm2 0H9V6h1v1zm2 0h-1V6h1v1zM4 9H3V8h1v1zm2 0H5V8h1v1zm2 0H7V8h1v1zm2 0H9V8h1v1zm2 0h-1V8h1v1zm-8 2H3v-1h1v1zm2 0H5v-1h1v1zm2 0H7v-1h1v1zm2 0H9v-1h1v1zm2 0h-1v-1h1v1zm-8 2H3v-1h1v1zm2 0H5v-1h1v1zm2 0H7v-1h1v1zm2 0H9v-1h1v1z M20 109.9988C20 93.43 33.4314 79.998 50 79.998H80L80 99.998H50C44.4772 99.998 40 104.476 40 109.9988L40 249.9988C40 255.5216 44.4772 259.9988 50 259.9988L190 259.9988C195.5228 259.9988 200 255.5216 200 249.9988V219.9996H110C93.4316 219.9996 80 206.5682 80 189.9996V50C80 33.432 93.4316 20 110 20H250C266.568 20 280 33.432 280 50V189.9996C280 206.5682 266.568 219.9996 250 219.9996H220V249.9988C220 266.5674 206.568 279.9988 190 279.9988H50C33.4314 279.9988 20 266.5674 20 249.9988V109.9988zM100 189.9996C100 195.5224 104.4772 199.9996 110 199.9996H250C255.522 199.9996 260 195.5224 260 189.9996V50C260 44.476 255.522 40 250 40H110C104.4772 40 100 44.476 100 50V189.9996z M0,0 L10,0 L6,5 L6,10 L4,10 L4,5 L0,0 + M396 712 L233 512 L178 580 L396 848 L861 272 L807 204 Z + M 1,7 A 6,6 0 0 0 13,7 + M854,346 512,0 170,346 232,404 470,166 470,684 554,684 554,166 794,404z + M170,678 512,1024 854,678 792,620 554,858 554,340 470,340 470,858 232,620z + M1.5,0 A1.5,1.5 0 1 1 1.5,3 A1.5,1.5 0 1 1 1.5,0 Z M1.5,6 A1.5,1.5 0 1 1 1.5,9 A1.5,1.5 0 1 1 1.5,6 Z M1.5,12 A1.5,1.5 0 1 1 1.5,15 A1.5,1.5 0 1 1 1.5,12 Z @@ -368,6 +374,21 @@ + + + + + + + + + + + + + + + @@ -1202,8 +1223,18 @@ - + + + + + + + + + + + @@ -1215,8 +1246,18 @@ - + + + + + + + + + + + @@ -1740,7 +1781,7 @@ + + + + + + - - + + + + + + + + + @@ -6567,6 +6832,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1204,8 +1225,18 @@ - + + + + + + + + + + + @@ -1217,8 +1248,18 @@ - + + + + + + + + + + + @@ -1742,7 +1783,7 @@ + + + + + + - - + + + + + + + + + @@ -6599,6 +6864,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml new file mode 100644 index 00000000..0c01d99d --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml @@ -0,0 +1,274 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml.cs new file mode 100644 index 00000000..842c67f6 --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/HomeExample.xaml.cs @@ -0,0 +1,261 @@ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Json; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using WPFDevelopers.Controls; +using Tag = WPFDevelopers.Controls.Tag; + +namespace WPFDevelopers.Samples.ExampleViews +{ + public partial class HomeExample : UserControl + { + private CancellationTokenSource _statisticsRequest; + private bool _statisticsLoaded; + private bool _synchronizingTheme; + + public HomeExample() + { + InitializeComponent(); + VersionTag.Content = typeof(Tag).Assembly.GetName().Version.ToString(3); + Loaded += HomeExample_Loaded; + Unloaded += HomeExample_Unloaded; + } + + private void HomeExample_Loaded(object sender, RoutedEventArgs e) + { + WPFDevelopers.Resources.ThemeChanged -= Resources_ThemeChanged; + WPFDevelopers.Resources.ThemeChanged += Resources_ThemeChanged; + SynchronizeTheme(); + if (!_statisticsLoaded) + RefreshStatistics(); + } + + private void HomeExample_Unloaded(object sender, RoutedEventArgs e) + { + WPFDevelopers.Resources.ThemeChanged -= Resources_ThemeChanged; + if (_statisticsRequest == null) + return; + + _statisticsRequest.Cancel(); + _statisticsRequest = null; + RefreshButton.IsEnabled = true; + } + + private void RefreshButton_Click(object sender, RoutedEventArgs e) + { + RefreshStatistics(); + } + + private void RefreshStatistics() + { + if (_statisticsRequest != null) + return; + + var request = new CancellationTokenSource(); + _statisticsRequest = request; + RefreshButton.IsEnabled = false; + StarsTag.Content = DownloadsTag.Content = "加载中"; + StatisticsStatus.Text = "正在读取 GitHub Star 和 NuGet 累计下载量..."; + var worker = new BackgroundWorker(); + worker.DoWork += (sender, e) => + { + var stars = LoadMetric("GitHub", () => + ReadCount(DownloadJson( + "https://api.github.com/repos/WPFDevelopersOrg/WPFDevelopers", request.Token).Stars)); + request.Token.ThrowIfCancellationRequested(); + var downloads = LoadMetric("NuGet", () => + { + var result = DownloadJson( + "https://azuresearch-usnc.nuget.org/query?q=packageid:WPFDevelopers&prerelease=true", request.Token); + var package = result.Data == null ? null : result.Data.FirstOrDefault(item => + string.Equals(item.Id, "WPFDevelopers", StringComparison.OrdinalIgnoreCase)); + if (package == null) + throw new InvalidDataException("NuGet 未返回 WPFDevelopers 包统计"); + return ReadCount(package.TotalDownloads); + }); + e.Result = new[] { stars, downloads }; + }; + worker.RunWorkerCompleted += (sender, e) => + { + var isCurrent = ReferenceEquals(_statisticsRequest, request); + request.Dispose(); + worker.Dispose(); + if (!isCurrent) + return; + + _statisticsRequest = null; + RefreshButton.IsEnabled = true; + if (e.Error != null) + { + StarsTag.Content = DownloadsTag.Content = "加载失败"; + StatisticsStatus.Text = "统计加载失败:" + e.Error.Message + "。请点击“刷新统计”重试。"; + return; + } + + var metrics = (MetricResult[])e.Result; + StarsTag.Content = metrics[0].Content; + DownloadsTag.Content = metrics[1].Content; + var errors = metrics.Where(metric => metric.Error != null).Select(metric => metric.Error).ToArray(); + _statisticsLoaded = errors.Length == 0; + StatisticsStatus.Text = _statisticsLoaded + ? "更新于 " + DateTime.Now.ToString("HH:mm:ss") + " · 下载量为 NuGet 所有版本累计下载量" + : string.Join(Environment.NewLine, errors); + }; + worker.RunWorkerAsync(); + } + + private static MetricResult LoadMetric(string source, Func load) + { + try + { + return new MetricResult { Content = load().ToString("N0", CultureInfo.InvariantCulture) }; + } + catch (WebException ex) + { + return MetricFailure(source, ex); + } + catch (SerializationException ex) + { + return MetricFailure(source, ex); + } + catch (InvalidDataException ex) + { + return MetricFailure(source, ex); + } + } + + private static MetricResult MetricFailure(string source, Exception error) + { + return new MetricResult + { + Content = "加载失败", + Error = source + " 统计加载失败:" + error.Message + "。请点击“刷新统计”重试。" + }; + } + + private static T DownloadJson(string address, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + var request = (HttpWebRequest)WebRequest.Create(address); + request.UserAgent = "WPFDevelopers-Demo/1.0"; + request.Accept = "application/json"; + request.Timeout = 15000; + request.ReadWriteTimeout = 15000; + using (cancellationToken.Register(request.Abort)) + using (var response = request.GetResponse()) + using (var stream = response.GetResponseStream()) + { + var result = new DataContractJsonSerializer(typeof(T)).ReadObject(stream); + if (result == null) + throw new InvalidDataException("统计响应为空"); + return (T)result; + } + } + + private static long ReadCount(long? count) + { + if (!count.HasValue || count.Value < 0) + throw new InvalidDataException("统计响应缺少有效的计数"); + return count.Value; + } + + private void RepositoryButton_Click(object sender, RoutedEventArgs e) + { + var button = sender as Button; + var address = button == null ? null : button.Tag as string; + Uri uri; + if (!Uri.TryCreate(address, UriKind.Absolute, out uri) || uri.Scheme != Uri.UriSchemeHttps) + throw new InvalidOperationException("Repository button has no valid HTTPS address."); + + try + { + Process.Start(new ProcessStartInfo(uri.AbsoluteUri) { UseShellExecute = true }); + LinkError.Visibility = Visibility.Collapsed; + } + catch (Win32Exception ex) + { + ShowLinkError(ex); + } + catch (InvalidOperationException ex) + { + ShowLinkError(ex); + } + } + + private void ShowLinkError(Exception error) + { + LinkError.Text = "无法打开链接:" + error.Message; + LinkError.Visibility = Visibility.Visible; + } + + private void Segmented_ItemClick(object sender, RoutedEventArgs e) + { + if (_synchronizingTheme) return; + var segmented = sender as Segmented; + var theme = segmented.SelectedIndex == 0 ? ThemeType.Light : ThemeType.Dark; + if (ThemeManager.Instance.Resources.Theme == theme) return; + App.Theme = theme; + ThemeManager.Instance.SwitchTheme(PART_Segmented, theme); + SynchronizeTheme(); + } + + private void Resources_ThemeChanged(ThemeType currentTheme) + { + SynchronizeTheme(); + } + + private void SynchronizeTheme() + { + var theme = ThemeManager.Instance.Resources.Theme; + _synchronizingTheme = true; + try + { + PART_Segmented.SelectedIndex = theme == ThemeType.Dark ? 1 : 0; + SegmentedLight.IsChecked = theme != ThemeType.Dark; + SegmentedDark.IsChecked = theme == ThemeType.Dark; + } + finally + { + _synchronizingTheme = false; + } + } + + private sealed class MetricResult + { + public string Content { get; set; } + public string Error { get; set; } + } + + [DataContract] + private sealed class RepositoryStatistics + { + [DataMember(Name = "stargazers_count")] + public long? Stars { get; set; } + } + + [DataContract] + private sealed class PackageSearchResult + { + [DataMember(Name = "data")] + public PackageStatistics[] Data { get; set; } + } + + [DataContract] + private sealed class PackageStatistics + { + [DataMember(Name = "id")] + public string Id { get; set; } + + [DataMember(Name = "totalDownloads")] + public long? TotalDownloads { get; set; } + } + } +} diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/CropControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml similarity index 67% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/CropControlExample.xaml rename to src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml index b70ccb68..fba9a81d 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/CropControlExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml @@ -1,5 +1,5 @@  - + - - + + + Haader="ImageCrop.xaml" /> + Haader="ImageCrop.cs" /> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml.cs similarity index 56% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml.cs rename to src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml.cs index 9decfc70..49592109 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml.cs +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ImageCropExample.xaml.cs @@ -3,11 +3,11 @@ namespace WPFDevelopers.Samples.ExampleViews { /// - /// RulerControlExample.xaml 的交互逻辑 + /// ImageCropExample.xaml 的交互逻辑 /// - public partial class RulerControlExample : UserControl + public partial class ImageCropExample : UserControl { - public RulerControlExample() + public ImageCropExample() { InitializeComponent(); } diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml index 808ceea5..9d25d8a3 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml @@ -24,6 +24,31 @@ HorizontalAlignment="Right" wd:PanelHelper.Spacing="2" Orientation="Horizontal"> + + + + + + + + + + + - + @@ -149,35 +175,119 @@ - + - - - - - - - + + + + + + + + + + - - + + + ItemsSource="{Binding NavigateMenuModelList}" + SelectedItem="{Binding NavigateMenuItem, Mode=TwoWay}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -188,6 +298,7 @@ @@ -195,7 +306,6 @@ diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml.cs index c5175b3b..af4a8766 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml.cs +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Windows.Media.Animation; using WPFDevelopers.Controls; +using WPFDevelopers.Helpers; using WPFDevelopers.Samples.ExampleViews; using WPFDevelopers.Samples.Helpers; using MessageBox = WPFDevelopers.Controls.MessageBox; @@ -21,6 +22,7 @@ public partial class MainWindow public MainWindow() { InitializeComponent(); + VersionText.Text = "v" + typeof(MainWindow).BaseType.Assembly.GetName().Version.ToString(3); Loaded += OnMainWindow_Loaded; Closing += MainWindow_Closing; } @@ -33,8 +35,13 @@ private void OnMainWindow_Loaded(object sender, RoutedEventArgs e) private void ThemeSwitchBtn_Click(object sender, RoutedEventArgs e) { - var targetTheme = App.Theme == ThemeType.Dark ? ThemeType.Light : ThemeType.Dark; - ThemeManager.Instance.SwitchTheme(ThemeSwitchBtn, targetTheme); + ToggleTheme(ThemeSwitchBtn); + } + + public void ToggleTheme(FrameworkElement source) + { + var targetTheme = ThemeManager.Instance.Resources.Theme == ThemeType.Dark ? ThemeType.Light : ThemeType.Dark; + ThemeManager.Instance.SwitchTheme(source, targetTheme); App.Theme = targetTheme; SetThemeSource(); ThemeSwitchBtn.IsChecked = targetTheme == ThemeType.Dark; @@ -56,7 +63,7 @@ private void Quit_Click(object sender, RoutedEventArgs e) private void About_Click(object sender, RoutedEventArgs e) { - new AboutWindow().Show(); + new AboutWindow().MaskShowDialog(); } private void SendMessage_Click(object sender, RoutedEventArgs e) { diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MaskExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/MaskExample.xaml.cs index bb0f0113..eca20909 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MaskExample.xaml.cs +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MaskExample.xaml.cs @@ -15,12 +15,12 @@ public MaskExample() private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { - new AboutWindow().MaskShowDialog(); + new AboutWindow { Owner = System.Windows.Window.GetWindow(this) }.MaskShowDialog(); } private void Button_Click_1(object sender, System.Windows.RoutedEventArgs e) { - new AboutWindow().MaskShow(); + new AboutWindow { Owner = System.Windows.Window.GetWindow(this) }.MaskShow(); } } } diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml.cs deleted file mode 100644 index 892c8f94..00000000 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace WPFDevelopers.Samples.ExampleViews -{ - /// - /// Interaction logic for OtherControlExample.xaml - /// - public partial class OtherControlExample : UserControl - { - public OtherControlExample() - { - InitializeComponent(); - } - } -} diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml similarity index 75% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml rename to src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml index d2505115..555c99a8 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml @@ -1,5 +1,5 @@  - - + - + PieSegmentModels="{Binding PieSegmentModels, RelativeSource={RelativeSource AncestorType=local:PieSegmentExample}}" /> + - - + + + Haader="PieSegment.xaml" /> + Haader="PieSegment.cs" /> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml.cs similarity index 91% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml.cs rename to src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml.cs index 01b5bbba..5edd0dc4 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/PieControlExample.xaml.cs +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/PieSegmentExample.xaml.cs @@ -7,9 +7,9 @@ namespace WPFDevelopers.Samples.ExampleViews { /// - /// PieControlExample.xaml 的交互逻辑 + /// PieSegmentExample.xaml 的交互逻辑 /// - public partial class PieControlExample : UserControl + public partial class PieSegmentExample : UserControl { public ObservableCollection PieSegmentModels { @@ -18,10 +18,10 @@ public ObservableCollection PieSegmentModels } public static readonly DependencyProperty PieSegmentModelsProperty = - DependencyProperty.Register("PieSegmentModels", typeof(ObservableCollection), typeof(PieControlExample), new PropertyMetadata(null)); + DependencyProperty.Register("PieSegmentModels", typeof(ObservableCollection), typeof(PieSegmentExample), new PropertyMetadata(null)); List> collectionList = new List>(); - public PieControlExample() + public PieSegmentExample() { InitializeComponent(); diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml similarity index 94% rename from src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml rename to src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml index 7deb39e9..88fd2322 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml @@ -1,5 +1,5 @@  - - + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml.cs new file mode 100644 index 00000000..b785f122 --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerExample.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace WPFDevelopers.Samples.ExampleViews +{ + /// + /// RulerExample.xaml 的交互逻辑 + /// + public partial class RulerExample : UserControl + { + public RulerExample() + { + InitializeComponent(); + } + } +} diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml new file mode 100644 index 00000000..36985c67 --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml.cs new file mode 100644 index 00000000..c0796688 --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollNavigationExample.xaml.cs @@ -0,0 +1,12 @@ +using System.Windows.Controls; + +namespace WPFDevelopers.Samples.ExampleViews +{ + public partial class ScrollNavigationExample : UserControl + { + public ScrollNavigationExample() + { + InitializeComponent(); + } + } +} diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml index 391c2f19..eebc697a 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ScrollViewerAnimationExample.xaml @@ -15,7 +15,10 @@ - + @@ -46,7 +49,8 @@ + IsScrollAnimation="True" + wd:ScrollViewerBehavior.IsBackToTopEnabled="True"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml index 3b77df6f..c67c0327 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/SpacingExample.xaml @@ -26,10 +26,17 @@ Height="40" Padding="20,0" Header="WrapPanel"> - + + VerticalAlignment="Top" + SelectedItem="{Binding ColorType, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + +