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 Aitex.Core.Util;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.ControlDataContext;

namespace Aitex.Core.UI.Control
{
    /// <summary>
    /// Interaction logic for MOPush.xaml
    /// </summary>
    public partial class MOPush : UserControl
    {

        MOLineDataItem MoLineData { get { return (this.DataContext as MOSourceDataItem).LineData; } }

        public MOPush()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty IsManualModeProperty = DependencyProperty.Register(
            "IsManualModeValve2", typeof(bool), typeof(MOPush),
            new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));

        public bool IsManualModeValve2
        {
            get
            {
                return (bool)GetValue(IsManualModeProperty);
            }
            set
            {
                SetValue(IsManualModeProperty, value);
            }
        }

        private void RecMOSource_MouseEnter(object sender, MouseEventArgs e)
        {
            RecMOSource.Opacity = 0.5;


            if (MoLineData != null)
            {
                string tooltipStr = string.Format("{0}\n\n原始重量:{1}克\n已使用量:{2}克\n剩余重量:{3}克\n剩余比例:{4}\n余量状态:{5}",
                         MoLineData.DisplayName,
                         MoLineData.MoTotalWeight.ToString("F2"),
                         MoLineData.MoUsedWeight.ToString("F2"),
                         MoLineData.MoRemainedWeight.ToString("F2"),
                         (MoLineData.MoRemainedPercentage * 100).ToString("F1") + "%",
                         MoLineData.IsMoRemainedWeightAlarm ? "报警" : "正常");

                this.ToolTip = tooltipStr;
            }
        }

        private void RecMOSource_MouseLeave(object sender, MouseEventArgs e)
        {
            RecMOSource.Opacity = 1;
        }

    }
}