Example #1
0
        /// <summary>
        /// Des the place.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <remarks>...</remarks>
        public void DePlace(NewgenPackage package)
        {
            if (package == null && package.Tile == null)
            {
                return;
            }

            // Find correct tile.
            var tileControl = TileControls.Find(x => x.package == package);

            if (tileControl == null)
            {
                return;
            }

            AnimationExtensions.Animate(tileControl, OpacityProperty, 150, 0, 0.7, 0.3);

            // Lazy-ness for animation.
            ThreadingExtensions.LazyInvokeThreadSafe(new Action(() => {
                tileControl.MouseLeftButtonDown -= OnTileControlMouseLeftButtonDown;
                tileControl.MouseLeftButtonUp   -= OnTileControlMouseLeftButtonUp;
                tileControl.MouseMove           -= OnTileControlMouseMove;

                // De-place tile.
                DePlace(tileControl, alsoRemoveFromHost: true, permanently: false);

                // Stop tile.
                tileControl.Stop();
            }), 180);
        }
Example #2
0
        /// <summary>
        /// Handles the <see cref="E:Closing" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">
        /// The <see cref="System.ComponentModel.CancelEventArgs" /> instance containing the event data.
        /// </param>
        /// <remarks>...</remarks>
        private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (Mouse.DirectlyOver == ThumbnailsContainer || (Mouse.DirectlyOver != null && this.IsAncestorOf(Mouse.DirectlyOver as UIElement)))
            {
                e.Cancel = true;
            }

            if (isclosepending)
            {
                ThreadingExtensions.LazyInvokeThreadSafe(() => {
                    isclosepending = false;
                    if (autoSwitchOnClose)
                    {
                        Switch();
                    }
                    else
                    {
                        Close();
                    }
                }, 200);

                ThumbnailsContainer.Children.Clear();

                AnimationExtensions.Animate(this, OpacityProperty, 500, 0, 0.1, 0.9);
                AnimationExtensions.Animate(this, LeftProperty, 1050, Left, -Left, 0.9, 0.1);

                e.Cancel = true;
            }
        }
Example #3
0
 /// <summary>
 /// Handles the MouseLeftButtonUp event of the StartButton control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param>
 /// <remarks>...</remarks>
 private void StartButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount >= 2)
     {
         App.Screen.Hide();
         CloseToolbar();
     }
     else
     {
         foreach (var window in App.Current.Windows)
         {
             if (window.GetType() == typeof(HubWindow) ||
                 window.GetType() == typeof(DWMPreviewPopup)
                 )
             {
                 continue;
             }
             ((Window)window).Activate();
             ((Window)window).Show();
         }
         foreach (var tileControl in App.Screen.TilesControl.TileControls)
         {
             AnimationExtensions.Animate(tileControl, OpacityProperty, 250, 0, 1);
         }
     }
 }
Example #4
0
        /// <summary>
        /// Adds the icon.
        /// </summary>
        /// <param name="hWnd">The h WND.</param>
        /// <remarks>...</remarks>
        internal void AddProcessIconUI(IntPtr hWnd)
        {
            // Get path.
            var pp       = WinAPI.GetProcessPath(hWnd);
            var hWndpath = new FileInfo(pp).Name;

            // Check if already added or not.
            foreach (var sbi in ProcessesContainer.Children.OfType <FrameworkElement>().ToList())
            {
                if (WinAPI.GetProcessPath(((List <IntPtr>)sbi.DataContext)[0]).Contains(hWndpath))
                {
                    ((List <IntPtr>)sbi.DataContext).Add(hWnd);

                    AnimationExtensions.Animate(sbi, OpacityProperty, 500, 0, 1, 0.2, 0.8);

                    return;
                }
            }

            // Get thumb.
            var thumb = InternalHelper.GetThumbnail(pp);

            if (thumb == null)
            {
                return;
            }

            // Create ui.
            var iconUIImage = new Image()
            {
                Source = thumb, Margin = new Thickness(7)
            };
            var iconUI = new Button()
            {
                DataContext = new List <IntPtr>()
                {
                    hWnd
                },
                Content   = iconUIImage,
                MinHeight = 32,
                MinWidth  = 32,
                MaxHeight = 64,
                MaxWidth  = 64,
                Style     = App.Current.Resources["B_FX_A1_Style"] as Style
            };

            iconUI.Background = ((BitmapSource)thumb).CalculateAverageColor(0xFF).ToBrush();
            RenderOptions.SetBitmapScalingMode(iconUIImage, BitmapScalingMode.HighQuality);
            iconUI.Loaded += iconUI_Loaded;
            iconUI.PreviewMouseLeftButtonUp += iconUI_PreviewMouseLeftButtonUp;
            iconUI.MouseEnter += iconUI_MouseEnter;
            iconUI.MouseLeave += iconUI_MouseLeave;

            // Add to list.
            ProcessesContainer.Children.Add(iconUI);

            // FX.
            AnimationExtensions.Animate(iconUI, OpacityProperty, 450, 0, 1, 0.2, 0.8);
        }
Example #5
0
 private void animateBackgroundColor(UIColor color)
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.EaseIn,
         () => BackgroundColor = color
         );
 }
 internal void AnimatePlayButton()
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.EaseOut,
         () => StartTimeEntryButton.Transform = CGAffineTransform.MakeScale(1f, 1f)
         );
 }
Example #7
0
 protected override void SetValue(nfloat value)
 {
     Target.Constant = value;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => ((UIView)Target.FirstItem).Superview.LayoutIfNeeded());
 }
Example #8
0
 protected override void SetValue(UIColor value)
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => Target.BackgroundColor = value
         );
 }
Example #9
0
 internal void HideCalendar()
 {
     TopCalendarConstraint.Constant = calendarHeight;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => View.LayoutSubviews(),
         () => CalendarIsVisible = false);
 }
Example #10
0
 public static Action <float> AnimatedAlpha(this IReactive <UIView> reactive)
 => alpha =>
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => reactive.Base.Alpha = alpha
         );
 };
Example #11
0
        /// <summary>
        /// Handles the <see cref="E:Loaded" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.UserBadgeControl.Reload();
            AnimationExtensions.Animate(this.Header, OpacityProperty, 250, 1);

            LoadToolbars();

            Api.Logger.LogInformation("STARTED screen.");
        }
Example #12
0
 public static Action <UIColor> AnimatedBackgroundColor(this IReactive <UIView> reactive) =>
 color =>
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => reactive.Base.BackgroundColor = color
         );
 };
Example #13
0
 public static Action <nfloat> ConstantAnimated(this IReactive <NSLayoutConstraint> reactive)
 => constant =>
 {
     reactive.Base.Constant = constant;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => ((UIView)reactive.Base.FirstItem).Superview.LayoutIfNeeded());
 };
Example #14
0
 internal void ShowCalendar()
 {
     TopCalendarConstraint.Constant = 0;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () => View.LayoutSubviews(),
         () => CalendarIsVisible = true);
 }
Example #15
0
 public static Action <bool> IsVisibleWithFade(this IReactive <UIView> reactive)
 => isVisible =>
 {
     var alpha = isVisible ? 1 : 0;
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.EaseIn,
         () =>
     {
         reactive.Base.Alpha = alpha;
     });
 };
Example #16
0
        /// <summary>
        /// Removes the icon.
        /// </summary>
        /// <param name="iconUI">The icon UI.</param>
        /// <remarks>...</remarks>
        internal void RemoveProcessIconUI(FrameworkElement iconUI)
        {
            // Remove from list.
            if (iconUI != null)
            {
                AnimationExtensions.Animate(iconUI, OpacityProperty, 700, 0, 0.1, 0.9);

                ThreadingExtensions.LazyInvokeThreadSafe(() => {
                    ProcessesContainer.Children.Remove(iconUI);
                }, 600);
            }
        }
Example #17
0
        protected override void SetValue(bool value)
        {
            Target.Transform = CGAffineTransform.MakeTranslation(0, 20);

            AnimationExtensions.Animate(
                Animation.Timings.EnterTiming,
                Animation.Curves.SharpCurve,
                () =>
            {
                Target.Hidden    = !value;
                Target.Transform = CGAffineTransform.MakeTranslation(0, 0);
            }
                );
        }
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var toController      = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var fromController    = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var animationDuration = TransitionDuration(transitionContext);

            if (presenting)
            {
                transitionContext.ContainerView.AddSubview(toController.View);

                var finalFrame = transitionContext.GetFinalFrameForViewController(toController);

                var frame = new CGRect(finalFrame.Location, finalFrame.Size);
                frame.Offset(0.0f, transitionContext.ContainerView.Frame.Height - 20);
                toController.View.Frame = frame;
                toController.View.Alpha = 0.5f;

                AnimationExtensions.Animate(animationDuration, Curves.CardInCurve, () =>
                {
                    toController.View.Frame = finalFrame;
                    toController.View.Alpha = 1.0f;
                },
                                            () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled));
            }
            else
            {
                var initialFrame = transitionContext.GetInitialFrameForViewController(fromController);
                initialFrame.Offset(0.0f, transitionContext.ContainerView.Frame.Height);
                var finalFrame = initialFrame;

                if (transitionContext.IsInteractive)
                {
                    UIView.Animate(
                        animationDuration,
                        () => fromController.View.Frame = finalFrame,
                        () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled)
                        );
                }
                else
                {
                    AnimationExtensions.Animate(animationDuration, Curves.CardOutCurve, () =>
                    {
                        fromController.View.Frame = finalFrame;
                        fromController.View.Alpha = 0.5f;
                    },
                                                () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled));
                }
            }
        }
Example #19
0
        public static Action <bool> AnimatedIsVisible(this IReactive <UIView> reactive)
        => isVisible =>
        {
            reactive.Base.Transform = CGAffineTransform.MakeTranslation(0, 20);

            AnimationExtensions.Animate(
                Animation.Timings.EnterTiming,
                Animation.Curves.SharpCurve,
                () =>
            {
                reactive.Base.Hidden    = !isVisible;
                reactive.Base.Transform = CGAffineTransform.MakeTranslation(0, 0);
            }
                );
        };
 protected override void SetValue(bool value)
 {
     AnimationExtensions.Animate(
         Animation.Timings.EnterTiming,
         Animation.Curves.SharpCurve,
         () =>
     {
         // This slight color change is needed for the fade animation to work.
         // Animating only the Enabled property has no effect.
         // Blame Apple.
         Target.TintColor = UIColor.White.ColorWithAlpha(value ? 1.0f : 0.99f);
         Target.Enabled   = value;
     }
         );
 }
Example #21
0
        protected override void SetValue(bool value)
        {
            var alpha = value ? 1 : 0;

            Task.Delay(1).ContinueWith(_ =>
            {
                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    AnimationExtensions.Animate(
                        Animation.Timings.EnterTiming,
                        Animation.Curves.EaseIn,
                        () => Target.Alpha = alpha
                        );
                });
            });
        }
Example #22
0
        private void showTimeEntryCard()
        {
            StopTimeEntryButton.Hidden  = false;
            CurrentTimeEntryCard.Hidden = false;

            AnimationExtensions.Animate(Timings.EnterTiming, showCardDelay, Curves.EaseOut,
                                        () => StartTimeEntryButton.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f),
                                        () =>
            {
                AnimationExtensions.Animate(Timings.LeaveTimingFaster, Curves.EaseIn,
                                            () => StopTimeEntryButton.Transform = CGAffineTransform.MakeScale(1.0f, 1.0f));

                AnimationExtensions.Animate(Timings.LeaveTiming, Curves.CardOutCurve,
                                            () => CurrentTimeEntryCard.Transform = CGAffineTransform.MakeTranslation(0, 0));
            });
        }
Example #23
0
        private void hideTimeEntryCard()
        {
            AnimationExtensions.Animate(Timings.LeaveTimingFaster, Curves.EaseIn,
                                        () => StopTimeEntryButton.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f),
                                        () => StopTimeEntryButton.Hidden    = true);

            AnimationExtensions.Animate(Timings.LeaveTiming, Curves.CardOutCurve,
                                        () => CurrentTimeEntryCard.Transform = CGAffineTransform.MakeTranslation(0, CurrentTimeEntryCard.Frame.Height),
                                        () =>
            {
                CurrentTimeEntryCard.Hidden = true;

                AnimationExtensions.Animate(Timings.EnterTiming, Curves.EaseOut,
                                            () => StartTimeEntryButton.Transform = CGAffineTransform.MakeScale(1f, 1f)
                                            );
            });
        }
        private void OnKeyboardNotification(NSNotification notification)
        {
            var visible = notification.Name == UIKeyboard.WillShowNotification;

            keyboardHeight = visible
                ? UIKeyboard.FrameEndFromNotification(notification).Height
                : 0.0;

            if (finishedPresenting && ContainerView != null && PresentedViewController.PresentedViewController == null)
            {
                var animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
                AnimationExtensions.Animate(animationDuration, Animation.Curves.StandardEase, ContainerViewWillLayoutSubviews);
            }
            else if (PresentingViewController == null)
            {
                ContainerView?.SetNeedsLayout();
            }
        }
Example #25
0
        /// <summary>
        /// Handles the <see cref="E:Loaded" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            Focus();
            Activate();

            AnimationExtensions.Animate(this, OpacityProperty, 250, 1, 0.8, 0.2);
            AnimationExtensions.Animate(this, LeftProperty, 250, 2 * Left, Left, 0.9, 0.1);

            var index = 1;

            foreach (var hWnd in hWnds)
            {
                try {
                    var text  = WinAPI.GetText(hWnd);
                    var dwmtc = new DWMThumbnailControl(this)
                    {
                        ToolTip = text,
                        Width   = Width - 50,
                        Height  = Height - 50,
                        Source  = hWnd
                    };

                    ThumbnailsContainer.Children.Add(dwmtc);
                    TextTitle.Text = text;

                    if (hWnds.Count > 1 && index > 1)
                    {
                        Width = Width + dwmtc.Width;
                    }
                    else
                    {
                        Width++;
                        Width--;
                    }

                    index++;
                }
                catch /* Eat */ { }
            }
        }
Example #26
0
        private void hideTimeEntryCard()
        {
            cardAnimationCancellation?.Cancel();
            cardAnimationCancellation = new CancellationTokenSource();

            AnimationExtensions.Animate(Timings.LeaveTimingFaster, Curves.EaseIn,
                                        () => StopTimeEntryButton.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f),
                                        () => StopTimeEntryButton.Hidden    = true,
                                        cancellationToken: cardAnimationCancellation.Token);

            AnimationExtensions.Animate(Timings.LeaveTiming, Curves.CardOutCurve,
                                        () => CurrentTimeEntryCard.Transform = CGAffineTransform.MakeTranslation(0, CurrentTimeEntryCard.Frame.Height),
                                        () =>
            {
                CurrentTimeEntryCard.Hidden = true;

                AnimationExtensions.Animate(Timings.EnterTiming, Curves.EaseOut,
                                            () => StartTimeEntryButton.Transform = CGAffineTransform.MakeScale(1f, 1f),
                                            cancellationToken: cardAnimationCancellation.Token);
            },
                                        cancellationToken: cardAnimationCancellation.Token);
        }
Example #27
0
 /// <summary>
 /// Reloads this instance.
 /// </summary>
 /// <remarks>...</remarks>
 public void Reload()
 {
     this.InvokeAsyncThreadSafe(() => {
         if (!Settings.Current.IsUserTileEnabled)
         {
             this.Visibility = Visibility.Collapsed;
         }
         else
         {
             this.Visibility = Visibility.Visible;
             this.Opacity    = 0;
             AnimationExtensions.Animate(this, OpacityProperty, 300, 1);
             var userimagefile = System.IO.Path.GetTempPath() + "\\" + Environment.UserName + ".bmp";
             if (File.Exists(userimagefile))
             {
                 File.Copy(userimagefile, Settings.Current.StartScreenUserImage, true);
             }
             UsernameText.Text = Environment.UserName;
             UserImage.Source  = (Settings.Current.StartScreenUserImage).ToBitmapSource() ?? UserImage.Source;
         }
     });
 }
Example #28
0
        private void AnimateStart()
        {
            this.IsHubActive = true;
            switch (this.Animation)
            {
            case AnimationType.Custom: {
                this.IsHubActive = false;
                this.Left        = 0;
                this.Top         = 0;
                this.Width       = SystemParameters.PrimaryScreenWidth;
                this.Height      = SystemParameters.PrimaryScreenHeight;
            }
            break;

            case AnimationType.Internal:
            default: {
                this.IsHubActive = true;
                this.Left        = -SystemParameters.PrimaryScreenWidth;
                this.Top         = 0;
                this.Width       = SystemParameters.PrimaryScreenWidth;
                this.Height      = SystemParameters.PrimaryScreenHeight;

                var leftanimation = new DoubleAnimation()
                {
                    To                = 0,
                    Duration          = new Duration(TimeSpan.FromMilliseconds(180)),
                    BeginTime         = TimeSpan.FromMilliseconds(50),
                    AccelerationRatio = 0.3,
                    DecelerationRatio = 0.7,
                };
                this.BeginAnimation(LeftProperty, leftanimation);
                AnimationExtensions.Animate(this, OpacityProperty, 3, 0, 1, 0.3, 0.7);
            }
            break;
            }
        }
Example #29
0
        private void showTimeEntryCard()
        {
            StopTimeEntryButton.Hidden  = false;
            CurrentTimeEntryCard.Hidden = false;

            cardAnimationCancellation?.Cancel();
            cardAnimationCancellation = new CancellationTokenSource();

            TimeEntriesLogTableViewBottomToTopCurrentEntryConstraint.Active = true;

            AnimationExtensions.Animate(Timings.EnterTiming, showCardDelay, Curves.EaseOut,
                                        () => StartTimeEntryButton.Transform = CGAffineTransform.MakeScale(0.01f, 0.01f),
                                        () =>
            {
                AnimationExtensions.Animate(Timings.LeaveTimingFaster, Curves.EaseIn,
                                            () => StopTimeEntryButton.Transform = CGAffineTransform.MakeScale(1.0f, 1.0f),
                                            cancellationToken: cardAnimationCancellation.Token);

                AnimationExtensions.Animate(Timings.LeaveTiming, Curves.CardOutCurve,
                                            () => CurrentTimeEntryCard.Transform = CGAffineTransform.MakeTranslation(0, 0),
                                            cancellationToken: cardAnimationCancellation.Token);
            },
                                        cancellationToken: cardAnimationCancellation.Token);
        }
Example #30
0
 public void ThrowsWithNullSelf()
 {
     Assert.Throws <ArgumentNullException>(() => AnimationExtensions.Animate(null, "Foo", d => (float)d, f => { }));
 }