File size: 1,880 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Globalization;
using System.Management.Automation;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace Microsoft.PowerShell.Commands.ShowCommandInternal
{
    /// <summary>
    /// Interaction logic for MultipleSelectionControl.xaml.
    /// </summary>
    public partial class MultipleSelectionControl : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the MultipleSelectionControl class.
        /// </summary>
        public MultipleSelectionControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Show more items in new dialog.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void ButtonBrowse_Click(object sender, RoutedEventArgs e)
        {
            MultipleSelectionDialog multipleSelectionDialog = new MultipleSelectionDialog();
            multipleSelectionDialog.Title = this.multipleValueButton.ToolTip.ToString();
            multipleSelectionDialog.listboxParameter.ItemsSource = comboxParameter.ItemsSource;
            multipleSelectionDialog.ShowDialog();

            if (multipleSelectionDialog.DialogResult != true)
            {
                return;
            }

            StringBuilder newComboText = new StringBuilder();

            foreach (object selectedItem in multipleSelectionDialog.listboxParameter.SelectedItems)
            {
                newComboText.Append(CultureInfo.InvariantCulture, $"{selectedItem},");
            }

            if (newComboText.Length > 1)
            {
                newComboText.Remove(newComboText.Length - 1, 1);
            }

            comboxParameter.Text = newComboText.ToString();
        }
    }
}