init
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using DTS.Common.Interface.Channels.ChannelCodes;
|
||||
|
||||
namespace DTS.Common.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LookupPopup.xaml
|
||||
/// </summary>
|
||||
public partial class LookupPopup : Popup
|
||||
{
|
||||
public IEnumerable<IChannelCode> AllChannelCodes { get; private set; }
|
||||
|
||||
public LookupPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public delegate void ChannelCodeSelectedEventHandler(object sender, string code, string name);
|
||||
|
||||
public event ChannelCodeSelectedEventHandler ChannelCodeSelected;
|
||||
private void LookupPopup_OnOpenedClosed(object sender, EventArgs e)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("PossibleChannels"));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PossibleChannelsProperty =
|
||||
DependencyProperty.Register(
|
||||
"PossibleChannels",
|
||||
typeof(IList),
|
||||
typeof(LookupPopup),
|
||||
new PropertyMetadata(Enumerable.Repeat(new { Code = "", Name = "" }, 0).ToList())
|
||||
);
|
||||
|
||||
public IList PossibleChannels
|
||||
{
|
||||
get => (IList)GetValue(PossibleChannelsProperty);
|
||||
set => SetValue(PossibleChannelsProperty, value);
|
||||
}
|
||||
|
||||
private void PossibleChannels_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender == null) return;
|
||||
if (((DataGrid)sender).SelectedIndex < 0) return;
|
||||
|
||||
var item = PossibleChannels[((DataGrid)sender).SelectedIndex];
|
||||
e.Handled = false;
|
||||
ChannelCodeSelected?.Invoke(this, item.GetType().GetProperty("Code")?.GetValue(item, null).ToString(), item.GetType().GetProperty("Name")?.GetValue(item, null).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user