Пример #1
0
 // Display a determinate progress indicator
 public void progressStart(string options)
 {
     string[] args = JSON.JsonHelper.Deserialize <string[]>(options);
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (frame != null)
         {
             PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
             if (page != null)
             {
                 var temp  = page.FindName("LayoutRoot");
                 Grid grid = temp as Grid;
                 if (grid != null)
                 {
                     if (progressLayer != null)
                     {
                         grid.Children.Remove(progressLayer);
                     }
                     progressLayer           = new ProgressLayer();
                     progressLayer.IsEnabled = true;
                     progressLayer.progressBar.IsIndeterminate = false;
                     progressLayer.progressBar.Maximum         = 100;
                     progressLayer.title.Text   = args[0];
                     progressLayer.message.Text = args[1];
                     grid.Children.Add(progressLayer);
                 }
             }
         }
     });
 }
Пример #2
0
 // Display an indeterminate progress indicator
 public void activityStart(string options)
 {
     string[] args = JSON.JsonHelper.Deserialize <string[]>(options);
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (frame != null)
         {
             PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
             if (page != null)
             {
                 var temp  = page.FindName("LayoutRoot");
                 Grid grid = temp as Grid;
                 if (grid != null)
                 {
                     if (progressLayer != null)
                     {
                         grid.Children.Remove(progressLayer);
                     }
                     progressLayer            = new ProgressLayer();
                     progressLayer.IsEnabled  = true;
                     progressLayer.title.Text = !String.IsNullOrEmpty(args[0]) ? args[0] : args[1];
                     if (!String.IsNullOrEmpty(args[0]) && !String.IsNullOrEmpty(args[1]))
                     {
                         progressLayer.message.Text = args[1];
                     }
                     grid.Children.Add(progressLayer);
                 }
             }
         }
     });
 }
Пример #3
0
        private void StopAnimating()
        {
            if (!IsAnimating)
            {
                return;
            }

            ProgressLayer.RemoveAnimation(KNBCircleRotationAnimationKey);
            ProgressLayer.RemoveAnimation(KNBCircleStrokeAnimationKey);
            _isAnimating = false;

            if (HidesWhenStopped)
            {
                Hidden = true;
            }
        }
Пример #4
0
 // Remove our determinate progress indicator
 public void progressStop(string unused)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         if (progressLayer != null)
         {
             progressLayer.IsEnabled     = false;
             PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
             if (frame != null)
             {
                 PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
                 if (page != null)
                 {
                     Grid grid = page.FindName("LayoutRoot") as Grid;
                     if (grid != null)
                     {
                         grid.Children.Remove(progressLayer);
                     }
                 }
             }
             progressLayer = null;
         }
     });
 }
Пример #5
0
        public void StartAnimating()
        {
            if (IsAnimating)
            {
                return;
            }

            CABasicAnimation animation = new CABasicAnimation();

            animation.KeyPath        = "transform.rotation";
            animation.Duration       = 4.0;
            animation.From           = new NSNumber(0.0f);
            animation.To             = new NSNumber(2 * Math.PI);
            animation.RepeatCount    = float.MaxValue;
            animation.TimingFunction = _timingFunction;
            ProgressLayer.AddAnimation(animation, KNBCircleRotationAnimationKey);

            CABasicAnimation headAnimation = new CABasicAnimation();

            headAnimation.KeyPath        = "strokeStart";
            headAnimation.Duration       = 1.0;
            headAnimation.From           = new NSNumber(0.0);
            headAnimation.To             = new NSNumber(0.25);
            headAnimation.TimingFunction = _timingFunction;

            CABasicAnimation tailAnimation = new CABasicAnimation();

            tailAnimation.KeyPath        = "strokeEnd";
            tailAnimation.Duration       = 1.0;
            tailAnimation.From           = new NSNumber(0.0);
            tailAnimation.To             = new NSNumber(1.0);
            tailAnimation.TimingFunction = _timingFunction;

            CABasicAnimation endHeadAnimation = new CABasicAnimation();

            endHeadAnimation.KeyPath        = "strokeStart";
            endHeadAnimation.BeginTime      = 1.0;
            endHeadAnimation.Duration       = 0.5;
            endHeadAnimation.From           = new NSNumber(0.25);
            endHeadAnimation.To             = new NSNumber(1.0);
            endHeadAnimation.TimingFunction = _timingFunction;

            CABasicAnimation endTailAnimation = new CABasicAnimation();

            endTailAnimation.KeyPath        = "strokeEnd";
            endTailAnimation.BeginTime      = 1.0;
            endTailAnimation.Duration       = 0.5;
            endTailAnimation.From           = new NSNumber(1.0);
            endTailAnimation.To             = new NSNumber(1.0);
            endTailAnimation.TimingFunction = _timingFunction;

            CAAnimationGroup animations = new CAAnimationGroup();

            animations.Duration    = 1.5;
            animations.Animations  = new CAAnimation[] { headAnimation, tailAnimation, endHeadAnimation, endTailAnimation };
            animations.RepeatCount = float.MaxValue;
            ProgressLayer.AddAnimation(animations, KNBCircleStrokeAnimationKey);

            _isAnimating = true;

            if (HidesWhenStopped)
            {
                Hidden = false;
            }
        }