mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
{
|
|
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");
|
|
}
|
|
|
|
if (item is DesignerItemViewModelBase)
|
|
{
|
|
return (Style)itemsControl.FindResource("designerItemStyle");
|
|
}
|
|
|
|
if (item is ConnectionViewModel)
|
|
{
|
|
return (Style)itemsControl.FindResource("connectorItemStyle");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|