移除了文件

This commit is contained in:
fengjiayi
2024-10-29 10:46:39 +08:00
parent 65ca04e38d
commit 0088d32f12
44 changed files with 123 additions and 5557 deletions

View File

@@ -1,16 +0,0 @@
<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>

View File

@@ -1,28 +0,0 @@
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();
}
}
}

View File

@@ -1,21 +0,0 @@
<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>

View File

@@ -1,28 +0,0 @@
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();
}
}
}

View File

@@ -1,88 +0,0 @@
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;
// }
//}
}

View File

@@ -1,18 +0,0 @@
<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>

View File

@@ -1,28 +0,0 @@
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();
}
}
}

View File

@@ -1,35 +0,0 @@
<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>

View File

@@ -1,85 +0,0 @@
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);
}
}
}
}

View File

@@ -1,99 +0,0 @@
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;
}
}

View File

@@ -1,4 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>

View File

@@ -1,8 +0,0 @@
<UserControl x:Class="RealTimeObjectViewer.ObjectViewerControl"
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">
<Grid>
<TreeView x:Name="ObjectTreeView" />
</Grid>
</UserControl>

View File

@@ -1,146 +0,0 @@
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>
/// ObjectViewerWindow.xaml 的交互逻辑
/// </summary>
public partial class ObjectViewerControl : UserControl
{
public ObjectViewerControl()
{
InitializeComponent();
}
private object _objectInstance;
private Action _closeCallback;
public void LoadObjectInformation(object obj,Action closeCallback)
{
if (obj == null || closeCallback == null)
return;
_closeCallback = closeCallback;
_objectInstance = obj;
var objectType = obj.GetType();
var rootNode = new TreeViewItem { Header = objectType.Name, Tag = obj };
// 添加占位符节点
AddPlaceholderNode(rootNode);
ObjectTreeView.Items.Clear();
ObjectTreeView.Items.Add(rootNode);
// 监听展开事件
rootNode.Expanded += TreeViewItem_Expanded;
}
private void AddPlaceholderNode(TreeViewItem node)
{
node.Items.Add(new TreeViewItem { Header = "Loading..." });
}
private void TreeViewItem_Expanded(object sender, RoutedEventArgs e)
{
var item = (TreeViewItem)sender;
if (item.Items.Count == 1 && item.Items[0] is TreeViewItem placeholder && placeholder.Header.ToString() == "Loading...")
{
item.Items.Clear();
if (item.Tag is object obj)
{
var objectType = obj.GetType();
AddMembersToTreeNode(item, obj, objectType);
}
}
}
private void AddMembersToTreeNode(TreeViewItem node, object obj, Type type)
{
// 获取属性和字段
var members = type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
foreach (var member in members)
{
TreeViewItem memberNode = ConfigureTreeViewItem(obj, member);
node.Items.Add(memberNode);
}
}
private TreeViewItem ConfigureTreeViewItem(object obj, MemberInfo member)
{
TreeViewItem memberNode = new TreeViewItem { Header = member.Name };
if (member is PropertyInfo property)
{
string propertyValue = GetPropertyValue(obj, property);
memberNode.Header = $"{property.Name} : {property.PropertyType.Name} = {propertyValue}";
if (!property.PropertyType.IsPrimitive && property.PropertyType != typeof(string))
{
AddPlaceholderNode(memberNode);
memberNode.Expanded += TreeViewItem_Expanded;
}
}
else if (member is FieldInfo field)
{
string fieldValue = GetFieldValue(obj, field);
memberNode.Header = $"{field.Name} : {field.FieldType.Name} = {fieldValue}";
if (!field.FieldType.IsPrimitive && field.FieldType != typeof(string))
{
AddPlaceholderNode(memberNode);
memberNode.Expanded += TreeViewItem_Expanded;
}
}
return memberNode;
}
private string GetPropertyValue(object obj, PropertyInfo property)
{
try
{
var value = property.GetValue(obj);
return value?.ToString() ?? "null";
}
catch
{
return "Error";
}
}
private string GetFieldValue(object obj, FieldInfo field)
{
try
{
var value = field.GetValue(obj);
return value?.ToString() ?? "null";
}
catch
{
return "Error";
}
}
private void Window_Closed(object sender, EventArgs e)
{
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
_closeCallback?.Invoke();
}
}
}