96 lines
2.4 KiB
C#
96 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Threading;
|
|
|
|
namespace ProductionUiCordonelLegacy.UserControls.FinalTest
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for UcDialog.xaml
|
|
/// </summary>
|
|
public partial class UcDialog : UserControl
|
|
{
|
|
public UcDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public class DialogOption
|
|
{
|
|
public DialogOption(String headLine, String desc, Action selectedAction)
|
|
{
|
|
HeadLine = headLine;
|
|
Desc = desc;
|
|
SelectedAction = selectedAction;
|
|
}
|
|
private Action SelectedAction;
|
|
private String HeadLine = "Hl";
|
|
private String Desc = "descr";
|
|
public UIElement GeneratBtn()
|
|
{
|
|
var btn = new Button();
|
|
btn.Content = HeadLine;
|
|
btn.Click += (sender, args) => { SelectedAction.Invoke(); };
|
|
|
|
return btn;
|
|
|
|
}
|
|
|
|
public UIElement GeneratInfo()
|
|
{
|
|
var lbl = new Label();
|
|
lbl.Content = Desc;
|
|
lbl.Width = 800;
|
|
return lbl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
internal void SetDesc(String v)
|
|
{
|
|
lblDescription.Dispatcher.Invoke(DispatcherPriority.Send,
|
|
new Action(() =>
|
|
{
|
|
|
|
lblDescription.Content = v;
|
|
|
|
}
|
|
));
|
|
}
|
|
|
|
public void SetDialogOptions(List<DialogOption> optList)
|
|
{
|
|
|
|
PanelSelection.Dispatcher.Invoke(DispatcherPriority.Send,
|
|
new Action(() =>
|
|
{
|
|
|
|
PanelSelection.Children.Clear();
|
|
}
|
|
));
|
|
|
|
foreach (var opt in optList)
|
|
{
|
|
|
|
|
|
|
|
Dispatcher.Invoke(DispatcherPriority.Send,
|
|
new Action(() =>
|
|
{
|
|
var stackPnl = new StackPanel();
|
|
stackPnl.Orientation = Orientation.Horizontal;
|
|
stackPnl.Children.Add(opt.GeneratBtn());
|
|
stackPnl.Children.Add(opt.GeneratInfo());
|
|
PanelSelection.Children.Add(stackPnl);
|
|
}
|
|
));
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|