X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-swig%2Fexamples%2Fimage-view.cs;h=6ece63b7fe6c3e45472f65168e0c7a10f78365f7;hp=7cd5359b9b65698c39523058ee619a5fdbade615;hb=c2c6ef4249c29f78bf92762137ec7b4eb7087ca6;hpb=c57e053b5795783ad92b0fd7f8fbaba6b6d9322a diff --git a/plugins/dali-swig/examples/image-view.cs b/plugins/dali-swig/examples/image-view.cs index 7cd5359..6ece63b 100755 --- a/plugins/dali-swig/examples/image-view.cs +++ b/plugins/dali-swig/examples/image-view.cs @@ -1,5 +1,4 @@ -/* -* 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. @@ -23,217 +22,218 @@ using Dali.Constants; namespace ImageViewExample { - class Example - { - public static void Log(string str) + class Example { - Console.WriteLine("[DALI C# SAMPLE] " + str); - } + public static void Log(string str) + { + Console.WriteLine("[DALI C# SAMPLE] " + str); + } - private Dali.Application _application; - private Animation _animation; - private ImageView _imageView; - private bool _isAniFinised = true; - private Layer layer, _layer1, _layer2; - private PushButton _pushButton1, _pushButton2; - private Stage stage; + private Dali.Application _application; + private Animation _animation; + private ImageView _imageView; + private bool _isAniFinised = true; + private Layer layer, _layer1, _layer2; + private PushButton _pushButton1, _pushButton2; + private Stage stage; - public Example(Dali.Application application) - { - _application = application; - _application.Initialized += Initialize; - } - - public void Initialize(object source, NUIApplicationInitEventArgs e) - { - Log("Customized Application Initialize event handler"); - stage = Stage.Instance; - stage.BackgroundColor = Color.Cyan; - stage.Touch += OnStageTouched; - stage.Wheel += OnStageWheelMoved; - stage.Key += OnStageKeyPressed; - //stage.EventProcessingFinished += OnStageEventProcessingFinished; - - layer = stage.GetDefaultLayer(); - _layer1 = new Layer(); - _layer2 = new Layer(); - stage.AddLayer(_layer1); - stage.AddLayer(_layer2); - Log("_layer1.Behavior =" + _layer1.Behavior ); - if( _layer1.Behavior == Layer.LayerBehavior.LAYER_UI ) - { - _layer1.Behavior = Layer.LayerBehavior.LAYER_2D; - Log("again _layer1.Behavior =" + _layer1.Behavior ); - } - // Add a ImageView to the stage - _imageView = new ImageView(); - _imageView.ResourceUrl = "./images/gallery-3.jpg"; - _imageView.ParentOrigin = ParentOrigin.Center; - _imageView.AnchorPoint = AnchorPoint.Center; - _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); - //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); - layer.Add(_imageView); - - _pushButton1 = new PushButton(); - _pushButton1.ParentOrigin = ParentOrigin.BottomLeft; - _pushButton1.AnchorPoint = AnchorPoint.BottomLeft; - _pushButton1.LabelText = "start animation"; - _pushButton1.Position = new Vector3(0.0f, stage.Size.Height * 0.1f, 0.0f); - _pushButton1.Clicked += OnPushButtonClicked1; - _layer1.Add(_pushButton1); - - _pushButton2 = new PushButton(); - _pushButton2.ParentOrigin = ParentOrigin.BottomLeft; - _pushButton2.AnchorPoint = AnchorPoint.BottomLeft; - _pushButton2.LabelText = "reload image with same URL"; - _pushButton2.Position = new Vector3(0.0f, stage.Size.Height * 0.2f, 0.0f); - _pushButton2.Clicked += OnPushButtonClicked2; - _layer2.Add(_pushButton2); + public Example(Dali.Application application) + { + _application = application; + _application.Initialized += Initialize; + } - } + public void Initialize(object source, NUIApplicationInitEventArgs e) + { + Log("Customized Application Initialize event handler"); + stage = Stage.Instance; + stage.BackgroundColor = Color.Cyan; + stage.Touch += OnStageTouched; + stage.Wheel += OnStageWheelMoved; + stage.Key += OnStageKeyPressed; + //stage.EventProcessingFinished += OnStageEventProcessingFinished; + + layer = stage.GetDefaultLayer(); + _layer1 = new Layer(); + _layer2 = new Layer(); + stage.AddLayer(_layer1); + stage.AddLayer(_layer2); + Log("_layer1.Behavior =" + _layer1.Behavior); + if (_layer1.Behavior == Layer.LayerBehavior.LAYER_UI) + { + _layer1.Behavior = Layer.LayerBehavior.LAYER_2D; + Log("again _layer1.Behavior =" + _layer1.Behavior); + } + // Add a ImageView to the stage + _imageView = new ImageView(); + _imageView.ResourceUrl = "./images/gallery-3.jpg"; + _imageView.ParentOrigin = ParentOrigin.Center; + _imageView.AnchorPoint = AnchorPoint.Center; + _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); + //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); + layer.Add(_imageView); + + _pushButton1 = new PushButton(); + _pushButton1.ParentOrigin = ParentOrigin.BottomLeft; + _pushButton1.AnchorPoint = AnchorPoint.BottomLeft; + _pushButton1.LabelText = "start animation"; + _pushButton1.Position = new Vector3(0.0f, stage.Size.Height * 0.1f, 0.0f); + _pushButton1.Clicked += OnPushButtonClicked1; + _layer1.Add(_pushButton1); + + _pushButton2 = new PushButton(); + _pushButton2.ParentOrigin = ParentOrigin.BottomLeft; + _pushButton2.AnchorPoint = AnchorPoint.BottomLeft; + _pushButton2.LabelText = "reload image with same URL"; + _pushButton2.Position = new Vector3(0.0f, stage.Size.Height * 0.2f, 0.0f); + _pushButton2.Clicked += OnPushButtonClicked2; + _layer2.Add(_pushButton2); - public bool OnPushButtonClicked2(object sender, Button.ClickedEventArgs e) - { - if( _imageView ) - { - Log("OnPushButtonClicked2()!"); - layer.Remove(_imageView); - _imageView = new ImageView(); - _imageView.ResourceUrl = "./images/gallery-3.jpg"; - _imageView.ParentOrigin = ParentOrigin.Center; - _imageView.AnchorPoint = AnchorPoint.Center; - _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); - //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); - layer.Add(_imageView); - } - - return true; - } + } + public bool OnPushButtonClicked2(object sender, Button.ClickedEventArgs e) + { + if (_imageView) + { + Log("OnPushButtonClicked2()!"); + layer.Remove(_imageView); + _imageView = new ImageView(); + _imageView.ResourceUrl = "./images/gallery-3.jpg"; + _imageView.ParentOrigin = ParentOrigin.Center; + _imageView.AnchorPoint = AnchorPoint.Center; + _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); + //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); + layer.Add(_imageView); + } + + return true; + } - public bool OnPushButtonClicked1(object sender, Button.ClickedEventArgs e) - { - if( _isAniFinised == true ) - { - _isAniFinised = false; - Log("OnPushButtonClicked1()!"); - // Create a new _animation - if( _animation ) + public bool OnPushButtonClicked1(object sender, Button.ClickedEventArgs e) { - //_animation.Stop(Dali.Constants.Animation.EndAction.Stop); - _animation.Reset(); + if (_isAniFinised == true) + { + _isAniFinised = false; + Log("OnPushButtonClicked1()!"); + + // Create a new _animation + if (_animation) + { + //_animation.Stop(Dali.Constants.Animation.EndAction.Stop); + _animation.Reset(); + } + + _animation = new Animation(); + _animation.StartTime = 0; + _animation.EndTime = 1000; + _animation.TargetProperty = "PixelArea"; + _animation.Destination = new Vector4(0.5f, 0.0f, 0.5f, 0.5f); + _animation.AnimateTo(_imageView); + + _animation.StartTime = 1000; + _animation.EndTime = 2000; + _animation.TargetProperty = "PixelArea"; + _animation.Destination = new Vector4(0.5f, 0.5f, 0.5f, 0.5f); + _animation.AnimateTo(_imageView); + + _animation.StartTime = 2000; + _animation.EndTime = 3000; + _animation.TargetProperty = "PixelArea"; + _animation.Destination = new Vector4(0.0f, 0.0f, 1.0f, 1.0f); + _animation.AnimateTo(_imageView); + + _animation.StartTime = 3000; + _animation.EndTime = 4000; + _animation.TargetProperty = "PixelArea"; + _animation.Destination = new Vector4(0.5f, 0.5f, 0.5f, 0.5f); + _animation.AnimateTo(_imageView); + + _animation.StartTime = 4000; + _animation.EndTime = 6000; + _animation.TargetProperty = "Size"; + KeyFrames _keyFrames = new KeyFrames(); + _keyFrames.Add(0.0f, new Size(0.0f, 0.0f, 0.0f)); + _keyFrames.Add(0.3f, new Size((stage.Size * 0.7f))); + _keyFrames.Add(1.0f, new Size(stage.Size)); + _animation.AnimateBetween(_imageView, _keyFrames, Animation.Interpolation.Linear); + + _animation.EndAction = Animation.EndActions.Discard; + + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + _animation.Finished += AnimationFinished2; + + // Play the _animation + _animation.Play(); + } + + return true; } - _animation = new Animation(); - _animation.StartTime = 0; - _animation.EndTime = 1000; - _animation.TargetProperty = "PixelArea"; - _animation.Destination = new Vector4(0.5f, 0.0f, 0.5f, 0.5f); - _animation.AnimateTo(_imageView); - - _animation.StartTime = 1000; - _animation.EndTime = 2000; - _animation.TargetProperty = "PixelArea"; - _animation.Destination = new Vector4(0.5f, 0.5f, 0.5f, 0.5f); - _animation.AnimateTo(_imageView); - - _animation.StartTime = 2000; - _animation.EndTime = 3000; - _animation.TargetProperty = "PixelArea"; - _animation.Destination = new Vector4(0.0f, 0.0f, 1.0f, 1.0f); - _animation.AnimateTo(_imageView); - - _animation.StartTime = 3000; - _animation.EndTime = 4000; - _animation.TargetProperty = "PixelArea"; - _animation.Destination = new Vector4(0.5f, 0.5f, 0.5f, 0.5f); - _animation.AnimateTo(_imageView); - - _animation.StartTime = 4000; - _animation.EndTime = 6000; - _animation.TargetProperty = "Size"; - KeyFrames _keyFrames = new KeyFrames(); - _keyFrames.Add(0.0f, new Size3D(0.0f, 0.0f, 0.0f) ); - _keyFrames.Add(0.3f, new Size3D( (stage.Size * 0.7f) ) ); - _keyFrames.Add(1.0f, new Size3D( stage.Size ) ); - _animation.AnimateBetween(_imageView, _keyFrames, Animation.Interpolation.Linear); - - _animation.EndAction = Animation.EndActions.Discard; - - // Connect the signal callback for animaiton finished signal - _animation.Finished += AnimationFinished; - _animation.Finished += AnimationFinished2; - - // Play the _animation - _animation.Play(); - } - - return true; - } - - // Callback for _animation finished signal handling - public void AnimationFinished(object sender, EventArgs e) - { - Log("AnimationFinished()!"); - } + // Callback for _animation finished signal handling + public void AnimationFinished(object sender, EventArgs e) + { + Log("AnimationFinished()!"); + } - // Callback for second _animation finished signal handling - public void AnimationFinished2(object sender, EventArgs e) - { - Log("AnimationFinished2()!"); - if(_animation) - { - Log("Duration= " + _animation.Duration); - Log("EndAction= " + _animation.EndAction); - _isAniFinised = true; - } - } + // Callback for second _animation finished signal handling + public void AnimationFinished2(object sender, EventArgs e) + { + Log("AnimationFinished2()!"); + if (_animation) + { + Log("Duration= " + _animation.Duration); + Log("EndAction= " + _animation.EndAction); + _isAniFinised = true; + } + } - public void OnStageEventProcessingFinished(object sender, EventArgs e) - { - Log("OnStageEventProcessingFinished()!"); - if( e != null) - { - Log("e != null !"); - } - } + public void OnStageEventProcessingFinished(object sender, EventArgs e) + { + Log("OnStageEventProcessingFinished()!"); + if (e != null) + { + Log("e != null !"); + } + } - public void OnStageKeyPressed(object sender, Stage.KeyEventArgs e) - { - Log("OnStageKeyEventOccured()!"); - Log("keyPressedName=" + e.Key.KeyPressedName); - Log("state=" + e.Key.State); - } + public void OnStageKeyPressed(object sender, Stage.KeyEventArgs e) + { + Log("OnStageKeyEventOccured()!"); + Log("keyPressedName=" + e.Key.KeyPressedName); + Log("state=" + e.Key.State); + } - public void OnStageWheelMoved(object sender, Stage.WheelEventArgs e) - { - Log("OnStageWheelEventOccured()!"); - Log("direction=" + e.Wheel.Direction); - Log("type=" + e.Wheel.Type); - } + public void OnStageWheelMoved(object sender, Stage.WheelEventArgs e) + { + Log("OnStageWheelEventOccured()!"); + Log("direction=" + e.Wheel.Direction); + Log("type=" + e.Wheel.Type); + } - // Callback for stage touched signal handling - public void OnStageTouched(object sender, Stage.TouchEventArgs e) - { - Log("OnStageTouched()! e.TouchData.GetState(0)=" + e.Touch.GetState(0)); - } + // Callback for stage touched signal handling + public void OnStageTouched(object sender, Stage.TouchEventArgs e) + { + Log("OnStageTouched()! e.TouchData.GetState(0)=" + e.Touch.GetState(0)); + } - public void MainLoop() - { - _application.MainLoop (); - } + public void MainLoop() + { + _application.MainLoop(); + } - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - Log("Main() called!"); + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + Log("Main() called!"); - Example example = new Example(Application.NewApplication()); - example.MainLoop (); + Example example = new Example(Application.NewApplication()); + example.MainLoop(); + } } - } } +