2 * Copyright(c) 2019 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.
18 using System.ComponentModel;
24 /// The Shadow composed of image for View
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class ImageShadow : ShadowBase, Tizen.NUI.Internal.ICloneable
29 private static readonly Rectangle noBorder = new Rectangle();
33 private Rectangle border;
38 [EditorBrowsable(EditorBrowsableState.Never)]
39 public ImageShadow() : base()
41 propertyMap[Visual.Property.Type] = new PropertyValue((int)Visual.Type.NPatch);
44 internal ImageShadow(ImageShadow other, PropertyChangedCallback callback = null) : base(other)
46 propertyMap[Visual.Property.Type] = new PropertyValue((int)Visual.Type.NPatch);
49 Border = other.Border;
50 OnPropertyChanged = callback;
54 /// The string conversion
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 public static implicit operator ImageShadow(string value)
59 ImageShadow imageShadow = new ImageShadow()
69 [EditorBrowsable(EditorBrowsableState.Never)]
72 return new ImageShadow() {
81 /// Deep copy method (static)
82 /// This provides nullity check.
84 [EditorBrowsable(EditorBrowsableState.Never)]
85 static public object Clone(ImageShadow instance)
87 return instance == null ? null : new ImageShadow() {
88 Offset = instance.offset,
89 Extents = instance.extents,
91 Border = instance.border
95 private void OnBorderChanged(int x, int y, int width, int height)
100 private void UpdateUrl()
102 propertyMap[ImageVisualProperty.URL] = PropertyValue.CreateWithGuard(url);
103 OnPropertyChanged?.Invoke(this);
106 private void UpdateBorder()
108 propertyMap[ImageVisualProperty.Border] = PropertyValue.CreateWithGuard(border);
109 OnPropertyChanged?.Invoke(this);
113 /// The url for the shadow image to load.
115 [EditorBrowsable(EditorBrowsableState.Never)]
131 /// The border area of the n-patch image.
132 /// Set left, right, bottom, top length of the border you don't want to stretch in the image.
134 [EditorBrowsable(EditorBrowsableState.Never)]
135 public Rectangle Border
143 border = new Rectangle(OnBorderChanged, value ?? noBorder);
148 override internal bool IsValid()
150 return !string.IsNullOrEmpty(url);