You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.7 KiB
81 lines
2.7 KiB
using System.Windows;
|
|
using System.ComponentModel;
|
|
using System;
|
|
|
|
namespace HMIControl
|
|
{
|
|
|
|
public class Cyclone : HMIControlBase
|
|
{
|
|
public static readonly DependencyProperty HighLevelProperty = DependencyProperty.Register("HighLevel", typeof(bool), typeof(Cyclone),
|
|
new PropertyMetadata(false, OnHighLevelChanged));
|
|
|
|
[Category("HMI")]
|
|
public bool HighLevel
|
|
{
|
|
set
|
|
{
|
|
SetValue(HighLevelProperty, value);
|
|
}
|
|
get
|
|
{
|
|
return (bool)GetValue(HighLevelProperty);
|
|
}
|
|
}
|
|
|
|
static Cyclone()
|
|
{
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(Cyclone), new FrameworkPropertyMetadata(typeof(Cyclone)));
|
|
}
|
|
|
|
private static void OnHighLevelChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
|
{
|
|
VisualStateManager.GoToState(obj as Cyclone, (bool)args.NewValue ? "aboveHigh" : "belowHigh", true);
|
|
}
|
|
|
|
public override string[] GetActions()
|
|
{
|
|
return new string[] { TagActions.DEVICENAME, TagActions.VISIBLE, TagActions.CAPTION, TagActions.HIGHLEVEL,};
|
|
}
|
|
|
|
public override void OnApplyTemplate()
|
|
{
|
|
base.OnApplyTemplate();
|
|
Fan fan = base.GetTemplateChild("fan") as Fan;
|
|
Motor motor = base.GetTemplateChild("motor") as Motor;
|
|
children = new ITagLink[] { motor, fan };
|
|
}
|
|
|
|
public override LinkPosition[] GetLinkPositions()
|
|
{
|
|
return new LinkPosition[3]
|
|
{
|
|
new LinkPosition(new Point(0.5,0),ConnectOrientation.Top),
|
|
new LinkPosition(new Point(0.4,1),ConnectOrientation.Bottom),
|
|
new LinkPosition(new Point(1,0.35),ConnectOrientation.Right)
|
|
};
|
|
}
|
|
|
|
public override Action SetTagReader(string key, Delegate tagChanged)
|
|
{
|
|
switch (key)
|
|
{
|
|
case TagActions.HIGHLEVEL:
|
|
var _funcHighLevel = tagChanged as Func<bool>;
|
|
if (_funcHighLevel != null)
|
|
{
|
|
return delegate { HighLevel = _funcHighLevel(); };
|
|
}
|
|
else return null;
|
|
case TagActions.CAPTION:
|
|
var _funcCap = tagChanged as Func<string>;
|
|
if (_funcCap != null)
|
|
{
|
|
return delegate { Caption = _funcCap(); };
|
|
}
|
|
else return null;
|
|
}
|
|
return base.SetTagReader(key, tagChanged);
|
|
}
|
|
}
|
|
}
|
|
|