2 * Copyright(c) 2022 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;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Components;
23 namespace Tizen.NUI.StyleGuide
25 // IExample inehrited class will be automatically added in the main examples list.
26 internal class SwitchExample : ContentPage, IExample
28 private View rootContent;
29 private Switch[] switchTest = new Switch[4];
32 public void Activate()
35 public void Deactivate()
39 /// Modify this method for adding other examples.
40 public SwitchExample() : base()
42 Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n");
44 WidthSpecification = LayoutParamPolicies.MatchParent;
45 HeightSpecification = LayoutParamPolicies.MatchParent;
46 // Navigator bar title is added here.
49 Title = "Switch Default Style",
52 // Example root content view.
53 // you can decorate, add children on this view.
54 rootContent = new View()
56 WidthSpecification = LayoutParamPolicies.MatchParent,
57 HeightSpecification = LayoutParamPolicies.MatchParent,
59 Layout = new LinearLayout()
61 LinearOrientation = LinearLayout.Orientation.Vertical,
62 HorizontalAlignment = HorizontalAlignment.Center,
63 VerticalAlignment = VerticalAlignment.Center,
64 CellPadding = new Size2D(10, 20),
68 path = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
72 Content = rootContent;
75 private void CreateSwitchView()
77 // Create switch styles
78 SwitchStyle styleTest = new SwitchStyle
80 Size = new Size(100, 100),
82 Track = new ImageViewStyle
84 ResourceUrl = new Selector<string>
86 Normal = path + "/switch/controller_switch_bg_off.png",
87 Selected = path + "/switch/controller_switch_bg_on.png",
88 Disabled = path + "/switch/controller_switch_bg_off_dim.png",
89 DisabledSelected = path + "/switch/controller_switch_bg_on_dim.png",
91 Size = new Size(200, 100),
92 Border = new Rectangle(30, 30, 30, 30),
94 Thumb = new ImageViewStyle
96 Size = new Size(100, 100),
97 ResourceUrl = new Selector<string>
99 Normal = path + "/switch/controller_switch_handler.png",
100 Selected = path + "/switch/controller_switch_handler.png",
101 Disabled = path + "/switch/controller_switch_handler_dim.png",
102 DisabledSelected = path + "/switch/controller_switch_handler_dim.png",
107 // Create by Property
108 for (int i = 0; i < 4; i++)
110 switchTest[i] = new Switch();
111 switchTest[i].ApplyStyle(styleTest);
112 switchTest[i].Size = new Size(200, 100);
113 switchTest[i].Margin = new Extents(10, 10, 10, 10);
114 switchTest[i].Feedback = true;
115 rootContent.Add(switchTest[i]);
117 switchTest[2].IsEnabled = false;
118 switchTest[3].IsSelected = true;