首次上传
This commit is contained in:
@@ -0,0 +1,418 @@
|
||||
<UserControl
|
||||
x:Class="Sicentury.Core.UserControls.BusyIndicator"
|
||||
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:local="clr-namespace:Sicentury.Core.UserControls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="230"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="{x:Type local:CirclePointRingLoading}">
|
||||
<Setter Property="Foreground" Value="#FFFFFFFF" />
|
||||
<Setter Property="IsHitTestVisible" Value="False" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="MinHeight" Value="20" />
|
||||
<Setter Property="MinWidth" Value="20" />
|
||||
<Setter Property="Height" Value="60" />
|
||||
<Setter Property="Width" Value="60" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:CirclePointRingLoading}">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<FrameworkElement.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style x:Key="ProgressRingEllipseStyle" TargetType="{x:Type Ellipse}">
|
||||
<Setter Property="Opacity" Value="0" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</FrameworkElement.Resources>
|
||||
<Grid
|
||||
Name="Ring"
|
||||
MaxWidth="{Binding MaxSideLength, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
MaxHeight="{Binding MaxSideLength, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
FlowDirection="LeftToRight"
|
||||
RenderTransformOrigin=".5,.5"
|
||||
Visibility="Visible">
|
||||
<Canvas RenderTransformOrigin=".5,.5">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E1R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E1"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
<Canvas RenderTransformOrigin=".5,.5">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E2R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E2"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
<Canvas RenderTransformOrigin=".5,.5">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E3R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E3"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
<Canvas RenderTransformOrigin=".5,.5">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E4R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E4"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
<Canvas RenderTransformOrigin=".5,.5">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E5R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E5"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
<Canvas
|
||||
Name="SixthCircle"
|
||||
RenderTransformOrigin=".5,.5"
|
||||
Visibility="Collapsed">
|
||||
<UIElement.RenderTransform>
|
||||
<RotateTransform x:Name="E6R" />
|
||||
</UIElement.RenderTransform>
|
||||
<Ellipse
|
||||
Name="E6"
|
||||
Width="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Height="{Binding EllipseDiameter, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Margin="{Binding EllipseOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ProgressRingEllipseStyle}" />
|
||||
</Canvas>
|
||||
</Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="SizeStates">
|
||||
<VisualState x:Name="Large">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames
|
||||
Storyboard.TargetName="SixthCircle"
|
||||
Storyboard.TargetProperty="Visibility"
|
||||
Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0">
|
||||
<ObjectKeyFrame.Value>
|
||||
<Visibility>Visible</Visibility>
|
||||
</ObjectKeyFrame.Value>
|
||||
</DiscreteObjectKeyFrame>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Small" />
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="ActiveStates">
|
||||
<VisualState x:Name="Inactive" />
|
||||
<VisualState x:Name="Active">
|
||||
<Storyboard RepeatBehavior="Forever">
|
||||
<ObjectAnimationUsingKeyFrames
|
||||
Storyboard.TargetName="Ring"
|
||||
Storyboard.TargetProperty="Visibility"
|
||||
Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0">
|
||||
<ObjectKeyFrame.Value>
|
||||
<Visibility>Visible</Visibility>
|
||||
</ObjectKeyFrame.Value>
|
||||
</DiscreteObjectKeyFrame>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="0"
|
||||
Storyboard.TargetName="E1"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.167"
|
||||
Storyboard.TargetName="E2"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.334"
|
||||
Storyboard.TargetName="E3"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.501"
|
||||
Storyboard.TargetName="E4"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.668"
|
||||
Storyboard.TargetName="E5"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.835"
|
||||
Storyboard.TargetName="E6"
|
||||
Storyboard.TargetProperty="Opacity">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0" />
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="0"
|
||||
Storyboard.TargetName="E1R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-110" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="10" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="93" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="205" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="357" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="439" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="585" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.167"
|
||||
Storyboard.TargetName="E2R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-116" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="4" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="87" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="199" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="351" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="433" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="579" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.334"
|
||||
Storyboard.TargetName="E3R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-122" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="-2" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="81" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="193" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="345" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="427" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="573" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.501"
|
||||
Storyboard.TargetName="E4R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-128" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="-8" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="75" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="187" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="339" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="421" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="567" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.668"
|
||||
Storyboard.TargetName="E5R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-134" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="-14" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="69" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="181" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="331" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="415" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="561" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00.835"
|
||||
Storyboard.TargetName="E6R"
|
||||
Storyboard.TargetProperty="Angle">
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.13,0.21,0.1,0.7"
|
||||
KeyTime="0"
|
||||
Value="-140" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.02,0.33,0.38,0.77"
|
||||
KeyTime="0:0:0.433"
|
||||
Value="-20" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="63" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0.57,0.17,0.95,0.75"
|
||||
KeyTime="0:0:1.617"
|
||||
Value="175" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0.19,0.07,0.72"
|
||||
KeyTime="0:0:2.017"
|
||||
Value="325" />
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="409" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeySpline="0,0,0.95,0.37"
|
||||
KeyTime="0:0:3.217"
|
||||
Value="555" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Border>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<local:CirclePointRingLoading
|
||||
Width="20"
|
||||
Height="20"
|
||||
HorizontalAlignment="Left"
|
||||
EllipseDiameter="3"
|
||||
Foreground="#3ca9fe"
|
||||
IsActive="True"
|
||||
IsLarge="True"
|
||||
Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=Visibility}" />
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Margin="10,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="10"
|
||||
Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=Message}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Grid.Row="1"
|
||||
Width="60"
|
||||
Height="25"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Click="BtnCancel_OnClick"
|
||||
Content="Cancel"
|
||||
FontSize="8" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,70 @@
|
||||
/************************************************************************
|
||||
*@file FrameworkLocal\UIClient\CenterViews\Core\UserControls\BusyIndicator.cs
|
||||
* @author Su Liang
|
||||
* @Date 2022-08-03
|
||||
*
|
||||
* @copyright © Sicentury Inc.
|
||||
*
|
||||
* @brief Reconstructed to support rich functions.
|
||||
*
|
||||
* @details
|
||||
* *****************************************************************************/
|
||||
|
||||
|
||||
using System.Windows;
|
||||
|
||||
namespace Sicentury.Core.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for BusyIndicator.xaml
|
||||
/// </summary>
|
||||
public partial class BusyIndicator
|
||||
{
|
||||
public BusyIndicator()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||
"Message", typeof(string), typeof(BusyIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => (string)GetValue(MessageProperty);
|
||||
set => SetValue(MessageProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Routed Events
|
||||
|
||||
// Register a custom routed event using the Bubble routing strategy.
|
||||
public static readonly RoutedEvent CanceledEvent = EventManager.RegisterRoutedEvent(
|
||||
name: nameof(Canceled),
|
||||
routingStrategy: RoutingStrategy.Bubble,
|
||||
handlerType: typeof(RoutedEventHandler),
|
||||
ownerType: typeof(ParameterNodeTreeViewControl));
|
||||
|
||||
// Provide CLR accessors for assigning an event handler.
|
||||
public event RoutedEventHandler Canceled
|
||||
{
|
||||
add => AddHandler(CanceledEvent, value);
|
||||
remove => RemoveHandler(CanceledEvent, value);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sicentury.Core.UserControls
|
||||
{
|
||||
[TemplateVisualState(Name = "Large", GroupName = "SizeStates")]
|
||||
[TemplateVisualState(Name = "Small", GroupName = "SizeStates")]
|
||||
[TemplateVisualState(Name = "Inactive", GroupName = "ActiveStates")]
|
||||
[TemplateVisualState(Name = "Active", GroupName = "ActiveStates")]
|
||||
public class CirclePointRingLoading : Control
|
||||
{
|
||||
// Token: 0x17000001 RID: 1
|
||||
// (get) Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
|
||||
// (set) Token: 0x06000002 RID: 2 RVA: 0x00002072 File Offset: 0x00000272
|
||||
public double BindableWidth
|
||||
{
|
||||
get => (double)base.GetValue(CirclePointRingLoading.BindableWidthProperty);
|
||||
private set => base.SetValue(CirclePointRingLoading.BindableWidthProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000003 RID: 3 RVA: 0x00002088 File Offset: 0x00000288
|
||||
private static void BindableWidthCallback(DependencyObject dependencyObject,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var circlePointRingLoading = dependencyObject as CirclePointRingLoading;
|
||||
var flag = circlePointRingLoading == null;
|
||||
if (!flag)
|
||||
{
|
||||
circlePointRingLoading.SetEllipseDiameter((double)e.NewValue);
|
||||
circlePointRingLoading.SetEllipseOffset((double)e.NewValue);
|
||||
circlePointRingLoading.SetMaxSideLength((double)e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000004 RID: 4 RVA: 0x000020E0 File Offset: 0x000002E0
|
||||
private void SetEllipseDiameter(double width)
|
||||
{
|
||||
this.EllipseDiameter = width / 8.0;
|
||||
}
|
||||
|
||||
// Token: 0x06000005 RID: 5 RVA: 0x000020F5 File Offset: 0x000002F5
|
||||
private void SetEllipseOffset(double width)
|
||||
{
|
||||
this.EllipseOffset = new Thickness(0.0, width / 2.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
// Token: 0x06000006 RID: 6 RVA: 0x0000212A File Offset: 0x0000032A
|
||||
private void SetMaxSideLength(double width)
|
||||
{
|
||||
this.MaxSideLength = ((width <= 20.0) ? 20.0 : width);
|
||||
}
|
||||
|
||||
// Token: 0x17000002 RID: 2
|
||||
// (get) Token: 0x06000007 RID: 7 RVA: 0x0000214C File Offset: 0x0000034C
|
||||
// (set) Token: 0x06000008 RID: 8 RVA: 0x0000216E File Offset: 0x0000036E
|
||||
public bool IsActive
|
||||
{
|
||||
get => (bool)base.GetValue(CirclePointRingLoading.IsActiveProperty);
|
||||
set => base.SetValue(CirclePointRingLoading.IsActiveProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000009 RID: 9 RVA: 0x00002184 File Offset: 0x00000384
|
||||
private static void IsActiveChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var circlePointRingLoading = sender as CirclePointRingLoading;
|
||||
var flag = circlePointRingLoading == null;
|
||||
if (!flag)
|
||||
{
|
||||
circlePointRingLoading.UpdateActiveState();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600000A RID: 10 RVA: 0x000021AC File Offset: 0x000003AC
|
||||
private void UpdateActiveState()
|
||||
{
|
||||
var isActive = this.IsActive;
|
||||
if (isActive)
|
||||
{
|
||||
VisualStateManager.GoToState(this, this.StateActive, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(this, this.StateInActive, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000003 RID: 3
|
||||
// (get) Token: 0x0600000B RID: 11 RVA: 0x000021E4 File Offset: 0x000003E4
|
||||
// (set) Token: 0x0600000C RID: 12 RVA: 0x00002206 File Offset: 0x00000406
|
||||
public bool IsLarge
|
||||
{
|
||||
get => (bool)base.GetValue(CirclePointRingLoading.IsLargeProperty);
|
||||
set => base.SetValue(CirclePointRingLoading.IsLargeProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x0600000D RID: 13 RVA: 0x0000221C File Offset: 0x0000041C
|
||||
private static void IsLargeChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var circlePointRingLoading = sender as CirclePointRingLoading;
|
||||
var flag = circlePointRingLoading == null;
|
||||
if (!flag)
|
||||
{
|
||||
circlePointRingLoading.UpdateLargeState();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600000E RID: 14 RVA: 0x00002244 File Offset: 0x00000444
|
||||
private void UpdateLargeState()
|
||||
{
|
||||
var isLarge = this.IsLarge;
|
||||
if (isLarge)
|
||||
{
|
||||
VisualStateManager.GoToState(this, this.StateLarge, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(this, this.StateSmall, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000004 RID: 4
|
||||
// (get) Token: 0x0600000F RID: 15 RVA: 0x0000227C File Offset: 0x0000047C
|
||||
// (set) Token: 0x06000010 RID: 16 RVA: 0x0000229E File Offset: 0x0000049E
|
||||
public double MaxSideLength
|
||||
{
|
||||
get => (double)base.GetValue(CirclePointRingLoading.MaxSideLengthProperty);
|
||||
set => base.SetValue(CirclePointRingLoading.MaxSideLengthProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x17000005 RID: 5
|
||||
// (get) Token: 0x06000011 RID: 17 RVA: 0x000022B4 File Offset: 0x000004B4
|
||||
// (set) Token: 0x06000012 RID: 18 RVA: 0x000022D6 File Offset: 0x000004D6
|
||||
public double EllipseDiameter
|
||||
{
|
||||
get => (double)base.GetValue(CirclePointRingLoading.EllipseDiameterProperty);
|
||||
set => base.SetValue(CirclePointRingLoading.EllipseDiameterProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x17000006 RID: 6
|
||||
// (get) Token: 0x06000013 RID: 19 RVA: 0x000022EC File Offset: 0x000004EC
|
||||
// (set) Token: 0x06000014 RID: 20 RVA: 0x0000230E File Offset: 0x0000050E
|
||||
public Thickness EllipseOffset
|
||||
{
|
||||
get => (Thickness)base.GetValue(CirclePointRingLoading.EllipseOffsetProperty);
|
||||
set => base.SetValue(CirclePointRingLoading.EllipseOffsetProperty, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000015 RID: 21 RVA: 0x00002324 File Offset: 0x00000524
|
||||
public CirclePointRingLoading()
|
||||
{
|
||||
|
||||
|
||||
base.SizeChanged += new SizeChangedEventHandler((object argument0, SizeChangedEventArgs argument1) =>
|
||||
this.BindableWidth = base.ActualWidth);
|
||||
}
|
||||
|
||||
// Token: 0x06000016 RID: 22 RVA: 0x00002378 File Offset: 0x00000578
|
||||
static CirclePointRingLoading()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(CirclePointRingLoading),
|
||||
new FrameworkPropertyMetadata(typeof(CirclePointRingLoading)));
|
||||
UIElement.VisibilityProperty.OverrideMetadata(typeof(CirclePointRingLoading), new FrameworkPropertyMetadata(
|
||||
delegate (DependencyObject ringObject, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var flag = e.NewValue != e.OldValue;
|
||||
if (flag)
|
||||
{
|
||||
var circlePointRingLoading = (CirclePointRingLoading)ringObject;
|
||||
var flag2 = (Visibility)e.NewValue > Visibility.Visible;
|
||||
if (flag2)
|
||||
{
|
||||
circlePointRingLoading.SetCurrentValue(CirclePointRingLoading.IsActiveProperty, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
circlePointRingLoading.IsActive = true;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// Token: 0x06000017 RID: 23 RVA: 0x00002531 File Offset: 0x00000731
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
this.UpdateLargeState();
|
||||
this.UpdateActiveState();
|
||||
}
|
||||
|
||||
// Token: 0x04000001 RID: 1
|
||||
private string StateActive = "Active";
|
||||
|
||||
// Token: 0x04000002 RID: 2
|
||||
private string StateInActive = "InActive";
|
||||
|
||||
// Token: 0x04000003 RID: 3
|
||||
private string StateLarge = "Large";
|
||||
|
||||
// Token: 0x04000004 RID: 4
|
||||
private string StateSmall = "Small";
|
||||
|
||||
// Token: 0x04000005 RID: 5
|
||||
public static readonly DependencyProperty BindableWidthProperty = DependencyProperty.Register("BindableWidth",
|
||||
typeof(double), typeof(CirclePointRingLoading),
|
||||
new PropertyMetadata(0.0, new PropertyChangedCallback(CirclePointRingLoading.BindableWidthCallback)));
|
||||
|
||||
// Token: 0x04000006 RID: 6
|
||||
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register("IsActive",
|
||||
typeof(bool), typeof(CirclePointRingLoading),
|
||||
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
new PropertyChangedCallback(CirclePointRingLoading.IsActiveChanged)));
|
||||
|
||||
// Token: 0x04000007 RID: 7
|
||||
public static readonly DependencyProperty IsLargeProperty = DependencyProperty.Register("IsLarge", typeof(bool),
|
||||
typeof(CirclePointRingLoading),
|
||||
new PropertyMetadata(true, new PropertyChangedCallback(CirclePointRingLoading.IsLargeChangedCallback)));
|
||||
|
||||
// Token: 0x04000008 RID: 8
|
||||
public static readonly DependencyProperty MaxSideLengthProperty = DependencyProperty.Register("MaxSideLength",
|
||||
typeof(double), typeof(CirclePointRingLoading), new PropertyMetadata(0.0));
|
||||
|
||||
// Token: 0x04000009 RID: 9
|
||||
public static readonly DependencyProperty EllipseDiameterProperty =
|
||||
DependencyProperty.Register("EllipseDiameter", typeof(double), typeof(CirclePointRingLoading),
|
||||
new PropertyMetadata(0.0));
|
||||
|
||||
// Token: 0x0400000A RID: 10
|
||||
public static readonly DependencyProperty EllipseOffsetProperty = DependencyProperty.Register("EllipseOffset",
|
||||
typeof(Thickness), typeof(CirclePointRingLoading), new PropertyMetadata(default(Thickness)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
<UserControl
|
||||
x:Class="Sicentury.Core.UserControls.ParameterNodeTreeViewControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:attachedProperties="clr-namespace:Sicentury.Core.AttachedProperties"
|
||||
xmlns:converters="clr-namespace:Sicentury.Core.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="400"
|
||||
mc:Ignorable="d"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
|
||||
<UserControl.Resources>
|
||||
<converters:ParameterNodeTreeViewVisibilityMultiBindingConverter x:Key="NodeVisibilityConverter" />
|
||||
|
||||
<Style x:Key="styleTitle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="FontWeight" Value="Black" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="5,0" />
|
||||
</Style>
|
||||
|
||||
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Setter Property="Margin" Value="1,0,0,0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Width" Value="30" />
|
||||
<Setter Property="Height" Value="30" />
|
||||
</Style>
|
||||
<Style TargetType="Path">
|
||||
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground, Mode=OneTime}" />
|
||||
<Setter Property="Stretch" Value="Uniform" />
|
||||
<Setter Property="Width" Value="16" />
|
||||
<Setter Property="Height" Value="16" />
|
||||
|
||||
</Style>
|
||||
|
||||
<ResourceDictionary x:Key="whatever">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/MECF.Framework.UI.Client;component/Themes/SeaBlue/Button.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Group management Group list -->
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Margin="0,5,0,0"
|
||||
Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=VisibilityTopTools}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Style="{StaticResource styleTitle}" Text="{lex:Loc ID_TXT_Group}" />
|
||||
<ComboBox
|
||||
x:Name="cbxPresetList"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=SelectedGroup}"
|
||||
SelectionChanged="CbxPresetList_OnSelectionChanged" />
|
||||
|
||||
<!-- Group management toolbar -->
|
||||
<StackPanel
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnNewGroup"
|
||||
Click="BtnNewGroup_OnClick"
|
||||
ToolTip="New Group">
|
||||
<Button.Content>
|
||||
<Path Data="M405 213v43h-64v64h-42v-64h-64v-43h64v-64h42v64h64zM427 384c24 0 42 -19 42 -43v-213c0 -24 -18 -43 -42 -43h-342c-24 0 -42 19 -42 43v256c0 24 18 43 42 43h128l43 -43h171z">
|
||||
<Path.LayoutTransform>
|
||||
<ScaleTransform ScaleY="-1" />
|
||||
</Path.LayoutTransform>
|
||||
</Path>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnSave"
|
||||
Click="BtnSave_OnClick"
|
||||
ToolTip="Save">
|
||||
<Button.Content>
|
||||
<Path Data="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnSaveAs"
|
||||
Click="BtnSaveAs_OnClick"
|
||||
ToolTip="Save As">
|
||||
<Button.Content>
|
||||
<Path Data="M17,7V3H7V7H17M14,17A3,3 0 0,0 17,14A3,3 0 0,0 14,11A3,3 0 0,0 11,14A3,3 0 0,0 14,17M19,1L23,5V17A2,2 0 0,1 21,19H7C5.89,19 5,18.1 5,17V3A2,2 0 0,1 7,1H19M1,7H3V21H17V23H3A2,2 0 0,1 1,21V7Z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnDelete"
|
||||
Click="BtnDelete_OnClick"
|
||||
ToolTip="Delete">
|
||||
<Button.Content>
|
||||
<Path Data="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnRefreshPresetList"
|
||||
Click="BtnRefreshPresetList_OnClick"
|
||||
ToolTip="Refresh">
|
||||
<Button.Content>
|
||||
<Path Data=" M536.3 250.4H750V464C749.7 511.3 722 522.7 688.6 489.2L640.5 441C598.3 474.1 546.5 492.2 492 492.2C427.4 492.2 366.6 467 321 421.3C275.2 375.8 250 315 250 250.4C250 185.7 275.2 124.9 320.9 79.3C366.6 33.5 427.3 8.3 492 8.3C556.5 8.3 617.3 33.5 663 79.3C675.4 91.7 686.3 105.2 695.5 119.5C710 142 703.5 172 681 186.4C658.5 200.8 628.5 194.3 614.1 171.8C608.6 163.2 602 155.1 594.6 147.6C567.2 120.2 530.7 105.1 492 105.1C453.2 105.1 416.8 120.2 389.3 147.6C361.9 175 346.8 211.5 346.8 250.3C346.8 289.1 361.9 325.5 389.3 352.9C416.8 380.3 453.2 395.4 492 395.4C520.6 395.4 548 387 571.5 371.6L511.2 311.1C477.7 277.7 489.1 250.4 536.3 250.4z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<TreeView
|
||||
x:Name="ParameterTreeView"
|
||||
Grid.Row="2"
|
||||
Margin="0,5,0,0"
|
||||
ItemsSource="{Binding Path=TreeRoot.ChildNodes, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Mode=TwoWay}"
|
||||
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
|
||||
VirtualizingStackPanel.CacheLengthUnit="Item"
|
||||
VirtualizingStackPanel.IsVirtualizing="True"
|
||||
VirtualizingStackPanel.ScrollUnit="Pixel"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||
<!--<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="TreeView.SelectedItemChanged">
|
||||
<cal:ActionMessage MethodName="OnTreeSelectedChanged">
|
||||
<cal:Parameter Value="{Binding ElementName=ParameterTreeView,Path=SelectedItem}"></cal:Parameter>
|
||||
</cal:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}" TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="Visibility">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{StaticResource NodeVisibilityConverter}">
|
||||
<Binding Path="IsMatch" />
|
||||
<Binding Path="Visibility" />
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, Delay=10}">
|
||||
<!--<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="ParameterCheck">
|
||||
<micro:Parameter Value="{Binding }"/>
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
</CheckBox>
|
||||
<TextBlock
|
||||
attachedProperties:TextBlockHighlighter.ForeColor="{Binding RelativeSource={RelativeSource Self}, Path=Foreground}"
|
||||
attachedProperties:TextBlockHighlighter.HighlightColor="Yellow"
|
||||
attachedProperties:TextBlockHighlighter.Selection="{Binding Path=FilterKeyWord, Mode=OneWay}"
|
||||
Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
|
||||
|
||||
|
||||
<!-- Tree View Function Buttons -->
|
||||
<Grid Grid.Row="3">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="0,0,5,0" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Path
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="5,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Data="M1024 320v256h-704v-64h-128v192h576v256h-768v-256h128v-640h192v-128h704v256h-704v-64h-128v320h128v-128z"
|
||||
Fill="Black"
|
||||
ToolTip="Selection" />
|
||||
<TextBlock Text="{Binding TreeRoot.SelectedTerminalCount, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}" ToolTip="Selected Nodes" />
|
||||
<TextBlock Text="/" />
|
||||
<TextBlock Text="{Binding TreeRoot.TotalTerminalCount, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}" ToolTip="Total Nodes" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation=" Horizontal">
|
||||
<Button
|
||||
x:Name="btnExcludeNode"
|
||||
Click="BtnExcludeNode_OnClick"
|
||||
ToolTip="Edit Exclude Nodes List"
|
||||
Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=VisibilityExcludeNodesButton}">
|
||||
<Button.Content>
|
||||
<Path Data="M117.65 187.5H82.35L76.3 157.2125L50.6 174.3375L25.65 149.4L42.775 123.7L12.5 117.65V82.35L42.7875 76.3L25.6625 50.6L50.6 25.65L76.3 42.775L82.35 12.5H108.3875A56.575 56.575 0 0 0 96.925 25.0625H92.65L89.05 43.075A55.9125 55.9125 0 0 0 88.2125 47.25L86.7625 54.5375L77.2125 58.4875L52.2125 41.8125L41.8125 52.2L58.5 77.2125L54.55 86.7625L25.075 92.65V107.35L54.55 113.2375L58.5 122.7875L41.825 147.7875L52.2125 158.1875L77.2125 141.5L86.7625 145.45L92.65 174.925H107.35L113.2375 145.45L122.7875 141.5L147.7875 158.175L158.1875 147.7875L141.5125 122.775L145.4625 113.225L152.7375 111.775C154.15 111.55 155.55 111.275 156.925 110.9375L174.9375 107.3375V103.0625C179.6875000000001 99.8875 183.9250000000001 96.025 187.5000000000001 91.6V117.65L157.225 123.7L174.3500000000001 149.4L149.4 174.35L123.7000000000001 157.225L117.65 187.5zM100 125A25 25 0 0 0 123.4375 108.725A55.75 55.75 0 0 1 112.1875 102.8125A12.5 12.5 0 1 1 97.1875 87.8125A55.75 55.75 0 0 1 91.275 76.5625A25 25 0 0 0 100 125zM116 90.0625A43.75 43.75 0 1 0 171.5 22.4375A43.75 43.75 0 0 0 116 90.0625zM112.5 62.5V50H175V62.5H112.5z">
|
||||
<Path.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Path.LayoutTransform>
|
||||
</Path>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnShowAll"
|
||||
Click="BtnShowAll_OnClick"
|
||||
ToolTip="Show All">
|
||||
<Button.Content>
|
||||
<Path Data="M512 746.667c-325.675 0-423.552-282.325-424.448-285.184l-4.523-13.483 4.48-13.483c0.939-2.859 98.816-285.184 424.491-285.184s423.552 282.325 424.448 285.184l4.523 13.483-4.48 13.483c-0.939 2.859-98.816 285.184-424.491 285.184zM512 277.333c-94.123 0-170.667 76.544-170.667 170.667s76.544 170.667 170.667 170.667 170.667-76.544 170.667-170.667-76.544-170.667-170.667-170.667zM512 533.333c-46.251 0-85.333-39.083-85.333-85.333s39.083-85.333 85.333-85.333 85.333 39.083 85.333 85.333-39.083 85.333-85.333 85.333z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
x:Name="btnShowSelectedOnly"
|
||||
Click="BtnShowSelectedOnly_OnClick"
|
||||
ToolTip="Show Selected Only">
|
||||
<Button.Content>
|
||||
<Path Data="M256,352c53,0,96-43,96-96s-43-96-96-96s-96,43-96,96S203,352,256,352z M256,432c-97,0-176-80-176-176c0-95,75-176,176-176c96,0,176,74,176,176C432,354,354,432,256,432z M256,480c121,0,224-97,224-224c0-121-97-224-224-224C135,32,32,129,32,256C32,377,129,480,256,480z">
|
||||
<Path.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Path.LayoutTransform>
|
||||
</Path>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
x:Name="btnCollapseAll"
|
||||
Click="BtnCollapseAll_OnClick"
|
||||
ToolTip="Collapse All">
|
||||
<Button.Content>
|
||||
<Path Data="M 19,29L 47,29L 47,57L 19,57L 19,29 Z M 43,33L 23,33.0001L 23,53L 43,53L 43,33 Z M 39,41L 39,45L 27,45L 27,41L 39,41 Z M 24,24L 51.9999,24.0001L 51.9999,52L 48.9999,52.0001L 48.9999,27.0001L 24,27.0001L 24,24 Z M 54,47L 53.9999,22.0001L 29,22L 29,19L 57,19L 57,47L 54,47 Z " />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnExpandAll"
|
||||
Click="BtnExpandAll_OnClick"
|
||||
ToolTip="Expand All">
|
||||
<Button.Content>
|
||||
<Path Data="M 19,29L 47,29L 47,57L 19,57L 19,29 Z M 43,33L 23,33.0001L 23,53L 43,53L 43,33 Z M 39,41L 39,45L 35,45L 35,49L 31,49L 31,45L 27,45L 27,41L 31,41L 31,37L 35,37L 35,41L 39,41 Z M 24,24L 51.9999,24.0001L 51.9999,52L 48.9999,52.0001L 48.9999,27.0001L 24,27.0001L 24,24 Z M 53.9999,47L 53.9999,22.0001L 29,22L 29,19L 56.9999,19.0001L 57,47L 53.9999,47 Z " />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Filter Input Box -->
|
||||
<Grid Grid.Row="4" Margin="0,5,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Filter Toolbar -->
|
||||
<TextBlock Style="{StaticResource styleTitle}" Text="{lex:Loc ID_TXT_Filter}" />
|
||||
<TextBox
|
||||
x:Name="txtFilterKeyword"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
KeyDown="TxtFilterKeyword_OnKeyDown">
|
||||
<attachedProperties:WatermarkService.Watermark>
|
||||
<TextBlock VerticalAlignment="Center" Text="Press Enter to Apply" />
|
||||
</attachedProperties:WatermarkService.Watermark>
|
||||
</TextBox>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnApplyFilter"
|
||||
Click="BtnApplyFilter_OnClick"
|
||||
ToolTip="Apply Filter">
|
||||
<Button.Content>
|
||||
<Path Data="M416 448L319 351Q277 383 224 383 181 383 144 362 107 340 86 303 64 266 64 223 64 180 86 143 107 106 144 85 181 63 224 63 267 63 304 85 341 106 363 143 384 180 384 223 384 277 351 319L448 416 416 448ZM223 336Q270 336 303 303 335 270 335 224 335 177 303 145 270 112 223 112 177 112 144 145 111 177 111 224 111 270 144 303 177 336 223 336Z" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnClearFilter"
|
||||
Click="BtnClearFilter_OnClick"
|
||||
ToolTip="Clear Filter">
|
||||
<Button.Content>
|
||||
<Path Data="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z">
|
||||
<Path.LayoutTransform>
|
||||
<ScaleTransform ScaleY="-1" />
|
||||
</Path.LayoutTransform>
|
||||
</Path>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,537 @@
|
||||
/************************************************************************
|
||||
*@file FrameworkLocal\UIClient\CenterViews\Core\UserControls\ParameterNodeTreeViewControl.cs
|
||||
* @author Su Liang
|
||||
* @Date 2022-08-01
|
||||
*
|
||||
* @copyright © Sicentury Inc.
|
||||
*
|
||||
* @brief Reconstructed to support rich functions.
|
||||
*
|
||||
* @details
|
||||
* *****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using Sicentury.Core.Dialogs;
|
||||
using Sicentury.Core.Tree;
|
||||
|
||||
namespace Sicentury.Core.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ParameterNodeTreeViewControl.xaml
|
||||
/// </summary>
|
||||
public partial class ParameterNodeTreeViewControl
|
||||
{
|
||||
#region Variables
|
||||
|
||||
private bool _clearGroupSelectionOnly = false;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 父级文件夹。
|
||||
/// </summary>
|
||||
private const string PRESET_GROUP_SUB_FOLDER_NAME = "PresetGroups";
|
||||
|
||||
public ParameterNodeTreeViewControl()
|
||||
{
|
||||
//InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(System.EventArgs e)
|
||||
{
|
||||
InitializeComponent();
|
||||
base.OnInitialized(e);
|
||||
|
||||
LoadPresetGroupFilesList();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public static readonly DependencyProperty TreeRootProperty = DependencyProperty.Register(
|
||||
nameof(TreeRoot), typeof(TreeNode), typeof(ParameterNodeTreeViewControl),
|
||||
new PropertyMetadata(default(TreeNode), (o, p) =>
|
||||
{
|
||||
if (o is ParameterNodeTreeViewControl control)
|
||||
{
|
||||
if (p.NewValue is TreeNode tree)
|
||||
{
|
||||
tree.TerminalNodeSelectionChanged += (sender, b) =>
|
||||
{
|
||||
control.RaiseEvent(new RoutedEventArgs(TerminalNodeSelectionChangedEvent, sender));
|
||||
};
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回TreeView数据源。
|
||||
/// </summary>
|
||||
public TreeNode TreeRoot
|
||||
{
|
||||
get => (TreeNode)GetValue(TreeRootProperty);
|
||||
set => SetValue(TreeRootProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty PresetGroupsFolderNameProperty = DependencyProperty.Register(
|
||||
"PresetGroupsFolderName", typeof(string), typeof(ParameterNodeTreeViewControl),
|
||||
new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回存放预设组信息的子文件夹名称。
|
||||
/// </summary>
|
||||
public string PresetGroupsFolderName
|
||||
{
|
||||
get => (string)GetValue(PresetGroupsFolderNameProperty);
|
||||
set => SetValue(PresetGroupsFolderNameProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty VisibilityExcludeNodesButtonProperty = DependencyProperty.Register(
|
||||
nameof(VisibilityExcludeNodesButton), typeof(Visibility), typeof(ParameterNodeTreeViewControl), new PropertyMetadata(System.Windows.Visibility.Hidden));
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示节点排除列表编辑按钮。
|
||||
/// </summary>
|
||||
public Visibility VisibilityExcludeNodesButton
|
||||
{
|
||||
get => (Visibility)GetValue(VisibilityExcludeNodesButtonProperty);
|
||||
set => SetValue(VisibilityExcludeNodesButtonProperty, value);
|
||||
}
|
||||
|
||||
//
|
||||
public static readonly DependencyProperty VisibilityTopToolsProperty = DependencyProperty.Register(
|
||||
nameof(VisibilityTopTools), typeof(Visibility), typeof(ParameterNodeTreeViewControl), new PropertyMetadata(System.Windows.Visibility.Visible));
|
||||
/// <summary>
|
||||
/// 顶部工具栏显示属性,不需要编辑时;
|
||||
/// </summary>
|
||||
public Visibility VisibilityTopTools
|
||||
{
|
||||
get => (Visibility)GetValue(VisibilityTopToolsProperty);
|
||||
set => SetValue(VisibilityTopToolsProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Routed Events
|
||||
|
||||
// Register a custom routed event using the Bubble routing strategy.
|
||||
public static readonly RoutedEvent TerminalNodeSelectionChangedEvent = EventManager.RegisterRoutedEvent(
|
||||
name: nameof(TerminalNodeSelectionChanged),
|
||||
routingStrategy: RoutingStrategy.Bubble,
|
||||
handlerType: typeof(RoutedEventHandler),
|
||||
ownerType: typeof(ParameterNodeTreeViewControl));
|
||||
|
||||
// Provide CLR accessors for assigning an event handler.
|
||||
public event RoutedEventHandler TerminalNodeSelectionChanged
|
||||
{
|
||||
add => AddHandler(TerminalNodeSelectionChangedEvent, value);
|
||||
remove => RemoveHandler(TerminalNodeSelectionChangedEvent, value);
|
||||
}
|
||||
|
||||
|
||||
// Register a custom routed event using the Bubble routing strategy.
|
||||
public static readonly RoutedEvent EditExcludeNodesListEvent = EventManager.RegisterRoutedEvent(
|
||||
name: nameof(EditExcludeNodesList),
|
||||
routingStrategy: RoutingStrategy.Bubble,
|
||||
handlerType: typeof(RoutedEventHandler),
|
||||
ownerType: typeof(ParameterNodeTreeViewControl));
|
||||
|
||||
// Provide CLR accessors for assigning an event handler.
|
||||
public event RoutedEventHandler EditExcludeNodesList
|
||||
{
|
||||
add => AddHandler(EditExcludeNodesListEvent, value);
|
||||
remove => RemoveHandler(EditExcludeNodesListEvent, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回组信息文件名的完整路径。
|
||||
/// </summary>
|
||||
/// <param name="groupName">组名称</param>
|
||||
/// <returns></returns>
|
||||
private string GetPresetGroupFullFileName(string groupName)
|
||||
{
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PRESET_GROUP_SUB_FOLDER_NAME,
|
||||
PresetGroupsFolderName, groupName + ".json");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回保存组信息的文件夹名称。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetPresetGroupsFolderName()
|
||||
{
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PRESET_GROUP_SUB_FOLDER_NAME,
|
||||
PresetGroupsFolderName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载指定文件夹内的所有json文件。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
private void LoadPresetGroupFilesList(string selectedGroupName = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(PresetGroupsFolderName))
|
||||
throw new ArgumentException("the preset group files folder is not set.",
|
||||
paramName: nameof(PresetGroupsFolderName));
|
||||
|
||||
var folderName = GetPresetGroupsFolderName();
|
||||
|
||||
|
||||
var previousSelection = selectedGroupName;
|
||||
// 如果未指定下次待加载的项目,则保存当前的选择
|
||||
if (string.IsNullOrEmpty(previousSelection))
|
||||
if (cbxPresetList.SelectedItem != null)
|
||||
previousSelection = cbxPresetList.SelectedItem.ToString();
|
||||
|
||||
// 如果文件夹不存在,返回空列表
|
||||
if (!Directory.Exists(folderName))
|
||||
{
|
||||
Directory.CreateDirectory(folderName);
|
||||
cbxPresetList.ItemsSource = new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
var source =
|
||||
Directory.EnumerateFiles(folderName, "*.json")
|
||||
.Select(Path.GetFileNameWithoutExtension)
|
||||
.ToList();
|
||||
cbxPresetList.ItemsSource = source;
|
||||
|
||||
// 重新选择上次的选择
|
||||
if (string.IsNullOrEmpty(previousSelection) == false)
|
||||
{
|
||||
if (source.FirstOrDefault(x => x == previousSelection) != null)
|
||||
cbxPresetList.SelectedItem = previousSelection;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果TreeView还没有加载内容,则不要自动选择
|
||||
if (TreeRoot != null)
|
||||
cbxPresetList.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅清空Group下拉框的选项,而不清除TreeView的选择状态。
|
||||
/// <para>通常用于DataGrid中删除条目后,清除Group选项。</para>
|
||||
/// </summary>
|
||||
public void ClearPresetGroupSelectionOnly()
|
||||
{
|
||||
_clearGroupSelectionOnly = true;
|
||||
cbxPresetList.SelectedIndex = -1;
|
||||
_clearGroupSelectionOnly = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// 创建节点排除清单。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void BtnExcludeNode_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.RaiseEvent(new RoutedEventArgs(EditExcludeNodesListEvent, this));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重新加载组列表。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnRefreshPresetList_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadPresetGroupFilesList();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to refresh the group list, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建组。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnNewGroup_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
TreeRoot.UnselectAll();
|
||||
cbxPresetList.SelectedIndex = -1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to create new group, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存组。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnSave_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
var groupName = "";
|
||||
|
||||
//if (TreeRoot.SelectedTerminalCount > TreeNode.QUERY_LIMIT_COUNT)
|
||||
//{
|
||||
// MessageBox.Show($"Too many items are selected, it's limited to {TreeNode.QUERY_LIMIT_COUNT}.",
|
||||
// "Error", MessageBoxButton.OK,
|
||||
// MessageBoxImage.Error);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (cbxPresetList.SelectedIndex == -1)
|
||||
{
|
||||
var dlg = new PresetGroupSaveDialog("Save Group", cbxPresetList.ItemsSource?.Cast<string>());
|
||||
var ret = dlg.ShowDialog();
|
||||
if (ret.HasValue && ret.Value == true)
|
||||
{
|
||||
groupName = dlg.GroupName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groupName = cbxPresetList.SelectedItem.ToString();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 保存
|
||||
TreeNodeSelectionGroupInfo.SaveToJsonFile(GetPresetGroupFullFileName(groupName), TreeRoot);
|
||||
|
||||
LoadPresetGroupFilesList(groupName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to save group {groupName}, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 另存为组。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnSaveAs_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (cbxPresetList.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("No group is selected.", "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var newName = $"Copy of {cbxPresetList.SelectedValue}";
|
||||
|
||||
var dlg = new PresetGroupSaveDialog("Save As Group",
|
||||
cbxPresetList.ItemsSource?.Cast<string>(),
|
||||
newName);
|
||||
|
||||
var ret = dlg.ShowDialog();
|
||||
if (ret.HasValue && ret.Value)
|
||||
{
|
||||
var groupName = cbxPresetList.SelectedItem.ToString();
|
||||
|
||||
try
|
||||
{
|
||||
// 保存
|
||||
TreeNodeSelectionGroupInfo.SaveToJsonFile(GetPresetGroupFullFileName(groupName), TreeRoot);
|
||||
|
||||
// 保存一个空文件
|
||||
TreeNodeSelectionGroupInfo.SaveToJsonFile(GetPresetGroupFullFileName(dlg.GroupName), TreeRoot);
|
||||
|
||||
LoadPresetGroupFilesList(dlg.GroupName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to save as group {groupName}, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择组。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CbxPresetList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (cbxPresetList.SelectedIndex == -1)
|
||||
{
|
||||
//
|
||||
if (_clearGroupSelectionOnly)
|
||||
return;
|
||||
|
||||
TreeRoot.UnselectAll();
|
||||
return;
|
||||
}
|
||||
|
||||
var groupName = cbxPresetList.SelectedValue.ToString();
|
||||
|
||||
try
|
||||
{
|
||||
TreeNodeSelectionGroupInfo.RecoveryFromJsonFile(GetPresetGroupFullFileName(groupName), TreeRoot);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to recovery group {groupName}, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除组。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 如果没选中任何组,忽略操作
|
||||
if (cbxPresetList.SelectedIndex == -1)
|
||||
return;
|
||||
|
||||
var groupName = cbxPresetList.SelectedItem.ToString();
|
||||
if (string.IsNullOrEmpty(groupName))
|
||||
return;
|
||||
|
||||
var ret = MessageBox.Show($"Are you sure to delete the group {groupName}", "Warning",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (ret == MessageBoxResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileSystem.DeleteFile(GetPresetGroupFullFileName(groupName), UIOption.OnlyErrorDialogs,
|
||||
RecycleOption.SendToRecycleBin);
|
||||
LoadPresetGroupFilesList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var err = $"Unable to delete group {groupName}, {ex.Message}";
|
||||
MessageBox.Show(err, "Error", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 折叠所有节点。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnCollapseAll_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (TreeRoot.ChildNodes.Count > 0)
|
||||
{
|
||||
TreeRoot.CollapseAll();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展开所有节点。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnExpandAll_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (TreeRoot.ChildNodes.Count > 0)
|
||||
{
|
||||
TreeRoot.ExpandAll();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用筛选器。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void BtnApplyFilter_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TreeRoot.SuspendUpdate();
|
||||
TreeRoot.ApplyFilter(txtFilterKeyword.Text);
|
||||
TreeRoot.ResumeUpdate();
|
||||
txtFilterKeyword.SelectAll();
|
||||
txtFilterKeyword.Focus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除筛选器
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnClearFilter_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TreeRoot.SuspendUpdate();
|
||||
TreeRoot.ClearFilter();
|
||||
TreeRoot.ResumeUpdate();
|
||||
txtFilterKeyword.Text = "";
|
||||
txtFilterKeyword.Focus();
|
||||
|
||||
}
|
||||
|
||||
private void TxtFilterKeyword_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key != Key.Enter)
|
||||
return;
|
||||
|
||||
TreeRoot.ApplyFilter(txtFilterKeyword.Text);
|
||||
txtFilterKeyword.SelectAll();
|
||||
txtFilterKeyword.Focus();
|
||||
}
|
||||
|
||||
private void BtnShowSelectedOnly_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TreeRoot.ShowSelectedOnly();
|
||||
}
|
||||
|
||||
private void BtnShowAll_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TreeRoot.ShowAll();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user