|
- using BPASmartClient.CustomResource.UserControls.Enum;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- 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 BPASmartClient.CustomResource.UserControls
- {
- /// <summary>
- /// MotorTwo.xaml 的交互逻辑
- /// </summary>
- public partial class MotorTwo : UserControl
- {
- public MotorTwo()
- {
- InitializeComponent();
- }
-
- public static DependencyProperty MotorColorsProperty = DependencyProperty.Register("MotorColors", typeof(MotorColor), typeof(MotorTwo), new FrameworkPropertyMetadata(MotorColor.Gray, FrameworkPropertyMetadataOptions.AffectsRender));
-
- public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(bool), typeof(MotorTwo), new PropertyMetadata(false));
-
- public static readonly DependencyProperty PLCAddressValueProperty = DependencyProperty.Register("PLCAddressValue", typeof(string), typeof(MotorTwo), new FrameworkPropertyMetadata("0"));
-
- private ImageSource imageSource;
-
- [Category("HMI")]
- public MotorColor MotorColors
- {
- get
- {
- return (MotorColor)GetValue(MotorColorsProperty);
- }
- set
- {
- SetValue(MotorColorsProperty, value);
- }
- }
-
- /// <summary>
- /// 重绘整个呈现的过程
- /// </summary>
- /// <param name="drawingContext"></param>
- protected override void OnRender(DrawingContext drawingContext)
- {
- double actualWidth = base.ActualWidth;
- double actualHeight = base.ActualHeight;
- switch (MotorColors)
- {
- case MotorColor.Gray:
- imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGray.png"));
- drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
- break;
- case MotorColor.Green:
- imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGreen.png"));
- drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
- break;
- case MotorColor.Red:
- imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorRed.png"));
- drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
- break;
- case MotorColor.Yellow:
- imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorYellow.png"));
- drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
- break;
- default:
- imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGray.png"));
- drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
- break;
- }
- }
-
- protected override void OnInitialized(EventArgs e)
- {
- base.OnInitialized(e);
- bool flag = LicenseManager.UsageMode == LicenseUsageMode.Designtime;
- bool flag2 = Process.GetCurrentProcess().ProcessName == "devenv";
- if (!(flag || flag2))
- {
- }
- }
- }
- }
|