// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
// Note that this code is NOT compiled for WinRT.
// WinRT uses a different binding system since it doesn't support implicit type converters.
#if !WINRT
///
/// A binding value for doubles.
///
public sealed class BindableProgressBarValue
{
///
/// Raw value is used for the implicit converter case, where dev provided a raw double. We store the raw value,
/// so that later on when generating the XML, we can provide this value rather than binding syntax.
///
internal AdaptiveProgressBarValue RawValue { get; private set; }
internal bool RawIsIndeterminate { get; private set; }
///
/// The name that maps to your binding data value.
///
public string BindingName { get; set; }
///
/// Initializes a new binding for a double value, with the required binding value name. Do NOT include surrounding {} brackets.
///
/// The name that maps to your binding data value.
public BindableProgressBarValue(string bindingName)
{
BindingName = bindingName;
}
///
/// Private constructor used by the implicit converter to assign the raw value.
///
private BindableProgressBarValue()
{
}
internal string ToXmlString()
{
if (BindingName != null)
{
return "{" + BindingName + "}";
}
if (RawValue != null)
{
return RawValue.ToXmlString();
}
return null;
}
///
/// Creates a that has a raw value assigned.
///
/// The raw value
public static implicit operator BindableProgressBarValue(AdaptiveProgressBarValue v)
{
return new BindableProgressBarValue()
{
RawValue = v
};
}
///
/// Returns the raw value of the .
///
/// The to obtain the raw value from.
public static implicit operator AdaptiveProgressBarValue(BindableProgressBarValue b)
{
return b.RawValue;
}
///
/// Creates an that has tbe raw double value.
///
/// The raw value
public static implicit operator BindableProgressBarValue(double d)
{
return AdaptiveProgressBarValue.FromValue(d);
}
}
#endif
}