using System;
|
using System.Collections.Generic;
|
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 Bro.UI.Ctrls
|
{
|
/// <summary>
|
/// ProductionSelectionCtrl.xaml 的交互逻辑
|
/// </summary>
|
public partial class ProductionSelectionCtrl : UserControl
|
{
|
#region Property
|
public static readonly DependencyProperty ProductionCodeSourceProperty;
|
public static readonly DependencyProperty CurrentProductionCodeProperty;
|
public static readonly DependencyProperty IsEnableChangeProductionProperty;
|
|
public List<string> ProductionCodeSource
|
{
|
get => GetValue(ProductionCodeSourceProperty) as List<string>;
|
set => SetValue(ProductionCodeSourceProperty, value);
|
}
|
|
public string CurrentProductionCode
|
{
|
get => GetValue(CurrentProductionCodeProperty).ToString();
|
set => SetValue(CurrentProductionCodeProperty, value);
|
}
|
|
public bool IsEnableChangeProduction
|
{
|
get => (bool)GetValue(IsEnableChangeProductionProperty);
|
set => SetValue(IsEnableChangeProductionProperty, value);
|
}
|
#endregion
|
|
#region Event
|
//public static RoutedEvent ConfirmProductionChangedEvent;
|
|
//public event RoutedEventHandler Cmmd_ConfirmProducionChanged
|
//{
|
// add { AddHandler(ConfirmProductionChangedEvent, value); }
|
// remove { RemoveHandler(ConfirmProductionChangedEvent, value); }
|
//}
|
#endregion
|
|
public ProductionSelectionCtrl()
|
{
|
InitializeComponent();
|
}
|
|
static ProductionSelectionCtrl()
|
{
|
ProductionCodeSourceProperty = DependencyProperty.Register("ProductionCodeSource", typeof(List<string>), typeof(ProductionSelectionCtrl), new PropertyMetadata(new List<string>(), OnProductionCodeSourcePropertyChanged));
|
|
CurrentProductionCodeProperty = DependencyProperty.Register("CurrentProductionCode", typeof(string), typeof(ProductionSelectionCtrl), new PropertyMetadata("", OnCurrentProductionCodePropertyChanged));
|
|
IsEnableChangeProductionProperty = DependencyProperty.Register("IsEnableChangeProduction", typeof(bool), typeof(ProductionSelectionCtrl), new PropertyMetadata(true, OnIsEnableChangeProductionPropertyChanged));
|
|
//ConfirmProductionChangedEvent = EventManager.RegisterRoutedEvent("ConfirmProductionChanged", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(ProductionSelectionCtrl));
|
}
|
|
private static void OnIsEnableChangeProductionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
{
|
ProductionSelectionCtrl ctrl = d as ProductionSelectionCtrl;
|
if (ctrl != null)
|
{
|
ctrl.cboPCodes.IsEnabled = ctrl.btnConfirmPCode.IsEnabled = (bool)e.NewValue;
|
}
|
}
|
|
private static void OnCurrentProductionCodePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
{
|
ProductionSelectionCtrl ctrl = d as ProductionSelectionCtrl;
|
if (ctrl != null)
|
{
|
ctrl.cboPCodes.SelectedItem = e.NewValue.ToString();
|
}
|
}
|
|
private static void OnProductionCodeSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
{
|
ProductionSelectionCtrl ctrl = d as ProductionSelectionCtrl;
|
if (ctrl != null)
|
{
|
ctrl.cboPCodes.ItemsSource = (e.NewValue as List<string>) ?? new List<string>();
|
}
|
}
|
|
private void btnConfirmPCode_Click(object sender, RoutedEventArgs e)
|
{
|
CurrentProductionCode = cboPCodes.SelectedItem.ToString();
|
}
|
}
|
}
|