2 * Copyright (c) 2017 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 /*
11 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
17 * http://www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
36 private View _colorView;
37 private View _textView;
39 private bool _textAnimationComplete;
41 private Dali.Application _currentApplication;
43 private AnimationTest(Dali.Application application)
45 _currentApplication = application;
46 _textAnimationComplete = false;
47 _currentApplication.Initialized += Initialize;
50 private void Initialize(object source, NUIApplicationInitEventArgs e)
56 private void AnimationFinished(object sender, EventArgs e)
58 Console.WriteLine("Visual AnimationFinished");
60 Property.Map colorVisual = new Property.Map();
61 colorVisual.Add( Visual.Property.Type, new Property.Value( (int)Visual.Type.Color ))
62 .Add( ColorVisualProperty.MixColor, new Property.Value( Color.Blue ));
63 _colorView.Background = colorVisual;
66 private void TextAnimationFinished(object sender, EventArgs e)
68 Console.WriteLine("Text AnimationFinished");
69 _textAnimationComplete = true;
73 * Test animates a text visual automatically and logs result to console once animation finished signal emitted.
75 * Manually pressing the button starts animating a visual and changes it color at end of animation.
77 * Tests Animation signal logic.
80 private void AnimationTest01()
82 Console.WriteLine("AnimationTest");
84 _textAnimationComplete = false;
86 Window window = Window.Instance;
87 window.BackgroundColor = Color.White;
88 Size2D windowSize = window.Size;
90 // Create Color Visual
91 _colorView = new View();
92 _colorView.Size = new Vector3(120.0f, 120.0f, 0.0f);
93 _colorView.WidthResizePolicy = "FIXED";
94 _colorView.HeightResizePolicy = "FIXED";
95 Property.Map colorVisual = new Property.Map();
96 colorVisual.Add( Visual.Property.Type, new Property.Value( (int)Visual.Type.Color ))
97 .Add( ColorVisualProperty.MixColor, new Property.Value( Color.Green ));
98 _colorView.Background = colorVisual;
100 Window.Instance.Add(_colorView);
102 Animation _animation = new Animation(1000); // 1000 milli-second of duration
103 _animation.StartTime = 500;
104 _animation.EndTime = 1000;
105 _animation.TargetProperty = "Position";
106 _animation.Destination = new Vector3(150.0f, 150.0f, 0.0f);
107 _animation.AnimateTo(_colorView);
108 _animation.Finished += AnimationFinished;
110 PushButton buttonWithSimpleTooltip = new PushButton();
111 buttonWithSimpleTooltip.LabelText = "Press to Animate";
112 buttonWithSimpleTooltip.UnselectedColor = new Vector4(0.6f, 0.92f, 1.0f, 1.0f);
113 buttonWithSimpleTooltip.SelectedColor = new Vector4(0.6f, 0.7f, 1.0f, 1.0f);
114 buttonWithSimpleTooltip.WidthResizePolicy = "USE_NATURAL_SIZE";
115 buttonWithSimpleTooltip.Position = new Position(windowSize.Width /2 , 0, 0);
117 Window.Instance.Add(buttonWithSimpleTooltip);
118 buttonWithSimpleTooltip.SetFocusable(true);
119 buttonWithSimpleTooltip.TooltipText = "RePosition Square and change color to Blue";
120 buttonWithSimpleTooltip.Clicked += (obj, ee) =>
126 _textView = new View();
127 _textView.WidthResizePolicy = "USE_NATURAL_SIZE";
128 Property.Map textVisual = new Property.Map();
129 textVisual.Add(Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Text))
130 .Add(Dali.Constants.TextVisualProperty.Text, new Property.Value("Moved Text"))
131 .Add(Dali.Constants.TextVisualProperty.PointSize, new Property.Value(24));
133 _textView.Background = textVisual;
134 _textView.Position = new Position(0, 200, 0);
135 Window.Instance.Add(_textView);
137 Animation textAnimation = new Animation(3000); // 3000 milli-second of duration
139 textAnimation.TargetProperty = "Position";
140 textAnimation.Destination = new Vector3(windowSize.Width/2, 200.0f, 0.0f);
141 textAnimation.AnimateTo(_textView);
142 textAnimation.Finished += TextAnimationFinished;
144 textAnimation.Play();
147 private void StartTimer(int duration)
149 System.Timers.Timer timer = new System.Timers.Timer(duration);
150 timer.Elapsed += OnTimerElasped;
151 timer.AutoReset = false;
155 private void OnTimerElasped(System.Object source, ElapsedEventArgs e)
157 if (_textAnimationComplete == true)
159 Console.WriteLine("PASSED.");
163 Console.WriteLine("FAILED");
167 static void Main(string[] args)
169 Application application = Application.NewApplication();
170 AnimationTest test = new AnimationTest(application);
171 application.MainLoop();