Files
aistudio-wpf-diagram/AIStudio.Wpf.DiagramDesigner/StyleSelectors/DesignerItemsControlItemStyleSelector.cs
2022-10-28 22:45:39 +08:00

65 lines
1.9 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 LinkPointDesignerItemViewModel)
{
return (Style)itemsControl.FindResource("linkpointItemStyle");
}
if (item is PointDesignerItemViewModel)
{
return (Style)itemsControl.FindResource("pointItemStyle");
}
if (item is LogicalGateItemViewModelBase)
{
return (Style)itemsControl.FindResource("logicalItemStyle");
}
if (item is DesignerItemViewModelBase)
{
return (Style)itemsControl.FindResource("designerItemStyle");
}
if (item is ConnectorViewModel)
{
return (Style)itemsControl.FindResource("connectorItemStyle");
}
return null;
}
}
}