namespace FeedbackGeneratorQQ.Utils
{
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
public static class ElementsGenerator
{
/// <summary>
/// Creates a container for an attribute
/// </summary>
/// <returns> Return a StackPanel container for an attribute </returns>
public static StackPanel CreateDefaultAttributeContainer()
{
return new StackPanel
{
Orientation = Orientation.Vertical,
Width = 150
};
}
/// <summary>
/// Creates an attribute checkbox by the given attribute name
/// </summary>
/// <param name="name"> The attribute name </param>
/// <returns> Returns attribute checkbox </returns>
public static CheckBox CreateDefaultAttributeCheckbox(string name)
{
return new CheckBox
{
Content = name.Length < 20 ? name : string.Concat(name.Substring(0, 20), "..."),
ToolTip = name,
Padding = new Thickness(4, -1, 0, 0),
Margin = new Thickness(4),
};
}
/// <summary>
/// Creates an attribute type combobox with the given list of options
/// </summary>
/// <param name="attributeTypes"> Options to select </param>
/// <returns> Returns attribute type combobox </returns>
public static ComboBox CreateDefaultAttributeCombobox(List<string> attributeTypes)
{
ComboBox combobox = new ComboBox
{
Width = 100,
HorizontalAlignment = HorizontalAlignment.Center,
DisplayMemberPath = "Key",
SelectedValuePath = "Value",
};
attributeTypes.ForEach(type => combobox.Items.Add(new KeyValuePair<string, string>(type, type)));
return combobox;
}
}
}