MOPush.xaml.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Util;
  15. using Aitex.Core.RT.Log;
  16. using Aitex.Core.UI.ControlDataContext;
  17. namespace Aitex.Core.UI.Control
  18. {
  19. /// <summary>
  20. /// Interaction logic for MOPush.xaml
  21. /// </summary>
  22. public partial class MOPush : UserControl
  23. {
  24. MOLineDataItem MoLineData { get { return (this.DataContext as MOSourceDataItem).LineData; } }
  25. public MOPush()
  26. {
  27. InitializeComponent();
  28. }
  29. public static readonly DependencyProperty IsManualModeProperty = DependencyProperty.Register(
  30. "IsManualModeValve2", typeof(bool), typeof(MOPush),
  31. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
  32. public bool IsManualModeValve2
  33. {
  34. get
  35. {
  36. return (bool)GetValue(IsManualModeProperty);
  37. }
  38. set
  39. {
  40. SetValue(IsManualModeProperty, value);
  41. }
  42. }
  43. private void RecMOSource_MouseEnter(object sender, MouseEventArgs e)
  44. {
  45. RecMOSource.Opacity = 0.5;
  46. if (MoLineData != null)
  47. {
  48. string tooltipStr = string.Format("{0}\n\n原始重量:{1}克\n已使用量:{2}克\n剩余重量:{3}克\n剩余比例:{4}\n余量状态:{5}",
  49. MoLineData.DisplayName,
  50. MoLineData.MoTotalWeight.ToString("F2"),
  51. MoLineData.MoUsedWeight.ToString("F2"),
  52. MoLineData.MoRemainedWeight.ToString("F2"),
  53. (MoLineData.MoRemainedPercentage * 100).ToString("F1") + "%",
  54. MoLineData.IsMoRemainedWeightAlarm ? "报警" : "正常");
  55. this.ToolTip = tooltipStr;
  56. }
  57. }
  58. private void RecMOSource_MouseLeave(object sender, MouseEventArgs e)
  59. {
  60. RecMOSource.Opacity = 1;
  61. }
  62. }
  63. }