mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-07 08:26:34 +08:00
GIT练习
This commit is contained in:
16
WorkBench/Themes/Condition/BoolConditionControl.xaml
Normal file
16
WorkBench/Themes/Condition/BoolConditionControl.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="DynamicDemo.Themes.Condition.BoolConditionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicDemo.Themes.Condition"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<ComboBox x:Name="ConditionComboBox"
|
||||
SelectedValue="{Binding Condition, Mode=TwoWay}">
|
||||
<ComboBoxItem Content="Is True" Tag="IsTrue" />
|
||||
<ComboBoxItem Content="Is False" Tag="IsFalse" />
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
WorkBench/Themes/Condition/BoolConditionControl.xaml.cs
Normal file
28
WorkBench/Themes/Condition/BoolConditionControl.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DynamicDemo.Themes.Condition
|
||||
{
|
||||
/// <summary>
|
||||
/// BoolConditionControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class BoolConditionControl : UserControl
|
||||
{
|
||||
public BoolConditionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
WorkBench/Themes/Condition/IntConditionControl.xaml
Normal file
21
WorkBench/Themes/Condition/IntConditionControl.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<UserControl x:Class="DynamicDemo.Themes.Condition.IntConditionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicDemo.Themes.Condition"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<ComboBox x:Name="ConditionComboBox"
|
||||
SelectedValue="{Binding Condition, Mode=TwoWay}">
|
||||
<ComboBoxItem Content="Greater Than" Tag="GreaterThan" />
|
||||
<ComboBoxItem Content="Less Than" Tag="LessThan" />
|
||||
<ComboBoxItem Content="Equal To" Tag="EqualTo" />
|
||||
<ComboBoxItem Content="Between" Tag="Between" />
|
||||
<ComboBoxItem Content="Not Between" Tag="NotBetween" />
|
||||
<ComboBoxItem Content="Not In Range" Tag="NotInRange" />
|
||||
</ComboBox>
|
||||
<TextBox x:Name="ValueTextBox" Text="{Binding Value, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
WorkBench/Themes/Condition/IntConditionControl.xaml.cs
Normal file
28
WorkBench/Themes/Condition/IntConditionControl.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DynamicDemo.Themes.Condition
|
||||
{
|
||||
/// <summary>
|
||||
/// IntConditionControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class IntConditionControl : UserControl
|
||||
{
|
||||
public IntConditionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
88
WorkBench/Themes/Condition/Model.cs
Normal file
88
WorkBench/Themes/Condition/Model.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DynamicDemo.Themes.Condition
|
||||
{
|
||||
//public class IntConditionNode : ConditionNode
|
||||
//{
|
||||
// public int Value { get; set; }
|
||||
// public int MinValue { get; set; }
|
||||
// public int MaxValue { get; set; }
|
||||
// public List<int> ExcludeValues { get; set; }
|
||||
|
||||
// public override bool Evaluate(object value)
|
||||
// {
|
||||
// if (value is int intValue)
|
||||
// {
|
||||
// switch (Condition)
|
||||
// {
|
||||
// case ConditionType.GreaterThan:
|
||||
// return intValue > Value;
|
||||
// case ConditionType.LessThan:
|
||||
// return intValue < Value;
|
||||
// case ConditionType.EqualTo:
|
||||
// return intValue == Value;
|
||||
// case ConditionType.Between:
|
||||
// return intValue >= MinValue && intValue <= MaxValue;
|
||||
// case ConditionType.NotBetween:
|
||||
// return intValue < MinValue || intValue > MaxValue;
|
||||
// case ConditionType.NotInRange:
|
||||
// return !ExcludeValues.Contains(intValue);
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public class BoolConditionNode : ConditionNode
|
||||
//{
|
||||
// public override bool Evaluate(object value)
|
||||
// {
|
||||
// if (value is bool boolValue)
|
||||
// {
|
||||
// switch (Condition)
|
||||
// {
|
||||
// case ConditionType.IsTrue:
|
||||
// return boolValue;
|
||||
// case ConditionType.IsFalse:
|
||||
// return !boolValue;
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public class StringConditionNode : ConditionNode
|
||||
//{
|
||||
// public string Substring { get; set; }
|
||||
|
||||
// public override bool Evaluate(object value)
|
||||
// {
|
||||
// if (value is string stringValue)
|
||||
// {
|
||||
// switch (Condition)
|
||||
// {
|
||||
// case ConditionType.Contains:
|
||||
// return stringValue.Contains(Substring);
|
||||
// case ConditionType.DoesNotContain:
|
||||
// return !stringValue.Contains(Substring);
|
||||
// case ConditionType.IsNotEmpty:
|
||||
// return !string.IsNullOrEmpty(stringValue);
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
18
WorkBench/Themes/Condition/StringConditionControl.xaml
Normal file
18
WorkBench/Themes/Condition/StringConditionControl.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="DynamicDemo.Themes.Condition.StringConditionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicDemo.Themes.Condition"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<ComboBox x:Name="ConditionComboBox"
|
||||
SelectedValue="{Binding Condition, Mode=TwoWay}">
|
||||
<ComboBoxItem Content="Contains" Tag="Contains" />
|
||||
<ComboBoxItem Content="Does Not Contain" Tag="DoesNotContain" />
|
||||
<ComboBoxItem Content="Is Not Empty" Tag="IsNotEmpty" />
|
||||
</ComboBox>
|
||||
<TextBox x:Name="SubstringTextBox" Text="{Binding Substring, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
WorkBench/Themes/Condition/StringConditionControl.xaml.cs
Normal file
28
WorkBench/Themes/Condition/StringConditionControl.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DynamicDemo.Themes.Condition
|
||||
{
|
||||
/// <summary>
|
||||
/// StringConditionControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class StringConditionControl : UserControl
|
||||
{
|
||||
public StringConditionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
WorkBench/Themes/ConditionControl.xaml
Normal file
35
WorkBench/Themes/ConditionControl.xaml
Normal file
@@ -0,0 +1,35 @@
|
||||
<UserControl x:Class="DynamicDemo.Themes.ConditionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicDemo.Themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--<ComboBox x:Name="ConditionTypeComboBox" SelectionChanged="ConditionTypeComboBox_SelectionChanged">
|
||||
<ComboBoxItem Content="GreaterThan" Tag="{x:Static local:ConditionType.GreaterThan}"/>
|
||||
<ComboBoxItem Content="LessThan" Tag="{x:Static local:ConditionType.LessThan}"/>
|
||||
<ComboBoxItem Content="EqualTo" Tag="{x:Static local:ConditionType.EqualTo}"/>
|
||||
<ComboBoxItem Content="InRange" Tag="{x:Static local:ConditionType.InRange}"/>
|
||||
<ComboBoxItem Content="NotInRange" Tag="{x:Static local:ConditionType.NotInRange}"/>
|
||||
<ComboBoxItem Content="NotInSpecificRange" Tag="{x:Static local:ConditionType.NotInSpecificRange}"/>
|
||||
<ComboBoxItem Content="IsTrue" Tag="{x:Static local:ConditionType.IsTrue}"/>
|
||||
<ComboBoxItem Content="IsFalse" Tag="{x:Static local:ConditionType.IsFalse}"/>
|
||||
<ComboBoxItem Content="Contains" Tag="{x:Static local:ConditionType.Contains}"/>
|
||||
<ComboBoxItem Content="DoesNotContain" Tag="{x:Static local:ConditionType.DoesNotContain}"/>
|
||||
<ComboBoxItem Content="IsNotEmpty" Tag="{x:Static local:ConditionType.IsNotEmpty}"/>
|
||||
</ComboBox>
|
||||
<TextBox x:Name="ValueTextBox" Visibility="Collapsed"/>
|
||||
<TextBox x:Name="Value2TextBox" Visibility="Collapsed"/>-->
|
||||
|
||||
<StackPanel Grid.Row="0" x:Name="ConditionsPanel" Orientation="Vertical" Height="400"/>
|
||||
<Button Grid.Row="1" Content="Add Condition" Click="OnAddConditionClicked" />
|
||||
<!-- 其他控件 -->
|
||||
</Grid>
|
||||
</UserControl>
|
||||
85
WorkBench/Themes/ConditionControl.xaml.cs
Normal file
85
WorkBench/Themes/ConditionControl.xaml.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using DynamicDemo.Themes.Condition;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DynamicDemo.Themes
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// ConditionControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ConditionControl : UserControl
|
||||
{
|
||||
public ConditionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//private void ConditionTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
//{
|
||||
// var selectedType = (ConditionType)((ComboBoxItem)ConditionTypeComboBox.SelectedItem).Tag;
|
||||
// UpdateInputVisibility(selectedType);
|
||||
//}
|
||||
|
||||
//private void UpdateInputVisibility(ConditionType type)
|
||||
//{
|
||||
// ValueTextBox.Visibility = Visibility.Collapsed;
|
||||
// Value2TextBox.Visibility = Visibility.Collapsed;
|
||||
|
||||
// switch (type)
|
||||
// {
|
||||
// case ConditionType.GreaterThan:
|
||||
// case ConditionType.LessThan:
|
||||
// case ConditionType.EqualTo:
|
||||
// case ConditionType.Contains:
|
||||
// case ConditionType.DoesNotContain:
|
||||
// ValueTextBox.Visibility = Visibility.Visible;
|
||||
// break;
|
||||
// case ConditionType.InRange:
|
||||
// case ConditionType.NotInRange:
|
||||
// ValueTextBox.Visibility = Visibility.Visible;
|
||||
// Value2TextBox.Visibility = Visibility.Visible;
|
||||
// break;
|
||||
// case ConditionType.IsTrue:
|
||||
// case ConditionType.IsFalse:
|
||||
// case ConditionType.IsNotEmpty:
|
||||
// // No additional input needed
|
||||
// break;
|
||||
// case ConditionType.NotInSpecificRange:
|
||||
// // Handle specific range input, possibly with a different control
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
private void OnAddConditionClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 示例:添加一个IntConditionNode
|
||||
var intConditionNode = new IntConditionNode { Condition = ConditionType.GreaterThan, Value = 10 };
|
||||
AddConditionNode(intConditionNode);
|
||||
}
|
||||
|
||||
public void AddConditionNode(ConditionNode node)
|
||||
{
|
||||
UserControl control = null;
|
||||
|
||||
if (node is IntConditionNode)
|
||||
{
|
||||
control = new IntConditionControl { DataContext = node };
|
||||
}
|
||||
else if (node is BoolConditionNode)
|
||||
{
|
||||
control = new BoolConditionControl { DataContext = node };
|
||||
}
|
||||
else if (node is StringConditionNode)
|
||||
{
|
||||
control = new StringConditionControl { DataContext = node };
|
||||
}
|
||||
|
||||
if (control != null)
|
||||
{
|
||||
ConditionsPanel.Children.Add(control);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
99
WorkBench/Themes/ConditionControlModel.cs
Normal file
99
WorkBench/Themes/ConditionControlModel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
namespace DynamicDemo.Themes;
|
||||
|
||||
public enum ConditionType
|
||||
{
|
||||
GreaterThan,
|
||||
LessThan,
|
||||
EqualTo,
|
||||
Between,
|
||||
NotBetween,
|
||||
NotInRange,
|
||||
IsTrue,
|
||||
IsFalse,
|
||||
Contains,
|
||||
DoesNotContain,
|
||||
IsNotEmpty
|
||||
}
|
||||
|
||||
public abstract class ConditionNode
|
||||
{
|
||||
public ConditionType Condition { get; set; }
|
||||
public abstract bool Evaluate(object value);
|
||||
}
|
||||
|
||||
public class IntConditionNode : ConditionNode
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public List<int> ExcludeValues { get; set; }
|
||||
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is int intValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.GreaterThan:
|
||||
return intValue > Value;
|
||||
case ConditionType.LessThan:
|
||||
return intValue < Value;
|
||||
case ConditionType.EqualTo:
|
||||
return intValue == Value;
|
||||
case ConditionType.Between:
|
||||
return intValue >= MinValue && intValue <= MaxValue;
|
||||
case ConditionType.NotBetween:
|
||||
return intValue < MinValue || intValue > MaxValue;
|
||||
case ConditionType.NotInRange:
|
||||
return !ExcludeValues.Contains(intValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class BoolConditionNode : ConditionNode
|
||||
{
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.IsTrue:
|
||||
return boolValue;
|
||||
case ConditionType.IsFalse:
|
||||
return !boolValue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class StringConditionNode : ConditionNode
|
||||
{
|
||||
public string Substring { get; set; }
|
||||
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is string stringValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.Contains:
|
||||
return stringValue.Contains(Substring);
|
||||
case ConditionType.DoesNotContain:
|
||||
return !stringValue.Contains(Substring);
|
||||
case ConditionType.IsNotEmpty:
|
||||
return !string.IsNullOrEmpty(stringValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
115
WorkBench/Themes/MethodDetailsControl.xaml
Normal file
115
WorkBench/Themes/MethodDetailsControl.xaml
Normal file
@@ -0,0 +1,115 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Serein.WorkBench.Themes"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="{x:Type local:MethodDetailsControl}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:MethodDetailsControl}">
|
||||
|
||||
<ItemsControl ItemsSource="{Binding MethodDetails.ExplicitDatas, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{Binding}">
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsExplicitData}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid Background="#E3FDFD">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding Index,StringFormat=agr{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<CheckBox Grid.Column="1" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
|
||||
<TextBlock Grid.Column="2" MinWidth="50" Text="{Binding ParameterName}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" MinWidth="50" Text="无须指定参数"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsExplicitData}" Value="true" />
|
||||
<Condition Binding="{Binding ExplicitTypeName}" Value="Select" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid Background="#E3FDFD">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding Index,StringFormat=agr{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<CheckBox Grid.Column="1" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
|
||||
<TextBlock Grid.Column="2" MinWidth="50" Text="{Binding ParameterName}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Column="3"
|
||||
MinWidth="50"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectedItem="{Binding DataValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsExplicitData}" Value="true" />
|
||||
<Condition Binding="{Binding ExplicitTypeName}" Value="Value" />
|
||||
<!--<Condition Binding="{Binding ExplicitTypeName}" Value="{x:Type sys:String}" />
|
||||
<Condition Binding="{Binding ExplicitTypeName}" Value="{x:Type sys:Double}" />-->
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid Background="#E3FDFD">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding Index,StringFormat=agr{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<CheckBox Grid.Column="1" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
|
||||
<TextBlock Grid.Column="2" MinWidth="50" Text="{Binding ParameterName}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Column="3" MinWidth="50" Text="{Binding DataValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
74
WorkBench/Themes/MethodDetailsControl.xaml.cs
Normal file
74
WorkBench/Themes/MethodDetailsControl.xaml.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using Serein.DynamicFlow;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.WorkBench.Themes
|
||||
{
|
||||
public class MultiConditionConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values.Length == 2 && values[0] is Type valueType && values[1] is bool isEnabled)
|
||||
{
|
||||
if (isEnabled)
|
||||
{
|
||||
if (valueType == typeof(string) || valueType == typeof(int) || valueType == typeof(double))
|
||||
{
|
||||
return "TextBoxTemplate";
|
||||
}
|
||||
else if (typeof(IEnumerable).IsAssignableFrom(valueType))
|
||||
{
|
||||
return "ComboBoxTemplate";
|
||||
}
|
||||
}
|
||||
}
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public partial class MethodDetailsControl : UserControl//,ItemsControl
|
||||
{
|
||||
static MethodDetailsControl()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MethodDetailsControl), new FrameworkPropertyMetadata(typeof(MethodDetailsControl)));
|
||||
}
|
||||
|
||||
|
||||
public MethodDetails MethodDetails
|
||||
{
|
||||
get { return (MethodDetails)GetValue(MethodDetailsProperty); }
|
||||
set { SetValue(MethodDetailsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MethodDetailsProperty = DependencyProperty.Register("MethodDetails", typeof(MethodDetails),
|
||||
typeof(MethodDetailsControl), new PropertyMetadata(null, new PropertyChangedCallback(OnPropertyChange)));
|
||||
|
||||
static void OnPropertyChange(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
|
||||
var MethodDetails = (MethodDetails)args.NewValue;
|
||||
//MethodDetails.ExplicitDatas[0].
|
||||
}
|
||||
}
|
||||
}
|
||||
4
WorkBench/Themes/MultiConditionConverter.xaml
Normal file
4
WorkBench/Themes/MultiConditionConverter.xaml
Normal file
@@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
15
WorkBench/Themes/TypeViewerWindow.xaml
Normal file
15
WorkBench/Themes/TypeViewerWindow.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<Window x:Class="Serein.WorkBench.Themes.TypeViewerWindow"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Serein.WorkBench.Themes"
|
||||
mc:Ignorable="d"
|
||||
Topmost="True"
|
||||
Title="TypeViewerWindow" Height="300" Width="300">
|
||||
<Grid>
|
||||
<Grid>
|
||||
<TreeView x:Name="TypeTreeView"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
71
WorkBench/Themes/TypeViewerWindow.xaml.cs
Normal file
71
WorkBench/Themes/TypeViewerWindow.xaml.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
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 Serein.WorkBench.Themes
|
||||
{
|
||||
/// <summary>
|
||||
/// TypeViewerWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TypeViewerWindow : Window
|
||||
{
|
||||
public TypeViewerWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Type Type { get; set; }
|
||||
|
||||
public void LoadTypeInformation()
|
||||
{
|
||||
if (Type == null)
|
||||
return;
|
||||
|
||||
var rootNode = new TreeViewItem { Header = Type.Name };
|
||||
AddMembersToTreeNode(rootNode, Type);
|
||||
TypeTreeView.Items.Clear();
|
||||
TypeTreeView.Items.Add(rootNode);
|
||||
}
|
||||
|
||||
private void AddMembersToTreeNode(TreeViewItem node, Type type)
|
||||
{
|
||||
var members = type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
|
||||
foreach (var member in members)
|
||||
{
|
||||
var memberNode = new TreeViewItem { Header = member.Name };
|
||||
if (member is PropertyInfo property)
|
||||
{
|
||||
var propertyType = property.PropertyType;
|
||||
memberNode.Header = $"{member.Name} : {propertyType.Name}";
|
||||
if (!propertyType.IsPrimitive && propertyType != typeof(string))
|
||||
{
|
||||
AddMembersToTreeNode(memberNode, propertyType);
|
||||
}
|
||||
}
|
||||
else if (member is MethodInfo method)
|
||||
{
|
||||
var parameters = method.GetParameters();
|
||||
var paramStr = string.Join(", ", parameters.Select(p => $"{p.ParameterType.Name} {p.Name}"));
|
||||
memberNode.Header = $"{member.Name}({paramStr})";
|
||||
}
|
||||
else if (member is FieldInfo field)
|
||||
{
|
||||
memberNode.Header = $"{member.Name} : {field.FieldType.Name}";
|
||||
}
|
||||
|
||||
node.Items.Add(memberNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user