样式demo
This commit is contained in:
@@ -147,7 +147,7 @@ public static class InputAssist
|
||||
{
|
||||
passwordBox.Password = newVal;
|
||||
}
|
||||
|
||||
UpdateHasPassword(passwordBox);
|
||||
// 确保监听用户输入
|
||||
passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
|
||||
}
|
||||
|
||||
@@ -397,10 +397,7 @@
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="emboss" Property="Intensity" Value="1" />
|
||||
<!--<Setter Property="BorderThickness" Value="1" />-->
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="emboss" Property="Intensity" Value="0.4" />
|
||||
<Setter TargetName="slot" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
@@ -422,6 +419,52 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LightedButtonStyle" TargetType="{x:Type Button}">
|
||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Padding" Value="10,4" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Grid>
|
||||
<decorations:LightedSurface
|
||||
x:Name="surface"
|
||||
Margin="0"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter
|
||||
x:Name="contentPresenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Focusable="False"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</decorations:LightedSurface>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Button.IsDefaulted" Value="True" />
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="surface" Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="surface" Property="Foreground" Value="{DynamicResource PrimaryPressedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="surface" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="IconButtonStyle" TargetType="Button">
|
||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace NeoUI.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// 标签、纸片、徽章可点击跳转链接
|
||||
/// </summary>
|
||||
public class Chip : ContentControl
|
||||
{
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="ChooseButtonWidth" Value="20" />
|
||||
<Setter Property="PlaceholderText" Value="请选择..." />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="MinWidth" Value="200" />
|
||||
<Setter Property="MinWidth" Value="150" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
||||
@@ -46,6 +47,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Name="PlaceholderTextBlock"
|
||||
Grid.Column="0"
|
||||
Margin="5,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
@@ -136,6 +138,7 @@
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Border.CornerRadius" Value="4" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="PlaceholderText" Value="请选择..." />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="ChooseButtonWidth" Value="20" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ChooseBox : System.Windows.Controls.TextBox
|
||||
nameof(Filter),
|
||||
typeof(string),
|
||||
typeof(ChooseBox),
|
||||
new PropertyMetadata("文本文件|*.*"));
|
||||
new PropertyMetadata("所有文件|*.*"));
|
||||
#endregion
|
||||
|
||||
#region DefaultFileName
|
||||
|
||||
@@ -427,6 +427,7 @@
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请选择..." />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="8" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
|
||||
|
||||
@@ -109,7 +109,8 @@
|
||||
|
||||
<Style x:Key="DefaultTextBoxDatePickerStyle" TargetType="{x:Type DatePickerTextBox}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
@@ -421,6 +422,7 @@
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<!--<Setter Property="Margin" Value="0"/>-->
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="CalendarStyle" Value="{StaticResource DefaultCalendarPickerStyle}" />
|
||||
<Setter Property="MinWidth" Value="150" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
|
||||
@@ -467,7 +467,7 @@
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource ChipListBoxItemStyle}" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource EmbossChipListBoxItemStyle}" />
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
<ResourceDictionary Source="/NeoUI;component/Controls/Button.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="SlotNumberBox" TargetType="{x:Type controls:NumberBox}">
|
||||
<Style x:Key="SlotNumberBoxStyle" TargetType="{x:Type controls:NumberBox}">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Padding" Value="2" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:NumberBox}">
|
||||
@@ -74,7 +76,7 @@
|
||||
Background="Transparent"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1,0,0,0">
|
||||
<Grid Width="20">
|
||||
<Grid Width="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="1" />
|
||||
@@ -83,9 +85,9 @@
|
||||
<Button
|
||||
x:Name="PART_IncreaseButton"
|
||||
Grid.Row="0"
|
||||
Padding="0"
|
||||
Padding="-3"
|
||||
assists:ControlAssist.CornerRadius="0,4,0,0"
|
||||
FontSize="8"
|
||||
FontSize="4"
|
||||
IsTabStop="False"
|
||||
Style="{DynamicResource FlattenButtonStyle}">
|
||||
<controls:IconElement
|
||||
@@ -106,9 +108,9 @@
|
||||
<Button
|
||||
x:Name="PART_DecreaseButton"
|
||||
Grid.Row="2"
|
||||
Padding="0"
|
||||
Padding="-3"
|
||||
assists:ControlAssist.CornerRadius="0,0,4,0"
|
||||
FontSize="8"
|
||||
FontSize="4"
|
||||
IsTabStop="False"
|
||||
Style="{DynamicResource FlattenButtonStyle}">
|
||||
<controls:IconElement
|
||||
@@ -159,6 +161,7 @@
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:NumberBox}">
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
xmlns:converters="clr-namespace:NeoUI.Converters"
|
||||
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations">
|
||||
|
||||
<!--<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/NeuWPF;component/Controls/ButtonsStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>-->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/NeoUI;component/Controls/ComboBox.xaml" />
|
||||
<ResourceDictionary Source="/NeoUI;component/Controls/TextBox.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- 页码按钮的样式 -->
|
||||
<Style x:Key="EmbossPaginationButtonStyle" TargetType="Button">
|
||||
@@ -154,6 +155,64 @@
|
||||
</Style>
|
||||
|
||||
<!-- PaginationControl 的主模板 -->
|
||||
<Style x:Key="EmbossPaginationStyle" TargetType="{x:Type controls:Pagination}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:Pagination}">
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
|
||||
<!-- 页码按钮列表 -->
|
||||
<ItemsControl ItemsSource="{Binding PageItems, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type controls:PageItem}">
|
||||
<Button
|
||||
Content="{Binding Text}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Style="{StaticResource EmbossPaginationButtonStyle}"
|
||||
ToolTip="{Binding ToolTip}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- 页面尺寸选择器 -->
|
||||
<ComboBox
|
||||
Margin="8,0,0,0"
|
||||
ItemsSource="{Binding PageSizeOptions, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding PageSize, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
Style="{StaticResource FloatComboBoxStyle}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding StringFormat={}{0} 条/页}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!-- 跳转输入框 -->
|
||||
<StackPanel
|
||||
Margin="8,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{Binding ShowPageInput, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
|
||||
<TextBlock VerticalAlignment="Center" Text="跳至" />
|
||||
<TextBox
|
||||
x:Name="PART_PageInputTextBox"
|
||||
Width="50"
|
||||
Margin="4,0"
|
||||
HorizontalContentAlignment="Center"
|
||||
Style="{StaticResource SlotTextBoxStyle}"
|
||||
Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="页" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type controls:Pagination}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<ResourceDictionary Source="/NeoUI;component/Themes/Animations.xaml" />
|
||||
<ResourceDictionary Source="/NeoUI;component/Controls/IconElement.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<ControlTemplate x:Key="SlotPasswordBoxTemplate" TargetType="{x:Type PasswordBox}">
|
||||
<decorations:SlotBorder
|
||||
x:Name="slot"
|
||||
@@ -18,11 +19,22 @@
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
x:Name="Placeholder"
|
||||
Margin="5,0,0,0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="Center"
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
Visibility="Collapsed" />
|
||||
<ScrollViewer
|
||||
x:Name="PART_ContentHost"
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden" />
|
||||
</Grid>
|
||||
</decorations:SlotBorder>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
@@ -38,7 +50,9 @@
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="slot" Property="ShaderEnabled" Value="False" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<!--<Trigger Property="IsMouseOver" Value="True" />-->
|
||||
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
@@ -56,49 +70,6 @@
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="PasswordBoxTemplate" TargetType="{x:Type PasswordBox}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
||||
SnapsToDevicePixels="True">
|
||||
<ScrollViewer
|
||||
x:Name="PART_ContentHost"
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden" />
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="True" />
|
||||
<Condition Property="IsSelectionActive" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="Cursor" Value="None" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="SlotPasswordBoxEyeableTemplate" TargetType="{x:Type PasswordBox}">
|
||||
<ControlTemplate.Resources>
|
||||
<!-- 聚焦对象 -->
|
||||
@@ -324,6 +295,86 @@
|
||||
</Trigger>-->
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="SlotPasswordBoxStyle" TargetType="PasswordBox">
|
||||
<Setter Property="PasswordChar" Value="●" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入密码..." />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="2" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="Template" Value="{StaticResource SlotPasswordBoxTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="assists:InputAssist.IsPasswordVisible" Value="True">
|
||||
<Setter Property="Template" Value="{StaticResource SlotPasswordBoxEyeableTemplate}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<ControlTemplate x:Key="PasswordBoxTemplate" TargetType="{x:Type PasswordBox}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
x:Name="Placeholder"
|
||||
Margin="5,0,0,0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="Center"
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
Visibility="Collapsed" />
|
||||
<ScrollViewer
|
||||
x:Name="PART_ContentHost"
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="True" />
|
||||
<Condition Property="IsSelectionActive" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="Cursor" Value="None" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
|
||||
<ControlTemplate x:Key="PasswordBoxEyeableTemplate" TargetType="{x:Type PasswordBox}">
|
||||
<Grid>
|
||||
<Border
|
||||
@@ -464,34 +515,11 @@
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="SlotPasswordBoxStyle" TargetType="PasswordBox">
|
||||
<Setter Property="PasswordChar" Value="●" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="Template" Value="{StaticResource SlotPasswordBoxTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="assists:InputAssist.IsPasswordVisible" Value="True">
|
||||
<Setter Property="Template" Value="{StaticResource SlotPasswordBoxEyeableTemplate}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="PasswordChar" Value="●" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入密码" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
xmlns:decorations="clr-namespace:NeoUI.Controls.Decorations"
|
||||
xmlns:internal="clr-namespace:NeoUI.Converters.Internal">
|
||||
|
||||
<ControlTemplate x:Key="HorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<!--#region SlotProgress-->
|
||||
<ControlTemplate x:Key="SlotHorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="ProgressIndeterminateHorizontal" RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||
@@ -98,7 +99,7 @@
|
||||
</LinearGradientBrush.RelativeTransform>
|
||||
</LinearGradientBrush>
|
||||
-->
|
||||
<ControlTemplate x:Key="ProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<ControlTemplate x:Key="SlotProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||||
@@ -176,13 +177,161 @@
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="{x:Type ProgressBar}">
|
||||
<Style x:Key="SlotProgressBarStyle" TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Height" Value="20" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Template" Value="{StaticResource SlotHorizontalProgressTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="IsIndeterminate" Value="False" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Template" Value="{StaticResource SlotProgressVerticalTemplate}" />
|
||||
<Setter Property="Width" Value="20" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<!--#endregion-->
|
||||
|
||||
<ControlTemplate x:Key="HorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="ProgressIndeterminateHorizontal" RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||
<EasingDoubleKeyFrame KeyTime="0" Value="-1" />
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<Border
|
||||
x:Name="backgroundBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<Grid x:Name="BarGrid" HorizontalAlignment="Left">
|
||||
<!-- 计算进度条宽度 -->
|
||||
<Grid.Width>
|
||||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="7">
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Minimum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Maximum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Value"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||||
</MultiBinding>
|
||||
</Grid.Width>
|
||||
<!-- 进度条 -->
|
||||
<Border
|
||||
x:Name="borderProgress"
|
||||
Background="{TemplateBinding Foreground}"
|
||||
CornerRadius="3" />
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsIndeterminate" Value="True" />
|
||||
<Condition Property="IsEnabled" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="BarGrid" Property="Width" Value="auto" />
|
||||
<Setter TargetName="BarGrid" Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateHorizontal}" />
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="ProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||||
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<Border
|
||||
x:Name="backgroundBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<Grid x:Name="BarGrid" VerticalAlignment="Bottom">
|
||||
<!-- 计算进度条宽度 -->
|
||||
<Grid.Height>
|
||||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="7">
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Minimum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Maximum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Value"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||||
</MultiBinding>
|
||||
</Grid.Height>
|
||||
<!-- 进度条 -->
|
||||
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsIndeterminate" Value="True" />
|
||||
<Condition Property="IsEnabled" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="BarGrid" Property="Height" Value="auto" />
|
||||
<Setter TargetName="BarGrid" Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Height" Value="8" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Template" Value="{StaticResource HorizontalProgressTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
@@ -192,7 +341,7 @@
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Template" Value="{StaticResource ProgressVerticalTemplate}" />
|
||||
<Setter Property="Width" Value="20" />
|
||||
<Setter Property="Width" Value="8" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
</Trigger>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- 滑块默认样式 -->
|
||||
<ControlTemplate x:Key="DefaultSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<ControlTemplate x:Key="ShadowSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
@@ -47,6 +47,363 @@
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="ShadowSliderVerticalTemplate" TargetType="{x:Type Slider}">
|
||||
<Border
|
||||
x:Name="border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="{TemplateBinding MinWidth}" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
<TickBar
|
||||
x:Name="TopTick"
|
||||
Grid.Column="0"
|
||||
Width="4"
|
||||
Margin="0,0,2,0"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Placement="Left"
|
||||
Visibility="Collapsed" />
|
||||
<Border
|
||||
x:Name="TrackBackground"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Width="8"
|
||||
HorizontalAlignment="center"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4">
|
||||
<Grid>
|
||||
<Border
|
||||
Width="8"
|
||||
Margin="-1"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="{TemplateBinding Foreground}"
|
||||
CornerRadius="4">
|
||||
<Border.Height>
|
||||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="1">
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Minimum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Maximum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Value"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||||
</MultiBinding>
|
||||
</Border.Height>
|
||||
</Border>
|
||||
<Canvas Margin="-1,-6">
|
||||
<Rectangle
|
||||
x:Name="PART_SelectionRange"
|
||||
Width="4.0"
|
||||
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
|
||||
Visibility="Hidden" />
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Track
|
||||
x:Name="PART_Track"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb
|
||||
x:Name="Thumb"
|
||||
Width="22"
|
||||
Height="20"
|
||||
VerticalAlignment="Top"
|
||||
Focusable="False"
|
||||
OverridesDefaultStyle="True"
|
||||
Template="{StaticResource ShadowSliderThumbTemplate}" />
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
<TickBar
|
||||
x:Name="BottomTick"
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Width="4"
|
||||
Margin="2,0,0,0"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Placement="Right"
|
||||
Visibility="Collapsed" />
|
||||
<!-- 新增:简单的值显示TextBlock -->
|
||||
<TextBlock
|
||||
x:Name="ValueDisplay"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}">
|
||||
<TextBlock.LayoutTransform>
|
||||
<RotateTransform Angle="-90" />
|
||||
</TextBlock.LayoutTransform>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||||
<Setter TargetName="TrackBackground" Property="Margin" Value="2,5,0,5" />
|
||||
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||||
<Setter TargetName="TrackBackground" Property="Margin" Value="0,5,2,5" />
|
||||
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="TickPlacement" Value="Both">
|
||||
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelectionRangeEnabled" Value="True">
|
||||
<Setter TargetName="PART_SelectionRange" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter TargetName="Thumb" Property="Foreground" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
<!-- 新增:可以选择是否显示值 -->
|
||||
<Trigger Property="Tag" Value="HideValue">
|
||||
<Setter TargetName="ValueDisplay" Property="Visibility" Value="Collapsed" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="ShadowSliderHorizontalTemplate" TargetType="{x:Type Slider}">
|
||||
<Border
|
||||
x:Name="border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="40" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TickBar
|
||||
x:Name="TopTick"
|
||||
Grid.Row="0"
|
||||
Height="4"
|
||||
Margin="0,0,0,2"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Placement="Top"
|
||||
Visibility="Collapsed" />
|
||||
<Border
|
||||
x:Name="TrackBackground"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Height="8"
|
||||
VerticalAlignment="center"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4">
|
||||
<Grid>
|
||||
<Border
|
||||
Height="8"
|
||||
Margin="-1"
|
||||
HorizontalAlignment="Left"
|
||||
Background="{TemplateBinding Foreground}"
|
||||
CornerRadius="4">
|
||||
<Border.Width>
|
||||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="0">
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Minimum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Maximum"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="Value"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||||
</MultiBinding>
|
||||
</Border.Width>
|
||||
</Border>
|
||||
<Canvas Margin="-6,-1">
|
||||
<Rectangle
|
||||
x:Name="PART_SelectionRange"
|
||||
Height="4.0"
|
||||
Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
|
||||
Visibility="Hidden" />
|
||||
</Canvas>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
<Track
|
||||
x:Name="PART_Track"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparentStyle}" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb
|
||||
x:Name="Thumb"
|
||||
Width="20"
|
||||
Height="22"
|
||||
VerticalAlignment="Center"
|
||||
Focusable="False"
|
||||
OverridesDefaultStyle="True"
|
||||
Template="{StaticResource ShadowSliderThumbTemplate}" />
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
<TickBar
|
||||
x:Name="BottomTick"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Height="4"
|
||||
Margin="0,2,0,0"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Placement="Bottom"
|
||||
Visibility="Collapsed" />
|
||||
<!-- 新增:简单的值显示TextBlock,放在滑块下方 -->
|
||||
<TextBlock
|
||||
x:Name="ValueDisplay"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="4,0,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat=F1}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TickPlacement" Value="TopLeft">
|
||||
<Setter TargetName="TrackBackground" Property="Margin" Value="5,2,5,0" />
|
||||
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="TickPlacement" Value="BottomRight">
|
||||
<Setter TargetName="TrackBackground" Property="Margin" Value="5,0,5,2" />
|
||||
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="TickPlacement" Value="Both">
|
||||
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelectionRangeEnabled" Value="True">
|
||||
<Setter TargetName="PART_SelectionRange" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter TargetName="Thumb" Property="Foreground" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="ShadowSliderStyle" TargetType="{x:Type Slider}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
|
||||
<Setter Property="Template" Value="{StaticResource ShadowSliderHorizontalTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Template" Value="{StaticResource ShadowSliderVerticalTemplate}" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
</Trigger>
|
||||
<!-- 触发器:当IsEnabled属性为False时,设置前景色为灰色 -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="TickPlacement" Value="TopLeft" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="TickPlacement" Value="BottomRight" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="TickPlacement" Value="Both" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="IsSnapToTickEnabled" Value="True" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="DefaultSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
UseLayoutRounding="True">
|
||||
<Ellipse
|
||||
x:Name="grip"
|
||||
Width="15"
|
||||
Height="15"
|
||||
Fill="{DynamicResource ControlBackgroundNormalBrush}"
|
||||
StrokeThickness="1">
|
||||
<!--<Ellipse.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="12"
|
||||
Opacity="0.4"
|
||||
Color="{DynamicResource DarkShadowColor}" />
|
||||
</Ellipse.Effect>-->
|
||||
</Ellipse>
|
||||
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True" />
|
||||
<Trigger Property="IsDragging" Value="True">
|
||||
<!--<Setter TargetName="grip" Property="Effect">
|
||||
<Setter.Value>
|
||||
<DropShadowEffect
|
||||
BlurRadius="4"
|
||||
Opacity="0.6"
|
||||
ShadowDepth="3"
|
||||
Color="{DynamicResource DarkShadowColor}" />
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="grip" Property="Effect" Value="{x:Null}" />
|
||||
<Setter TargetName="grip" Property="Fill" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="grip" Property="Stroke" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<!-- 轨道垂直默认样式 -->
|
||||
<ControlTemplate x:Key="SliderVerticalTemplate" TargetType="{x:Type Slider}">
|
||||
@@ -133,8 +490,6 @@
|
||||
<Track.Thumb>
|
||||
<Thumb
|
||||
x:Name="Thumb"
|
||||
Width="22"
|
||||
Height="20"
|
||||
VerticalAlignment="Top"
|
||||
Focusable="False"
|
||||
OverridesDefaultStyle="True"
|
||||
|
||||
@@ -186,6 +186,7 @@
|
||||
<Style x:Key="SlotTextBoxStyle" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入..." />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
@@ -194,6 +195,7 @@
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
|
||||
@@ -44,12 +44,11 @@
|
||||
<!-- 主 TimePicker 样式 -->
|
||||
<Style TargetType="{x:Type controls:TimePicker}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<!--<Setter Property="Background" Value="Transparent" />-->
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="MinWidth" Value="150" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="10,4" />
|
||||
@@ -57,10 +56,10 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:TimePicker}">
|
||||
<Grid x:Name="templateRoot">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup
|
||||
x:Name="TimePickerPopup"
|
||||
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
||||
@@ -136,23 +135,22 @@
|
||||
<!-- Header -->
|
||||
<ContentPresenter
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentSource="Header" />
|
||||
<!-- 使用ToggleButton作为点击触发器 -->
|
||||
<ToggleButton
|
||||
x:Name="PART_ToggleButton"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="0"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Cursor="Hand">
|
||||
<!-- 主显示区域 -->
|
||||
<Border
|
||||
x:Name="ContentBorder"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="Center"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Border x:Name="ContentBorder" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
x:Name="HourTextBlock"
|
||||
@@ -178,6 +176,9 @@
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.5" />
|
||||
</Trigger>
|
||||
|
||||
@@ -79,7 +79,8 @@
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Text="{TemplateBinding Description}" />
|
||||
Text="{TemplateBinding Description}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
@@ -131,58 +131,127 @@
|
||||
_ => 1.0,
|
||||
};
|
||||
}
|
||||
//protected override Size MeasureOverride(Size availableSize)
|
||||
//{
|
||||
// double spaceTakenByAutoChildren = 0;
|
||||
// double totalSpanForFillChildren = 0;
|
||||
// double maxHeight = 0;
|
||||
|
||||
// --- 核心布局逻辑 (已更新以支持 Spacing) ---
|
||||
// // 【修改】计算所有间距占用的总宽度
|
||||
// var totalSpacing = Math.Max(0, InternalChildren.Count - 1) * Spacing;
|
||||
// // 【修改】计算真正可用于子控件的宽度
|
||||
// var effectiveWidth = Math.Max(0, availableSize.Width - totalSpacing);
|
||||
|
||||
// // 第一遍测量:自动大小的控件
|
||||
// foreach (UIElement child in InternalChildren)
|
||||
// {
|
||||
// if (child == null) continue;
|
||||
// var span = GetEffectiveSpan(child);
|
||||
// if (span < 0)
|
||||
// {
|
||||
// child.Measure(new Size(double.PositiveInfinity, availableSize.Height));
|
||||
// spaceTakenByAutoChildren += child.DesiredSize.Width;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// totalSpanForFillChildren += span;
|
||||
// }
|
||||
// }
|
||||
|
||||
// var remainingWidth = Math.Max(0, effectiveWidth - spaceTakenByAutoChildren);
|
||||
// var widthPerSpanUnit = (totalSpanForFillChildren > 0 && !double.IsInfinity(remainingWidth)) ? remainingWidth / totalSpanForFillChildren : 0;
|
||||
|
||||
// // 第二遍测量:比例填充的控件
|
||||
// foreach (UIElement child in InternalChildren)
|
||||
// {
|
||||
// if (child == null) continue;
|
||||
// var span = GetEffectiveSpan(child);
|
||||
// if (span >= 0)
|
||||
// {
|
||||
// child.Measure(new Size(widthPerSpanUnit * span, availableSize.Height));
|
||||
// }
|
||||
// if (child.DesiredSize.Height > maxHeight)
|
||||
// {
|
||||
// maxHeight = child.DesiredSize.Height;
|
||||
// }
|
||||
// }
|
||||
// // 返回的宽度应该是面板请求的总宽度
|
||||
// return new Size(availableSize.Width, maxHeight);
|
||||
//}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
double spaceTakenByAutoChildren = 0;
|
||||
double totalSpanForFillChildren = 0;
|
||||
double totalAutoWidth = 0;
|
||||
double totalSpanUnits = 0;
|
||||
double maxHeight = 0;
|
||||
bool isWidthInfinite = double.IsInfinity(availableSize.Width);
|
||||
|
||||
// 【修改】计算所有间距占用的总宽度
|
||||
var totalSpacing = Math.Max(0, InternalChildren.Count - 1) * Spacing;
|
||||
// 【修改】计算真正可用于子控件的宽度
|
||||
var effectiveWidth = Math.Max(0, availableSize.Width - totalSpacing);
|
||||
var childrenCount = InternalChildren.Count;
|
||||
var totalSpacing = Math.Max(0, childrenCount - 1) * Spacing;
|
||||
|
||||
// 第一遍测量:自动大小的控件
|
||||
// 第一遍测量:收集信息
|
||||
foreach (UIElement child in InternalChildren)
|
||||
{
|
||||
if (child == null) continue;
|
||||
if (child == null || child.Visibility == Visibility.Collapsed) continue;
|
||||
|
||||
var span = GetEffectiveSpan(child);
|
||||
if (span < 0)
|
||||
if (span < 0 || isWidthInfinite)
|
||||
{
|
||||
// 如果宽度是无穷大,或者子项是Auto,
|
||||
// 我们给它无穷大空间,看看它到底想占多大。
|
||||
child.Measure(new Size(double.PositiveInfinity, availableSize.Height));
|
||||
spaceTakenByAutoChildren += child.DesiredSize.Width;
|
||||
totalAutoWidth += child.DesiredSize.Width;
|
||||
}
|
||||
|
||||
if (span >= 0)
|
||||
{
|
||||
totalSpanUnits += span;
|
||||
}
|
||||
}
|
||||
|
||||
double finalWidth = 0;
|
||||
|
||||
if (isWidthInfinite)
|
||||
{
|
||||
// 情况 A: 宽度无穷大 (例如在 StackPanel 或 ScrollViewer 中)
|
||||
// 此时 Span 的逻辑无法分配“剩余空间”,通常做法是让 Span 项以 DesiredSize 形式并存
|
||||
// 或者你可以给 Span 项一个默认基础宽度(比如 0,或者它们内容的宽度)
|
||||
|
||||
// 这里我们把所有子项的 DesiredSize 加起来作为我们需要的总宽度
|
||||
finalWidth = totalAutoWidth + totalSpacing;
|
||||
|
||||
// 既然是无穷大,我们需要再次测量那些还没有正确 Measure 的 Span 项(可选)
|
||||
foreach (UIElement child in InternalChildren)
|
||||
{
|
||||
if (child == null || child.Visibility == Visibility.Collapsed) continue;
|
||||
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalSpanForFillChildren += span;
|
||||
}
|
||||
}
|
||||
// 情况 B: 宽度是有限的 (正常的 Grid 或固定宽度的容器)
|
||||
double remainingWidth = Math.Max(0, availableSize.Width - totalSpacing - totalAutoWidth);
|
||||
double widthPerSpanUnit = totalSpanUnits > 0 ? remainingWidth / totalSpanUnits : 0;
|
||||
|
||||
var remainingWidth = Math.Max(0, effectiveWidth - spaceTakenByAutoChildren);
|
||||
var widthPerSpanUnit = (totalSpanForFillChildren > 0 && !double.IsInfinity(remainingWidth)) ? remainingWidth / totalSpanForFillChildren : 0;
|
||||
|
||||
// 第二遍测量:比例填充的控件
|
||||
foreach (UIElement child in InternalChildren)
|
||||
{
|
||||
if (child == null) continue;
|
||||
if (child == null || child.Visibility == Visibility.Collapsed) continue;
|
||||
|
||||
var span = GetEffectiveSpan(child);
|
||||
if (span >= 0)
|
||||
{
|
||||
// 给 Span 项分配计算后的精确宽度
|
||||
child.Measure(new Size(widthPerSpanUnit * span, availableSize.Height));
|
||||
}
|
||||
if (child.DesiredSize.Height > maxHeight)
|
||||
{
|
||||
maxHeight = child.DesiredSize.Height;
|
||||
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
|
||||
}
|
||||
}
|
||||
// 返回的宽度应该是面板请求的总宽度
|
||||
return new Size(availableSize.Width, maxHeight);
|
||||
finalWidth = availableSize.Width; // 在有限宽度下,通常占用全部可用宽度
|
||||
}
|
||||
|
||||
// 重要:返回计算出的有限尺寸,绝不返回 availableSize.Width (如果是 Infinity)
|
||||
return new Size(finalWidth, maxHeight);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
用于控件的不同交互状态(正常、悬停、按压、选中、禁用)
|
||||
-->
|
||||
<!--<Color x:Key="ControlBackgroundNormalColor">#24272C</Color>-->
|
||||
<Color x:Key="ControlBackgroundNormalColor">#3D3D3E</Color>
|
||||
<Color x:Key="ControlBackgroundNormalColor">#282828</Color>
|
||||
<SolidColorBrush x:Key="ControlBackgroundNormalBrush" Color="{DynamicResource ControlBackgroundNormalColor}" />
|
||||
|
||||
<Color x:Key="ControlBackgroundHoverColor">#333333</Color>
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
<neu:NeoWindow
|
||||
<n:NeoWindow
|
||||
x:Class="NeoUITest.ControlTestWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dataModel="clr-namespace:NeoUITest.DataModel"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:neu="https://github.com/ShrlAlgo/NeoUI"
|
||||
xmlns:sys="clr-namespace:System;assembly=netfx.force.conflicts"
|
||||
xmlns:n="https://github.com/ShrlAlgo/NeoUI"
|
||||
Title="测试"
|
||||
Width="800"
|
||||
Height="600"
|
||||
d:Height="1200"
|
||||
d:SizeToContent="WidthAndHeight"
|
||||
d:DesignHeight="1200"
|
||||
Icon="/Resources/Images/ImageTest.png"
|
||||
mc:Ignorable="d">
|
||||
<!-- 主窗口背景色,这是拟态风格的基础 -->
|
||||
<neu:NeoWindow.Resources>
|
||||
<n:NeoWindow.Resources>
|
||||
<dataModel:DataGridDemo x:Key="Dgd" />
|
||||
<!--<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/NeuWPFTest;component/ButtonStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>-->
|
||||
</neu:NeoWindow.Resources>
|
||||
</n:NeoWindow.Resources>
|
||||
<!--<lu:WindowAssist.TitleBar>
|
||||
<Menu>
|
||||
<MenuItem Header="Help">
|
||||
@@ -31,26 +29,17 @@
|
||||
</Menu>
|
||||
</lu:WindowAssist.TitleBar>-->
|
||||
<Grid>
|
||||
<neu:StackPanel Background="{DynamicResource BackgroundLayoutBrush}" Spacing="10">
|
||||
<neu:PropertyField
|
||||
Grid.Row="0"
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<n:StackPanel Background="{DynamicResource BackgroundLayoutBrush}" Spacing="10">
|
||||
<n:PropertyField
|
||||
Margin="6,0"
|
||||
PropertyName="属性"
|
||||
PropertyValue="123" />
|
||||
<neu:PropertyField
|
||||
Grid.Row="1"
|
||||
<n:PropertyField
|
||||
Margin="6,0"
|
||||
PropertyName="属性x"
|
||||
PropertyValue="154" />
|
||||
<UniformGrid
|
||||
Grid.Row="6"
|
||||
Margin="20"
|
||||
HorizontalAlignment="Center">
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
<UniformGrid Rows="1">
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
@@ -69,7 +58,7 @@
|
||||
ToolTipService.Placement="Bottom" />
|
||||
<TextBox Style="{StaticResource SlotTextBoxStyle}" Text="TextBox" />
|
||||
</UniformGrid>
|
||||
<neu:NeuDataGrid
|
||||
<n:NeuDataGrid
|
||||
x:Name="NeuDG1"
|
||||
Margin="4"
|
||||
BindableSelectedItems="{Binding SelectedDataGridItems, Mode=TwoWay}"
|
||||
@@ -85,7 +74,37 @@
|
||||
DataContext="{StaticResource Dgd}"
|
||||
ItemsSource="{Binding DataCollection}"
|
||||
Style="{StaticResource CheckBoxHeadDataGridStyle}" />
|
||||
<UniformGrid Rows="4">
|
||||
<TextBox x:Name="License" />
|
||||
<Button
|
||||
Click="LicenseClick"
|
||||
Content="授权算号"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
<TextBox x:Name="PrivateKey" n:InputAssist.Prefix="私钥:" />
|
||||
<TextBox x:Name="PublicKey" n:InputAssist.Prefix="公钥:" />
|
||||
<Button
|
||||
Click="GenerateKeyClick"
|
||||
Content="计算公私密钥"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
<Button
|
||||
Click="ValidateClick"
|
||||
Content="验证"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
<Button
|
||||
Click="RemoveLicenseClick"
|
||||
Content="移除注册"
|
||||
Style="{StaticResource EmbossButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
|
||||
</neu:StackPanel>
|
||||
</UniformGrid>
|
||||
</n:StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</neu:NeoWindow>
|
||||
</n:NeoWindow>
|
||||
@@ -1,5 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Management;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace NeoUITest
|
||||
{
|
||||
@@ -8,9 +17,215 @@ namespace NeoUITest
|
||||
/// </summary>
|
||||
public partial class ControlTestWindow
|
||||
{
|
||||
private const string Privatekey =
|
||||
@"<RSAKeyValue><Modulus>rd5+EjU6QxaTY/AalU9g6ugAquN0ahJSgeahnf2CrfvUAWFNJ+SH7Qr0RcvOTyAbWfvLWoBDACKaPsg+8nRQcO3EZdFyjJ9oycLNrw38+gSB2+/79Axys/8MHtSXVUw9WN2e9LxeHOQGtcaoSsp+bPGaXswthovQ2CkvBTmCokcAOX6UaR7Av4npaXyEoGCUsZLEiSydMsNbQ+wLsumVg1H2o/cpkO0s4DiJHoF66zUuxA+pYSjSCn5KTUsOemf+gBsob6Sw+7WOToyiOkMdO9Op6esf8yL7DJ1Yd40XaKd5IeLQmEX/b+n1EV2JEkGO0p9q9MQRp6NrEc9LvfMJWQ==</Modulus><Exponent>AQAB</Exponent><P>yR+R5ofKJenqgMvXxT/Tqxka4jeuPz+Uta9WXYVyzIeyjESOEe1B9uM+DkhM27zw8XsG143KpzUp8jy5Gh6z14ivfUbv09GN5ICFWeqEOQJ8JSPfqcq5YKpFNY+zJGNgUfKdLwMUvu55O6Y2BdB2yLFwAUztUAW0qT+ZmINI3xM=</P><Q>3U84e83rhoi5o4kR9I4JllM1ys/43uvJSVDwkqAo+p7R1uFUsl1STNHVo/d0mJKXLOf8J4fI0yVz1H73XBHjEzJqJPWlycOArA+c8eKtLvvIlauSh1ulAJbSKlINxjr6aVjXH9ztGKRVIRU2EuUPKQKwnxScKrqNbeGqRKHPx2M=</Q><DP>ktj9I3AkFfisIywyuC+5MeUbru5uyHl48As8qP4l6tZtdGMdxFMSZdxX0//QNmTHG9nzDfHWdK2pmdfiYwLl1spTL8pak7Mewidgtl03+5Qn5spBpWyCW+UWsVvhtgDlNBBL2iaKwDnIxNe//BDQmgqMODbd0x7HYQgx8pxw2Yc=</DP><DQ>dblkhIcfmKs2hQWvJXZBJ1QQM1i6PGsU4glKT9Uet2KwoSuwUElQNEkS6mwB+/9Op7an7adPbvJnUUxQ7QsezeFtkUeS72cuFVkg1ZMNKQcKxoNEKPjZJx0ToyuO5DoPZua5WNu+y/LuzfBomVh73gbuSVE/WYNvJFp8ppGk450=</DQ><InverseQ>gSHzvMS0Fu4j/yuzjOjLXYxR8qP3AweEbLlM8/SBjpT5qq+R+j/m3q7vTvYZwwMqAMamGWmTHAlQvOjnSeV2Qnb2C/bqs5jTTiDGyY/xqGV8pFlkegieBl+zJYrOyisUP/xNk4ckKhGfGUIan91N8R5M9Dk2x0hOTCY7m4Tv2SI=</InverseQ><D>polHLj+Hh7z2/jF79OnsRfRkt0pYNkVIfB4hTYgGBIoCfjPpyD0wKM9mO/hDqyxwplb0Z8IU6us53MrG6EqaxiAoDvJ4CtOhdie+BV+boQpyK+0I4rCNqXSw8lLkhRIabKUSXQ6UAo4zEyeuCL0+LTGZkBV3wbjoGDQSUqnMQ4uzvuGsWUU76Y/nnpYf6VVajCsLAseQbdAbeLuL0WPmNqO+E3SLsL72z5lgqkk5yyEQYDTWZMEuFUsyGmP+XC4EBp44IW3eQmPPBfUqxRvCAq2Gvk95Q+9H9FZlTW4ctMSezOZaH9pAaJvG5QL2ggw+KXh+pljnM8bYtL2I+KWtNQ==</D></RSAKeyValue>";
|
||||
|
||||
public ControlTestWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LicenseClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var license = CreateLicense(LicenseEngine.GetMachineCode(), "20251230", Privatekey);
|
||||
LicenseEngine.SaveToRegistry("Key", license);
|
||||
License.Text=license;
|
||||
MessageBox.Show("授权码已写入注册表");
|
||||
}
|
||||
|
||||
// 开发者工具中的生成逻辑
|
||||
public string CreateLicense(string machineCode, string expiryDate, string privateKey)
|
||||
{
|
||||
string dataToSign = $"{machineCode}|{expiryDate}";
|
||||
using var rsa = new RSACryptoServiceProvider();
|
||||
rsa.FromXmlString(privateKey);
|
||||
var formatter = new RSAPKCS1SignatureFormatter(rsa);
|
||||
formatter.SetHashAlgorithm("SHA256");
|
||||
|
||||
byte[] dataBytes = Encoding.UTF8.GetBytes(dataToSign);
|
||||
using var sha = SHA256.Create();
|
||||
byte[] hash = sha.ComputeHash(dataBytes);
|
||||
string signature = Convert.ToBase64String(formatter.CreateSignature(hash));
|
||||
// 最终格式:签名|机器码|到期日期
|
||||
return $"{signature}|{machineCode}|{expiryDate}";
|
||||
}
|
||||
|
||||
private void GenerateKeyClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using var rsa = new RSACryptoServiceProvider(2048);
|
||||
PublicKey.Text = rsa.ToXmlString(false); // 放在插件里
|
||||
PrivateKey.Text = rsa.ToXmlString(true); // 自己妥善保存
|
||||
}
|
||||
|
||||
private void ValidateClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = LicenseEngine.Validate();
|
||||
MessageBox.Show(result.message);
|
||||
}
|
||||
|
||||
private void RemoveLicenseClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LicenseEngine.DestroyAllLicenseData();
|
||||
MessageBox.Show("授权已注销");
|
||||
}
|
||||
}
|
||||
public class LicenseEngine
|
||||
{
|
||||
// 【重要】替换为你生成的公钥
|
||||
private const string PublicKey = @"<RSAKeyValue><Modulus>rd5+EjU6QxaTY/AalU9g6ugAquN0ahJSgeahnf2CrfvUAWFNJ+SH7Qr0RcvOTyAbWfvLWoBDACKaPsg+8nRQcO3EZdFyjJ9oycLNrw38+gSB2+/79Axys/8MHtSXVUw9WN2e9LxeHOQGtcaoSsp+bPGaXswthovQ2CkvBTmCokcAOX6UaR7Av4npaXyEoGCUsZLEiSydMsNbQ+wLsumVg1H2o/cpkO0s4DiJHoF66zUuxA+pYSjSCn5KTUsOemf+gBsob6Sw+7WOToyiOkMdO9Op6esf8yL7DJ1Yd40XaKd5IeLQmEX/b+n1EV2JEkGO0p9q9MQRp6NrEc9LvfMJWQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
|
||||
|
||||
private static string RegPath = @$"Software\{Assembly.GetExecutingAssembly().GetName()}\License";
|
||||
|
||||
/// <summary>
|
||||
/// 完整验证逻辑
|
||||
/// </summary>
|
||||
public static (bool isValid, string message) Validate()
|
||||
{
|
||||
string licenseKey = LoadFromRegistry("Key");
|
||||
if (string.IsNullOrEmpty(licenseKey)) return (false, "未找到授权码");
|
||||
|
||||
try
|
||||
{
|
||||
// 1. RSA 解密/验证逻辑
|
||||
// 激活码格式:签名(Base64)|机器码|到期日期
|
||||
var parts = licenseKey.Split('|');
|
||||
if (parts.Length != 3) return (false, "授权格式非法");
|
||||
|
||||
string signature = parts[0];
|
||||
string mCode = parts[1];
|
||||
string expiryStr = parts[2];
|
||||
|
||||
// 2. 验证是否是本机的机器码
|
||||
if (mCode != GetMachineCode()) return (false, "授权码与本机硬件不匹配");
|
||||
|
||||
// 3. 验证 RSA 签名(确保数据没被篡改)
|
||||
if (!VerifySignature($"{mCode}|{expiryStr}", signature)) return (false, "授权签名校验失败");
|
||||
|
||||
// 4. 时间校验
|
||||
DateTime expiryDate = DateTime.ParseExact(expiryStr, "yyyyMMdd", CultureInfo.InvariantCulture);
|
||||
DateTime now = GetRobustDateTime();
|
||||
|
||||
// 防回滚检查
|
||||
DateTime lastRun = GetLastRunTime();
|
||||
if (now < lastRun) return (false, "系统时间异常,请检查时钟");
|
||||
UpdateLastRunTime(now);
|
||||
|
||||
if (now > expiryDate) return (false, $"授权已于 {expiryDate:yyyy-MM-dd} 到期");
|
||||
|
||||
return (true, "授权有效");
|
||||
}
|
||||
catch { return (false, "解析授权出错"); }
|
||||
}
|
||||
|
||||
private static bool VerifySignature(string data, string signature)
|
||||
{
|
||||
using (var rsa = new RSACryptoServiceProvider())
|
||||
{
|
||||
rsa.FromXmlString(PublicKey);
|
||||
var formatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
formatter.SetHashAlgorithm("SHA256");
|
||||
byte[] dataBytes = Encoding.UTF8.GetBytes(data);
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
byte[] hash = sha.ComputeHash(dataBytes);
|
||||
return formatter.VerifySignature(hash, Convert.FromBase64String(signature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetMachineCode()
|
||||
{
|
||||
// 组合 CPU ID + 硬盘 ID
|
||||
string raw = GetHardwareId("Win32_Processor", "ProcessorId") +
|
||||
GetHardwareId("Win32_PhysicalMedia", "SerialNumber");
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes(raw));
|
||||
return BitConverter.ToString(hash).Replace("-", "").Substring(0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetHardwareId(string wmiClass, string property)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var mc = new ManagementClass(wmiClass))
|
||||
foreach (var mo in mc.GetInstances()) return mo[property]?.ToString().Trim();
|
||||
}
|
||||
catch { }
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
// 获取可靠的时间(网络优先,本地其次)
|
||||
private static DateTime GetRobustDateTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = WebRequest.Create("http://www.baidu.com");
|
||||
request.Timeout = 2000;
|
||||
using (var response = request.GetResponse())
|
||||
{
|
||||
string dateStr = response.Headers["Date"];
|
||||
return DateTime.ParseExact(dateStr, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
|
||||
}
|
||||
}
|
||||
catch { return DateTime.Now; }
|
||||
}
|
||||
|
||||
#region 注册表操作
|
||||
private static DateTime GetLastRunTime()
|
||||
{
|
||||
string val = LoadFromRegistry("T");
|
||||
return string.IsNullOrEmpty(val) ? DateTime.MinValue : new DateTime(long.Parse(val));
|
||||
}
|
||||
private static void UpdateLastRunTime(DateTime now) => SaveToRegistry("T", now.Ticks.ToString());
|
||||
|
||||
public static void SaveToRegistry(string key, string val)
|
||||
{
|
||||
using var r = Registry.CurrentUser.CreateSubKey(RegPath);
|
||||
r.SetValue(key, val);
|
||||
}
|
||||
private static string LoadFromRegistry(string key)
|
||||
{
|
||||
using var r = Registry.CurrentUser.OpenSubKey(RegPath);
|
||||
return r?.GetValue(key)?.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 仅移除当前的激活码(重置授权状态,但保留时间戳防止白嫖)
|
||||
/// </summary>
|
||||
public static void ClearLicenseKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var r = Registry.CurrentUser.OpenSubKey(RegPath, true))
|
||||
{
|
||||
if (r != null && r.GetValue("Key") != null)
|
||||
{
|
||||
r.DeleteValue("Key");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("移除授权码失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 彻底销毁所有授权痕迹(包括时间戳记录,通常用于卸载)
|
||||
/// </summary>
|
||||
public static void DestroyAllLicenseData()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 第二个参数为 false 表示:如果路径不存在,不抛出异常
|
||||
Registry.CurrentUser.DeleteSubKeyTree(RegPath, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("彻底清理注册表失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,57 +138,17 @@
|
||||
</ComboBox>
|
||||
</ToolBar>
|
||||
<ToolBar Foreground="{DynamicResource PrimaryFocusedBrush}" Header="工具栏">
|
||||
<ToggleButton Content="切换" />
|
||||
<Button
|
||||
x:Name="Test"
|
||||
Click="Test_OnClick"
|
||||
Content="测试" />
|
||||
Content="测试窗口" />
|
||||
<Button Click="Icon_OnClick" Content="图标" />
|
||||
<Button Click="ColorPalette_OnClick" Content="配色" />
|
||||
<Button Click="ShowNeumorphism_Click" Content="Neumorphism" />
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<!-- 中间部分 -->
|
||||
<n:Anchor Grid.Row="1" Margin="4">
|
||||
<n:StackPanel Spacing="5">
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="装饰器 Decoration" Header="装饰器">
|
||||
<StackPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:SlotBorder
|
||||
Height="100"
|
||||
Margin="5"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="凹槽"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
<n:EmbossBorder
|
||||
Margin="5"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="浮雕"
|
||||
ContextMenu="{StaticResource ContextMenuDemo}"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}"
|
||||
ToolTip="右键" />
|
||||
<n:Card
|
||||
Margin="5"
|
||||
Content="卡片"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
</n:FlexibleRowPanel>
|
||||
|
||||
<n:LightedSurface
|
||||
Height="100"
|
||||
Margin="5"
|
||||
Content="在此处移动鼠标"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="警告提示 Alert">
|
||||
<StackPanel>
|
||||
<CheckBox x:Name="IsBanner" Content="标题" />
|
||||
@@ -337,10 +297,6 @@
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:Tag Content="默认标签" />
|
||||
<n:Tag
|
||||
Closable="True"
|
||||
Content="可关闭标签"
|
||||
Style="{StaticResource EmbossTag}" />
|
||||
<n:Tag
|
||||
Closable="True"
|
||||
Content="颜色标签"
|
||||
@@ -381,7 +337,7 @@
|
||||
ColumnSpacing="0"
|
||||
Columns="6"
|
||||
RowSpacing="0"
|
||||
Rows="4">
|
||||
Rows="2">
|
||||
<Button n:ControlAssist.Icon="{n:Icon SymbolValue=SmartButton}" Content="基本" />
|
||||
<Button
|
||||
n:ControlAssist.Icon="{n:Icon SymbolValue=SmartButton}"
|
||||
@@ -678,42 +634,6 @@
|
||||
<n:ToggleSwitch IsChecked="True" IsEnabled="False" />
|
||||
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:ToggleSwitch IsChecked="False" Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
<n:ToggleSwitch
|
||||
IsChecked="False"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
<n:ToggleSwitch IsChecked="True" Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
|
||||
<n:ToggleSwitch
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.OffContent="{n:Icon SymbolValue=ToggleOff}"
|
||||
n:ControlAssist.OnContent="{n:Icon ToggleOn}"
|
||||
n:ControlAssist.ShowText="True"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.OffContent="{n:Icon SymbolValue=ToggleOff}"
|
||||
n:ControlAssist.OnContent="{n:Icon ToggleOn}"
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.ShowText="False"
|
||||
IsChecked="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
IsChecked="False"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
</n:FlexibleRowPanel>
|
||||
</StackPanel>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="文本标签 Label">
|
||||
<UniformGrid Rows="1">
|
||||
@@ -743,39 +663,7 @@
|
||||
IsChecked="True"
|
||||
IsEnabled="False" />
|
||||
</UniformGrid>
|
||||
<UniformGrid Rows="1">
|
||||
<CheckBox Content="复选框" Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
<UniformGrid Rows="1">
|
||||
<CheckBox Content="复选框" Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Content="复选框"
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
</UniformGrid>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="单选框 RadioButton">
|
||||
<n:FlexibleRowPanel>
|
||||
<RadioButton
|
||||
@@ -803,28 +691,6 @@
|
||||
GroupName="RadioG2"
|
||||
IsEnabled="False" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<RadioButton
|
||||
Content="单选按钮 A"
|
||||
GroupName="RadioG3"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
<RadioButton
|
||||
Content="单选按钮 C"
|
||||
GroupName="RadioG3"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
<RadioButton
|
||||
Content="禁用单选按钮 A"
|
||||
GroupName="RadioG4"
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
<RadioButton
|
||||
Content="禁用单选按钮 C"
|
||||
GroupName="RadioG4"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
</StackPanel>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="滑动/滚动条 Slider">
|
||||
<Grid>
|
||||
@@ -921,8 +787,8 @@
|
||||
</StackPanel>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="文件、文件夹 Browser">
|
||||
<n:FlexibleRowPanel>
|
||||
<n:ChooseBox PlaceholderText="请选择路径" />
|
||||
<n:ChooseBox IsEnabled="False" Text="选择路径" />
|
||||
<n:ChooseBox />
|
||||
<n:ChooseBox IsEnabled="False" />
|
||||
</n:FlexibleRowPanel>
|
||||
<UniformGrid Rows="1">
|
||||
<n:UploadArea
|
||||
@@ -951,7 +817,6 @@
|
||||
<n:FlexibleRowPanel n:ControlAssist.AnchorHeaderText="时间日期 DataPicker" LayoutMode="Auto">
|
||||
<StackPanel>
|
||||
<DatePicker />
|
||||
<DatePicker Style="{StaticResource SlotDatePicker}" />
|
||||
</StackPanel>
|
||||
<Calendar Margin="5">
|
||||
<Calendar.BlackoutDates>
|
||||
@@ -1053,7 +918,7 @@
|
||||
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel LayoutMode="Auto" Spacing="20">
|
||||
<UniformGrid Columns="1">
|
||||
<UniformGrid Columns="3">
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
@@ -1063,87 +928,14 @@
|
||||
<ListBoxItem Content="Away" />
|
||||
<ListBoxItem Content="Night" />
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
IsEnabled="False"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
|
||||
</UniformGrid>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
SelectedIndex="1"
|
||||
SelectionMode="Multiple"
|
||||
Style="{StaticResource SlotTabGroupListBoxStyle}">
|
||||
<ListBoxItem Content="Home" />
|
||||
<ListBoxItem Content="Away" />
|
||||
<ListBoxItem Content="Night" />
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
IsEnabled="False"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlotTabGroupListBoxStyle}">
|
||||
<ListBoxItem Content="Home" />
|
||||
<ListBoxItem Content="Away" />
|
||||
<ListBoxItem Content="Night" />
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
SelectedIndex="0"
|
||||
SelectionMode="Multiple"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
|
||||
</n:FlexibleRowPanel>
|
||||
</StackPanel>
|
||||
<StackPanel n:ControlAssist.AnchorHeaderText="数据展示 TabControl">
|
||||
<WrapPanel>
|
||||
<TabControl Style="{StaticResource NavigationTabControlStyle}">
|
||||
<TabItem Header="选项卡 1">
|
||||
<Grid Margin="4">
|
||||
<!-- <Separator /> -->
|
||||
<DataGrid
|
||||
Margin="4"
|
||||
DataContext="{StaticResource Dgd}"
|
||||
ItemsSource="{Binding DataCollection}"
|
||||
SelectedItem="{Binding SelectedDataGridItem}" />
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="选项卡 2" />
|
||||
<TabItem Header="禁用选项卡" IsEnabled="False" />
|
||||
</TabControl>
|
||||
|
||||
<TabControl>
|
||||
<TabItem Header="选项卡 1">
|
||||
|
||||
@@ -403,6 +403,15 @@ public partial class MainWindow
|
||||
|
||||
#endregion
|
||||
|
||||
private void ShowNeumorphism_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NeumorphismWindow window = new NeumorphismWindow
|
||||
{
|
||||
Owner = this,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
||||
};
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
#region 数据模型
|
||||
|
||||
@@ -30,5 +30,8 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NeoUI\NeoUI.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Management" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
519
NeoUI/NeoUITest/NeumorphismWindow.xaml
Normal file
519
NeoUI/NeoUITest/NeumorphismWindow.xaml
Normal file
@@ -0,0 +1,519 @@
|
||||
<n:NeoWindow
|
||||
x:Class="NeoUITest.NeumorphismWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dataModel="clr-namespace:NeoUITest.DataModel"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:n="https://github.com/ShrlAlgo/NeoUI"
|
||||
xmlns:neoUiTest="clr-namespace:NeoUITest"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Title="NeumorphismWindow"
|
||||
Width="800"
|
||||
Height="450"
|
||||
d:DataContext="{d:DesignInstance Type=neoUiTest:MainWindow}"
|
||||
d:Height="Auto"
|
||||
mc:Ignorable="d">
|
||||
<n:NeoWindow.Resources>
|
||||
<ResourceDictionary>
|
||||
<ContextMenu x:Key="ContextMenuDemo">
|
||||
<MenuItem Header="菜单01" />
|
||||
<MenuItem Header="菜单02" />
|
||||
<Separator />
|
||||
<MenuItem Header="菜单03">
|
||||
<MenuItem Header="菜单A1" />
|
||||
<MenuItem Header="菜单A2" />
|
||||
<Separator />
|
||||
<MenuItem Header="菜单A3" />
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
<neoUiTest:MainViewModel x:Key="MainViewModel" />
|
||||
<!-- <ResourceDictionary.MergedDictionaries> -->
|
||||
<!-- <enu:ThemesDictionary Theme="Dark" /> -->
|
||||
<!-- <enu:ControlsDictionary /> -->
|
||||
<!-- </ResourceDictionary.MergedDictionaries> -->
|
||||
<dataModel:DataGridDemo x:Key="Dgd" />
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
</n:NeoWindow.Resources>
|
||||
<Grid>
|
||||
<!--<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>-->
|
||||
<n:Anchor>
|
||||
<n:StackPanel Spacing="5">
|
||||
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="装饰器 Decoration" Header="Decoration">
|
||||
<StackPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:SlotBorder
|
||||
Height="100"
|
||||
Margin="5"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="凹槽"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
<n:EmbossBorder
|
||||
Margin="5"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="浮雕"
|
||||
ContextMenu="{StaticResource ContextMenuDemo}"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}"
|
||||
ToolTip="右键" />
|
||||
<n:Card
|
||||
Margin="5"
|
||||
Content="卡片"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
</n:FlexibleRowPanel>
|
||||
|
||||
<n:LightedSurface
|
||||
Height="100"
|
||||
Margin="5"
|
||||
Content="在此处移动鼠标"
|
||||
CornerRadius="16"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource PrimaryGradientBrush}" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="按钮 Buttons" Header="Buttons">
|
||||
<WrapPanel>
|
||||
<Button
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕按钮"
|
||||
FontSize="16"
|
||||
Style="{StaticResource EmbossButtonStyle}" />
|
||||
<Button
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
FontSize="16"
|
||||
Style="{StaticResource EmbossIconButtonStyle}" />
|
||||
<Button
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮动按钮"
|
||||
FontSize="16"
|
||||
Style="{StaticResource FloatButtonStyle}" />
|
||||
<Button
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="光亮按钮"
|
||||
FontSize="16"
|
||||
Style="{StaticResource LightedButtonStyle}" />
|
||||
</WrapPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="文本框 TextBox" Header="TextBox">
|
||||
<StackPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<TextBox Style="{StaticResource SlotTextBoxStyle}" />
|
||||
<PasswordBox n:InputAssist.Password="453" Style="{StaticResource SlotPasswordBoxStyle}" />
|
||||
<PasswordBox
|
||||
n:InputAssist.Clearable="True"
|
||||
n:InputAssist.IsPasswordVisible="True"
|
||||
n:InputAssist.Password="453"
|
||||
Style="{StaticResource SlotPasswordBoxStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<DatePicker Style="{StaticResource SlotDatePicker}" />
|
||||
<n:NumberBox Style="{StaticResource SlotNumberBoxStyle}" />
|
||||
<n:NumericBox Style="{StaticResource SlotTextBoxStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:ChooseBox Style="{StaticResource SlotChooseBoxStyle}" />
|
||||
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="Component" Header="Avatar Tag">
|
||||
<n:FlexibleRowPanel>
|
||||
<n:Avatar Style="{StaticResource SlotAvatarStyle}" />
|
||||
<n:Tag Content="Tag" Style="{StaticResource EmbossTag}" />
|
||||
<n:Chip Content="Chip" Style="{StaticResource EmbossChipStyle}" />
|
||||
<n:Chip
|
||||
Content="必应"
|
||||
Style="{StaticResource EmbossChipStyle}"
|
||||
Url="www.bing.com">
|
||||
<n:Chip.Header>
|
||||
<n:IconElement Symbol="Search" />
|
||||
</n:Chip.Header>
|
||||
</n:Chip>
|
||||
</n:FlexibleRowPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="单选框 RadioButton" Header="RadioButton">
|
||||
<n:FlexibleRowPanel>
|
||||
<RadioButton
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
<RadioButton
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
Style="{StaticResource EmbossRadioButtonStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="切换 Toggle" Header="Toggle">
|
||||
<StackPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<ToggleButton
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕切换"
|
||||
FontSize="16"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource EmbossToggleButtonStyle}" />
|
||||
<n:ToggleSwitch
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.OffContent="{n:Icon SymbolValue=ToggleOff}"
|
||||
n:ControlAssist.OnContent="{n:Icon ToggleOn}"
|
||||
n:ControlAssist.ShowText="True"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.OffContent="{n:Icon SymbolValue=ToggleOff}"
|
||||
n:ControlAssist.OnContent="{n:Icon ToggleOn}"
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
n:ControlAssist.ShowText="False"
|
||||
IsChecked="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
<n:ToggleSwitch
|
||||
IsChecked="False"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource SlotToggleSwitch}" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<n:ToggleSwitch IsChecked="False" Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
<n:ToggleSwitch
|
||||
IsChecked="False"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
<n:ToggleSwitch IsChecked="True" Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
|
||||
<n:ToggleSwitch
|
||||
IsChecked="True"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource FloatToggleSwitchStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="复选框 CheckBox" Header="CheckBox">
|
||||
<StackPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<CheckBox
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
Style="{StaticResource EmbossCheckBoxStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
<n:FlexibleRowPanel>
|
||||
<CheckBox
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
IsChecked="True"
|
||||
Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
<CheckBox
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
Content="浮雕单选框"
|
||||
FontSize="16"
|
||||
Style="{StaticResource SlotCheckBoxStyle}" />
|
||||
</n:FlexibleRowPanel>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="组合框 ComboBox" Header="ComboBox">
|
||||
<n:FlexibleRowPanel>
|
||||
<ComboBox
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
FontSize="16"
|
||||
Style="{StaticResource FloatComboBoxStyle}" />
|
||||
<n:Cascader
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding StaffList, Mode=TwoWay}"
|
||||
SelectedValue="{Binding SelectedItem, Mode=TwoWay}"
|
||||
SubmenuMemberPath="Children" />
|
||||
</n:FlexibleRowPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="分页导航 Pagination" Header="Pagination">
|
||||
<n:FlexibleRowPanel>
|
||||
<n:Pagination
|
||||
Margin="0,15,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
CurrentPage="3"
|
||||
PageSize="20"
|
||||
ShowPageInput="True"
|
||||
Style="{StaticResource EmbossPaginationStyle}"
|
||||
TotalItems="102" />
|
||||
</n:FlexibleRowPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="标签导航 TabControl" Header="TabControl">
|
||||
<n:FlexibleRowPanel>
|
||||
<TabControl Style="{StaticResource NavigationTabControlStyle}">
|
||||
<TabItem Header="选项卡 1">
|
||||
<Grid Margin="4">
|
||||
<!-- <Separator /> -->
|
||||
<DataGrid
|
||||
Margin="4"
|
||||
DataContext="{StaticResource Dgd}"
|
||||
ItemsSource="{Binding DataCollection}"
|
||||
SelectedItem="{Binding SelectedDataGridItem}" />
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="选项卡 2" />
|
||||
<TabItem Header="禁用选项卡" IsEnabled="False" />
|
||||
</TabControl>
|
||||
</n:FlexibleRowPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="滑动/滚动条 Slider" Header="Slider Progress">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<CheckBox x:Name="IsSpining" Content="加载中" />
|
||||
<StackPanel Height="100" Orientation="Horizontal">
|
||||
<Slider
|
||||
x:Name="ProgressVerticalSlider"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Orientation="Vertical"
|
||||
Value="25" />
|
||||
<Slider
|
||||
x:Name="ProgressVerticalSlider1"
|
||||
IsEnabled="False"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Orientation="Vertical"
|
||||
Value="25" />
|
||||
<ProgressBar
|
||||
Height="100"
|
||||
IsIndeterminate="{Binding ElementName=ProgressCheckbox, Path=IsChecked}"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Orientation="Vertical"
|
||||
Style="{StaticResource SlotProgressBarStyle}"
|
||||
Value="{Binding ElementName=ProgressVerticalSlider, Path=Value}" />
|
||||
<ProgressBar
|
||||
Height="100"
|
||||
IsEnabled="False"
|
||||
IsIndeterminate="{Binding ElementName=ProgressCheckbox, Path=IsChecked}"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Orientation="Vertical"
|
||||
Style="{StaticResource SlotProgressBarStyle}"
|
||||
Value="{Binding ElementName=ProgressVerticalSlider, Path=Value}" />
|
||||
<ProgressBar
|
||||
Height="100"
|
||||
IsEnabled="False"
|
||||
IsIndeterminate="True"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Orientation="Vertical"
|
||||
Style="{StaticResource SlotProgressBarStyle}"
|
||||
Value="100" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Column="1" Panel.ZIndex="10">
|
||||
<n:Spin Spinning="{Binding ElementName=IsSpining, Path=IsChecked}" Tip="加载中...">
|
||||
<StackPanel x:Name="SpinPanel">
|
||||
<CheckBox x:Name="ProgressCheckbox" Content="进度待定" />
|
||||
<Slider
|
||||
x:Name="ProgressSlider"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Value="25" />
|
||||
<Slider
|
||||
x:Name="ProgressTickSlider"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
TickFrequency="10"
|
||||
TickPlacement="TopLeft" />
|
||||
<Slider
|
||||
x:Name="ProgressSlider1"
|
||||
IsEnabled="False"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Value="25" />
|
||||
<ProgressBar
|
||||
IsIndeterminate="{Binding ElementName=ProgressCheckbox, Path=IsChecked}"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Style="{StaticResource SlotProgressBarStyle}"
|
||||
Value="{Binding ElementName=ProgressSlider, Path=Value}" />
|
||||
<ProgressBar
|
||||
IsEnabled="False"
|
||||
IsIndeterminate="{Binding ElementName=ProgressCheckbox, Path=IsChecked}"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Style="{StaticResource SlotProgressBarStyle}"
|
||||
Value="{Binding ElementName=ProgressSlider, Path=Value}" />
|
||||
</StackPanel>
|
||||
</n:Spin>
|
||||
<n:Spin
|
||||
HorizontalAlignment="Left"
|
||||
Spinning="{Binding ElementName=IsSpining, Path=IsChecked}"
|
||||
Tip="加载中...">
|
||||
<n:Spin.Indicator>
|
||||
<n:IconElement Symbol="Downloading" />
|
||||
</n:Spin.Indicator>
|
||||
</n:Spin>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="列表框 ListBox" Header="ListBox">
|
||||
<n:StackPanel Orientation="Horizontal" Spacing="3">
|
||||
<n:StackPanel Spacing="10">
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
IsEnabled="False"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource EmbossChipListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
<sys:String>Another Tab</sys:String>
|
||||
</ListBox>
|
||||
</n:StackPanel>
|
||||
<n:StackPanel Orientation="Horizontal" Spacing="3">
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
SelectedIndex="1"
|
||||
SelectionMode="Multiple"
|
||||
Style="{StaticResource SlotTabGroupListBoxStyle}">
|
||||
<ListBoxItem Content="Home" />
|
||||
<ListBoxItem Content="Away" />
|
||||
<ListBoxItem Content="Night" />
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
IsEnabled="False"
|
||||
SelectedIndex="1"
|
||||
Style="{StaticResource SlotTabGroupListBoxStyle}">
|
||||
<ListBoxItem Content="Home" />
|
||||
<ListBoxItem Content="Away" />
|
||||
<ListBoxItem Content="Night" />
|
||||
</ListBox>
|
||||
<ListBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
n:BehaviorAssist.EnableSlideAnimation="True"
|
||||
n:ControlAssist.Orientation="Vertical"
|
||||
SelectedIndex="0"
|
||||
SelectionMode="Multiple"
|
||||
Style="{StaticResource SlideTabGroupListBoxStyle}">
|
||||
<!-- 这里是你的数据项 -->
|
||||
<sys:String>Tab 1</sys:String>
|
||||
<sys:String>Tab 2</sys:String>
|
||||
<sys:String>Tab 3</sys:String>
|
||||
</ListBox>
|
||||
</n:StackPanel>
|
||||
</n:StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox n:ControlAssist.AnchorHeaderText="折叠 Accordion" Header="Accordion">
|
||||
<n:Accordion
|
||||
Width="200"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource EmbossAccordionStyle}">
|
||||
<n:AccordionItem Header="User Profile" IsExpanded="True">
|
||||
<StackPanel Margin="10">
|
||||
<TextBlock Text="Name: John Doe" />
|
||||
<TextBlock Text="Email: john.doe@example.com" />
|
||||
</StackPanel>
|
||||
</n:AccordionItem>
|
||||
<n:AccordionItem Header="User Profile">
|
||||
<StackPanel Margin="10">
|
||||
<TextBlock Text="Name: John Doe" />
|
||||
<TextBlock Text="Email: john.doe@example.com" />
|
||||
</StackPanel>
|
||||
</n:AccordionItem>
|
||||
<n:AccordionItem Header="User Profile">
|
||||
<StackPanel Margin="10">
|
||||
<TextBlock Text="Name: John Doe" />
|
||||
<TextBlock Text="Email: john.doe@example.com" />
|
||||
</StackPanel>
|
||||
</n:AccordionItem>
|
||||
<n:AccordionItem Header="Application Settings">
|
||||
<StackPanel>
|
||||
<CheckBox Content="Enable Dark Mode" />
|
||||
<CheckBox Content="Auto-save every 5 minutes" />
|
||||
</StackPanel>
|
||||
</n:AccordionItem>
|
||||
<n:AccordionItem Header="Help & Support">
|
||||
<TextBlock
|
||||
Margin="10"
|
||||
Text="For support, please visit our website."
|
||||
TextWrapping="Wrap" />
|
||||
</n:AccordionItem>
|
||||
</n:Accordion>
|
||||
</GroupBox>
|
||||
</n:StackPanel>
|
||||
|
||||
</n:Anchor>
|
||||
</Grid>
|
||||
</n:NeoWindow>
|
||||
27
NeoUI/NeoUITest/NeumorphismWindow.xaml.cs
Normal file
27
NeoUI/NeoUITest/NeumorphismWindow.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Shapes;
|
||||
|
||||
namespace NeoUITest
|
||||
{
|
||||
/// <summary>
|
||||
/// NeumorphismWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class NeumorphismWindow
|
||||
{
|
||||
public NeumorphismWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
174
ShrlAlgoToolkit.Core/Assists/LicenseEngine.cs
Normal file
174
ShrlAlgoToolkit.Core/Assists/LicenseEngine.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace ShrlAlgoToolkit.Core.Assists
|
||||
{
|
||||
public class LicenseEngine
|
||||
{
|
||||
// 【重要】替换为你生成的公钥
|
||||
private const string PublicKey = @"<RSAKeyValue><Modulus>rd5+EjU6QxaTY/AalU9g6ugAquN0ahJSgeahnf2CrfvUAWFNJ+SH7Qr0RcvOTyAbWfvLWoBDACKaPsg+8nRQcO3EZdFyjJ9oycLNrw38+gSB2+/79Axys/8MHtSXVUw9WN2e9LxeHOQGtcaoSsp+bPGaXswthovQ2CkvBTmCokcAOX6UaR7Av4npaXyEoGCUsZLEiSydMsNbQ+wLsumVg1H2o/cpkO0s4DiJHoF66zUuxA+pYSjSCn5KTUsOemf+gBsob6Sw+7WOToyiOkMdO9Op6esf8yL7DJ1Yd40XaKd5IeLQmEX/b+n1EV2JEkGO0p9q9MQRp6NrEc9LvfMJWQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
|
||||
|
||||
private static string RegPath = @$"Software\{Assembly.GetExecutingAssembly().GetName()}\License";
|
||||
|
||||
/// <summary>
|
||||
/// 完整验证逻辑
|
||||
/// </summary>
|
||||
public static (bool isValid, string message) Validate()
|
||||
{
|
||||
string licenseKey = LoadFromRegistry("Key");
|
||||
if (string.IsNullOrEmpty(licenseKey)) return (false, "未找到授权码");
|
||||
|
||||
try
|
||||
{
|
||||
// 1. RSA 解密/验证逻辑
|
||||
// 激活码格式:签名(Base64)|机器码|到期日期
|
||||
var parts = licenseKey.Split('|');
|
||||
if (parts.Length != 3) return (false, "授权格式非法");
|
||||
|
||||
string signature = parts[0];
|
||||
string mCode = parts[1];
|
||||
string expiryStr = parts[2];
|
||||
|
||||
// 2. 验证是否是本机的机器码
|
||||
if (mCode != GetMachineCode()) return (false, "授权码与本机硬件不匹配");
|
||||
|
||||
// 3. 验证 RSA 签名(确保数据没被篡改)
|
||||
if (!VerifySignature($"{mCode}|{expiryStr}", signature)) return (false, "授权签名校验失败");
|
||||
|
||||
// 4. 时间校验
|
||||
DateTime expiryDate = DateTime.ParseExact(expiryStr, "yyyyMMdd", CultureInfo.InvariantCulture);
|
||||
DateTime now = GetRobustDateTime();
|
||||
|
||||
// 防回滚检查
|
||||
DateTime lastRun = GetLastRunTime();
|
||||
if (now < lastRun) return (false, "系统时间异常,请检查时钟");
|
||||
UpdateLastRunTime(now);
|
||||
|
||||
if (now > expiryDate) return (false, $"授权已于 {expiryDate:yyyy-MM-dd} 到期");
|
||||
|
||||
return (true, "授权有效");
|
||||
}
|
||||
catch { return (false, "解析授权出错"); }
|
||||
}
|
||||
|
||||
private static bool VerifySignature(string data, string signature)
|
||||
{
|
||||
using (var rsa = new RSACryptoServiceProvider())
|
||||
{
|
||||
rsa.FromXmlString(PublicKey);
|
||||
var formatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
formatter.SetHashAlgorithm("SHA256");
|
||||
byte[] dataBytes = Encoding.UTF8.GetBytes(data);
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
byte[] hash = sha.ComputeHash(dataBytes);
|
||||
return formatter.VerifySignature(hash, Convert.FromBase64String(signature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetMachineCode()
|
||||
{
|
||||
// 组合 CPU ID + 硬盘 ID
|
||||
string raw = GetHardwareId("Win32_Processor", "ProcessorId") +
|
||||
GetHardwareId("Win32_PhysicalMedia", "SerialNumber");
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes(raw));
|
||||
return BitConverter.ToString(hash).Replace("-", "").Substring(0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetHardwareId(string wmiClass, string property)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var mc = new ManagementClass(wmiClass))
|
||||
foreach (var mo in mc.GetInstances()) return mo[property]?.ToString().Trim();
|
||||
}
|
||||
catch { }
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
// 获取可靠的时间(网络优先,本地其次)
|
||||
private static DateTime GetRobustDateTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = WebRequest.Create("http://www.baidu.com");
|
||||
request.Timeout = 2000;
|
||||
using (var response = request.GetResponse())
|
||||
{
|
||||
string dateStr = response.Headers["Date"];
|
||||
return DateTime.ParseExact(dateStr, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
|
||||
}
|
||||
}
|
||||
catch { return DateTime.Now; }
|
||||
}
|
||||
|
||||
#region 注册表操作
|
||||
private static DateTime GetLastRunTime()
|
||||
{
|
||||
string val = LoadFromRegistry("T");
|
||||
return string.IsNullOrEmpty(val) ? DateTime.MinValue : new DateTime(long.Parse(val));
|
||||
}
|
||||
private static void UpdateLastRunTime(DateTime now) => SaveToRegistry("T", now.Ticks.ToString());
|
||||
|
||||
public static void SaveToRegistry(string key, string val)
|
||||
{
|
||||
using var r = Registry.CurrentUser.CreateSubKey(RegPath);
|
||||
r.SetValue(key, val);
|
||||
}
|
||||
private static string LoadFromRegistry(string key)
|
||||
{
|
||||
using var r = Registry.CurrentUser.OpenSubKey(RegPath);
|
||||
return r?.GetValue(key)?.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 仅移除当前的激活码(重置授权状态,但保留时间戳防止白嫖)
|
||||
/// </summary>
|
||||
public static void ClearLicenseKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var r = Registry.CurrentUser.OpenSubKey(RegPath, true))
|
||||
{
|
||||
if (r != null && r.GetValue("Key") != null)
|
||||
{
|
||||
r.DeleteValue("Key");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("移除授权码失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 彻底销毁所有授权痕迹(包括时间戳记录,通常用于卸载)
|
||||
/// </summary>
|
||||
public static void DestroyAllLicenseData()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 第二个参数为 false 表示:如果路径不存在,不抛出异常
|
||||
Registry.CurrentUser.DeleteSubKeyTree(RegPath, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("彻底清理注册表失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Management">
|
||||
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Management.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
61
ShrlAlgoToolkit.Revit/Assists/ColorAssist.cs
Normal file
61
ShrlAlgoToolkit.Revit/Assists/ColorAssist.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Core.Assists
|
||||
{
|
||||
public class ColorAssist
|
||||
{
|
||||
public static Color GetDistinctColorById(ElementId id)
|
||||
{
|
||||
int hash = id.GetHashCode();
|
||||
|
||||
// 修正点:强制转换为 (int),利用 unchecked 溢出机制
|
||||
// 2654435761 在 int 中就是 -1640531527
|
||||
// unchecked 关键字确保在某些开启了溢出检查的项目配置中不会报错
|
||||
unchecked
|
||||
{
|
||||
hash = hash * (int)2654435761;
|
||||
}
|
||||
|
||||
// 2. 将哈希值映射到 0.0 - 1.0 的色相 (Hue)
|
||||
// 使用黄金分割比 0.6180339887... 累加可以让颜色在色环上分布最均匀
|
||||
double goldenRatioConjugate = 0.618033988749895;
|
||||
double h = (hash * goldenRatioConjugate) % 1.0;
|
||||
|
||||
// 保证 h 为正数
|
||||
if (h < 0) h += 1.0;
|
||||
|
||||
// 3. 固定饱和度 (S) 和 亮度 (V) 为较高值,保证颜色鲜艳
|
||||
double s = 0.7; // 饱和度 0.0-1.0
|
||||
double v = 0.9; // 亮度 0.0-1.0
|
||||
|
||||
// 4. HSV 转 Revit Color (RGB)
|
||||
return HsvToRgb(h, s, v);
|
||||
}
|
||||
|
||||
// 辅助函数:HSV 转 Revit Color
|
||||
private static Color HsvToRgb(double h, double s, double v)
|
||||
{
|
||||
int hi = (int)(h * 6);
|
||||
double f = h * 6 - hi;
|
||||
byte p = (byte)(v * (1 - s) * 255);
|
||||
byte q = (byte)(v * (1 - f * s) * 255);
|
||||
byte t = (byte)(v * (1 - (1 - f) * s) * 255);
|
||||
byte vByte = (byte)(v * 255);
|
||||
|
||||
switch (hi % 6)
|
||||
{
|
||||
case 0: return new Color(vByte, t, p);
|
||||
case 1: return new Color(q, vByte, p);
|
||||
case 2: return new Color(p, vByte, t);
|
||||
case 3: return new Color(p, q, vByte);
|
||||
case 4: return new Color(t, p, vByte);
|
||||
default: return new Color(vByte, p, q);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
/// <summary>
|
||||
/// 三维视图可用
|
||||
/// </summary>
|
||||
internal class EnableInView3D : IExternalCommandAvailability
|
||||
public class EnableInView3D : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
||||
applicationData.ActiveUIDocument?.Document.ActiveView is View3D && applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
||||
|
||||
@@ -9,16 +9,13 @@ namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
public class FuncFilter(Func<Element, bool> allowElement, Func<Reference, XYZ, bool> allowReference = null)
|
||||
: ISelectionFilter
|
||||
{
|
||||
private readonly Func<Element, bool> elementFunc = allowElement;
|
||||
private readonly Func<Reference, XYZ, bool> referenceFunc = allowReference;
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
return elementFunc(elem);
|
||||
return allowElement(elem);
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return referenceFunc == null || referenceFunc(reference, position);
|
||||
return allowReference == null || allowReference(reference, position);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,45 @@ namespace ShrlAlgoToolkit.Revit.Assists
|
||||
{
|
||||
internal class GeometryAssist
|
||||
{
|
||||
/// <summary>
|
||||
///获取元素的包围框
|
||||
/// </summary>
|
||||
/// <param name="elements"></param>
|
||||
/// <returns></returns>
|
||||
public static BoundingBoxXYZ GetBoundingBox(List<Element> elements)
|
||||
{
|
||||
if (elements == null || elements.Count == 0)
|
||||
{
|
||||
return new BoundingBoxXYZ();
|
||||
}
|
||||
|
||||
var gmax = XYZ.Zero;
|
||||
var gmin = XYZ.Zero;
|
||||
var elementIds = elements.Select(e => e.Id).ToList();
|
||||
var doc = elements.FirstOrDefault()?.Document;
|
||||
using (SubTransaction sub = new SubTransaction(doc))
|
||||
{
|
||||
sub.Start();
|
||||
Group g;
|
||||
if (doc.IsFamilyDocument)
|
||||
{
|
||||
g = doc.FamilyCreate.NewGroup(elementIds);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
g = doc.Create.NewGroup(elementIds);
|
||||
}
|
||||
gmax = g.get_BoundingBox(null).Max;
|
||||
gmin = g.get_BoundingBox(null).Min;
|
||||
sub.RollBack();
|
||||
}
|
||||
return new BoundingBoxXYZ
|
||||
{
|
||||
Max = gmax,
|
||||
Min = gmin
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 对曲线列表进行排序,使其正确排序和定向,形成线串。
|
||||
/// </summary>
|
||||
|
||||
@@ -3,8 +3,6 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Windows;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
@@ -17,10 +15,10 @@ public class KeyIntPtrHelper
|
||||
|
||||
private static void CompleteMultiSelection()
|
||||
{
|
||||
var rvtwindow = ComponentManager.ApplicationWindow;
|
||||
var window = ComponentManager.ApplicationWindow;
|
||||
var list = new List<IntPtr>();
|
||||
var flag = EnumChildWindows(
|
||||
rvtwindow,
|
||||
window,
|
||||
(hwnd, l) =>
|
||||
{
|
||||
var windowText = new StringBuilder(200);
|
||||
@@ -79,8 +77,7 @@ public class KeyIntPtrHelper
|
||||
foreach (var intPtr2 in handles)
|
||||
{
|
||||
var windowTextLength = GetWindowTextLength(intPtr2);
|
||||
if (windowTextLength != 0)
|
||||
{
|
||||
if (windowTextLength == 0) continue;
|
||||
var stringBuilder = new StringBuilder(windowTextLength);
|
||||
_ = GetWindowText(intPtr2, stringBuilder, windowTextLength + 1);
|
||||
if (stringBuilder.ToString().ToLower().Contains("autodesk revit"))
|
||||
@@ -90,7 +87,6 @@ public class KeyIntPtrHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = intPtr;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Events;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists
|
||||
@@ -18,32 +12,32 @@ namespace ShrlAlgoToolkit.Revit.Assists
|
||||
/// var command = RevitCommandId.LookupPostableCommandId(PostableCommand.TypeProperties);
|
||||
/// UiApplication.PostCommand(command);</c>
|
||||
/// </example>
|
||||
internal class RevitCommandEndedMonitor
|
||||
public class RevitCommandEndedMonitor
|
||||
{
|
||||
private readonly UIApplication _revitUiApplication;
|
||||
private readonly UIApplication revitUiApplication;
|
||||
|
||||
private bool _initializingCommandMonitor;
|
||||
private bool initializingCommandMonitor;
|
||||
|
||||
public event EventHandler CommandEnded;
|
||||
|
||||
public RevitCommandEndedMonitor(UIApplication revituiApplication)
|
||||
public RevitCommandEndedMonitor(UIApplication uIApplication)
|
||||
{
|
||||
_revitUiApplication = revituiApplication;
|
||||
revitUiApplication = uIApplication;
|
||||
|
||||
_initializingCommandMonitor = true;
|
||||
initializingCommandMonitor = true;
|
||||
|
||||
_revitUiApplication.Idling += OnRevitUiApplicationIdling;
|
||||
revitUiApplication.Idling += OnRevitUiApplicationIdling;
|
||||
}
|
||||
|
||||
private void OnRevitUiApplicationIdling(object sender, IdlingEventArgs idlingEventArgs)
|
||||
{
|
||||
if (_initializingCommandMonitor)
|
||||
if (initializingCommandMonitor)
|
||||
{
|
||||
_initializingCommandMonitor = false;
|
||||
initializingCommandMonitor = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_revitUiApplication.Idling -= OnRevitUiApplicationIdling;
|
||||
revitUiApplication.Idling -= OnRevitUiApplicationIdling;
|
||||
|
||||
OnCommandEnded();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
internal static class SpatialAssist
|
||||
public static class SpatialAssist
|
||||
{
|
||||
//private static List<Curve> _curvesSorted;
|
||||
/// <summary>
|
||||
@@ -432,7 +432,8 @@ internal static class SpatialAssist
|
||||
// return list;
|
||||
//}
|
||||
}
|
||||
internal interface ICurveContainer
|
||||
|
||||
public interface ICurveContainer
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class CategoryAssist
|
||||
public static class CategoryExtension
|
||||
{
|
||||
public static Element ToElement(this ElementId elementId, Document doc)
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Electrical;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class ConnectorExtensions
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Reflection;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class DebugAssist
|
||||
public static class DebugExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成瞬态显示的方法
|
||||
@@ -6,13 +6,12 @@ using System.Windows;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Visual;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class DocumentAssist
|
||||
public static class DocumentExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 轴网标注
|
||||
@@ -881,7 +880,6 @@ public static class DocumentAssist
|
||||
/// <param name="definitionId">定义名称,即是族名称、类型名称(强制一致),创建多个实例时,如果相同,则会合并在一个族中</param>
|
||||
/// <param name="category">族类别</param>
|
||||
/// <param name="geos">几何</param>
|
||||
/// <param name="transform">位置</param>
|
||||
/// <returns></returns>
|
||||
public static DirectShape CreateDirectShapeInstance(this Document doc, string definitionId, BuiltInCategory category, List<GeometryObject> geos)
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class ElementCollectorExtensions
|
||||
{
|
||||
|
||||
@@ -1,51 +1,9 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
public static class ElementAssist
|
||||
public static class ElementExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///获取元素的包围框
|
||||
/// </summary>
|
||||
/// <param name="elements"></param>
|
||||
/// <returns></returns>
|
||||
public static BoundingBoxXYZ GetBoundingBox(List<Element> elements)
|
||||
{
|
||||
if (elements == null || elements.Count == 0)
|
||||
{
|
||||
return new BoundingBoxXYZ();
|
||||
}
|
||||
|
||||
var gmax = XYZ.Zero;
|
||||
var gmin = XYZ.Zero;
|
||||
var elementIds = elements.Select(e => e.Id).ToList();
|
||||
var doc = elements.FirstOrDefault()?.Document;
|
||||
using (SubTransaction sub = new SubTransaction(doc))
|
||||
{
|
||||
sub.Start();
|
||||
Group g;
|
||||
if (doc.IsFamilyDocument)
|
||||
{
|
||||
g = doc.FamilyCreate.NewGroup(elementIds);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
g = doc.Create.NewGroup(elementIds);
|
||||
}
|
||||
gmax = g.get_BoundingBox(null).Max;
|
||||
gmin = g.get_BoundingBox(null).Min;
|
||||
sub.RollBack();
|
||||
}
|
||||
return new BoundingBoxXYZ
|
||||
{
|
||||
Max = gmax,
|
||||
Min = gmin
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 镜像元素
|
||||
/// </summary>
|
||||
@@ -4,7 +4,7 @@ using System.Windows;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.ExtensibleStorage;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// 可扩展存储工具Schema框架->由字段Field组成,是定义
|
||||
@@ -148,8 +148,7 @@ public static class ExtensibleStorageExtensions
|
||||
/// <summary>
|
||||
/// 通过guid名称获取Schema
|
||||
/// </summary>
|
||||
/// <param name="elm"></param>
|
||||
/// <param name="schemaName"></param>
|
||||
/// <param name="schemaGuid"></param>
|
||||
/// <returns></returns>
|
||||
public static Schema GetSchemaByGuid(Guid schemaGuid)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
internal static class HostObjectExtensions
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Text;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class ImportInstanceAssist
|
||||
public static class ImportInstanceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据所选的参考,获取所有相同的块参照
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions
|
||||
{
|
||||
internal class JIGAssist
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Autodesk.Revit.DB.Plumbing;
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// MEP扩展类
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class MaterialExtensions
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -224,13 +225,12 @@ public static class RoomExtensions
|
||||
material == null
|
||||
? new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId)
|
||||
: new SolidOptions(material.Id, ElementId.InvalidElementId);
|
||||
options = new SolidOptions(material.Id, ElementId.InvalidElementId);
|
||||
var solid = GeometryCreationUtilities.CreateExtrusionGeometry(curveLoops, XYZ.BasisZ, height);
|
||||
var solid = GeometryCreationUtilities.CreateExtrusionGeometry(curveLoops, XYZ.BasisZ, height, options);
|
||||
|
||||
var directShape = doc.CreateDirectShapeInstance(
|
||||
"房间实体",
|
||||
BuiltInCategory.OST_GenericModel,
|
||||
new List<GeometryObject> { solid });
|
||||
[solid]);
|
||||
directShape.get_Parameter(BuiltInParameter.DOOR_NUMBER).Set(room.Name);
|
||||
//ds.SetName(room.Name);
|
||||
//var option = ds.GetOptions();
|
||||
@@ -241,11 +241,7 @@ public static class RoomExtensions
|
||||
var elements = new FilteredElementCollector(doc);
|
||||
var solidFillPattern = elements.OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().First(a => a.GetFillPattern().IsSolidFill);
|
||||
|
||||
var random = new Random(DateTime.Now.Millisecond);
|
||||
var r = Convert.ToByte(random.Next(0, 255));
|
||||
var g = Convert.ToByte(random.Next(0, 255));
|
||||
var b = Convert.ToByte(random.Next(0, 255));
|
||||
var color = new Color(r, g, b);
|
||||
var color = ColorAssist.GetDistinctColorById(directShape.Id);
|
||||
var ogs = new OverrideGraphicSettings();
|
||||
ogs.SetProjectionLineColor(color);
|
||||
#if REVIT2018
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class SpatialExtensions
|
||||
{
|
||||
private static readonly double _curveTolerance = 0.0025;
|
||||
private static readonly double CurveTolerance = 0.0025;
|
||||
/// <summary>
|
||||
/// 容差
|
||||
/// </summary>
|
||||
@@ -117,7 +115,7 @@ public static class SpatialExtensions
|
||||
startParameter += param1;
|
||||
if (curve.IsInside(startParameter))
|
||||
{
|
||||
if (startParameter < _curveTolerance || originParameter < _curveTolerance)//过短,返回空,一般是0
|
||||
if (startParameter < CurveTolerance || originParameter < CurveTolerance)//过短,返回空,一般是0
|
||||
{
|
||||
startCurve = null;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class UIDocumentAssist
|
||||
public static class UIDocumentExtensons
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行命令选择元素或选择元素执行操作
|
||||
@@ -10,15 +10,13 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
using adWin = Autodesk.Windows;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class UIExtensions
|
||||
{
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
/// SectionView:
|
||||
/// RightDirection = CropBox.Transform.BasisX;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
namespace ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
public static class WallExtensions
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<Import_RootNamespace>ShrlAlgoToolkit.Revit</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\CategoryAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\CategoryExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\ColorAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\DuplicateTypeNamesHandler.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\RevitCommandEndedMonitor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ReferenceExtensions.cs" />
|
||||
@@ -38,7 +39,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\OptionsBarAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\ParameterAssist.cs" />
|
||||
<Compile Include="..\ShrlAlgoToolkit.Revit\Extensions\ParameterExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\PointerExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\PointerExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\RevitIniAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\ShortcutRepAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\SpatialAssist.cs" />
|
||||
@@ -49,15 +50,14 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assists\VisualAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ApplicationExtensions.cs" />
|
||||
<Compile Include="..\ShrlAlgoToolkit.Revit\Extensions\ConnectorExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DebugAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DocumentAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ElementAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DebugExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DocumentExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ElementExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ElementCollectorExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ExtensibleStorageExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\FamilyExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\HostObjectExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ImportInstanceAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\JIGAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ImportInstanceExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\KeyboardShortcutExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\LevelExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\MaterialExtensions.cs" />
|
||||
@@ -66,7 +66,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ScheduleExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SpatialExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\TransactionExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\UIDocumentAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\UIDocumentExtensons.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\UIExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\UnitExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ViewExtensions.cs" />
|
||||
|
||||
@@ -84,7 +84,7 @@ public static class DWGAssist
|
||||
}
|
||||
|
||||
//保存文件
|
||||
ACadSharp.IO.DxfWriter.Write(output, doc, false, OnNotification);
|
||||
ACadSharp.IO.DxfWriter.Write(output, doc);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public static class DWGAssist
|
||||
/// <param name="doc"></param>
|
||||
public static void WriteAsciiDxf(this CadDocument doc, string filePath)
|
||||
{
|
||||
ACadSharp.IO.DxfWriter.Write(filePath, doc, false, OnNotification);
|
||||
ACadSharp.IO.DxfWriter.Write(filePath, doc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,7 +125,7 @@ public static class DWGAssist
|
||||
/// <param name="doc"></param>
|
||||
public static void WriteBinaryDxf(this CadDocument doc, string filePath)
|
||||
{
|
||||
ACadSharp.IO.DxfWriter.Write(filePath, doc, true, OnNotification);
|
||||
ACadSharp.IO.DxfWriter.Write(filePath, doc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -31,21 +31,18 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
private static byte[] BitSourceToArray(BitmapSource bitmapSource)
|
||||
{
|
||||
BitmapEncoder encoder = new JpegBitmapEncoder();
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
|
||||
encoder.Save(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetPngStartingOffset(byte[] previewData)
|
||||
{
|
||||
var markerFound = false;
|
||||
var startingOffset = 0;
|
||||
var previousValue = 0;
|
||||
using (var ms = new MemoryStream(previewData))
|
||||
{
|
||||
using var ms = new MemoryStream(previewData);
|
||||
for (var i = 0; i < previewData.Length; i++)
|
||||
{
|
||||
var currentValue = ms.ReadByte();
|
||||
@@ -126,7 +123,6 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -139,23 +135,19 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
/// <returns></returns>
|
||||
private static Image GetPreviewAsImage(byte[] previewData)
|
||||
{
|
||||
if (previewData == null || previewData.Length <= 0)
|
||||
{
|
||||
using (var newBitmap = new Bitmap(128, 128))
|
||||
if (previewData is not { Length: > 0 })
|
||||
{
|
||||
using var newBitmap = new Bitmap(128, 128);
|
||||
return newBitmap.Clone() as Bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
// read past the Revit metadata to the start of the PNG image
|
||||
var startingOffset = GetPngStartingOffset(previewData);
|
||||
if (startingOffset == 0)
|
||||
{
|
||||
using (var newBitmap = new Bitmap(128, 128))
|
||||
{
|
||||
using var newBitmap = new Bitmap(128, 128);
|
||||
return newBitmap.Clone() as Bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -174,31 +166,22 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
{
|
||||
// use a memory stream to decode the PNG image data
|
||||
// and copy the decoded data into a byte array
|
||||
using (var ms = new MemoryStream(pngDataBuffer))
|
||||
{
|
||||
using var ms = new MemoryStream(pngDataBuffer);
|
||||
var decoder = new PngBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat,
|
||||
BitmapCacheOption.Default);
|
||||
decoderData = BitSourceToArray(decoder.Frames[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// if the decoded data is valie
|
||||
if (decoderData != null && decoderData.Length > 0)
|
||||
if (decoderData is { Length: > 0 })
|
||||
{
|
||||
// use another memory stream to create a Bitmap
|
||||
// and then an Image from that Bitmap
|
||||
using (var ms = new MemoryStream(decoderData))
|
||||
{
|
||||
using (var newBitmap = new Bitmap(ms))
|
||||
{
|
||||
using (Image newImage = newBitmap)
|
||||
{
|
||||
using var ms = new MemoryStream(decoderData);
|
||||
using var newBitmap = new Bitmap(ms);
|
||||
using Image newImage = newBitmap;
|
||||
return newImage.Clone() as Image;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
@@ -237,9 +220,9 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
try
|
||||
{
|
||||
detailInfo = detailInfo.Trim();
|
||||
var index = detailInfo.IndexOf(":");
|
||||
var detailValue = detailInfo.Substring(detailInfo.IndexOf(":") + 1);
|
||||
var detailKey = detailInfo.Substring(0, detailInfo.IndexOf(":"));
|
||||
var index = detailInfo.IndexOf(":", StringComparison.Ordinal);
|
||||
var detailValue = detailInfo.Substring(index + 1);
|
||||
var detailKey = detailInfo.Substring(0, index);
|
||||
detailKey = detailKey.Trim().ToUpper().Replace(" ", string.Empty);
|
||||
detailKey = PurgeUnprintableCharacters(detailKey);
|
||||
detailValue = PurgeUnprintableCharacters(detailValue);
|
||||
@@ -339,8 +322,7 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
|
||||
string xmlStr;
|
||||
byte[] streamData;
|
||||
using (var streamReader = streamInfo.GetStream(FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using var streamReader = streamInfo.GetStream(FileMode.Open, FileAccess.Read);
|
||||
streamData = new byte[streamReader.Length];
|
||||
streamReader.Read(streamData, 0, streamData.Length);
|
||||
xmlStr = Encoding.UTF8.GetString(streamData);
|
||||
@@ -426,7 +408,6 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
|
||||
return symbols;
|
||||
}
|
||||
}
|
||||
|
||||
private static StringBuilder ParsePartAtom(string unicodeData)
|
||||
{
|
||||
@@ -448,19 +429,42 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
return s;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解析预览图像
|
||||
/// 解析预览图像(使用循环确保完整读取,避免 CA2022 警告)
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <returns></returns>
|
||||
private static Image ParsePreviewImage(StreamInfo stream)
|
||||
{
|
||||
byte[] streamData = null;
|
||||
byte[] streamData;
|
||||
using (var streamReader = stream.GetStream(FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
streamData = new byte[streamReader.Length];
|
||||
streamReader.Read(streamData, 0, streamData.Length);
|
||||
//unicodeData = Encoding.Unicode.GetString(streamData);
|
||||
//unicodeData = Encoding.UTF8.GetString(streamData);
|
||||
// 获取长度并校验
|
||||
long lengthLong = streamReader.Length;
|
||||
if (lengthLong < 0)
|
||||
{
|
||||
throw new IOException("Stream length is negative.");
|
||||
}
|
||||
|
||||
if (lengthLong > int.MaxValue)
|
||||
{
|
||||
throw new IOException("Stream is too large to be read into a single byte array.");
|
||||
}
|
||||
|
||||
var totalBytes = (int)lengthLong;
|
||||
streamData = new byte[totalBytes];
|
||||
|
||||
int offset = 0;
|
||||
while (offset < totalBytes)
|
||||
{
|
||||
int bytesRead = streamReader.Read(streamData, offset, totalBytes - offset);
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
// 流在预期字节读取完成前就结束,抛出异常以避免不完整数据处理
|
||||
throw new EndOfStreamException("Unable to read the full stream data.");
|
||||
}
|
||||
|
||||
offset += bytesRead;
|
||||
}
|
||||
}
|
||||
|
||||
return GetPreviewAsImage(streamData);
|
||||
@@ -537,10 +541,9 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
foreach (var streamInfo in streams)
|
||||
{
|
||||
string unicodeData;
|
||||
byte[] streamData = null;
|
||||
using (var streamReader = streamInfo.GetStream(FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
streamData = new byte[streamReader.Length];
|
||||
byte[] streamData = new byte[streamReader.Length];
|
||||
streamReader.Read(streamData, 0, streamData.Length);
|
||||
unicodeData = Encoding.Unicode.GetString(streamData);
|
||||
//unicodeData = Encoding.UTF8.GetString(streamData);
|
||||
@@ -601,7 +604,7 @@ namespace ShrlAlgoToolkit.RevitAddins.Assists
|
||||
foreach (var letter in oldValueArray)
|
||||
{
|
||||
int decimalValue = letter;
|
||||
if (decimalValue >= 32 && decimalValue <= 126)
|
||||
if (decimalValue is >= 32 and <= 126)
|
||||
{
|
||||
sb.Append(letter);
|
||||
}
|
||||
|
||||
38
ShrlAlgoToolkit.RevitAddins/Confuser.crproj
Normal file
38
ShrlAlgoToolkit.RevitAddins/Confuser.crproj
Normal file
@@ -0,0 +1,38 @@
|
||||
<project outputDir="Confused" baseDir="." xmlns="http://confuser.codeplex.com">
|
||||
<!--
|
||||
1. 全局规则:开启常规混淆
|
||||
preset="normal" 包含了:控制流混淆、参数重命名、资源加密等。
|
||||
它也会默认开启重命名(rename)。
|
||||
-->
|
||||
<rule pattern="true" preset="normal">
|
||||
<!-- 可以在这里微调全局设置,比如加强控制流 -->
|
||||
<protection id="ctrl flow" />
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
2. 关键规则:保留所有类名(不重命名类)
|
||||
pattern="member-type('type')" 意思是指:匹配所有的“类型”定义(Class/Interface/Struct)。
|
||||
action="remove" 意思是指:对匹配到的这些项,移除指定的保护。
|
||||
-->
|
||||
<rule pattern="member-type('type')">
|
||||
<protection id="rename" action="remove" />
|
||||
</rule>
|
||||
|
||||
<!-- 3. (可选但推荐) 确保 RevitAPI 接口方法不被错误重命名 -->
|
||||
<!--
|
||||
通常 ConfuserEx 会自动识别接口实现不进行重命名,但为了保险,
|
||||
可以显式排除 Execute 和 OnStartup 方法。
|
||||
-->
|
||||
<rule pattern="name('Execute') or name('OnStartup') or name('OnShutdown')">
|
||||
<protection id="rename" action="remove" />
|
||||
</rule>
|
||||
|
||||
<!-- 4. 指定模块 -->
|
||||
<module path="ShrlAlgoToolkit.RevitAddins.dll" />
|
||||
|
||||
<!-- 5. 引用路径 (非常重要) -->
|
||||
<!-- 为了让ConfuserEx知道哪些方法是接口实现(从而不重命名它们),它需要找到 RevitAPI.dll -->
|
||||
<!-- 请根据您的Revit安装路径修改,或者确保RevitAPI.dll在编译输出目录中 -->
|
||||
<!-- <probePath>C:\Program Files\Autodesk\Revit 2020</probePath>-->
|
||||
|
||||
</project>
|
||||
@@ -464,7 +464,7 @@ namespace ShrlAlgoToolkit.RevitAddins.RvCommon
|
||||
//{
|
||||
// foreach (var curve in item)
|
||||
// {
|
||||
// previewIds.Add(DebugAssist.CreateTransientElements(doc, curve));
|
||||
// previewIds.Add(DebugExtensions.CreateTransientElements(doc, curve));
|
||||
// }
|
||||
//}
|
||||
//var solid = GeometryCreationUtilities.CreateSweptGeometry(
|
||||
|
||||
@@ -7,7 +7,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using RandomColorGenerator;
|
||||
//using RandomColorGenerator;
|
||||
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvMEP;
|
||||
@@ -37,33 +37,24 @@ public partial class HeadroomCheckViewModel : ObservableObject
|
||||
var allRooms = uiapp.ActiveUIDocument.Document.OfClass<SpatialElement>().OfType<Room>();
|
||||
var groups = allRooms.GroupBy(r => r.Name);
|
||||
IEnumerable<IGrouping<string, Room>> enumerable = groups as IGrouping<string, Room>[] ?? groups.ToArray();
|
||||
var colors = GetRandomColors(enumerable.Count());
|
||||
for (int i = 0; i < enumerable.Count(); i++)
|
||||
{
|
||||
var group = enumerable.ElementAt(i);
|
||||
var color = colors.ElementAt(i);
|
||||
foreach (var room in group)
|
||||
{
|
||||
var r = new RoomCheckItem()
|
||||
{
|
||||
Room = room,
|
||||
Name = room.Name,
|
||||
Color = color,
|
||||
};
|
||||
roomItems.Add(r);
|
||||
}
|
||||
}
|
||||
return roomItems;
|
||||
}
|
||||
private static IEnumerable<Color> GetRandomColors(int count)
|
||||
{
|
||||
var colors = RandomColor.GetColors(ColorScheme.Random, Luminosity.Light, count);
|
||||
|
||||
return colors.Select(color => new Color(color.R, color.G, color.B));
|
||||
}
|
||||
private bool CanClick()
|
||||
{
|
||||
return Enumerable.Any<RoomCheckItem>(Rooms);
|
||||
return Rooms is { Count: > 0 };
|
||||
}
|
||||
[RelayCommand(CanExecute = nameof(CanClick))]
|
||||
private void AnalysisHeadroom()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvMEP
|
||||
{
|
||||
@@ -13,9 +14,10 @@ namespace ShrlAlgoToolkit.RevitAddins.RvMEP
|
||||
public partial string Name { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(Color))]
|
||||
public partial Room Room { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial Color Color { get; set; }
|
||||
public partial Color Color { get; set; } = ColorAssist.GetDistinctColorById(Room.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<project outputDir="." baseDir="." xmlns="http://confuser.codeplex.com">
|
||||
<!--
|
||||
1. 全局规则:开启常规混淆
|
||||
preset="normal" 包含了:控制流混淆、参数重命名、资源加密等。
|
||||
它也会默认开启重命名(rename)。
|
||||
-->
|
||||
<rule pattern="true" preset="normal">
|
||||
<!-- 可以在这里微调全局设置,比如加强控制流 -->
|
||||
<protection id="ctrl flow" />
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
2. 关键规则:保留所有类名(不重命名类)
|
||||
pattern="member-type('type')" 意思是指:匹配所有的“类型”定义(Class/Interface/Struct)。
|
||||
action="remove" 意思是指:对匹配到的这些项,移除指定的保护。
|
||||
-->
|
||||
<rule pattern="member-type('type')">
|
||||
<protection id="rename" action="remove" />
|
||||
</rule>
|
||||
|
||||
<!-- 3. (可选但推荐) 确保 RevitAPI 接口方法不被错误重命名 -->
|
||||
<!--
|
||||
通常 ConfuserEx 会自动识别接口实现不进行重命名,但为了保险,
|
||||
可以显式排除 Execute 和 OnStartup 方法。
|
||||
-->
|
||||
<rule pattern="name('Execute') or name('OnStartup') or name('OnShutdown')">
|
||||
<protection id="rename" action="remove" />
|
||||
</rule>
|
||||
|
||||
<!-- 4. 指定模块 -->
|
||||
<module path="ShrlAlgoToolkit.RevitAddins.dll" />
|
||||
|
||||
<!-- 5. 引用路径 (非常重要) -->
|
||||
<!-- 为了让ConfuserEx知道哪些方法是接口实现(从而不重命名它们),它需要找到 RevitAPI.dll -->
|
||||
<!-- 请根据您的Revit安装路径修改,或者确保RevitAPI.dll在编译输出目录中 -->
|
||||
<!-- <probePath>C:\Program Files\Autodesk\Revit 2020</probePath>-->
|
||||
|
||||
</project>
|
||||
@@ -72,6 +72,16 @@
|
||||
<DebugType>None</DebugType>
|
||||
<OutputPath>..\bin\Release\$(RevitVersion)</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Obfuscate>true</Obfuscate>
|
||||
<!--Default values. The following lines can be removed, unless they are changed.-->
|
||||
<ConfuserReplaceOutput>true</ConfuserReplaceOutput>
|
||||
<ConfuserProject>$(MSBuildProjectDirectory)\$(MSBuildProjectName).crproj</ConfuserProject>
|
||||
<ConfuserKeyFile>$(AssemblyOriginatorKeyFile)</ConfuserKeyFile>
|
||||
<ConfuserIntermediateOutputPath>$(IntermediateOutputPath)</ConfuserIntermediateOutputPath>
|
||||
<ConfuserOutDir>$(OutDir)</ConfuserOutDir>
|
||||
<ConfuserSymbolFileName>symbols.map</ConfuserSymbolFileName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- <Reference Include="Microsoft.CSharp" Condition="'$(RevitVersion)' == '2018' Or '$(RevitVersion)' == '2019' Or '$(RevitVersion)' == '2020'" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" Condition="'$(RevitVersion)' == '2018' Or '$(RevitVersion)' == '2019' Or '$(RevitVersion)' == '2020' " />-->
|
||||
@@ -84,28 +94,26 @@
|
||||
<PackageReference Include="CommunityToolkit.Common" Version="8.4.0" />
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.4.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Confuser.MSBuild" Version="1.6.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
||||
<PackageReference Include="ACadSharp" Version="3.0.8" />
|
||||
<PackageReference Include="ACadSharp" Version="3.3.13" />
|
||||
<PackageReference Include="FuzzySharp" Version="2.0.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.1" />
|
||||
<!--TreatAsUsed="true"标记为已使用-->
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" TreatAsUsed="True" />
|
||||
<PackageReference Include="Nice3point.Revit.Extensions" Version="2020.3.0" />
|
||||
<PackageReference Include="randomColorSharped.NetStandard" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
<!-- <ItemGroup Condition="$(DefineConstants.Contains('WINFORMS'))"> -->
|
||||
<!-- <Reference Include="System.Windows.Forms" /> -->
|
||||
<!-- </ItemGroup> -->
|
||||
<ItemGroup>
|
||||
<!--<PackageReference Include="Autodesk.Revit.SDK" Version="$(RevitVersion).*" PrivateAssets="All" />-->
|
||||
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Api.AdWindows" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Api.RevitAPIIFC" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Api.UIFramework" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Api.UIFrameworkServices" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<!-- <PackageReference Include="Autodesk.Revit.SDK" Version="2020.*" Condition=" '$(RevitVersion)' == '2020' " PrivateAssets="All" />
|
||||
<PackageReference Include="Autodesk.Revit.SDK" Version="2025.*" Condition=" '$(RevitVersion)' == '2025' " PrivateAssets="All" />-->
|
||||
<PackageReference Include="Nice3point.Revit.Api.AdWindows" Version="$(RevitVersion).*" PrivateAssets="All" />
|
||||
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2019.*" Condition=" '$(RevitVersion)' == '2018' " />
|
||||
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2020.*" Condition=" '$(RevitVersion)' == '2020' " />
|
||||
<PackageReference Include="ValueConverters" Version="3.1.22" />
|
||||
@@ -207,4 +215,5 @@
|
||||
<Copy SourceFiles="@(FilesToMove)" DestinationFolder="$(OutputPath)Libraries\%(RecursiveDir)" SkipUnchangedFiles="True" />
|
||||
</Target>
|
||||
<Import Project="..\ShrlAlgoToolkit.Revit\ShrlAlgoToolkit.Revit.projitems" Label="Shared" />
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
using ShrlAlgoToolkit.RevitAddins.Fonts;
|
||||
using ShrlAlgoToolkit.RevitAddins.ModelManager;
|
||||
|
||||
using ShrlAlgoToolkit.RevitAddins.Properties;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvCivil;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvCommon;
|
||||
@@ -19,12 +19,9 @@ using ShrlAlgoToolkit.RevitAddins.RvIndependent.NetworkCreator;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvMEP;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvView;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.UIRibbon;
|
||||
|
||||
//[Obfuscation(Exclude = true, ApplyToMembers = true)]
|
||||
public class RvApp : ExternalApplication
|
||||
{
|
||||
private static readonly string TabName = Settings.Default.TabName;
|
||||
|
||||
Reference in New Issue
Block a user