From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/Widgets/WidgetFactory.cs | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 V3/Widgets/WidgetFactory.cs (limited to 'V3/Widgets/WidgetFactory.cs') diff --git a/V3/Widgets/WidgetFactory.cs b/V3/Widgets/WidgetFactory.cs new file mode 100644 index 0000000..35e8e1b --- /dev/null +++ b/V3/Widgets/WidgetFactory.cs @@ -0,0 +1,78 @@ +namespace V3.Widgets +{ + /// + /// A widget factory. + /// + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class WidgetFactory + { + private IBasicWidgetFactory mFactory; + + public WidgetFactory(IBasicWidgetFactory factory) + { + mFactory = factory; + } + + /// + /// Creates a new button with the given text. + /// + /// the text of the button + /// the created button + public Button CreateButton(string text) + { + return CreateTextWidget(mFactory.CreateButton(), text); + } + + /// + /// Creates a new empty widget. + /// + /// the created widget + public EmptyWidget CreateEmptyWidget() + { + return mFactory.CreateEmptyWidget(); + } + + /// + /// Creates a new select button with the given text options. + /// + /// the values of the button + /// the created button + public SelectButton CreateSelectButton(string[] values) + { + var widget = CreateTextWidget(mFactory.CreateSelectButton(), ""); + foreach (var val in values) + widget.Values.Add(val); + return widget; + } + + /// + /// Creates a new select button without options. + /// + /// the created button + public SelectButton CreateSelectButton() + { + return mFactory.CreateSelectButton(); + } + + /// + /// Creates a new label with the given text. + /// + /// the text of the label + /// the created label + public Label CreateLabel(string text) + { + return CreateTextWidget(mFactory.CreateLabel(), text); + } + + private T CreateTextWidget(T widget, string text) where T : ITextWidget + { + widget.Text = text; + return widget; + } + + public AchievementBox CreateAchievementBox() + { + return mFactory.CreateAchievementBox(); + } + } +} -- cgit v1.2.1