/* * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Text; namespace Tizen.Applications.WatchfaceComplication { /// /// Represents the RangedValueData class for the RangedValue type complication. /// /// 6 public class RangedValueData : ComplicationData { /// /// Initializes the RangedValueData class. /// /// The current value. /// The minimum value. /// The max value. /// The short text. /// The icon path. /// The title. /// The extra data. /// Thrown when parameter is invalid. /// /// /// protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData) /// { /// if (type == ComplicationTypes.RangedValue) /// { /// return new RangedValueData(50, 0, 100, "short", "icon path", "title", "extra"); /// } /// else if (type == ComplicationTypes.LongText) /// { /// return new LongTextData("longlong", "icon path", "title", null); /// } /// } /// /// /// 6 public RangedValueData(double currentValue, double minValue, double maxValue, string shortText, string iconPath, string title, string extraData) { if (minValue > maxValue || currentValue < minValue || currentValue > maxValue) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "Invalid value range min(" + minValue + "), cur(" + currentValue + "), max(" + maxValue + ")"); Type = ComplicationTypes.RangedValue; base.RangeMin = minValue; base.RangeMax = maxValue; base.RangeCurrent = currentValue; ShortText = shortText; IconPath = iconPath; Title = title; ExtraData = extraData; } /// /// The information about the current range value of complication data. /// /// Thrown when try to set invalid value. /// 6 public new double RangeCurrent { get { return base.RangeCurrent; } set { if (value > base.RangeMax) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid min(" + value + "), current value can not bigger than max(" + base.RangeMax + ")"); if (value < base.RangeMin) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid min(" + value + "), min value can not smaller than min(" + base.RangeMin + ")"); base.RangeCurrent = value; } } /// /// The information about the min range value of complication data. /// /// Thrown when try to set invalid value. /// 6 public new double RangeMin { get { return base.RangeMin; } set { if (value > base.RangeCurrent) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid min(" + value + "), min value can not bigger than current(" + base.RangeCurrent + ")"); base.RangeMin = value; } } /// /// The information about the max range value of complication data. /// /// Thrown when try to set invalid value. /// 6 public new double RangeMax { get { return base.RangeMax; } set { if (value < base.RangeCurrent) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "invalid min(" + value + "), min value can not smaller than current(" + base.RangeCurrent + ")"); base.RangeMax = value; } } /// /// The short text data. /// /// Thrown when try to set invalid value. /// 6 public new string ShortText { get { return base.ShortText; } set { if (value == null) ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text"); base.ShortText = value; } } /// /// The icon path data. /// /// 6 public new string IconPath { get { return base.IconPath; } set { base.IconPath = value; } } /// /// The title data. /// /// 6 public new string Title { get { return base.Title; } set { base.Title = value; } } /// /// The extra data. /// /// 6 public new string ExtraData { get { return base.ExtraData; } set { base.ExtraData = value; } } /// /// The information about the screen reader text of complication data. /// /// 6 public new string ScreenReaderText { get { return base.ScreenReaderText; } set { base.ScreenReaderText = value; } } } }