107 lines
2.8 KiB
C#
107 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
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;
|
|
|
|
using C4IT.Logging;
|
|
|
|
using static C4IT.Logging.cLogManager;
|
|
|
|
namespace FasdDesktopUi.Basics.UserControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MultiButton.xaml
|
|
/// </summary>
|
|
public partial class MultiButton : UserControl
|
|
{
|
|
public int ResultIndex { get; private set; } = -1;
|
|
|
|
public event EventHandler<MultiButtonEventArgs> ResultChanged;
|
|
|
|
public MultiButton()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void DialogButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
DialogButton_Click(sender);
|
|
}
|
|
|
|
private void DialogButton_TouchDown(object sender, TouchEventArgs e)
|
|
{
|
|
DialogButton_Click(sender);
|
|
}
|
|
|
|
private void DialogButton_Click(object sender)
|
|
{
|
|
try
|
|
{
|
|
if (!(sender is FrameworkElement senderElement))
|
|
return;
|
|
|
|
if (!(senderElement.Tag is int resultIndex))
|
|
return;
|
|
|
|
ResultIndex = resultIndex;
|
|
ResultChanged(this, new MultiButtonEventArgs(resultIndex));
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
LogException(E);
|
|
}
|
|
}
|
|
|
|
public void SetButtonText(List<string> ButtonTextList)
|
|
{
|
|
ButtonPanel.Children.Clear();
|
|
if (ButtonTextList == null)
|
|
return;
|
|
|
|
var resultIndex = 0;
|
|
foreach (var buttonText in ButtonTextList)
|
|
{
|
|
var _gd = new Grid();
|
|
ButtonPanel.Children.Add(_gd);
|
|
|
|
var _cd = new ColumnDefinition();
|
|
_cd.SharedSizeGroup = "ButtonStack";
|
|
_gd.ColumnDefinitions.Add(_cd);
|
|
|
|
var _bd = new Border();
|
|
_bd.Tag = resultIndex;
|
|
_gd.Children.Add(_bd);
|
|
|
|
var _tb = new TextBlock();
|
|
_tb.Text = buttonText;
|
|
_bd.Child = _tb;
|
|
|
|
resultIndex++;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class MultiButtonEventArgs : RoutedEventArgs
|
|
{
|
|
public int ResultIndex { get; private set; } = -1;
|
|
|
|
public MultiButtonEventArgs(int resultIndex)
|
|
{
|
|
ResultIndex = resultIndex;
|
|
}
|
|
|
|
}
|
|
|
|
}
|