Fix: Button data binding
This commit is contained in:
1 parent
5e908e2768
commit
a294382c7d
2 files changed
+41
-2
No files matched your search
@@ -17,7 +17,16 @@ namespace Vocaluxe.UI.BasicElements.Text
|
|||||||
{
|
{
|
||||||
var instance = CUiElement.CreateInstance<CUiElementText>(properties, children);
|
var instance = CUiElement.CreateInstance<CUiElementText>(properties, children);
|
||||||
properties.TryGetValue("value", out string value);
|
properties.TryGetValue("value", out string value);
|
||||||
instance.Controller.Text = value;
|
|
||||||
|
if (properties.ContainsKey("bindingid"))
|
||||||
|
{
|
||||||
|
instance.Controller.Text = DummyClass.RegisterBinding<string>(properties["bindingid"], (sender, s) => instance.Controller.Text = s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instance.Controller.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Vocaluxe.UI.Screens;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Vocaluxe.UI.Screens;
|
||||||
|
|
||||||
namespace Vocaluxe.UI
|
namespace Vocaluxe.UI
|
||||||
{
|
{
|
||||||
@@ -6,5 +8,33 @@ namespace Vocaluxe.UI
|
|||||||
{
|
{
|
||||||
// Should be somewhere in Vocaluxe
|
// Should be somewhere in Vocaluxe
|
||||||
public static EUiScreenType CurrentScreen => EUiScreenType.ScreenMain;
|
public static EUiScreenType CurrentScreen => EUiScreenType.ScreenMain;
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, string> StringData = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{"btnsingdescription", "Sing"},
|
||||||
|
{"btnpartydescription", "Party"},
|
||||||
|
{"btnoptionsdescription", "Options"},
|
||||||
|
{"btnprofilesdescription", "Profiles"},
|
||||||
|
{"btnexitdescription", "Exit"},
|
||||||
|
|
||||||
|
};
|
||||||
|
private static readonly Dictionary<string, int> IntData = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
public static T RegisterBinding<T>(string bindingId, EventHandler<T> eventHandler)
|
||||||
|
{
|
||||||
|
// eventHandler is used to notify about changes -> not implemented yet
|
||||||
|
|
||||||
|
switch (typeof(T).ToString())
|
||||||
|
{
|
||||||
|
case "System.String":
|
||||||
|
StringData.TryGetValue(bindingId.ToLower(), out string stringResult);
|
||||||
|
return (T)Convert.ChangeType(stringResult, typeof(T));
|
||||||
|
case "System.Int32":
|
||||||
|
IntData.TryGetValue(bindingId.ToLower(), out int intResult);
|
||||||
|
return (T)Convert.ChangeType(intResult, typeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user