2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class DesignerItemsControlItemStyleSelector : StyleSelector
|
|
|
|
|
|
{
|
|
|
|
|
|
static DesignerItemsControlItemStyleSelector()
|
|
|
|
|
|
{
|
|
|
|
|
|
Instance = new DesignerItemsControlItemStyleSelector();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DesignerItemsControlItemStyleSelector Instance
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
private set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Style SelectStyle(object item, DependencyObject container)
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(container);
|
|
|
|
|
|
if (itemsControl == null)
|
|
|
|
|
|
throw new InvalidOperationException("DesignerItemsControlItemStyleSelector : Could not find ItemsControl");
|
|
|
|
|
|
|
|
|
|
|
|
if (item is GifImageItemViewModel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (Style)itemsControl.FindResource("gifimageItemStyle");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (item is LogicalGateItemViewModelBase)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (Style)itemsControl.FindResource("logicalItemStyle");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
if (item is BlockDesignerItemViewModel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (Style)itemsControl.FindResource("blockItemStyle");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
if (item is DesignerItemViewModelBase)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (Style)itemsControl.FindResource("designerItemStyle");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (item is ConnectionViewModel)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
return (Style)itemsControl.FindResource("connectorItemStyle");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|