using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Aitex.Core.UI.Control { /// /// Interaction logic for Knot.xaml /// public partial class Knot : UserControl { public Knot() { InitializeComponent(); } public static readonly DependencyProperty KnotNameProperty = DependencyProperty.Register( "KnotName", typeof(string), typeof(Knot), new FrameworkPropertyMetadata("未知阀门", FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty KnotDirectionProperty = DependencyProperty.Register( "KnotDirection", typeof(ValveDirection), typeof(Knot), new FrameworkPropertyMetadata(ValveDirection.ToBottom, FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty KnotTypeProperty = DependencyProperty.Register( "KnotT", typeof(KnotType), typeof(Knot), new FrameworkPropertyMetadata(KnotType.Knot, FrameworkPropertyMetadataOptions.AffectsRender)); /// /// Description /// public static readonly DependencyProperty ThroughInnerColorProperty = DependencyProperty.Register("ThroughInnerColor", typeof(string), typeof(Knot), new FrameworkPropertyMetadata("White")); /// /// A property wrapper for the /// dependency property:
/// Description ///
public string ThroughInnerColor { get { return (string)GetValue(ThroughInnerColorProperty); } set { SetValue(ThroughInnerColorProperty, value); } } /// /// Description /// public static readonly DependencyProperty KnotElliColorProperty = DependencyProperty.Register("KnotElliColor", typeof(string), typeof(Knot), new FrameworkPropertyMetadata("Black")); /// /// A property wrapper for the /// dependency property:
/// Description ///
public string KnotElliColor { get { return (string)GetValue(KnotElliColorProperty); } set { SetValue(KnotElliColorProperty, value); } } /// /// node or through tag /// public KnotType KnotT { get { return (KnotType)GetValue(KnotTypeProperty); } set { SetValue(KnotTypeProperty, value); } } /// /// direction of the valve /// public ValveDirection KnotDirection { get { return (ValveDirection)GetValue(KnotDirectionProperty); } set { SetValue(KnotDirectionProperty, value); } } /// /// valve name /// public string KnotName { get { return (string)GetValue(KnotNameProperty); } set { SetValue(KnotNameProperty, value); } } public PipeType PipeStyleType { get; set; } /// /// over rendering behavior /// /// protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); switch (KnotDirection) { case ValveDirection.ToBottom: case ValveDirection.ToTop: rotateTransform.Angle = 90; break; case ValveDirection.ToLeft: break; case ValveDirection.ToRight: rotateTransform.Angle = 180; break; default: break; } if (KnotT == KnotType.Knot) { knotElli.Visibility = Visibility.Visible; throughPath.Visibility = Visibility.Hidden; } else { knotElli.Visibility = Visibility.Hidden; throughPath.Visibility = Visibility.Visible; } switch (PipeStyleType) { case Control.PipeType.DarkThick: knotElli.Stroke = Brushes.Black; pathThrough.Stroke = Brushes.Black; break; case Control.PipeType.GrayThick: knotElli.Stroke = Brushes.Gray; pathThrough.Stroke = Brushes.Gray; break; case Control.PipeType.Normal: default: //knotElli.Stroke = Brushes.Black; //pathThrough.Stroke = Brushes.Black; break; } } } public enum KnotType { Knot = 1, Through = 2 } }