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>
        /// Deletes the group.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <remarks>...</remarks>
        public void DeleteGroup(TileControlsGroupBarSettings g)
        {
            if (Settings.Current.TileScreenGroups.Count <= 1)
            {
                return;
            }

            var index    = 0;
            var atcolumn = 0;

            for (var i = 0; i < Settings.Current.TileScreenGroups.Count; i++)
            {
                index     = i;
                atcolumn += Settings.Current.TileScreenGroups[i].Column;
                if (Settings.Current.TileScreenGroups[i].Id == g.Id)
                {
                    break;
                }
            }

            Settings.Current.TileScreenGroups.RemoveAt(index);
            TilesControlGroupsHost.Children.RemoveAt(index);

            Unload(atcolumn - g.Column, g.Column);
            ThreadingExtensions.LazyInvokeThreadSafe(() => PushAtColumnBy(atcolumn, -g.Column), 100.0);
        }
Example #4
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 #5
0
        /// <summary>
        /// Handles the MouseLeave event of the iconUI control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void iconUI_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            // Should not fire, but in case.
            if (popup == null || !popup.IsLoaded)
            {
                return;
            }

            // Close popup after 1 sec.
            popupTimer = ThreadingExtensions.LazyInvokeThreadSafe(() => {
                popup.Close();
            }, 1000);
        }
Example #6
0
        /// <summary>
        /// Updates the list.
        /// </summary>
        /// <remarks>...</remarks>
        private void UpdateList()
        {
            try {
                currentTextParts = (package.CustomizedSettings.List.Count > 0
                    ? package.CustomizedSettings.List[random.Next(package.CustomizedSettings.List.Count)]
                    : Settings.ListItemDefault)
                                   .Split(Settings.ListItemPartsDelimiter);

                (Content.Resources["TransitionAnimationOff"] as Storyboard).Begin();

                ThreadingExtensions.LazyInvokeThreadSafe(
                    () => {
                    TextBlock_Quote.Text  = currentTextParts[0];
                    TextBlock_Author.Text = currentTextParts[1];
                    (Content.Resources["TransitionAnimationOn"] as Storyboard).Begin();
                },
                    700);
            }
            catch /* Eat */ { }

            listTimer = ThreadingExtensions.LazyInvokeThreadSafe(UpdateList, package.CustomizedSettings.ListInterval);
        }
Example #7
0
        /// <summary>
        /// Loads the toolbars.
        /// </summary>
        /// <remarks>...</remarks>
        private void LoadToolbars()
        {
            StartBar = new StartBar();
            if (Settings.Current.UseThumbailsBar)
            {
                ThumbnailsBar = new ThumbnailsBar();
            }

            if (Settings.Current.UseThumbailsBar)
            {
                ThumbnailsBar.OpenToolbar();
            }
            StartBar.OpenToolbar();

            ThreadingExtensions.LazyInvokeThreadSafe(() => {
                if (Settings.Current.UseThumbailsBar)
                {
                    ThumbnailsBar.CloseToolbar();
                }
                StartBar.CloseToolbar();
            }, 250);
        }
Example #8
0
 /// <summary>
 /// Toggles the wait dialog.
 /// </summary>
 /// <param name="circles">if set to <c>true</c> [circles].</param>
 /// <param name="text">The text.</param>
 /// <remarks>...</remarks>
 internal void ToggleWaitDialog(bool circles = true, string text = null)
 {
     if (WaitDialog == null || !WaitDialog.IsLoaded)
     {
         WaitDialog = new WaitWindow();
         WaitDialog.Show();
         if (!string.IsNullOrWhiteSpace(text))
         {
             WaitDialog.Text.Text = text;
         }
         WaitDialog.Start(circles);
     }
     else
     {
         WaitDialog.Stop();
         ThreadingExtensions.LazyInvokeThreadSafe(() => {
             WaitDialog.Hide();
             WaitDialog.Close();
             WaitDialog = null;
         }, 600);
         WinAPI.FlushMemory();
     }
 }
Example #9
0
        private void AnimateClose()
        {
            switch (this.Animation)
            {
            case AnimationType.Custom: {
                this.Topmost     = false;
                this.IsHubActive = false;
                this.Close();
            }
            break;

            case AnimationType.Internal:
            default: {
                var leftanimation = new DoubleAnimation()
                {
                    To                = -this.ActualWidth,
                    Duration          = new Duration(TimeSpan.FromMilliseconds(180)),
                    BeginTime         = TimeSpan.FromMilliseconds(1),
                    AccelerationRatio = 0.7,
                    DecelerationRatio = 0,
                };
                leftanimation.Completed += (a, b) => {
                    this.Left = -this.ActualWidth;

                    leftanimation = null;
                    ThreadingExtensions.LazyInvokeThreadSafe(new Action(() => {
                            IsHubActive = false;
                            Topmost     = false;
                            Hide();
                            Close();
                        }), TimeSpan.FromMilliseconds(1));
                };
                this.BeginAnimation(LeftProperty, leftanimation);
            }
            break;
            }
        }
Example #10
0
        /// <summary>
        /// Initializes the component.
        /// </summary>
        public void InitializeComponent()
        {
            Api.CallHubOpening();

            try {
                this.Style = (Style)Application.Current.Resources["ResetWindowStyle"];
            }
            catch /* Eat */ { /* Tasty ? */ }

            this.Left    = 0;
            this.Top     = 0;
            this.Opacity = 0;
#if DEBUG
            this.Topmost = false;
#else
            this.Topmost = true;
#endif
            this.ShowInTaskbar = false;
            this.WindowStyle   = WindowStyle.None;
            this.ResizeMode    = ResizeMode.NoResize;

            this.VisualBitmapScalingMode = BitmapScalingMode.HighQuality;
            this.VisualClearTypeHint     = ClearTypeHint.Auto;
            this.VisualTextHintingMode   = TextHintingMode.Auto;
            this.VisualTextRenderingMode = TextRenderingMode.Auto;
            this.VisualEdgeMode          = EdgeMode.Unspecified;

            this.Effect = new DropShadowEffect()
            {
                BlurRadius = 25, Color = Colors.Black, ShadowDepth = 3, Direction = 270
            };

            this.ResetUICulture();

            ThreadingExtensions.LazyInvokeThreadSafe(() => AnimateStart(), TimeSpan.FromMilliseconds(180));
        }
Example #11
0
 /// <summary>
 /// Loads this instance.
 /// </summary>
 /// <remarks>...</remarks>
 public void Load()
 {
     listTimer  = ThreadingExtensions.LazyInvokeThreadSafe(UpdateList, 100);
     feedsTimer = ThreadingExtensions.LazyInvoke(UpdateFeeds, 7500);
 }
Example #12
0
 /// <summary>
 /// Handles the <see cref="E:RefreshItemClick" /> 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 OnRefreshItemClick(object sender, RoutedEventArgs e)
 {
     App.Screen.ToggleWaitDialog();
     ThreadingExtensions.LazyInvokeThreadSafe(() => App.Screen.ToggleWaitDialog(), 250);
     ThreadingExtensions.LazyInvoke(() => WinAPI.FlushMemory(), 300);
 }
Example #13
0
        private void TickDragScroll(object sender, EventArgs e)
        {
            try { if (hscroll == null)
                  {
                      hscroll = this.Template.FindName("PART_HorizontalScrollBar", this) as FrameworkElement;
                  }
            }
            catch (Exception ex) { Api.Logger.LogError(ex); }
            if (_isDragging)
            {
                //if (VerticalScrollBarVisibility == ScrollBarVisibility.Disabled)
                //    Cursor = Cursors.SizeWE;
                //    if (HorizontalScrollBarVisibility == ScrollBarVisibility.Disabled)
                //        Cursor = Cursors.SizeNS;
                if (hscroll != null)
                {
                    AnimationExtensions.Animate(this.hscroll, OpacityProperty, 250, 1);
                }
                if (HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
                }
                GeneralTransform generalTransform         = this.TransformToVisual(this);
                Point            childToParentCoordinates = generalTransform.Transform(new Point(0, 0));
                Rect             bounds = new Rect(childToParentCoordinates, this.RenderSize);

                if (bounds.Contains(_currentPoint))
                {
                    PerformScroll(PreviousVelocity);
                }

                if (!_mouseDown)
                {
                    CancelDrag(Velocity);
                }
                _previousPreviousPoint = _previousPoint;
                _previousPoint         = _currentPoint;
            }
            else if (Momentum.Length > 0)
            {
                Momentum *= (1.0 - _friction / 4.0);
                PerformScroll(Momentum);

                /*if (Momentum.Length < 0.1)
                 *  VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;*/
                if (hscroll != null)
                {
                    AnimationExtensions.Animate(hscroll, OpacityProperty, 250, 0);
                }
                ThreadingExtensions.LazyInvokeThreadSafe(new Action(() => { if (HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                                                                            {
                                                                                HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
                                                                            }
                                                                    }), 250);
                Cursor = Cursors.Arrow;
            }
            else
            {
                if (DragFinished != null)
                {
                    DragFinished(this, EventArgs.Empty);
                }
                if (_dragScrollTimer != null)
                {
                    _dragScrollTimer.Tick -= TickDragScroll;
                    _dragScrollTimer.Stop();
                    _dragScrollTimer = null;
                    //VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
                    if (hscroll != null)
                    {
                        AnimationExtensions.Animate(hscroll, OpacityProperty, 250, 0);
                    }
                    ThreadingExtensions.LazyInvokeThreadSafe(new Action(() => { if (HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                                                                                {
                                                                                    HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
                                                                                }
                                                                        }), 250);
                    Cursor = Cursors.Arrow;
                }
            }
        }
Example #14
0
        /// <summary>
        /// Closes the toolbar.
        /// </summary>
        /// <remarks>...</remarks>
        public virtual void CloseToolbar()
        {
            if (ContextMenu != null && ContextMenu.IsOpen)
            {
                return;
            }

            switch (Location)
            {
            case ToolbarLocation.Top:
                AnimationExtensions.Animate(
                    this,
                    Window.TopProperty,
                    DEFAULT_ANIM_TIME,
                    -Height,
                    0.3,
                    0.7,
                    false
                    );
                break;

            case ToolbarLocation.Bottom:
                AnimationExtensions.Animate(
                    this,
                    Window.TopProperty,
                    DEFAULT_ANIM_TIME,
                    SystemParameters.PrimaryScreenHeight,
                    0.3,
                    0.7,
                    false
                    );
                break;

            case ToolbarLocation.Left:
                AnimationExtensions.Animate(
                    this,
                    Window.LeftProperty,
                    DEFAULT_ANIM_TIME,
                    -Width + 7.0,
                    0.3,
                    0.7,
                    false
                    );
                break;

            case ToolbarLocation.Right:
                AnimationExtensions.Animate(
                    this,
                    Window.LeftProperty,
                    DEFAULT_ANIM_TIME,
                    SystemParameters.PrimaryScreenWidth - 7.0,
                    0.3,
                    0.7,
                    false
                    );
                break;

            case ToolbarLocation.None:
            default:
                break;
            }

            IsOpened = false;

            ThreadingExtensions.LazyInvokeThreadSafe(() => {
                TouchDecorator.Opacity   = 0.01;
                ContentDecorator.Opacity = 0;
            }, DEFAULT_ANIM_TIME);

            App.Screen.ZOrderHelper();

            WinAPI.RemoveFromDWM(this);
        }
        public void Start(Settings settings, Canvas artBoard)
        {
            artBoard.Children.Clear();

            image2 = new Image()
            {
                Stretch = System.Windows.Media.Stretch.Fill
            };
            artBoard.Children.Add(image2);
            image2.SetValue(Canvas.LeftProperty, 0);

            image1 = new Image()
            {
                Stretch = System.Windows.Media.Stretch.Fill
            };
            artBoard.Children.Add(image1);
            image1.SetValue(Canvas.LeftProperty, 0);

            var w = (int)SystemParameters.PrimaryScreenWidth;
            var h = (int)SystemParameters.PrimaryScreenHeight;

            var image    = new System.Drawing.Bitmap(w, h);
            var graphics = System.Drawing.Graphics.FromImage(image);

            graphics.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size(w, h));
            graphics.Dispose();

            BitmapSource result;

            if (image == null)
            {
                result = null;
                return;
            }
            else
            {
                result = Imaging.CreateBitmapSourceFromHBitmap(image.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            }

            image1.Source = result;
            image1.Width  = w;
            image1.Height = h;
            image2.Width  = w;
            image2.Height = h;

            AnimationExtensions.Animate(
                image1, Canvas.LeftProperty,
                750, 0, -SystemParameters.PrimaryScreenWidth,
                0.7, 0.3
                );

            ThreadingExtensions.LazyInvokeThreadSafe(new Action(() => {
                artBoard.Visibility = Visibility.Collapsed;

                {
                    if (settings.SlideShowImages.Count > 1)
                    {
                        artBoard.Visibility = Visibility.Visible;

                        image1.Source = new BitmapImage(new Uri(
                                                            settings.SlideShowImages[(new Random()).Next(0, settings.SlideShowImages.Count - 1)], UriKind.Absolute)
                                                        );

                        timer = Application.Current.Dispatcher.RunFor(() => {
                            try {
                                image2.Source = new BitmapImage(new Uri(
                                                                    settings.SlideShowImages[(new Random()).Next(0, settings.SlideShowImages.Count - 1)], UriKind.Absolute)
                                                                );

                                AnimationExtensions.Animate(
                                    image1, Canvas.LeftProperty,
                                    750, 0, -SystemParameters.PrimaryScreenWidth, null,
                                    0.7, 0.3, false, 1, null, FillBehavior.HoldEnd,
                                    (a, b) => {
                                    try {
                                        image1.Source = image2.Source;
                                    }
                                    catch { }
                                }
                                    , null);
                            }
                            catch { }
                        }, -1, settings.SlideShowTime * 750);
                    }
                }
            }), 1200);
        }