|
@@ -30,8 +30,6 @@ namespace PRS.Mobile
|
|
|
Initialize(value ?? new DFLayoutSignaturePad());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private Guid _id;
|
|
|
|
|
|
private byte[] _value;
|
|
|
public byte[] Value
|
|
@@ -59,20 +57,20 @@ namespace PRS.Mobile
|
|
|
|
|
|
public void Deserialize(string serialized)
|
|
|
{
|
|
|
- if (String.IsNullOrWhiteSpace(serialized))
|
|
|
- return;
|
|
|
- if (Guid.TryParse(serialized, out _id) && (_id != Guid.Empty))
|
|
|
- DigitalFormDocumentFactory.LoadDocument(_id,
|
|
|
- v => Device.BeginInvokeOnMainThread(() => Value = v));
|
|
|
- else if (serialized.IsBase64String())
|
|
|
+ if (!String.IsNullOrWhiteSpace(serialized) && serialized.IsBase64String())
|
|
|
Value = Convert.FromBase64String(serialized);
|
|
|
+ else
|
|
|
+ Value = null;
|
|
|
}
|
|
|
|
|
|
public string Serialize()
|
|
|
{
|
|
|
- if ((_id == Guid.Empty) && Value?.Any() == true)
|
|
|
- _id = DigitalFormDocumentFactory.SaveDocument(Value);
|
|
|
- return _id.ToString();
|
|
|
+ if (_value == null)
|
|
|
+ {
|
|
|
+ _pad.Save();
|
|
|
+ _value = GetSignature(_pad.ImageSource);
|
|
|
+ }
|
|
|
+ return Convert.ToBase64String(_value ?? new byte[] { });
|
|
|
}
|
|
|
|
|
|
public event DigitalFormViewChangedHandler ValueChanged;
|
|
@@ -194,7 +192,7 @@ namespace PRS.Mobile
|
|
|
_apply.IsEnabled = enabled && (App.Data.Me.Signature?.Any() == true);
|
|
|
_clear.IsEnabled = enabled && (Value?.Any() == true);
|
|
|
|
|
|
- var colors = DigitalFormUtils.GetColors(!enabled, Definition.Properties.Required, false);
|
|
|
+ var colors = DigitalFormUtils.GetColors(!enabled || _value?.Any() == true, Definition.Properties.Required, false);
|
|
|
BackgroundColor = colors.Background;
|
|
|
BorderColor = colors.Border;
|
|
|
}
|