2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.Collections.Generic;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.Components
25 /// LoadingStyle is a class which saves Loading's ux data.
27 /// <since_tizen> 8 </since_tizen>
28 public class LoadingStyle : ControlStyle
30 /// <summary>The FrameRateSelector bindable property.</summary>
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public static readonly BindableProperty FrameRateSelectorProperty = BindableProperty.Create("FrameRateSelector", typeof(Selector<int?>), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
34 ((LoadingStyle)bindable).frameRate = ((Selector<int?>)newValue)?.Clone();
36 defaultValueCreator: (bindable) =>
38 return ((LoadingStyle)bindable).frameRate;
41 /// <summary>The LoadingSize bindable property.</summary>
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public static readonly BindableProperty LoadingSizeProperty = BindableProperty.Create(nameof(LoadingSize), typeof(Size), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
45 ((LoadingStyle)bindable).Size = (Size)newValue;
47 defaultValueCreator: (bindable) =>
49 return ((LoadingStyle)bindable).Size;
52 /// <summary>The Images bindable property.</summary>
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public static readonly BindableProperty ImagesProperty = BindableProperty.Create(nameof(Images), typeof(string[]), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
56 ((LoadingStyle)bindable).images = new List<string>((string[])newValue);
58 defaultValueCreator: (bindable) =>
60 if (((LoadingStyle)bindable).images == null)
62 ((LoadingStyle)bindable).images = new List<string>();
64 return ((LoadingStyle)bindable).images?.ToArray();
67 /// <summary>The Images bindable property.</summary>
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public static readonly BindableProperty ImageListProperty = BindableProperty.Create(nameof(ImageList), typeof(IList<string>), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
71 ((LoadingStyle)bindable).images = newValue as List<string>;
73 defaultValueCreator: (bindable) =>
75 if(((LoadingStyle)bindable).images == null)
77 ((LoadingStyle)bindable).images = new List<string>();
79 return ((LoadingStyle)bindable).images;
82 private Selector<int?> frameRate;
83 private List<string> images;
85 static LoadingStyle() { }
88 /// Creates a new instance of a LoadingStyle.
90 /// <since_tizen> 8 </since_tizen>
91 public LoadingStyle() : base() { }
94 /// Creates a new instance of a LoadingStyle with style.
96 /// <param name="style">Create LoadingStyle by style customized by user.</param>
97 /// <since_tizen> 8 </since_tizen>
98 public LoadingStyle(LoadingStyle style) : base(style)
103 /// Gets or sets loading image resources.
105 /// <since_tizen> 8 </since_tizen>
106 public string[] Images
108 get => (string[])GetValue(ImagesProperty);
109 set => SetValue(ImagesProperty, value);
113 /// Gets loading image resources.
115 [EditorBrowsable(EditorBrowsableState.Never)]
116 public IList<string> ImageList
118 get => GetValue(ImageListProperty) as List<string>;
119 internal set => SetValue(ImageListProperty, value);
123 /// Gets or sets loading image size.
125 /// <since_tizen> 8 </since_tizen>
126 public Size LoadingSize
128 get => (Size)GetValue(LoadingSizeProperty);
129 set => SetValue(LoadingSizeProperty, value);
133 /// Gets or sets loading frame per second.
135 /// <since_tizen> 8 </since_tizen>
136 public Selector<int?> FrameRate
138 get => (Selector<int?>)GetValue(FrameRateSelectorProperty);
139 set => SetValue(FrameRateSelectorProperty, value);
143 /// Style's clone function.
145 /// <param name="bindableObject">The style that need to copy.</param>
146 /// <since_tizen> 8 </since_tizen>
147 public override void CopyFrom(BindableObject bindableObject)
149 base.CopyFrom(bindableObject);