synth create - increase error flash duration

This commit is contained in:
John Colvin committed 2018-03-07 23:40:28 -05:00
1 parent 55fc66512b
commit 4f94f4d6cf
3 files changed
+19 -11

No files matched your search

@@ -58,15 +58,15 @@ namespace mbts.spark {
commit = new DelegateCommand(async () => {
bool valid = true;
if (string.IsNullOrWhiteSpace(name)) {
flash_error_msg("Please enter a name", nameof(name)).ignore();
flash_error_msg("Please enter a name", SparkUtils.UI.MessageFlashDuration, nameof(name)).ignore();
valid = false;
}
else if (!await model.verify_name_is_unique(name)) {
flash_error_msg("Name already taken", nameof(name)).ignore();
flash_error_msg("Name already taken", SparkUtils.UI.MessageFlashDuration, nameof(name)).ignore();
valid = false;
}
if (_tick_factors == null || !_tick_factors.is_valid()) {
flash_error_msg("Invalid ticks", nameof(tick_factors)).ignore();
flash_error_msg("Invalid ticks", SparkUtils.UI.MessageFlashDuration, nameof(tick_factors)).ignore();
valid = false;
}
if (valid) {
@@ -205,14 +205,17 @@ namespace mbts.ui.shell
}
}
protected async Task flash_error_msg(string msg, params string[] properties) {
protected async Task flash_error_msg(string msg, TimeSpan duration, params string[] properties) {
foreach (var prop in properties)
set_error(prop, msg);
await Task.Delay(1000);
await Task.Delay(duration);
foreach (var prop in properties)
clear_error(prop);
}
protected async Task flash_error_msg(string msg, params string[] properties) =>
await flash_error_msg(msg, mbts.spark.SparkUtils.UI.ErrorFlashDuration, properties);
protected async Task flash_error(params string[] properties) =>
await flash_error_msg(string.Empty, properties);
+11 -6
View File
@@ -8,12 +8,11 @@ using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
namespace mbts.spark
{
static class SparkUtils
{
public static readonly TimeSpan DefaultTimeOut = TimeSpan.FromSeconds(3);
public static readonly TimeSpan DefaultPollInterval = TimeSpan.FromSeconds(0.1);
namespace mbts.spark {
static class SparkUtils {
public static readonly TimeSpan
DefaultPollInterval = TimeSpan.FromSeconds(0.1),
DefaultTimeOut = TimeSpan.FromSeconds(3);
#region Serialization
public static T deserialize_proto<T>(byte[] proto_bytes) =>
@@ -96,5 +95,11 @@ namespace mbts.spark
return (filtered_added.Except(filtered_changed, comparer), filtered_removed.Except(filtered_changed, comparer), filtered_changed);
}
#endregion
public static class UI {
public static readonly TimeSpan
ErrorFlashDuration = TimeSpan.FromSeconds(3),
MessageFlashDuration = TimeSpan.FromSeconds(2);
}
}
}