Fix the Styling issue with Custom View.
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / examples / control-dashboard.cs
index ff1e87e..3ec656e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,14 +40,16 @@ namespace MyCSharpExample
 
     private Dali.Application _application;
     private TableView _contentContainer;
+    private Timer _timer;
     private Stage _stage;
     private Popup _popup;
+    private ProgressBar _progressBar;
 
     // List of items
     private Item[] mViewList = {
       new Item("PushButton", true),  new Item("DropDown", false),    new Item("Toggle", true),
       new Item("InputField", false),  new Item("AnimateGif", false),  new Item("Loading", false),
-      new Item("ProgressBar", false), new Item("CheckBox", false),    new Item("RadioButton", true),
+      new Item("ProgressBar", true), new Item("CheckBox", false),    new Item("RadioButton", true),
       new Item("Tooltip", true),     new Item("Popup", true),       new Item("Toast", true),
       new Item("ItemView", false),    new Item("CheckBox", true)
     };
@@ -191,7 +193,33 @@ namespace MyCSharpExample
         }
         if (item.name.CompareTo("ProgressBar") == 0)
         {
+          _progressBar = new ProgressBar();
+          _progressBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
+          _progressBar.SetResizePolicy(ResizePolicyType.FIXED, DimensionType.HEIGHT);
+          _progressBar.SetSize( 0, 50 );
 
+          _progressBar.ValueChanged += OnProgressBarValueChanged;
+
+          _timer = new Timer( 100 );
+          _timer.Tick += ( obj, e ) =>
+          {
+            float progress = (float)Math.Round( _progressBar.ProgressValue , 2 );
+
+            if( progress == 1.0f )
+            {
+              _progressBar.ProgressValue = 0.0f;
+              _progressBar.SecondaryProgressValue = 0.01f;
+            }
+            else
+            {
+              _progressBar.ProgressValue = progress + 0.01f;
+              _progressBar.SecondaryProgressValue = progress + 0.21f;
+            }
+            return true;
+          };
+          _timer.Start();
+
+          _contentContainer.AddChild(_progressBar, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
         }
         if (item.name.CompareTo("ScrollBar") == 0)
         {
@@ -283,7 +311,7 @@ namespace MyCSharpExample
           text.MultiLine = true;
           text.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH);
           text.SetResizePolicy(ResizePolicyType.DIMENSION_DEPENDENCY, DimensionType.HEIGHT);
-          text.SetPadding(new RectFloat(10.0f, 10.0f, 20.0f, 0.0f));
+          text.SetPadding(new PaddingType(10.0f, 10.0f, 20.0f, 0.0f));
           _popup.SetContent(text);
           _popup.SetKeyboardFocusable(true);
           _popup.SetDisplayState(Popup.DisplayStateType.HIDDEN);
@@ -414,6 +442,15 @@ namespace MyCSharpExample
       return cancelButton;
     }
 
+    void OnProgressBarValueChanged( object source, ProgressBar.ValueChangedEventArgs e )
+    {
+      Property.Map labelVisual = new Property.Map();
+      labelVisual.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Text) )
+        .Add( Dali.Constants.TextVisualProperty.Text, new Property.Value( Math.Round( e.ProgressBar.ProgressValue, 2 ) +" / "+Math.Round( e.ProgressBar.SecondaryProgressValue, 2 )) );
+      e.ProgressBar.LabelVisual = labelVisual;
+      return;
+    }
+
     public void MainLoop()
     {
       _application.MainLoop();