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; using System.Runtime.Serialization; using Aitex.Core.Util; using Aitex.Core.UI.ControlDataContext; namespace Aitex.Core.UI.Control { /// /// Interaction logic for MFC4Process.xaml /// public partial class MFC4Process : UserControl { public MFC4Process() { InitializeComponent(); } MOSourceDataItem AirFlowMoLineData { get { return (this.DataContext as MOSourceDataItem); } } // public static readonly DependencyProperty SourceMFCProperty = DependencyProperty.Register( // "SourceMFC", typeof(AnalogDeviceDataItem), typeof(MFC4Process), // new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); // public AnalogDeviceDataItem SourceMFC // { // get // { // return (AnalogDeviceDataItem)this.GetValue(SourceMFCProperty); // } // set // { // this.SetValue(SourceMFCProperty, value); // } // } // public static readonly DependencyProperty Source2MFCProperty = DependencyProperty.Register( // "Source2MFC", typeof(AnalogDeviceDataItem), typeof(MFC4Process), // new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); // public AnalogDeviceDataItem Source2MFC // { // get // { // return (AnalogDeviceDataItem)this.GetValue(Source2MFCProperty); // } // set // { // this.SetValue(Source2MFCProperty, value); // } // } // public static readonly DependencyProperty InjectMFCProperty = DependencyProperty.Register( //"InjectMFC", typeof(AnalogDeviceDataItem), typeof(MFC4Process), //new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); // public AnalogDeviceDataItem InjectMFC // { // get // { // return (AnalogDeviceDataItem)this.GetValue(InjectMFCProperty); // } // set // { // this.SetValue(InjectMFCProperty, value); // } // } // public static readonly DependencyProperty DiluteMFCProperty = DependencyProperty.Register( //"DiluteMFC", typeof(AnalogDeviceDataItem), typeof(MFC4Process), //new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); // public AnalogDeviceDataItem DiluteMFC // { // get // { // return (AnalogDeviceDataItem)this.GetValue(DiluteMFCProperty); // } // set // { // this.SetValue(DiluteMFCProperty, value); // } // } // public bool IsMultiControlMFC{get;set;} // protected override void OnRender(DrawingContext drawingContext) // { // base.OnRender(drawingContext); // StringBuilder tooltip = new StringBuilder(); // Brush borderBrush = Brushes.Black; // string content = ""; // if (IsMultiControlMFC) // { // if (SourceMFC == null) return; // var source = SourceMFC.FeedBack; // var inject = InjectMFC.FeedBack; // var dilute = DiluteMFC.FeedBack; // var source2 = Source2MFC == null ? 0 : Source2MFC.FeedBack; // var flow = source + source2 + dilute; // if (flow == 0) // { // content = "0.00"; // } // else // { // double val = ((source * inject) / flow); // content = val >= 10 ? val.ToString("0.0") : val.ToString("0.00"); // } // if (SourceMFC.IsWarning) { borderBrush = Brushes.Red; tooltip.AppendLine(string.Format("mfc:{0},设备名:{1} 报警! 流量:{2}", SourceMFC.DeviceId, SourceMFC.DeviceName, SourceMFC.FeedBack.ToString("F1"))); } // if (InjectMFC.IsWarning) { borderBrush = Brushes.Red; tooltip.AppendLine(string.Format("mfc:{0},设备名:{1} 报警! 流量:{2}", InjectMFC.DeviceId, InjectMFC.DeviceName, InjectMFC.FeedBack.ToString("F1"))); } // if (DiluteMFC.IsWarning) { borderBrush = Brushes.Red; tooltip.AppendLine(string.Format("mfc:{0},设备名:{1} 报警! 流量:{2}", DiluteMFC.DeviceId, DiluteMFC.DeviceName, DiluteMFC.FeedBack.ToString("F1"))); } // } // else // { // if (SourceMFC != null && SourceMFC.IsWarning) { borderBrush = Brushes.Red; tooltip.AppendLine(string.Format("mfc:{0},设备名:{1} 报警! 流量:{2}", SourceMFC.DeviceId, SourceMFC.DeviceName, SourceMFC.FeedBack.ToString("F1"))); } // content = OptimizeFeedBack(SourceMFC); // } // btnLiuLiang.Foreground = borderBrush; // btnLiuLiang.BorderBrush = borderBrush; // btnLiuLiang.Content = content; // if (tooltip.Length > 0) // btnLiuLiang.ToolTip = tooltip.ToString(); // else // btnLiuLiang.ToolTip = null; // } // string OptimizeFeedBack(AnalogDeviceDataItem mfc) // { // if (mfc == null) return "-"; // if (mfc.FeedBack >= 10000) // return mfc.FeedBack.ToString("F0"); // else if (mfc.FeedBack >= 10) // return mfc.FeedBack.ToString("0.0"); // else // return mfc.FeedBack.ToString("0.00"); // } } }