mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-02 15:50:51 +08:00
添加项目文件。
This commit is contained in:
51
VisionFrame.Base/Converter/StringToNodeConverter.cs
Normal file
51
VisionFrame.Base/Converter/StringToNodeConverter.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace VisionFrame.Base.Converter
|
||||
{
|
||||
public class StringToNodeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
string[] _info = value.ToString().Split(";");
|
||||
|
||||
Assembly assembly = Assembly.GetEntryAssembly();
|
||||
Type type = assembly.GetType(_info[0]);
|
||||
if (_info.Length == 2)
|
||||
{
|
||||
assembly =
|
||||
Assembly.LoadFile(Environment.CurrentDirectory + "/Activities/" + _info[0] + ".dll");
|
||||
if (assembly == null) return null;
|
||||
|
||||
type = assembly.GetType(_info[1]);
|
||||
if (type == null) return null;
|
||||
}
|
||||
|
||||
object instance = Activator.CreateInstance(type);
|
||||
|
||||
Binding binding = new Binding("DataContext.AnchorDownCommand");
|
||||
binding.RelativeSource = new RelativeSource() { AncestorType = typeof(ItemsControl) };
|
||||
(instance as NodeBase).SetBinding(NodeBase.AnchorDownCommandProperty, binding);
|
||||
|
||||
|
||||
binding = new Binding("DataContext.AnchorUpCommand");
|
||||
binding.RelativeSource = new RelativeSource() { AncestorType = typeof(ItemsControl) };
|
||||
(instance as NodeBase).SetBinding(NodeBase.AnchorUpCommandProperty, binding);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user