优化更新代码,添加界面功能并整合

This commit is contained in:
GG Z
2025-02-10 20:53:40 +08:00
parent 83b846f15f
commit 978e03a67f
1389 changed files with 95739 additions and 22200 deletions

View File

@@ -0,0 +1,87 @@
<!--
This Source Code Form is subject to the terms of the MIT License.
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
All Rights Reserved.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:converters="clr-namespace:WPFluent.Converters">
<Style TargetType="{x:Type controls:TreeGridItem}">
<Setter Property="Margin" Value="0" />
</Style>
<Style TargetType="{x:Type controls:TreeGrid}">
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
<Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Standard" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel
IsVirtualizing="{TemplateBinding VirtualizingPanel.IsVirtualizing}"
Orientation="Vertical"
VirtualizationMode="{TemplateBinding VirtualizingPanel.VirtualizationMode}" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TreeGrid}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
Grid.Row="0"
Margin="0"
BorderBrush="Red"
BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="component" />
<!-- Placeholders for two columns of ToggleButton -->
<ColumnDefinition SharedSizeGroup="_toggle_group" />
<ColumnDefinition SharedSizeGroup="_toggle_group" />
<ColumnDefinition SharedSizeGroup="value" />
<ColumnDefinition SharedSizeGroup="min" />
<ColumnDefinition SharedSizeGroup="max" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Component" />
<!-- Empty TreeViewItem to measure the size of its ToggleButton into the "Toggle" group -->
<TreeViewItem Grid.Column="1" Padding="0" />
<TextBlock Grid.Column="3" Text="Value" />
<TextBlock Grid.Column="4" Text="Min" />
<TextBlock Grid.Column="5" Text="Max" />
</Grid>
</Border>
<!-- Header above -->
<controls:PassiveScrollViewer
Grid.Row="1"
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
Focusable="False"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</controls:PassiveScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,114 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
/// <summary>
/// TODO: Work in progress.
/// </summary>
public class TreeGrid : System.Windows.Controls.Primitives.Selector
{
/// <summary>
/// Identifies the <see cref="Headers"/> dependency property.
/// </summary>
public static readonly DependencyProperty HeadersProperty = DependencyProperty.Register(
nameof(Headers),
typeof(ObservableCollection<TreeGridHeader>),
typeof(TreeGrid),
new PropertyMetadata(null));
/*/// <summary>
/// Content is the data used to generate the child elements of this control.
/// </summary>
[Bindable(true)]
public object Content
{
get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}*/
public TreeGrid()
{
Headers = [];
Headers.CollectionChanged += Headers_CollectionChanged;
/*
var x = new System.Windows.Controls.ContentControl();
var y = new System.Windows.Controls.ItemsControl();
var z = new System.Windows.Controls.ListBox();
*/
}
private void Headers_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{ throw new NotImplementedException(); }
/*/// <summary>
/// Add an object child to this control
/// </summary>
void IAddChild.AddChild(object value)
{
AddChild(value);
}
public void AddText(string text)
{
throw new NotImplementedException();
}
/// <summary>
/// Add an object child to this control
/// </summary>
protected virtual void AddChild(object value)
{
// if conent is the first child or being cleared, set directly
if (Content == null || value == null)
Content = value;
else
throw new InvalidOperationException($"{typeof(TreeGrid)} cannot have multiple content");
}*/
protected virtual void OnHeadersChanged(DependencyPropertyChangedEventArgs e)
{
// Headers changed
}
/*
/// <summary>
/// Property for <see cref="Content"/>.
/// </summary>
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content),
typeof(object), typeof(TreeGrid), new PropertyMetadata(null, OnContentChanged));
*/
/// <summary>
/// Gets or sets the data used to generate the child elements of this control.
/// </summary>
[Bindable(true)]
public ObservableCollection<TreeGridHeader>? Headers
{
get => GetValue(HeadersProperty) as ObservableCollection<TreeGridHeader>;
set => SetValue(HeadersProperty, value);
}
/*
protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e)
{
// Content changed
}
*/
/*
private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not TreeGrid treeGrid)
{
return;
}
treeGrid.OnContentChanged(e);
}
*/
}

View File

@@ -0,0 +1,65 @@
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
/// <summary>
/// Work in progress.
/// </summary>
public class TreeGridHeader : System.Windows.FrameworkElement
{
/// <summary>
/// Identifies the <see cref="Group"/> dependency property.
/// </summary>
public static readonly DependencyProperty GroupProperty = DependencyProperty.Register(
nameof(Group),
typeof(string),
typeof(TreeGridHeader),
new PropertyMetadata(string.Empty));
/// <summary>
/// Identifies the <see cref="Title"/> dependency property.
/// </summary>
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
nameof(Title),
typeof(string),
typeof(TreeGridHeader),
new PropertyMetadata(string.Empty, OnTitleChanged));
private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if(d is not TreeGridHeader header)
{
return;
}
header.OnTitleChanged();
}
/// <summary>
/// This virtual method is called when <see cref="Title"/> is changed.
/// </summary>
protected virtual void OnTitleChanged()
{
var title = Title;
if(!string.IsNullOrEmpty(Group) || string.IsNullOrEmpty(title))
{
return;
}
SetCurrentValue(GroupProperty, title.ToLower().Trim());
}
/// <summary>
/// Gets or sets the column group name.
/// </summary>
[Localizability(LocalizationCategory.NeverLocalize)]
[MergableProperty(false)]
public string Group { get => (string)GetValue(GroupProperty); set => SetValue(GroupProperty, value); }
/// <summary>
/// Gets or sets the title that will be displayed.
/// </summary>
public string Title { get => (string)GetValue(TitleProperty); set => SetValue(TitleProperty, value); }
}

View File

@@ -0,0 +1,12 @@
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
/// <summary>
/// Work in progress.
/// </summary>
public class TreeGridItem : System.Windows.Controls.Control
{
}