public void Image_GET_VALUE_After_Set_ResourceUrl() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); string resultUrl1 = ""; PropertyMap map1 = testView.Image; bool ret1 = (map1.Find(ImageVisualProperty.URL)?.Get(out resultUrl1) ?? false) && string.IsNullOrEmpty(resultUrl1); Assert.AreEqual(false, ret1, "map don't have ResourceUrl"); // Note : Current version of ANIMATED_IMAGE Visual works well only ResourceUrl's suffix is *.gif or *.webp string testUrl1 = "test1.gif"; testView.ResourceUrl = testUrl1; PropertyMap map2 = testView.Image; bool ret2 = (map2.Find(ImageVisualProperty.URL)?.Get(out resultUrl1) ?? false) && !string.IsNullOrEmpty(resultUrl1); Assert.AreEqual(true, ret2, "map must have ResourceUrl"); Assert.AreEqual(testUrl1, resultUrl1, "...and That value must be equal what we added"); testView.Dispose(); }
public void IsRewardCollectionEmpty() { var itemsCount = CollectionView.Source.GetItemsCount(CollectionView, 0); if (itemsCount == 0) { EmptyCollectionView.Hidden = false; _swipe = new UISwipeGestureRecognizer(); _swipe.AddTarget(() => HideAreaCollection()); _swipe.Direction = UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Down; EmptyCollectionView.AddGestureRecognizer(_swipe); _tap = new UITapGestureRecognizer(); _tap.AddTarget(() => HideAreaCollection()); EmptyCollectionView.AddGestureRecognizer(_tap); var data = NSData.FromFile("Images/panda-ohno.gif"); var image = AnimatedImageView.GetAnimatedImageView(data, ViewForImage); ViewForImage.Image = image.Image; ViewForImage.StartAnimating(); } if (itemsCount != 0) { EmptyCollectionView.Hidden = true; } }
public void AnimatedImageViewCurrentFrame() { tlog.Debug(tag, $"AnimatedImageViewCurrentFrame START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); using (PropertyMap map = new PropertyMap()) { map.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); map.Insert(ImageVisualProperty.URL, new PropertyValue(url)); map.Insert(ImageVisualProperty.Border, new PropertyValue(new Extents(4, 4, 4, 4))); map.Insert(ImageVisualProperty.TotalFrameNumber, new PropertyValue(30)); map.Insert(ImageVisualProperty.CurrentFrameNumber, new PropertyValue(0)); testingTarget.Image = map; try { testingTarget.CurrentFrame = 15; var resutl = testingTarget.CurrentFrame; } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } } testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewCurrentFrame END (OK)"); }
private void CreateAnimatedImageView(AnimatedImageView animatedImageView) { if (Control != null) { var progressBar = Control as Android.Widget.ProgressBar; progressBar.IndeterminateDrawable = Context.GetDrawable(animatedImageView.SourceUrl); progressBar.Indeterminate = true; } }
public void AnimatedImageViewConstructor() { tlog.Debug(tag, $"AnimatedImageViewConstructor START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewConstructor END (OK)"); }
public void ResourceUrl_SET_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); // Note : Current version of ANIMATED_IMAGE Visual works well only ResourceUrl's suffix is *.gif or *.webp string testUrl1 = "test1.gif"; testView.ResourceUrl = testUrl1; Assert.AreEqual(testView.ResourceUrl, testUrl1, "ResourceUrl is not equal"); testView.Dispose(); }
public void TotalFrame_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); int expectedTotalFrame = 15; // The total frame of animated_image_path image Assert.AreEqual(-1, testView.TotalFrame, "Total frame should be -1 when ResourceUrl is not setup"); testView.ResourceUrl = animated_image_path; Assert.AreEqual(expectedTotalFrame, testView.TotalFrame, "Total frame doesn't matched!"); testView.Dispose(); }
public void NaturalSize2D_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); testView.ResourceUrl = animated_image_path; Size2D result = new Size2D(326, 171); // The size of animated_image_path image. Size2D size = testView.NaturalSize2D; Assert.AreEqual(result.Width, size.Width, "NaturalSize Width is not equal"); Assert.AreEqual(result.Height, size.Height, "NaturalSize Height is not equal"); testView.Dispose(); }
public void NaturalSize_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); testView.ResourceUrl = animated_image_path; Vector3 result = new Vector3(326, 171, 0); // The size of animated_image_path image. Vector3 size = testView.NaturalSize; Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal"); Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal"); testView.Dispose(); }
public void AnimatedImageViewResourceUrl() { tlog.Debug(tag, $"AnimatedImageViewResourceUrl START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); testingTarget.ResourceUrl = url; Assert.AreEqual(url, testingTarget.ResourceUrl, "Should be equal"); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewResourceUrl END (OK)"); }
public void AnimatedImageViewStopBehavior() { tlog.Debug(tag, $"AnimatedImageViewStopBehavior START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); testingTarget.StopBehavior = AnimatedImageView.StopBehaviorType.MinimumFrame; Assert.AreEqual(AnimatedImageView.StopBehaviorType.MinimumFrame, testingTarget.StopBehavior, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewStopBehavior END (OK)"); }
public void AnimatedImageViewLoopCount() { tlog.Debug(tag, $"AnimatedImageViewLoopCount START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); testingTarget.LoopCount = 3; Assert.AreEqual(3, testingTarget.LoopCount, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewLoopCount END (OK)"); }
public void AnimatedImageViewFrameDelay() { tlog.Debug(tag, $"AnimatedImageViewFrameDelay START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); testingTarget.FrameDelay = 300; Assert.AreEqual(300, testingTarget.FrameDelay, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewFrameDelay END (OK)"); }
public void NaturalSize_GET_VALUE_as_View_class() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); testView.ResourceUrl = animated_image_path; Vector3 result = new Vector3(326, 171, 0); // The size of animated_image_path image. View testView2 = testView; // Convert class as View. Vector3 size = testView2.NaturalSize; // Check whether virtual ImageView.GetNaturalSize() called well. Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal"); Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal"); testView.Dispose(); testView2.Dispose(); }
public void StopBehavior_SET_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); testView.ResourceUrl = animated_image_path; testView.StopBehavior = AnimatedImageView.StopBehaviorType.CurrentFrame; Assert.AreEqual(AnimatedImageView.StopBehaviorType.CurrentFrame, testView.StopBehavior, "StopBehavior is not equal"); testView.StopBehavior = AnimatedImageView.StopBehaviorType.MinimumFrame; Assert.AreEqual(AnimatedImageView.StopBehaviorType.MinimumFrame, testView.StopBehavior, "StopBehavior is not equal"); testView.StopBehavior = AnimatedImageView.StopBehaviorType.MaximumFrame; Assert.AreEqual(AnimatedImageView.StopBehaviorType.MaximumFrame, testView.StopBehavior, "StopBehavior is not equal"); testView.Dispose(); }
public void AnimatedImageViewCacheSize() { tlog.Debug(tag, $"AnimatedImageViewCacheSize START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); Assert.AreEqual(1, testingTarget.CacheSize, "Should be equal!"); testingTarget.CacheSize = 2; Assert.AreEqual(2, testingTarget.CacheSize, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"AnimatedImageViewCacheSize END (OK)"); }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); accelerometerManager = new AccelerometerManager(this, this); buttonPuppy = FindViewById <Button>(Resource.Id.button_puppy); buttonPuppy.Click += async(sender, args) => { state.CurrentTask = LoadImage(OverflowHelper.Animal.Dog); await state.CurrentTask; }; buttonKitty = FindViewById <Button>(Resource.Id.button_kitty); buttonKitty.Click += async(sender, args) => await LoadImage(OverflowHelper.Animal.Cat); progressBar = FindViewById <ProgressBar>(Resource.Id.progressbar); imageView = FindViewById <ImageView>(Resource.Id.imageview_animal); imageViewAnimated = FindViewById <Helpers.AnimatedImageView>(Resource.Id.imageview_animal_animated); progressBar.Visibility = ViewStates.Invisible; imageView.Visibility = ViewStates.Gone; imageViewAnimated.Visibility = ViewStates.Gone; state = LastNonConfigurationInstance as PuppyKittyState; if (state != null) { if (state.CurrentTask == null || state.CurrentTask.IsCompleted) { await SetImage(); } } else { state = new PuppyKittyState(); state.SetDefault = true; } }
public void AnimatedImageViewPlay() { tlog.Debug(tag, $"AnimatedImageViewPlay START"); var testingTarget = new AnimatedImageView(); Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView"); Assert.IsInstanceOf <AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type."); using (PropertyMap map = new PropertyMap()) { map.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); map.Insert(ImageVisualProperty.URL, new PropertyValue(url)); map.Insert(ImageVisualProperty.AlphaMaskURL, new PropertyValue(url)); map.Insert(ImageVisualProperty.AuxiliaryImageURL, new PropertyValue(url)); map.Insert(ImageVisualProperty.Border, new PropertyValue(new Extents(4, 4, 4, 4))); map.Insert(ImageVisualProperty.TotalFrameNumber, new PropertyValue(30)); map.Insert(ImageVisualProperty.CurrentFrameNumber, new PropertyValue(0)); testingTarget.Image = map; testingTarget.BatchSize = 2; testingTarget.CacheSize = 2; testingTarget.LoopCount = 3; testingTarget.StopBehavior = AnimatedImageView.StopBehaviorType.MinimumFrame; try { testingTarget.Play(); } catch (Exception e) { testingTarget.Dispose(); tlog.Debug(tag, e.Message.ToString()); tlog.Debug(tag, $"AnimatedImageViewPlay END (OK)"); Assert.Pass("Passed!"); } } testingTarget?.Dispose(); tlog.Debug(tag, $"AnimatedImageViewPlay END (OK)"); }
public void LoopCount_SET_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); Assert.AreEqual(-1, testView.LoopCount, "LoopCount should be -1 when ResourceUrl is not setup"); testView.ResourceUrl = animated_image_path; Assert.AreEqual(-1, testView.LoopCount, "LoopCount should be -1 (mean infinite loop) even ResourceUrl is setup"); int expectLoopCount = 3; testView.LoopCount = expectLoopCount; Assert.AreEqual(expectLoopCount, testView.LoopCount, "LoopCount doesn't matched!"); testView.LoopCount++; Assert.AreEqual(expectLoopCount + 1, testView.LoopCount, "LoopCount doesn't matched!"); testView.Dispose(); }
public void CurrentFrame_SET_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); Assert.AreEqual(-1, testView.CurrentFrame, "Current frame should be -1 when ResourceUrl is not setup"); testView.ResourceUrl = animated_image_path; Assert.AreEqual(0, testView.CurrentFrame, "Current frame doesn't matched!"); // Set CurrentFrame will works well only if view is scene on. NUIApplication.GetDefaultWindow().Add(testView); int expectFrame = 3; testView.CurrentFrame = expectFrame; Assert.AreEqual(expectFrame, testView.CurrentFrame, "Current frame doesn't matched!"); testView.Unparent(); testView.Dispose(); }
public void StartHUD(string message) { UIViewController controller = UIApplication.SharedApplication.KeyWindow.RootViewController; hud = new MBProgressHUD(controller.View); controller.View.AddSubview(hud); // The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/ // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) UIImageView gif = AnimatedImageView.GetAnimatedImageView("https://i.stack.imgur.com/naLBK.gif"); hud.CustomView = gif; // Add information to your HUD hud.Label.Text = message; hud.BezelView.Color = UIColor.Clear; hud.BezelView.TintColor = UIColor.Clear; hud.BezelView.Style = MBProgressHUDBackgroundStyle.SolidColor; hud.BezelView.BlurEffectStyle = UIBlurEffectStyle.Dark; // Set custom view mode hud.Mode = MBProgressHUDMode.CustomView; hud.Show(true); }
public void URLs_SET_GET_VALUE() { /* TEST CODE */ AnimatedImageView testView = new AnimatedImageView(); List <string> urls = testView.URLs; urls.Add(image_path); urls.Add(image_path); urls.Add(image_path); // URLs don't have any change notifier. So we have to update property forcely by SetValues API. testView.SetValues(); int expectedTotalFrame = urls.Count; int defaultFrameDelay = 100; ///< It can be changed in dali engine side int expectFrameDelay = 300; Assert.AreEqual(expectedTotalFrame, testView.TotalFrame, "Total frame doesn't matched!"); Assert.AreEqual(defaultFrameDelay, testView.FrameDelay, "Default frame delay doesn't matched!"); testView.FrameDelay = expectFrameDelay; Assert.AreEqual(expectFrameDelay, testView.FrameDelay, "frame delay doesn't matched!"); testView.Dispose(); }
public Box(Size2D boxSize, string boxTitle, string imageUrl) { this.Size2D = boxSize; this.Margin = new Extents(0, 0, 20, 20); this.BackgroundColor = Color.Magenta; title = new TextLabel(boxTitle); title.Size2D = new Size2D(boxSize.Width, GetRatio(20, boxSize.Height)); title.Position2D = new Position2D(0, 0); title.MultiLine = true; title.BackgroundColor = Color.Blue; title.TextColor = Color.Yellow; this.Add(title); image = new AnimatedImageView(); image.Size2D = new Size2D(boxSize.Width, GetRatio(50, boxSize.Height)); image.Position2D = new Position2D(0, title.Size2D.Height); image.ResourceUrl = imageUrl; image.Play(); this.Add(image); status = new TextLabel("Initialized"); status.Size2D = new Size2D(boxSize.Width, GetRatio(20, boxSize.Height)); status.Position2D = new Position2D(0, image.Position2D.Y + image.Size2D.Height); status.MultiLine = true; status.BackgroundColor = Color.White; status.PointSize = 20; this.Add(status); ButtonStyle aStyle = new ButtonStyle { IsSelectable = true, BackgroundImage = new Selector <string> { Normal = CommonResource.GetFHResourcePath() + "3. Button/[Button] App Primary Color/rectangle_toggle_btn_normal_24c447.png", Selected = CommonResource.GetFHResourcePath() + "3. Button/[Button] App Primary Color/rectangle_point_btn_normal_24c447.png", }, BackgroundImageBorder = new Selector <Rectangle> { All = new Rectangle(5, 5, 5, 5) }, ImageShadow = new ImageShadow(CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", new Rectangle(5, 5, 5, 5)), Overlay = new ImageViewStyle { ResourceUrl = new Selector <string> { Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png", Other = "" }, Border = new Selector <Rectangle> { All = new Rectangle(5, 5, 5, 5) }, }, Text = new TextLabelStyle { PointSize = new Selector <float?> { All = 20 }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, TextColor = new Selector <Color> { Normal = new Color(0.141f, 0.769f, 0.278f, 1), Selected = new Color(1, 1, 1, 1), }, } }; but1 = new Button(aStyle); but1.Size2D = new Size2D(GetRatio(32, boxSize.Width), GetRatio(10, boxSize.Height)); but1.PositionUsesPivotPoint = true; but1.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft; but1.PivotPoint = Tizen.NUI.ParentOrigin.BottomLeft; but1.Style.Text.Text = new Selector <string> { Normal = "Button1 Normal", Selected = "Button1 Selected", Disabled = "Button2 Disabled", }; this.Add(but1); but2 = new Button(aStyle); but2.Size2D = new Size2D(GetRatio(32, boxSize.Width), GetRatio(10, boxSize.Height)); but2.PositionUsesPivotPoint = true; but2.ParentOrigin = Tizen.NUI.ParentOrigin.BottomCenter; but2.PivotPoint = Tizen.NUI.ParentOrigin.BottomCenter; but2.Style.Text.Text = new Selector <string> { Normal = "Button2 Normal", Selected = "Button2 Selected", Disabled = "Button2 Disabled", }; this.Add(but2); but3 = new Button(aStyle); but3.Size2D = new Size2D(GetRatio(32, boxSize.Width), GetRatio(10, boxSize.Height)); but3.PositionUsesPivotPoint = true; but3.ParentOrigin = Tizen.NUI.ParentOrigin.BottomRight; but3.PivotPoint = Tizen.NUI.ParentOrigin.BottomRight; but3.Style.Text.Text = new Selector <string> { Normal = "Button3 Normal", Selected = "Button3 Selected", Disabled = "Button2 Disabled", }; this.Add(but3); }