Ejemplo n.º 1
0
        public void AnimateWindow(double isOpen, bool isForced)
        {
            if (isAnimating && !isForced)
            {
                return;
            }
            isAnimating = true;

            Pref.Visible = isOpen > 0 ? true : false;
            if (isOpen == 0)
            {
                windowSwitch.canTouch = false;
            }
            this.Focusable = true;
            this.Topmost   = false; this.Topmost = true;
            this.Activate();

            if (isOpen > 0)
            {
                this.WindowState = WindowState.Normal;
            }

            if (Pref.PrefVisible)
            {
                buttonPref.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }
            if (!Pref.Visible)
            {
                Layout.ReplaceSelector(-1);
            }

            Storyboard sb = new Storyboard();

            ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-200 * isOpen + 30, 0, 0, 0), new Thickness(-100 * (1 - isOpen) + 30, 0, 0, 0), TimeSpan.FromMilliseconds(300))
            {
                BeginTime = TimeSpan.FromMilliseconds(50 * isOpen),
            };

            if (isOpen > 0)
            {
                ta.EasingFunction = new ExponentialEase()
                {
                    Exponent = 5, EasingMode = EasingMode.EaseOut
                };
            }
            else
            {
                ta.EasingFunction = new ExponentialEase()
                {
                    Exponent = 6, EasingMode = EasingMode.EaseInOut
                };
            }

            Storyboard.SetTarget(ta, gridMain);
            Storyboard.SetTargetProperty(ta, new PropertyPath(Grid.MarginProperty));
            sb.Children.Add(ta);

            DoubleAnimation da3 = new DoubleAnimation(isOpen, TimeSpan.FromMilliseconds(200))
            {
                BeginTime = TimeSpan.FromMilliseconds(100),
            };

            Storyboard.SetTarget(da3, this);
            Storyboard.SetTargetProperty(da3, new PropertyPath(Window.OpacityProperty));
            sb.Children.Add(da3);

            sb.Completed += (o, e) => {
                windowSwitch.canTouch = true;
                isAnimating           = false;
                this.Activate();

                if (!Pref.Visible)
                {
                    SendWpfWindowBack(this);
                    this.WindowState = WindowState.Minimized;
                }
            };

            sb.Begin(this);
        }
Ejemplo n.º 2
0
        // Debute le shift des lettres
        private void StartAnimateShiftSecretWord()
        {
            // Margins pour positioner les lettres un par un
            double       marginLeftCenter  = 0;
            double       marginTop         = 0;
            double       marginCurrentLeft = 0;
            const double letterSpacing     = 0.60;

            // Calcul MarginLeftcenter
            foreach (Label letter in listNonUsedLetters)
            {
                /* Je fais le width et le height egal a son current width et height
                 * pour que la grosseur des bordures des lettres ne changent pas apres mon calcul.
                 */
                letter.Width  = letter.ActualWidth;
                letter.Height = letter.ActualHeight;

                // Rajoute le width
                marginLeftCenter += letter.ActualWidth;
            }

            /* Je cherhce le margin qui va centrer les lettres puis je soustrait le dixieme
             * du de beut et la fin des lettre a cause que le content des labels sont Centered.
             */
            marginLeftCenter = (grdGameScreen.ActualWidth - marginLeftCenter * letterSpacing) / 2 -
                               (listNonUsedLetters[0].Width + listNonUsedLetters[listNonUsedLetters.Count - 1].Width) * 0.1;

            // Calcul MarginTop
            marginTop         = (grdGameScreen.ActualHeight - cellSize) / 2;
            marginCurrentLeft = 0;

            for (int i = 0; i < listNonUsedLetters.Count; ++i)
            {
                Label letter = listNonUsedLetters[i];

                Point relativePos = letter.TransformToAncestor(grdGameScreen).Transform(new Point(0, 0));

                // Enleves les lettres de la grille
                grdLettres.Children.Remove(letter);
                // Mets les dans le gamescreen
                grdGameScreen.Children.Add(letter);

                // Je mets ces alignements car on calcul selon le margin
                letter.HorizontalContentAlignment = HorizontalAlignment.Center;
                letter.HorizontalAlignment        = HorizontalAlignment.Left;
                letter.VerticalAlignment          = VerticalAlignment.Top;

                letter.Margin = new Thickness(relativePos.X, relativePos.Y, 0, 0);

                // Shift les lettres dans leur ordre

                ThicknessAnimation anim = new ThicknessAnimation(new Thickness(marginLeftCenter + marginCurrentLeft, marginTop, 0, 0), TimeSpan.FromMilliseconds(3000 + i * 60))
                {
                    EasingFunction = new QuarticEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                };

                // Met les after effects apres la fin de la derniere animation
                if (i == listNonUsedLetters.Count - 1)
                {
                    anim.Completed += StartAnimateBounceWord;
                }

                letter.BeginAnimation(MarginProperty, anim);

                // Rajoute un margin par lettre selon leur width
                marginCurrentLeft += letter.Width * letterSpacing;
            }
        }
Ejemplo n.º 3
0
        private void BeginTranslate(Size size, int nowTime, int nextTime)
        {
            _myStoryboard?.Stop();
            _myStoryboard?.Remove();
            LyricBar.ClearValue(Border.MarginProperty);
            double viewWidth = CutView.MaxWidth, width = size.Width;

            if (width <= viewWidth)
            {
                return;
            }
            else
            {
                Logger.Debug($@"{size.Width}>{viewWidth}");
            }

            //const double minInterval = 0.5;
            //if (nextTime - nowTime < minInterval) return;
            var    interval  = nextTime == -1 ? 4000 : (nextTime - nowTime);
            double startTime = interval / 5 > 3000 ? 3000 : interval / 5;
            double duration;

            if (nextTime == -1)
            {
                duration = 3000;
            }
            else
            {
                if (nextTime - nowTime < 10000)
                {
                    if (interval - startTime < 1000)
                    {
                        duration = interval - startTime;
                    }
                    else
                    {
                        duration = interval - startTime - 1000;
                    }
                }
                else
                {
                    duration = 10000 - startTime - 1000;
                }
            }

            Logger.Debug(@"{0}->{1}, start: {2}, duration: {3}",
                         0, viewWidth - width, startTime, duration);
            var defaultAnimation = new ThicknessAnimation
            {
                From      = new Thickness(0),
                To        = new Thickness(0),
                BeginTime = TimeSpan.FromMilliseconds(0),
                Duration  = /*CommonUtils.GetDuration*/ (TimeSpan.FromMilliseconds(startTime))
            };
            var translateAnimation = new ThicknessAnimation
            {
                From      = new Thickness(0),
                To        = new Thickness(viewWidth - width - 16, 0, 0, 0),
                BeginTime = TimeSpan.FromMilliseconds(startTime),
                Duration  = /*CommonUtils.GetDuration*/ (TimeSpan.FromMilliseconds(duration))
            };

            Storyboard.SetTarget(defaultAnimation, LyricBar);
            Storyboard.SetTarget(translateAnimation, LyricBar);

            Storyboard.SetTargetProperty(defaultAnimation, new PropertyPath(Border.MarginProperty));
            Storyboard.SetTargetProperty(translateAnimation, new PropertyPath(Border.MarginProperty));

            _myStoryboard = new Storyboard();
            _myStoryboard.Children.Add(defaultAnimation);
            _myStoryboard.Children.Add(translateAnimation);

            _myStoryboard.Begin();
        }
Ejemplo n.º 4
0
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.Parent != null && this.Parent is FrameworkElement)
            {
                FrameworkElement parent = this.Parent as FrameworkElement;
                _move    = true;
                _lastPos = e.GetPosition(parent);
                _oldPos  = _lastPos;

                parent.PreviewMouseMove += (s, ee) =>
                {
                    if (_move)
                    {
                        Point  pos  = ee.GetPosition(parent);
                        double left = this.Margin.Left + pos.X - this._lastPos.X;
                        double top  = this.Margin.Top + pos.Y - this._lastPos.Y;
                        this.Margin = new Thickness(left, top, 0, 0);

                        _lastPos = e.GetPosition(parent);
                    }
                };

                parent.PreviewMouseUp += (s, ee) =>
                {
                    if (_move)
                    {
                        _move = false;

                        Point pos = ee.GetPosition(parent);
                        _newPos = pos;
                        double left   = this.Margin.Left + pos.X - this._lastPos.X;
                        double top    = this.Margin.Top + pos.Y - this._lastPos.Y;
                        double right  = parent.ActualWidth - left - this.ActualWidth;
                        double bottom = parent.ActualHeight - top - this.ActualHeight;

                        if (left < _distance && top < _distance) //左上
                        {
                            left = this._distanceNew;
                            top  = this._distanceNew;
                        }
                        else if (left < _distance && bottom < _distance) //左下
                        {
                            left = this._distanceNew;
                            top  = parent.ActualHeight - this.ActualHeight - this._distanceNew;
                        }
                        else if (right < _distance && top < _distance) //右上
                        {
                            left = parent.ActualWidth - this.ActualWidth - this._distanceNew;
                            top  = this._distanceNew;
                        }
                        else if (right < _distance && bottom < _distance) //右下
                        {
                            left = parent.ActualWidth - this.ActualWidth - this._distanceNew;
                            top  = parent.ActualHeight - this.ActualHeight - this._distanceNew;
                        }
                        else if (left < _distance && top > _distance && bottom > _distance) //左
                        {
                            left = this._distanceNew;
                            top  = this.Margin.Top;
                        }
                        else if (right < _distance && top > _distance && bottom > _distance) //右
                        {
                            left = parent.ActualWidth - this.ActualWidth - this._distanceNew;
                            top  = this.Margin.Top;
                        }
                        else if (top < _distance && left > _distance && right > _distance) //上
                        {
                            left = this.Margin.Left;
                            top  = this._distanceNew;
                        }
                        else if (bottom < _distance && left > _distance && right > _distance) //下
                        {
                            left = this.Margin.Left;
                            top  = parent.ActualHeight - this.ActualHeight - this._distanceNew;
                        }

                        ThicknessAnimation marginAnimation = new ThicknessAnimation();
                        marginAnimation.From     = this.Margin;
                        marginAnimation.To       = new Thickness(left, top, 0, 0);
                        marginAnimation.Duration = TimeSpan.FromMilliseconds(200);

                        Storyboard story = new Storyboard();
                        story.FillBehavior = FillBehavior.Stop;
                        story.Children.Add(marginAnimation);
                        Storyboard.SetTargetName(marginAnimation, "btn");
                        Storyboard.SetTargetProperty(marginAnimation, new PropertyPath("(0)", Border.MarginProperty));

                        story.Begin(this);

                        this.Margin = new Thickness(left, top, 0, 0);
                    }
                };
            }
        }
Ejemplo n.º 5
0
        private void optionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            String s = (string)((ListBox)sender).SelectedItem;

            if (s == null)
            {
                return;
            }
            Room selectedroom = (Room)actions[s];

            (selectedroom).Visibility      = Visibility.Visible;
            ((ListBox)sender).SelectedItem = null;

            //v sloppy, revist later

            DoomsdayClock.Content = Time;
            Grid     g        = (Grid)this.Parent;
            Grid     roomgrid = (Grid)g.Parent;
            GameGrid game     = (GameGrid)roomgrid.Parent;

            ThicknessAnimation animation = new ThicknessAnimation();


            Thickness oldCenter = game.currentRoom.Margin;
            Thickness newCenter = selectedroom.Margin;
            Thickness oldMargin = roomgrid.Margin;



            //roomgrid.Margin =
            Thickness newMargin = new Thickness(oldMargin.Left + (oldCenter.Left - newCenter.Left),
                                                oldMargin.Top + (oldCenter.Top - newCenter.Top),
                                                oldMargin.Right + (oldCenter.Right - newCenter.Right),
                                                oldMargin.Bottom + (oldCenter.Bottom - newCenter.Bottom));


            animation.From = oldMargin;
            animation.To   = newMargin;

            PowerEase pe = new PowerEase();

            pe.EasingMode = EasingMode.EaseInOut; pe.Power = 3;

            animation.EasingFunction = pe;
            animation.Duration       = new Duration(TimeSpan.FromSeconds(.5));

            roomgrid.BeginAnimation(Grid.MarginProperty, animation);

            List <Room> desc = game.currentRoom.getalldescendents();

            game.currentRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));

            // game.StartRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));
            }

            game.currentRoom = selectedroom;

            desc = game.currentRoom.getalldescendents();

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));
            }


            game.window.DoomsdayClock.Content = Time;

            game.adjustBG(Time);


            selectedroom.BGgrid.Background = Brushes.Blue;
            //CHANGE CHARA LOC

            if (oldCenter.Left == newCenter.Left)
            {
                game.window.avatar.standstill();
            }
            else if (oldCenter.Left < newCenter.Left)//traveling forward
            {
                game.window.avatar.fwd();
            }
            else
            {
                game.window.avatar.bwd();
            }
        }
Ejemplo n.º 6
0
        private void AnimateOut()
        {
            EventHandler outAnimationCompletedHandler  = null;
            EventHandler sizeAnimationCompletedHandler = null;

            var sizeAnimation = new DoubleAnimation()
            {
                From      = this.ActualHeight,
                To        = 0,
                Duration  = TimeSpan.FromMilliseconds(200),
                BeginTime = TimeSpan.FromMilliseconds(200)
            };

            sizeAnimationCompletedHandler = (s, ea) =>
            {
                sizeAnimation.Completed -= sizeAnimationCompletedHandler;

                this.Close();
            };

            sizeAnimation.Completed += sizeAnimationCompletedHandler;

            if (SlideIn)
            {
                var slideOutAnimation = new ThicknessAnimation()
                {
                    To       = new Thickness((ActualWidth + 10), MARGIN, 0, MARGIN),
                    Duration = TimeSpan.FromMilliseconds(300)
                };

                outAnimationCompletedHandler = (s, ea) =>
                {
                    slideOutAnimation.Completed -= outAnimationCompletedHandler;

                    this.BeginAnimation(HeightProperty, sizeAnimation);
                };

                slideOutAnimation.Completed += outAnimationCompletedHandler;

                this.BeginAnimation(MarginProperty, slideOutAnimation);
            }
            else
            {
                var fadeOutAnimation = new DoubleAnimation()
                {
                    From     = 1,
                    To       = 0,
                    Duration = TimeSpan.FromMilliseconds(200)
                };

                outAnimationCompletedHandler = (s, ea) =>
                {
                    fadeOutAnimation.Completed -= outAnimationCompletedHandler;

                    this.BeginAnimation(HeightProperty, sizeAnimation);
                };

                fadeOutAnimation.Completed += outAnimationCompletedHandler;

                this.BeginAnimation(OpacityProperty, fadeOutAnimation);
            }
        }
Ejemplo n.º 7
0
        // public static readonlyRoutedEvent
        private void FloatButton2_Loaded(object sender, RoutedEventArgs e)
        {
            if (MinEdgeDist > MinMagneticSuctionDist)
            {
                MinMagneticSuctionDist = MinEdgeDist * 2;
            }
            if (this.Parent != null && this.Parent is FrameworkElement)
            {
                FrameworkElement parent = this.Parent as FrameworkElement;
                double           left1  = parent.ActualWidth - PGrid.ActualWidth - this.MinEdgeDist;
                double           top1   = parent.ActualHeight - PGrid.ActualHeight - this.MinEdgeDist;
                this.Margin = new Thickness(left1, top1, 0, 0);

                parent.PreviewMouseMove += (s, ee) =>
                {
                    if (_move)
                    {
                        Point  pos  = ee.GetPosition(parent);
                        double left = this.Margin.Left + pos.X - this._lastPos.X;
                        double top  = this.Margin.Top + pos.Y - this._lastPos.Y;
                        this.Margin = new Thickness(left, top, 0, 0);

                        _lastPos = ee.GetPosition(parent);
                    }
                };

                parent.PreviewMouseUp += (s, ee) =>
                {
                    if (_move)
                    {
                        _move = false;

                        Point pos = ee.GetPosition(parent);
                        _newPos = pos;
                        double left   = this.Margin.Left + pos.X - this._lastPos.X;
                        double top    = this.Margin.Top + pos.Y - this._lastPos.Y;
                        double right  = parent.ActualWidth - left - PGrid.ActualWidth;
                        double bottom = parent.ActualHeight - top - PGrid.ActualHeight;

                        //textBlocklast.Text = "l.X:" + _lastPos.X + "l.Y: " + _lastPos.Y;
                        //textBlockm.Text = "M.l:" + Margin.Left + "M.t: " +Margin.Top;
                        //textBlock.Text = "left:" + left + "top: " + top;

                        if (left < MinMagneticSuctionDist && top < MinMagneticSuctionDist) //左上
                        {
                            left = this.MinEdgeDist;
                            top  = this.MinEdgeDist;
                        }
                        else if (left < MinMagneticSuctionDist && bottom < MinMagneticSuctionDist) //左下
                        {
                            left = this.MinEdgeDist;
                            top  = parent.ActualHeight - PGrid.ActualHeight - this.MinEdgeDist;
                        }
                        else if (right < MinMagneticSuctionDist && top < MinMagneticSuctionDist) //右上
                        {
                            left = parent.ActualWidth - PGrid.ActualWidth - this.MinEdgeDist;
                            top  = this.MinEdgeDist;
                        }
                        else if (right < MinMagneticSuctionDist && bottom < MinMagneticSuctionDist) //右下
                        {
                            left = parent.ActualWidth - PGrid.ActualWidth - this.MinEdgeDist;
                            top  = parent.ActualHeight - PGrid.ActualHeight - this.MinEdgeDist;
                        }
                        else if (left < MinMagneticSuctionDist && top > MinMagneticSuctionDist && bottom > MinMagneticSuctionDist) //左
                        {
                            left = this.MinEdgeDist;
                            top  = this.Margin.Top;
                        }
                        else if (right < MinMagneticSuctionDist && top > MinMagneticSuctionDist && bottom > MinMagneticSuctionDist) //右
                        {
                            left = parent.ActualWidth - PGrid.ActualWidth - this.MinEdgeDist;
                            top  = this.Margin.Top;
                        }
                        else if (top < MinMagneticSuctionDist && left > MinMagneticSuctionDist && right > MinMagneticSuctionDist) //上
                        {
                            left = this.Margin.Left;
                            top  = this.MinEdgeDist;
                        }
                        else if (bottom < MinMagneticSuctionDist && left > MinMagneticSuctionDist && right > MinMagneticSuctionDist) //下
                        {
                            left = this.Margin.Left;
                            top  = parent.ActualHeight - PGrid.ActualHeight - this.MinEdgeDist;
                        }

                        ThicknessAnimation marginAnimation = new ThicknessAnimation();
                        marginAnimation.From     = this.Margin;
                        marginAnimation.To       = new Thickness(left, top, 0, 0);
                        marginAnimation.Duration = TimeSpan.FromMilliseconds(200);

                        Storyboard story = new Storyboard();
                        story.FillBehavior = FillBehavior.Stop;
                        story.Children.Add(marginAnimation);
                        //Storyboard.SetTargetName(marginAnimation, "btn");
                        Storyboard.SetTarget(marginAnimation, this);
                        Storyboard.SetTargetProperty(marginAnimation, new PropertyPath("(0)", Border.MarginProperty));

                        story.Begin(this);

                        this.Margin = new Thickness(left, top, 0, 0);
                    }
                };
            }
        }
Ejemplo n.º 8
0
        private void playListNext_MouseDown(object sender, MouseButtonEventArgs e)
        {
            window = App.Current.MainWindow as MainWindow;
            if (IsAnimatible)
            {
                playListCurrentAnimatable = InitNewTextBox(playListCurrent);
                playListNextAnimatable    = InitNewTextBox(playListNext);
                playListPrevAnimatable    = InitNewTextBox(playListPrev);
                playListFreeAnimatable    = InitNewTextBox(playListNext);
                if (window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListNext.Text).ElementAt(0)) == window.collectionOfPlayLists.playLists.Count - 1)
                {
                    playListFreeAnimatable.Text = window.collectionOfPlayLists.playLists[0].Name;
                }
                else
                {
                    playListFreeAnimatable.Text = window.collectionOfPlayLists.playLists[window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListNext.Text).ElementAt(0)) + 1].Name;
                }

                playListCurrent.Visibility = System.Windows.Visibility.Hidden;
                playListPrev.Visibility    = System.Windows.Visibility.Hidden;
                playListNext.Visibility    = System.Windows.Visibility.Hidden;

                ThicknessAnimation animationOfLeft = new ThicknessAnimation();
                animationOfLeft.From     = new Thickness(-326, 0, 0, 0);
                animationOfLeft.To       = new Thickness(-726, 0, 0, 0);
                animationOfLeft.Duration = TimeSpan.FromSeconds(1);
                playListPrevAnimatable.BeginAnimation(TextBlock.MarginProperty, animationOfLeft);

                animationOfLeft          = new ThicknessAnimation();
                animationOfLeft.From     = new Thickness(0, 0, 0, 0);
                animationOfLeft.To       = new Thickness(-326, 0, 0, 0);
                animationOfLeft.Duration = TimeSpan.FromSeconds(1);
                playListCurrentAnimatable.BeginAnimation(TextBlock.MarginProperty, animationOfLeft);

                animationOfLeft          = new ThicknessAnimation();
                animationOfLeft.From     = new Thickness(326, 0, 0, 0);
                animationOfLeft.To       = new Thickness(0, 0, 0, 0);
                animationOfLeft.Duration = TimeSpan.FromSeconds(1);
                playListNextAnimatable.BeginAnimation(TextBlock.MarginProperty, animationOfLeft);

                animationOfLeft            = new ThicknessAnimation();
                animationOfLeft.From       = new Thickness(672, 0, 0, 0);
                animationOfLeft.To         = new Thickness(326, 0, 0, 0);
                animationOfLeft.Duration   = TimeSpan.FromSeconds(1);
                animationOfLeft.Completed += animationOfRight_Completed;
                playListFreeAnimatable.BeginAnimation(TextBlock.MarginProperty, animationOfLeft);
            }
            else
            {
                playListPrev.Text    = playListCurrent.Text;
                playListCurrent.Text = playListNext.Text;
                if (window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListNext.Text).ElementAt(0)) == window.collectionOfPlayLists.playLists.Count - 1)
                {
                    playListNext.Text = window.collectionOfPlayLists.playLists[0].Name;
                }
                else
                {
                    playListNext.Text = window.collectionOfPlayLists.playLists[window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListNext.Text).ElementAt(0)) + 1].Name;
                }
                playListView.Items.Clear();
                InitPlayListView(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0));
            }
        }
Ejemplo n.º 9
0
 public void AddDMText(string user, string text, bool warn)
 {
     if (user == null || text == null)
     {
         return;
     }
     if (Dispatcher.CheckAccess())
     {
         while (infos.Count >= 50)
         {
             infos.Dequeue();
         }
         if (warn)
         {
             infos.Enqueue($"! {text}\n");
         }
         else
         {
             if (string.IsNullOrEmpty(user))
             {
                 infos.Enqueue($"{text}\n");
             }
             else
             {
                 infos.Enqueue($"{user}: {text}\n");
             }
         }
         this.textBox.Text = string.Join("\n", infos);
         this.textBox.Focus();
         this.textBox.CaretIndex      = this.textBox.Text.Length;
         this.textBox.SelectionStart  = this.textBox.Text.Length;
         this.textBox.SelectionLength = 0;
         this.textBox.ScrollToEnd();
         if (true)
         {
             DanmakuTextControl danmakuTextControl = new DanmakuTextControl();
             danmakuTextControl.UserName.Text = user;
             if (warn)
             {
                 danmakuTextControl.UserName.Foreground = Brushes.Red;
                 danmakuTextControl.Text.Foreground     = Brushes.LightBlue;
             }
             text = text.Trim("\r\n ".ToCharArray());
             danmakuTextControl.Text.Text = text;
             danmakuTextControl.ChangeHeight();
             Storyboard storyboard = (Storyboard)danmakuTextControl.Resources["Storyboard1"];
             storyboard.Completed += new EventHandler(this.sb_Completed);
             this.overlay.LayoutRoot.Children.Add(danmakuTextControl);
         }
         if (!warn && showdanmu)
         {
             lock (this.fulloverlay.LayoutRoot.Children)
             {
                 FullScreenDanmaku fullScreenDanmaku = new FullScreenDanmaku();
                 fullScreenDanmaku.Text.Text = text;
                 fullScreenDanmaku.ChangeHeight();
                 double width = fullScreenDanmaku.Text.DesiredSize.Width;
                 Dictionary <double, bool> dictionary = new Dictionary <double, bool>();
                 dictionary.Add(0.0, true);
                 foreach (object current in this.fulloverlay.LayoutRoot.Children)
                 {
                     if (current is FullScreenDanmaku)
                     {
                         FullScreenDanmaku fullScreenDanmaku2 = current as FullScreenDanmaku;
                         if (!dictionary.ContainsKey((double)Convert.ToInt32(fullScreenDanmaku2.Margin.Top)))
                         {
                             dictionary.Add((double)Convert.ToInt32(fullScreenDanmaku2.Margin.Top), true);
                         }
                         if (fullScreenDanmaku2.Margin.Left > SystemParameters.PrimaryScreenWidth - width - 50.0)
                         {
                             dictionary[(double)Convert.ToInt32(fullScreenDanmaku2.Margin.Top)] = false;
                         }
                     }
                 }
                 double top;
                 if (dictionary.All(p => !p.Value))
                 {
                     top = dictionary.Max(p => p.Key) + fullScreenDanmaku.Text.DesiredSize.Height;
                 }
                 else
                 {
                     top = (from p in dictionary
                            where p.Value
                            select p).Min(p => p.Key);
                 }
                 Storyboard         storyboard2        = new Storyboard();
                 Duration           duration           = new Duration(TimeSpan.FromTicks(Convert.ToInt64((SystemParameters.PrimaryScreenWidth + width) / Store.FullOverlayEffect1 * 10000000.0)));
                 ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(SystemParameters.PrimaryScreenWidth, top, 0.0, 0.0), new Thickness(-width, top, 0.0, 0.0), duration);
                 storyboard2.Children.Add(thicknessAnimation);
                 storyboard2.Duration = duration;
                 Storyboard.SetTarget(thicknessAnimation, fullScreenDanmaku);
                 Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath("(FrameworkElement.Margin)", new object[0]));
                 this.fulloverlay.LayoutRoot.Children.Add(fullScreenDanmaku);
                 storyboard2.Completed += new EventHandler(this.s_Completed);
                 storyboard2.Begin();
             }
         }
     }
     else
     {
         this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate
         {
             this.AddDMText(user, text, warn);
         }));
     }
 }
Ejemplo n.º 10
0
        private void InitializeResources()
        {
            // Resource - [buttonAnimStyle] Style
            var    r_0_s_bo  = this[typeof(Button)];
            Style  r_0_s     = new Style(typeof(Button), r_0_s_bo as Style);
            Setter r_0_s_S_0 = new Setter(Button.WidthProperty, 200F);

            r_0_s.Setters.Add(r_0_s_S_0);
            Setter r_0_s_S_1 = new Setter(Button.MarginProperty, new Thickness(0F, 1F, 0F, 1F));

            r_0_s.Setters.Add(r_0_s_S_1);
            Setter r_0_s_S_2 = new Setter(Button.SnapsToDevicePixelsProperty, false);

            r_0_s.Setters.Add(r_0_s_S_2);
            EventTrigger r_0_s_ET_0 = new EventTrigger(Button.MouseEnterEvent);

            r_0_s.Triggers.Add(r_0_s_ET_0);
            BeginStoryboard r_0_s_ET_0_AC_0 = new BeginStoryboard();

            r_0_s_ET_0_AC_0.Name = "r_0_s_ET_0_AC_0";
            r_0_s_ET_0.AddAction(r_0_s_ET_0_AC_0);
            Storyboard r_0_s_ET_0_AC_0_SB = new Storyboard();

            r_0_s_ET_0_AC_0.Storyboard = r_0_s_ET_0_AC_0_SB;
            r_0_s_ET_0_AC_0_SB.Name    = "r_0_s_ET_0_AC_0_SB";
            ThicknessAnimation r_0_s_ET_0_AC_0_SB_TL_0 = new ThicknessAnimation();

            r_0_s_ET_0_AC_0_SB_TL_0.Name     = "r_0_s_ET_0_AC_0_SB_TL_0";
            r_0_s_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            r_0_s_ET_0_AC_0_SB_TL_0.From     = new Thickness(0F, 1F, 0F, 1F);
            r_0_s_ET_0_AC_0_SB_TL_0.To       = new Thickness(0F, 5F, 0F, 5F);
            SineEase r_0_s_ET_0_AC_0_SB_TL_0_EA = new SineEase();

            r_0_s_ET_0_AC_0_SB_TL_0.EasingFunction = r_0_s_ET_0_AC_0_SB_TL_0_EA;
            Storyboard.SetTargetProperty(r_0_s_ET_0_AC_0_SB_TL_0, Button.MarginProperty);
            r_0_s_ET_0_AC_0_SB.Children.Add(r_0_s_ET_0_AC_0_SB_TL_0);
            FloatAnimation r_0_s_ET_0_AC_0_SB_TL_1 = new FloatAnimation();

            r_0_s_ET_0_AC_0_SB_TL_1.Name     = "r_0_s_ET_0_AC_0_SB_TL_1";
            r_0_s_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            r_0_s_ET_0_AC_0_SB_TL_1.To       = 220F;
            SineEase r_0_s_ET_0_AC_0_SB_TL_1_EA = new SineEase();

            r_0_s_ET_0_AC_0_SB_TL_1.EasingFunction = r_0_s_ET_0_AC_0_SB_TL_1_EA;
            Storyboard.SetTargetProperty(r_0_s_ET_0_AC_0_SB_TL_1, Button.WidthProperty);
            r_0_s_ET_0_AC_0_SB.Children.Add(r_0_s_ET_0_AC_0_SB_TL_1);
            EventTrigger r_0_s_ET_1 = new EventTrigger(Button.MouseLeaveEvent);

            r_0_s.Triggers.Add(r_0_s_ET_1);
            BeginStoryboard r_0_s_ET_1_AC_0 = new BeginStoryboard();

            r_0_s_ET_1_AC_0.Name = "r_0_s_ET_1_AC_0";
            r_0_s_ET_1.AddAction(r_0_s_ET_1_AC_0);
            Storyboard r_0_s_ET_1_AC_0_SB = new Storyboard();

            r_0_s_ET_1_AC_0.Storyboard = r_0_s_ET_1_AC_0_SB;
            r_0_s_ET_1_AC_0_SB.Name    = "r_0_s_ET_1_AC_0_SB";
            ThicknessAnimation r_0_s_ET_1_AC_0_SB_TL_0 = new ThicknessAnimation();

            r_0_s_ET_1_AC_0_SB_TL_0.Name     = "r_0_s_ET_1_AC_0_SB_TL_0";
            r_0_s_ET_1_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            r_0_s_ET_1_AC_0_SB_TL_0.From     = new Thickness(0F, 5F, 0F, 5F);
            r_0_s_ET_1_AC_0_SB_TL_0.To       = new Thickness(0F, 1F, 0F, 1F);
            SineEase r_0_s_ET_1_AC_0_SB_TL_0_EA = new SineEase();

            r_0_s_ET_1_AC_0_SB_TL_0.EasingFunction = r_0_s_ET_1_AC_0_SB_TL_0_EA;
            Storyboard.SetTargetProperty(r_0_s_ET_1_AC_0_SB_TL_0, Button.MarginProperty);
            r_0_s_ET_1_AC_0_SB.Children.Add(r_0_s_ET_1_AC_0_SB_TL_0);
            FloatAnimation r_0_s_ET_1_AC_0_SB_TL_1 = new FloatAnimation();

            r_0_s_ET_1_AC_0_SB_TL_1.Name     = "r_0_s_ET_1_AC_0_SB_TL_1";
            r_0_s_ET_1_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            r_0_s_ET_1_AC_0_SB_TL_1.To       = 200F;
            SineEase r_0_s_ET_1_AC_0_SB_TL_1_EA = new SineEase();

            r_0_s_ET_1_AC_0_SB_TL_1.EasingFunction = r_0_s_ET_1_AC_0_SB_TL_1_EA;
            Storyboard.SetTargetProperty(r_0_s_ET_1_AC_0_SB_TL_1, Button.WidthProperty);
            r_0_s_ET_1_AC_0_SB.Children.Add(r_0_s_ET_1_AC_0_SB_TL_1);
            this.Add("buttonAnimStyle", r_0_s);
            // Resource - [buttonStyle] Style
            var    r_1_s_bo  = this[typeof(Button)];
            Style  r_1_s     = new Style(typeof(Button), r_1_s_bo as Style);
            Setter r_1_s_S_0 = new Setter(Button.BackgroundProperty, new SolidColorBrush(new ColorW(255, 140, 0, 255)));

            r_1_s.Setters.Add(r_1_s_S_0);
            Setter r_1_s_S_1 = new Setter(Button.WidthProperty, 200F);

            r_1_s.Setters.Add(r_1_s_S_1);
            Setter r_1_s_S_2 = new Setter(Button.PaddingProperty, new Thickness(2F));

            r_1_s.Setters.Add(r_1_s_S_2);
            this.Add("buttonStyle", r_1_s);
            // Resource - [logoEmptyKeys] BitmapImage
            BitmapImage r_2_bm = new BitmapImage();

            r_2_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall";
            this.Add("logoEmptyKeys", r_2_bm);
            // Resource - [MessageBoxButtonYes] String
            this.Add("MessageBoxButtonYes", "Yes!");
            // Resource - [Sounds] SoundSourceCollection
            var r_4_sounds = new SoundSourceCollection();

            SoundManager.Instance.AddSound("Click");
            r_4_sounds.Add(new SoundSource {
                SoundType = SoundType.ButtonsClick, SoundAsset = "Click", Volume = 1f
            });
            SoundManager.Instance.AddSound("KeyPress");
            r_4_sounds.Add(new SoundSource {
                SoundType = SoundType.TextBoxKeyPress, SoundAsset = "KeyPress", Volume = 1f
            });
            SoundManager.Instance.AddSound("Move");
            r_4_sounds.Add(new SoundSource {
                SoundType = SoundType.TabControlMove, SoundAsset = "Move", Volume = 1f
            });
            SoundManager.Instance.AddSound("Select");
            r_4_sounds.Add(new SoundSource {
                SoundType = SoundType.TabControlSelect, SoundAsset = "Select", Volume = 1f
            });
            this.Add("Sounds", r_4_sounds);
            // Resource - [TitleResource] String
            this.Add("TitleResource", "Basic UI Example");
            // Resource - [ToolTipText] String
            this.Add("ToolTipText", "Click to open message box");
            ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall");
            FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular");
            FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
        }
Ejemplo n.º 11
0
        private void timelineBoxItem_Click(object sender, MouseButtonEventArgs e)
        {
            Grid listItemGrid = (Grid)sender;
            Toot rawToot      = (Toot)listItemGrid.DataContext;

            if (e.ClickCount == 2)
            {
                rawToot.details_Click(sender, e);
                return;
            }

            Grid       listItemItems         = (Grid)listItemGrid.Children[0];
            StackPanel tootContentsContainer = (StackPanel)listItemItems.Children[4];
            StackPanel tootContents          = (StackPanel)tootContentsContainer.Children[0];
            Border     tootPadding           = (Border)tootContentsContainer.Children[2];
            Border     toolbarBorder         = (Border)listItemItems.Children[5];
            Thickness  margin  = toolbarBorder.Margin;
            Thickness  padding = tootPadding.Padding;

            ThicknessAnimation paddingAnimation = new ThicknessAnimation();

            paddingAnimation.From = padding;

            ThicknessAnimation marginAnimation = new ThicknessAnimation();

            marginAnimation.From = margin;

            if (MastodonAPIWrapper.sharedApiWrapper.nightModeEnabled && !rawToot.isStartToot)
            {
                toolbarBorder.Background = new SolidColorBrush(Color.FromArgb(255, 61, 61, 61));
            }
            else
            {
                toolbarBorder.Background = new SolidColorBrush(Color.FromArgb(255, 194, 194, 194));
            }

            if (padding.Bottom == 0)
            {
                padding.Bottom           = 35;
                margin.Bottom            = 0;
                toolbarBorder.Visibility = Visibility.Visible;
            }
            else if (padding.Bottom == 35)
            {
                padding.Bottom             = 0;
                margin.Bottom              = -35;
                marginAnimation.Completed += (sender2, e2) =>
                {
                    toolbarBorder.Visibility = Visibility.Collapsed;
                };
            }
            else
            {
                return;
            }

            paddingAnimation.To = padding;
            marginAnimation.To  = margin;

            Storyboard.SetTarget(paddingAnimation, tootPadding);
            Storyboard.SetTargetProperty(paddingAnimation, new PropertyPath(Border.PaddingProperty));

            Storyboard.SetTarget(marginAnimation, toolbarBorder);
            Storyboard.SetTargetProperty(marginAnimation, new PropertyPath(Border.MarginProperty));

            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(paddingAnimation);
            storyboard.Children.Add(marginAnimation);
            storyboard.SpeedRatio *= 3.5;
            storyboard.Begin();
        }
Ejemplo n.º 12
0
        private void timelineBoxItem_Enter(object sender, MouseEventArgs e)
        {
            return;

            Grid       listItemGrid          = (Grid)sender;
            Grid       listItemItems         = (Grid)listItemGrid.Children[0];
            StackPanel tootContentsContainer = (StackPanel)listItemItems.Children[4];
            StackPanel tootContents          = (StackPanel)tootContentsContainer.Children[0];
            Border     tootPadding           = (Border)tootContentsContainer.Children[2];
            Border     toolbarBorder         = (Border)listItemItems.Children[5];
            Thickness  margin  = toolbarBorder.Margin;
            Thickness  padding = tootPadding.Padding;
            Toot       rawToot;

            try
            {
                rawToot = (Toot)listItemGrid.DataContext;
            }
            catch (Exception)
            {
                return;
            }

            ThicknessAnimation paddingAnimation = new ThicknessAnimation();

            paddingAnimation.From = padding;

            ThicknessAnimation marginAnimation = new ThicknessAnimation();

            marginAnimation.From = margin;

            if (MastodonAPIWrapper.sharedApiWrapper.nightModeEnabled && !rawToot.isStartToot)
            {
                toolbarBorder.Background = new SolidColorBrush(Color.FromArgb(255, 61, 61, 61));
            }
            else
            {
                toolbarBorder.Background = new SolidColorBrush(Color.FromArgb(255, 194, 194, 194));
            }

            if (padding.Bottom != 35)
            {
                padding.Bottom           = 35;
                margin.Bottom            = 0;
                toolbarBorder.Visibility = Visibility.Visible;
            }
            else
            {
                return;
            }

            paddingAnimation.To = padding;
            marginAnimation.To  = margin;

            Storyboard.SetTarget(paddingAnimation, tootPadding);
            Storyboard.SetTargetProperty(paddingAnimation, new PropertyPath(Border.PaddingProperty));

            Storyboard.SetTarget(marginAnimation, toolbarBorder);
            Storyboard.SetTargetProperty(marginAnimation, new PropertyPath(Border.MarginProperty));

            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(paddingAnimation);
            storyboard.Children.Add(marginAnimation);
            storyboard.SpeedRatio *= 3.5;
            storyboard.Begin();

            /*Grid listItemGrid = (Grid)sender;
             * Toot boundData = (Toot)listItemGrid.DataContext;
             * Grid listItemItems = (Grid)listItemGrid.Children[0];
             * StackPanel tootContentsContainer = (StackPanel)listItemItems.Children[4];
             * StackPanel tootContents = (StackPanel)tootContentsContainer.Children[0];
             * StackPanel shareDetails = (StackPanel)tootContents.Children[5];
             * if (boundData.numFavorites > 0 || boundData.numRetoots > 0)
             *  shareDetails.Visibility = Visibility.Visible;*/
        }
Ejemplo n.º 13
0
        internal static void HideOverlay()
        {
            var moveAnimation = new ThicknessAnimation(new Thickness(2000, 0, -2000, 0), TimeSpan.FromSeconds(0.5));

            OverlayGrid.BeginAnimation(Grid.MarginProperty, moveAnimation);
        }
Ejemplo n.º 14
0
 private void InitializeResources() {
     // Resource - [HydrogenIcon] BitmapImage
     BitmapImage r_0_bm = new BitmapImage();
     r_0_bm.TextureAsset = "ImagesUI/hydrogen_res";
     this.Add("HydrogenIcon", r_0_bm);
     // Resource - [BiomassIcon] BitmapImage
     BitmapImage r_1_bm = new BitmapImage();
     r_1_bm.TextureAsset = "ImagesUI/biomass_res";
     this.Add("BiomassIcon", r_1_bm);
     // Resource - [CopperIcon] BitmapImage
     BitmapImage r_2_bm = new BitmapImage();
     r_2_bm.TextureAsset = "ImagesUI/copper_res";
     this.Add("CopperIcon", r_2_bm);
     // Resource - [LeadIcon] BitmapImage
     BitmapImage r_3_bm = new BitmapImage();
     r_3_bm.TextureAsset = "ImagesUI/lead_res";
     this.Add("LeadIcon", r_3_bm);
     // Resource - [AluminiumIcon] BitmapImage
     BitmapImage r_4_bm = new BitmapImage();
     r_4_bm.TextureAsset = "ImagesUI/aluminium_res";
     this.Add("AluminiumIcon", r_4_bm);
     // Resource - [NaturalGasIcon] BitmapImage
     BitmapImage r_5_bm = new BitmapImage();
     r_5_bm.TextureAsset = "ImagesUI/gas_res";
     this.Add("NaturalGasIcon", r_5_bm);
     // Resource - [PropaneIcon] BitmapImage
     BitmapImage r_6_bm = new BitmapImage();
     r_6_bm.TextureAsset = "ImagesUI/propane_res";
     this.Add("PropaneIcon", r_6_bm);
     // Resource - [DiamondIcon] BitmapImage
     BitmapImage r_7_bm = new BitmapImage();
     r_7_bm.TextureAsset = "ImagesUI/diamond_res";
     this.Add("DiamondIcon", r_7_bm);
     // Resource - [MonoGameLogo] BitmapImage
     BitmapImage r_8_bm = new BitmapImage();
     r_8_bm.TextureAsset = "Images/MonogameLogo";
     this.Add("MonoGameLogo", r_8_bm);
     // Resource - [MiningIcon] BitmapImage
     BitmapImage r_9_bm = new BitmapImage();
     r_9_bm.TextureAsset = "ImagesUI/mine_build";
     this.Add("MiningIcon", r_9_bm);
     // Resource - [TimberIcon] BitmapImage
     BitmapImage r_10_bm = new BitmapImage();
     r_10_bm.TextureAsset = "ImagesUI/timber_res";
     this.Add("TimberIcon", r_10_bm);
     // Resource - [TitaniumIcon] BitmapImage
     BitmapImage r_11_bm = new BitmapImage();
     r_11_bm.TextureAsset = "ImagesUI/titanium_res";
     this.Add("TitaniumIcon", r_11_bm);
     // Resource - [Building2] BitmapImage
     BitmapImage r_12_bm = new BitmapImage();
     r_12_bm.TextureAsset = "ImagesUI/building2";
     this.Add("Building2", r_12_bm);
     // Resource - [Building1] BitmapImage
     BitmapImage r_13_bm = new BitmapImage();
     r_13_bm.TextureAsset = "ImagesUI/building1";
     this.Add("Building1", r_13_bm);
     // Resource - [Sounds] SoundSourceCollection
     var r_14_sounds = new SoundSourceCollection();
     r_14_sounds.Add(new SoundSource { SoundType = SoundType.ButtonsClick, SoundAsset = "Click" });
     SoundManager.Instance.AddSound("Click");
     r_14_sounds.Add(new SoundSource { SoundType = SoundType.TextBoxKeyPress, SoundAsset = "KeyPress" });
     SoundManager.Instance.AddSound("KeyPress");
     r_14_sounds.Add(new SoundSource { SoundType = SoundType.TabControlMove, SoundAsset = "Move" });
     SoundManager.Instance.AddSound("Move");
     r_14_sounds.Add(new SoundSource { SoundType = SoundType.TabControlSelect, SoundAsset = "Select" });
     SoundManager.Instance.AddSound("Select");
     this.Add("Sounds", r_14_sounds);
     // Resource - [buttonAnimStyle] Style
     var r_15_s_bo = this[typeof(Button)];
     Style r_15_s = new Style(typeof(Button), r_15_s_bo as Style);
     Setter r_15_s_S_0 = new Setter(Button.WidthProperty, 200F);
     r_15_s.Setters.Add(r_15_s_S_0);
     Setter r_15_s_S_1 = new Setter(Button.MarginProperty, new Thickness(0F, 1F, 0F, 1F));
     r_15_s.Setters.Add(r_15_s_S_1);
     Setter r_15_s_S_2 = new Setter(Button.SnapsToDevicePixelsProperty, false);
     r_15_s.Setters.Add(r_15_s_S_2);
     EventTrigger r_15_s_ET_0 = new EventTrigger(Button.MouseEnterEvent);
     r_15_s.Triggers.Add(r_15_s_ET_0);
     BeginStoryboard r_15_s_ET_0_AC_0 = new BeginStoryboard();
     r_15_s_ET_0_AC_0.Name = "r_15_s_ET_0_AC_0";
     r_15_s_ET_0.AddAction(r_15_s_ET_0_AC_0);
     Storyboard r_15_s_ET_0_AC_0_SB = new Storyboard();
     r_15_s_ET_0_AC_0.Storyboard = r_15_s_ET_0_AC_0_SB;
     r_15_s_ET_0_AC_0_SB.Name = "r_15_s_ET_0_AC_0_SB";
     ThicknessAnimation r_15_s_ET_0_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_15_s_ET_0_AC_0_SB_TL_0.Name = "r_15_s_ET_0_AC_0_SB_TL_0";
     r_15_s_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_15_s_ET_0_AC_0_SB_TL_0.From = new Thickness(0F, 1F, 0F, 1F);
     r_15_s_ET_0_AC_0_SB_TL_0.To = new Thickness(0F, 5F, 0F, 5F);
     SineEase r_15_s_ET_0_AC_0_SB_TL_0_EA = new SineEase();
     r_15_s_ET_0_AC_0_SB_TL_0.EasingFunction = r_15_s_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_15_s_ET_0_AC_0_SB_TL_0, Button.MarginProperty);
     r_15_s_ET_0_AC_0_SB.Children.Add(r_15_s_ET_0_AC_0_SB_TL_0);
     FloatAnimation r_15_s_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     r_15_s_ET_0_AC_0_SB_TL_1.Name = "r_15_s_ET_0_AC_0_SB_TL_1";
     r_15_s_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_15_s_ET_0_AC_0_SB_TL_1.To = 220F;
     SineEase r_15_s_ET_0_AC_0_SB_TL_1_EA = new SineEase();
     r_15_s_ET_0_AC_0_SB_TL_1.EasingFunction = r_15_s_ET_0_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_15_s_ET_0_AC_0_SB_TL_1, Button.WidthProperty);
     r_15_s_ET_0_AC_0_SB.Children.Add(r_15_s_ET_0_AC_0_SB_TL_1);
     EventTrigger r_15_s_ET_1 = new EventTrigger(Button.MouseLeaveEvent);
     r_15_s.Triggers.Add(r_15_s_ET_1);
     BeginStoryboard r_15_s_ET_1_AC_0 = new BeginStoryboard();
     r_15_s_ET_1_AC_0.Name = "r_15_s_ET_1_AC_0";
     r_15_s_ET_1.AddAction(r_15_s_ET_1_AC_0);
     Storyboard r_15_s_ET_1_AC_0_SB = new Storyboard();
     r_15_s_ET_1_AC_0.Storyboard = r_15_s_ET_1_AC_0_SB;
     r_15_s_ET_1_AC_0_SB.Name = "r_15_s_ET_1_AC_0_SB";
     ThicknessAnimation r_15_s_ET_1_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_15_s_ET_1_AC_0_SB_TL_0.Name = "r_15_s_ET_1_AC_0_SB_TL_0";
     r_15_s_ET_1_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_15_s_ET_1_AC_0_SB_TL_0.From = new Thickness(0F, 5F, 0F, 5F);
     r_15_s_ET_1_AC_0_SB_TL_0.To = new Thickness(0F, 1F, 0F, 1F);
     SineEase r_15_s_ET_1_AC_0_SB_TL_0_EA = new SineEase();
     r_15_s_ET_1_AC_0_SB_TL_0.EasingFunction = r_15_s_ET_1_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_15_s_ET_1_AC_0_SB_TL_0, Button.MarginProperty);
     r_15_s_ET_1_AC_0_SB.Children.Add(r_15_s_ET_1_AC_0_SB_TL_0);
     FloatAnimation r_15_s_ET_1_AC_0_SB_TL_1 = new FloatAnimation();
     r_15_s_ET_1_AC_0_SB_TL_1.Name = "r_15_s_ET_1_AC_0_SB_TL_1";
     r_15_s_ET_1_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_15_s_ET_1_AC_0_SB_TL_1.To = 200F;
     SineEase r_15_s_ET_1_AC_0_SB_TL_1_EA = new SineEase();
     r_15_s_ET_1_AC_0_SB_TL_1.EasingFunction = r_15_s_ET_1_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_15_s_ET_1_AC_0_SB_TL_1, Button.WidthProperty);
     r_15_s_ET_1_AC_0_SB.Children.Add(r_15_s_ET_1_AC_0_SB_TL_1);
     this.Add("buttonAnimStyle", r_15_s);
     // Resource - [ZincIcon] BitmapImage
     BitmapImage r_16_bm = new BitmapImage();
     r_16_bm.TextureAsset = "ImagesUI/zinc_res";
     this.Add("ZincIcon", r_16_bm);
     // Resource - [SunBurnLogo] BitmapImage
     BitmapImage r_17_bm = new BitmapImage();
     r_17_bm.TextureAsset = "Images/SunBurn";
     this.Add("SunBurnLogo", r_17_bm);
     // Resource - [buttonStyle] Style
     var r_18_s_bo = this[typeof(Button)];
     Style r_18_s = new Style(typeof(Button), r_18_s_bo as Style);
     Setter r_18_s_S_0 = new Setter(Button.BackgroundProperty, new SolidColorBrush(new ColorW(255, 140, 0, 255)));
     r_18_s.Setters.Add(r_18_s_S_0);
     this.Add("buttonStyle", r_18_s);
     // Resource - [GoldIcon] BitmapImage
     BitmapImage r_19_bm = new BitmapImage();
     r_19_bm.TextureAsset = "ImagesUI/gold_res";
     this.Add("GoldIcon", r_19_bm);
     // Resource - [IronIcon] BitmapImage
     BitmapImage r_20_bm = new BitmapImage();
     r_20_bm.TextureAsset = "ImagesUI/iron_res";
     this.Add("IronIcon", r_20_bm);
     // Resource - [CoalIcon] BitmapImage
     BitmapImage r_21_bm = new BitmapImage();
     r_21_bm.TextureAsset = "ImagesUI/coal_res";
     this.Add("CoalIcon", r_21_bm);
     // Resource - [OilIcon] BitmapImage
     BitmapImage r_22_bm = new BitmapImage();
     r_22_bm.TextureAsset = "ImagesUI/oil_res";
     this.Add("OilIcon", r_22_bm);
     // Resource - [ThoriumIcon] BitmapImage
     BitmapImage r_23_bm = new BitmapImage();
     r_23_bm.TextureAsset = "ImagesUI/thorium_res";
     this.Add("ThoriumIcon", r_23_bm);
     // Resource - [UraniumIcon] BitmapImage
     BitmapImage r_24_bm = new BitmapImage();
     r_24_bm.TextureAsset = "ImagesUI/uranium_res";
     this.Add("UraniumIcon", r_24_bm);
     // Resource - [SilverIcon] BitmapImage
     BitmapImage r_25_bm = new BitmapImage();
     r_25_bm.TextureAsset = "ImagesUI/silver_res";
     this.Add("SilverIcon", r_25_bm);
     // Resource - [MagnesiumIcon] BitmapImage
     BitmapImage r_26_bm = new BitmapImage();
     r_26_bm.TextureAsset = "ImagesUI/magnesium_res";
     this.Add("MagnesiumIcon", r_26_bm);
     // Resource - [LivestockIcon] BitmapImage
     BitmapImage r_27_bm = new BitmapImage();
     r_27_bm.TextureAsset = "ImagesUI/livestock_res";
     this.Add("LivestockIcon", r_27_bm);
     // Resource - [WaterIcon] BitmapImage
     BitmapImage r_28_bm = new BitmapImage();
     r_28_bm.TextureAsset = "ImagesUI/water_res";
     this.Add("WaterIcon", r_28_bm);
     // Resource - [PlatinumIcon] BitmapImage
     BitmapImage r_29_bm = new BitmapImage();
     r_29_bm.TextureAsset = "ImagesUI/platinum_res";
     this.Add("PlatinumIcon", r_29_bm);
     ImageManager.Instance.AddImage("ImagesUI/hydrogen_res");
     ImageManager.Instance.AddImage("ImagesUI/biomass_res");
     ImageManager.Instance.AddImage("ImagesUI/copper_res");
     ImageManager.Instance.AddImage("ImagesUI/lead_res");
     ImageManager.Instance.AddImage("ImagesUI/aluminium_res");
     ImageManager.Instance.AddImage("ImagesUI/gas_res");
     ImageManager.Instance.AddImage("ImagesUI/propane_res");
     ImageManager.Instance.AddImage("ImagesUI/diamond_res");
     ImageManager.Instance.AddImage("Images/MonogameLogo");
     ImageManager.Instance.AddImage("ImagesUI/mine_build");
     ImageManager.Instance.AddImage("ImagesUI/timber_res");
     ImageManager.Instance.AddImage("ImagesUI/titanium_res");
     ImageManager.Instance.AddImage("ImagesUI/building2");
     ImageManager.Instance.AddImage("ImagesUI/building1");
     ImageManager.Instance.AddImage("ImagesUI/zinc_res");
     ImageManager.Instance.AddImage("Images/SunBurn");
     ImageManager.Instance.AddImage("ImagesUI/gold_res");
     ImageManager.Instance.AddImage("ImagesUI/iron_res");
     ImageManager.Instance.AddImage("ImagesUI/coal_res");
     ImageManager.Instance.AddImage("ImagesUI/oil_res");
     ImageManager.Instance.AddImage("ImagesUI/thorium_res");
     ImageManager.Instance.AddImage("ImagesUI/uranium_res");
     ImageManager.Instance.AddImage("ImagesUI/silver_res");
     ImageManager.Instance.AddImage("ImagesUI/magnesium_res");
     ImageManager.Instance.AddImage("ImagesUI/livestock_res");
     ImageManager.Instance.AddImage("ImagesUI/water_res");
     ImageManager.Instance.AddImage("ImagesUI/platinum_res");
 }
Ejemplo n.º 15
0
        public void PageLeave()
        {
            DispatcherTimer MenuTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.25)
            };
            int Count = 0;

            MenuTimer.Tick += delegate
            {
                MenuList[Count].BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                var MarginAnimation = new ThicknessAnimation()
                {
                    From = MenuList[Count].Margin,
                    To   = new Thickness(
                        MenuList[Count].Margin.Left + 50,
                        MenuList[Count].Margin.Top,
                        MenuList[Count].Margin.Right,
                        MenuList[Count].Margin.Bottom),
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                };
                if (Count == MenuList.Count - 1)
                {
                    MarginAnimation.Completed += delegate
                    {
                        DispatcherTimer FinalTimer = new DispatcherTimer()
                        {
                            Interval = TimeSpan.FromSeconds(0.75)
                        };
                        FinalTimer.Tick += delegate
                        {
                            LeaveAction?.Invoke();
                            FinalTimer.Stop();
                        };
                        TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                        {
                            From           = 1,
                            To             = 0,
                            Duration       = TimeSpan.FromSeconds(0.75),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                        {
                            From = TitleGrid.Margin,
                            To   = new Thickness(
                                TitleGrid.Margin.Left + 50,
                                TitleGrid.Margin.Top,
                                TitleGrid.Margin.Right - 50,
                                TitleGrid.Margin.Bottom),
                            Duration       = TimeSpan.FromSeconds(0.75),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        FinalTimer.Start();
                    }
                }
                ;
                MenuList[Count].BeginAnimation(MarginProperty, MarginAnimation);
                Count++;
                if (Count >= MenuList.Count)
                {
                    MenuTimer.Stop();
                }
            };
            MenuTimer.Start();
        }
Ejemplo n.º 16
0
        public void PageEnter(Room Target)
        {
            CurrentRoom = Target;
            if (CurrentRoom.IsHost(App.CurrentUser))
            {
                App.Server.AcceptCompleted += ServerAccepted;
            }
            ChatWindow.Closing += HideSyncAction;

            RoomNameLabel.Content   = Target.Name;
            BattleTypeLabel.Content = BattleTypeDictionary[Target.BattleType];
            if (CurrentRoom.IsHost(App.CurrentUser))
            {
                ChatWindow.Title       = Target.Name;
                ChatWindow.CurrentRoom = CurrentRoom;
                HostNameBox.Text       = Target.Host.Name;
                HostIntroBox.Text      = Target.Host.Introduction;
                if (Target.Host.Avator != null)
                {
                    using (MemoryStream Stream = new MemoryStream())
                    {
                        Target.Host.Avator.Save(Stream, ImageFormat.Png);
                        BitmapImage Temp = new BitmapImage();
                        Temp.BeginInit();
                        Temp.CacheOption  = BitmapCacheOption.OnLoad;
                        Temp.StreamSource = Stream;
                        Temp.EndInit();
                        AvatorImage.ImageSource = Temp;
                    }
                }
                DescriptionBlock.Text = Target.Description;

                GroupStack.Children.Clear();
                foreach (var Group in Target.Groups)
                {
                    var GroupItem = new Components.GroupItem();
                    GroupItem.JoinSyncAction = delegate(Player TargetUser)
                    {
                        foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                        {
                            foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                            {
                                if ((ParticipantItem.Participant != null &&
                                     ParticipantItem.Participant.Id != TargetUser.Id) ||
                                    (CurrentRoom.Host.Id == App.CurrentUser.Id && ParticipantItem.Participant == null))
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                                }
                                else
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                                }
                            }
                        }
                    };
                    GroupItem.QuitSyncAction = delegate
                    {
                        foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                        {
                            foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                            {
                                if (ParticipantItem.Participant == null ||
                                    (ParticipantItem.Participant != null && CurrentRoom.Host.Id == App.CurrentUser.Id))
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                                }
                                else
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                                }
                            }
                        }
                    };
                    GroupItem.Init(Group, Target);
                    GroupItem.Padding = new Thickness(0, 10, 0, 0);
                    GroupStack.Children.Add(GroupItem);
                }
            }
            else if (App.Client["ReadyToReceive"] != null && (bool)App.Client["ReadyToReceive"])
            {
                App.Client.Send(Encoding.UTF8.GetBytes("ReadyToReceive"));
                App.Client["ReadyToReceive"] = null;
                App.Client.ReceiveCompleted += BeginUpdateRoom;
            }
            else
            {
                App.Client.ReceiveCompleted += ReadyToUpdateRoom;
            }

            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 0,
                To             = 1,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = new Thickness(
                    TitleGrid.Margin.Left - 50,
                    TitleGrid.Margin.Top,
                    TitleGrid.Margin.Right + 50,
                    TitleGrid.Margin.Bottom),
                To             = TitleGrid.Margin,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };

            MarginAnimation.Completed += delegate
            {
                if (CurrentRoom.IsHost(App.CurrentUser))
                {
                    ContentGrid.Visibility = Visibility.Visible;
                    ContentGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                    {
                        From           = 0,
                        To             = 1,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    ContentGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                    {
                        From = new Thickness(
                            ContentGrid.Margin.Left - 50,
                            ContentGrid.Margin.Top,
                            ContentGrid.Margin.Right + 50,
                            ContentGrid.Margin.Bottom),
                        To             = ContentGrid.Margin,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                }
                else
                {
                    WaitingGrid.Visibility = Visibility.Visible;
                    WaitingGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                    {
                        From           = 0,
                        To             = 1,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    WaitingGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                    {
                        From = new Thickness(
                            WaitingGrid.Margin.Left - 50,
                            WaitingGrid.Margin.Top,
                            WaitingGrid.Margin.Right + 50,
                            WaitingGrid.Margin.Bottom),
                        To             = WaitingGrid.Margin,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                }
            };
            TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            TitleGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }
Ejemplo n.º 17
0
        public void PageEnter()
        {
            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 0,
                To             = 1,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = new Thickness(
                    TitleGrid.Margin.Left - 50,
                    TitleGrid.Margin.Top,
                    TitleGrid.Margin.Right + 50,
                    TitleGrid.Margin.Bottom),
                To             = TitleGrid.Margin,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };

            MarginAnimation.Completed += delegate
            {
                DispatcherTimer MenuTimer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(0.25)
                };
                int Count = 0;
                MenuTimer.Tick += delegate
                {
                    MenuList[Count].BeginAnimation(OpacityProperty, new DoubleAnimation()
                    {
                        From           = 0,
                        To             = 1,
                        Duration       = TimeSpan.FromSeconds(0.5),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    MenuList[Count].BeginAnimation(MarginProperty, new ThicknessAnimation()
                    {
                        From = new Thickness(
                            MenuList[Count].Margin.Left - 50,
                            MenuList[Count].Margin.Top,
                            MenuList[Count].Margin.Right,
                            MenuList[Count].Margin.Bottom),
                        To             = MenuList[Count].Margin,
                        Duration       = TimeSpan.FromSeconds(0.5),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    Count++;
                    if (Count >= MenuList.Count)
                    {
                        MenuTimer.Stop();
                    }
                };
                MenuTimer.Start();
            };
            TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            TitleGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }
Ejemplo n.º 18
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var parentGrid = new Grid();
            var grid       = new Grid();
            var content    = new ContentControl();

            grid.Background   = Brushes.Transparent;
            grid.ClipToBounds = true;
            parentGrid.Children.Add(grid);
            parentGrid.Children.Add(content);

            var c = Content;

            this.Content    = parentGrid;
            content.Content = c;

            grid.SetBinding(WidthProperty, new Binding("ActualWidth")
            {
                Source = parentGrid
            });
            grid.SetBinding(HeightProperty, new Binding("ActualHeight")
            {
                Source = parentGrid
            });

            parentGrid.PreviewMouseDown += (sender, e) =>
            {
                var targetWidth   = (Math.Max(ActualWidth, ActualHeight) * 2) / ExpandTime * (ExpandTime + FadeTime);
                var mousePosition = (e as MouseButtonEventArgs).GetPosition(this);
                var startMargin   = new Thickness(mousePosition.X, mousePosition.Y, 0, 0);
                var endMargin     = new Thickness(mousePosition.X - targetWidth / 2, mousePosition.Y - targetWidth / 2, 0, 0);

                var ellipse = new Ellipse()
                {
                    Fill = Brushes.White,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Opacity             = Opacity
                };
                ellipse.Margin = startMargin;
                ellipse.SetBinding(HeightProperty, new Binding("Width")
                {
                    Source = ellipse
                });

                Storyboard storyboard = new Storyboard();

                var expand = new DoubleAnimation(0, targetWidth, new Duration(TimeSpan.FromSeconds(ExpandTime + FadeTime)));
                storyboard.Children.Add(expand);
                Storyboard.SetTarget(expand, ellipse);
                Storyboard.SetTargetProperty(expand, new PropertyPath(WidthProperty));

                var marginShrink = new ThicknessAnimation(startMargin, endMargin, new Duration(TimeSpan.FromSeconds(ExpandTime + FadeTime)));
                storyboard.Children.Add(marginShrink);
                Storyboard.SetTarget(marginShrink, ellipse);
                Storyboard.SetTargetProperty(marginShrink, new PropertyPath(MarginProperty));

                var opacity = new DoubleAnimation(Opacity, 0, new Duration(TimeSpan.FromSeconds(FadeTime)));
                opacity.BeginTime = TimeSpan.FromSeconds(ExpandTime);
                storyboard.Children.Add(opacity);
                Storyboard.SetTarget(opacity, ellipse);
                Storyboard.SetTargetProperty(opacity, new PropertyPath(Ellipse.OpacityProperty));

                grid.Children.Add(ellipse);

                storyboard.Begin();

                var waitTime = ExpandTime + FadeTime;
                Task.Run(() =>
                {
                    Thread.Sleep(TimeSpan.FromSeconds(waitTime));
                    Dispatcher.Invoke(() =>
                    {
                        grid.Children.Remove(ellipse);
                    });
                });
                e.Handled = false;
            };
        }
Ejemplo n.º 19
0
        void DrawCoordinate()
        {
            Rectangle rectangle;
            TextBlock tb;

            _gridContent.ColumnDefinitions.Clear();
            _gridContent.RowDefinitions.Clear();
            _gridContent.Children.Clear();

            //_gridContent.Margin = new Thickness(_viewPortPad.Left, 0, 0, _viewPortPad.Bottom);
            _gridContent.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(_viewPortPad.Left, GridUnitType.Pixel)
            });
            _gridContent.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            _gridContent.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(_viewPortPad.Bottom, GridUnitType.Pixel)
            });

            var maxHeight = _gridContent.ActualHeight - _viewPortPad.Top - _viewPortPad.Bottom;
            var maxWidth  = _gridContent.ActualWidth - _viewPortPad.Left;

            var list = ItemsSource;

            foreach (var v in list)
            {
                var xx = maxHeight * (v.Value / _chartMaxNumber);
                _gridContent.Children.Add(
                    rectangle =
                        new Rectangle()
                {
                    Fill              = _defaultBrush,
                    Height            = maxHeight * (v.Value / _chartMaxNumber),
                    Width             = maxWidth / list.Count() * 0.6,
                    VerticalAlignment = VerticalAlignment.Bottom
                });

                var heightAnimationToValue = maxHeight * (v.Value / _chartMaxNumber);
                if (IsNeedItemSourceChangeAnimation)
                {
                    var doubleAnimation = new DoubleAnimation(0, heightAnimationToValue, new Duration(new TimeSpan(0, 0, 0, 0, 1000)));

                    rectangle.BeginAnimation(Rectangle.HeightProperty, doubleAnimation);
                }
                else
                {
                    rectangle.Height = heightAnimationToValue;
                }

                rectangle.Tag = v.Value;

                if (v.Value == this._maxValue)
                {
                    rectangle.Fill = _maxValueBrush;
                }
                _gridContent.Children.Add(
                    tb =
                        new TextBlock()
                {
                    Text                = v.Value.ToString("f"),
                    Margin              = new Thickness(0, 0, 0, maxHeight * (v.Value / _chartMaxNumber) + 5),
                    VerticalAlignment   = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Center,
                }
                    );


                var thicknessAnimationToValue = new Thickness(0, 0, 0, maxHeight * (v.Value / _chartMaxNumber) + 5);
                if (IsNeedItemSourceChangeAnimation)
                {
                    var thicknessAnimation = new ThicknessAnimation(new Thickness(0, 0, 0, 0),
                                                                    thicknessAnimationToValue,
                                                                    new Duration(new TimeSpan(0, 0, 0, 0, 1000)));
                    tb.BeginAnimation(TextBlock.MarginProperty, thicknessAnimation);
                }
                else
                {
                    tb.Margin = thicknessAnimationToValue;
                }

                rectangle.MouseEnter += Rectangle_MouseEnter;
                rectangle.MouseLeave += Rectangle_MouseLeave;
                _gridContent.ColumnDefinitions.Add(new ColumnDefinition());
                Grid.SetColumn(rectangle, _gridContent.ColumnDefinitions.Count - 1);
                Grid.SetColumn(tb, _gridContent.ColumnDefinitions.Count - 1);
            }
        }
Ejemplo n.º 20
0
        //move
        private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            //BGgrid.Background = Brushes.Blue;
            DoomsdayClock.Content = Time;
            Grid     g        = (Grid)this.Parent;
            Grid     roomgrid = (Grid)g.Parent;
            GameGrid game     = (GameGrid)roomgrid.Parent;

            ThicknessAnimation animation = new ThicknessAnimation();


            Thickness oldCenter = game.currentRoom.Margin;
            Thickness newCenter = this.Margin;
            Thickness oldMargin = roomgrid.Margin;



            //roomgrid.Margin =
            Thickness newMargin = new Thickness(oldMargin.Left + (oldCenter.Left - newCenter.Left),
                                                oldMargin.Top + (oldCenter.Top - newCenter.Top),
                                                oldMargin.Right + (oldCenter.Right - newCenter.Right),
                                                oldMargin.Bottom + (oldCenter.Bottom - newCenter.Bottom));


            animation.From = oldMargin;
            animation.To   = newMargin;

            PowerEase pe = new PowerEase();

            pe.EasingMode = EasingMode.EaseInOut; pe.Power = 3;

            animation.EasingFunction = pe;
            animation.Duration       = new Duration(TimeSpan.FromSeconds(.5));

            roomgrid.BeginAnimation(Grid.MarginProperty, animation);

            List <Room> desc = game.currentRoom.getalldescendents();

            game.currentRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));

            // game.StartRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));
            }

            game.currentRoom = this;

            desc = game.currentRoom.getalldescendents();

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));
            }


            game.window.DoomsdayClock.Content = Time;

            game.adjustBG(Time);


            BGgrid.Background = Brushes.Blue;
            //CHANGE CHARA LOC

            if (oldCenter.Left == newCenter.Left)
            {
                game.window.avatar.standstill();
            }
            else if (oldCenter.Left < newCenter.Left)//traveling forward
            {
                game.window.avatar.fwd();
            }
            else
            {
                game.window.avatar.bwd();
            }
        }
Ejemplo n.º 21
0
        private void button_MouseEnter(object sender, MouseEventArgs e)
        {
            /*if(AutoColour)
             * {
             *  if(Background is SolidColorBrush)
             *  {
             *      //SolidColorBrush scb = Background as SolidColorBrush;
             *      //MouseOnBackground =new SolidColorBrush( Color.FromArgb(scb.Color.A, (byte)Math.Min(scb.Color.R*1, 255), (byte)Math.Min(scb.Color.G*1.1,255), (byte)Math.Min(scb.Color.B*0.9, 255)));
             *      //EllipseColor = new SolidColorBrush(Color.FromArgb(255, (byte)Math.Min(scb.Color.R*1, 255), (byte)Math.Min(scb.Color.G*1.1, 255), (byte)Math.Min(scb.Color.B*0.9, 255)));
             *  }
             *
             * }*/

            if (Background is SolidColorBrush && BackgroundAnimation)
            {
                ColorAnimation ca = new ColorAnimation();
                ca.SpeedRatio = AnimationSpeed;
                if (MouseOnBackground is SolidColorBrush)
                {
                    ca.To = (MouseOnBackground as SolidColorBrush).Color;
                    //backgroundTemp = Background == null ? null : Background.Clone();
                }
                else if (MouseOnBackground == null)
                {
                    Color c = (Background as SolidColorBrush).Color;
                    ca.To = new Color()
                    {
                        A = c.A, G = (byte)(c.G * 0.87), R = (byte)(c.R * 0.87), B = (byte)(c.B * 0.87)
                    };
                }
                Color c1 = (Background as SolidColorBrush).Clone().Color;
                Background = new SolidColorBrush(c1);//防止被冻结
                Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
            if (BorderBrush is SolidColorBrush && BorderAnimation)
            {
                ColorAnimation ca = new ColorAnimation();
                ca.SpeedRatio = AnimationSpeed;
                if (MouseOnBorder is SolidColorBrush)
                {
                    ca.To = (MouseOnBorder as SolidColorBrush).Color;
                }
                else if (MouseOnBorder == null)
                {
                    Color c = (BorderBrush as SolidColorBrush).Color;
                    ca.To = new Color()
                    {
                        A = c.A, G = (byte)(c.G * 0.87), R = (byte)(c.R * 0.87), B = (byte)(c.B * 0.87)
                    };
                }
                BorderBrush.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
            if (MouseOnPadding != null && PaddingAnimation)
            {
                ThicknessAnimation t = new ThicknessAnimation();
                t.To         = MouseOnPadding;
                t.SpeedRatio = AnimationSpeed / 2;
                PowerEase pe = new PowerEase();
                pe.Power         = Power;
                t.EasingFunction = new PowerEase();
                BeginAnimation(PaddingProperty, t);
            }
            if (MouseOnMargin != null && MarginAnimation)
            {
                ThicknessAnimation t = new ThicknessAnimation();
                t.To         = MouseOnMargin;
                t.SpeedRatio = AnimationSpeed / 2;
                PowerEase pe = new PowerEase();
                pe.Power         = Power;
                t.EasingFunction = new PowerEase();
                BeginAnimation(MarginProperty, t);
            }
        }
Ejemplo n.º 22
0
        protected override void AddEquipment(CardView card, bool isFaked)
        {
            Equipment equip = card.Card.Type as Equipment;

            if (equip == null)
            {
                throw new ArgumentException("Cannot add non-equip to equip area.");
            }

            ToggleButton button = new ToggleButton();

            button.Style = Resources["BigEquipToggleButton"] as Style;
            button.HorizontalAlignment = HorizontalAlignment.Left;
            button.VerticalAlignment   = VerticalAlignment.Top;

            Grid targetArea = null;

            switch (equip.Category)
            {
            case CardCategory.Weapon:
                button.DataContext = PlayerModel.WeaponCommand;
                targetArea         = weaponArea;
                break;

            case CardCategory.Armor:
                button.DataContext = PlayerModel.ArmorCommand;
                targetArea         = armorArea;
                break;

            case CardCategory.DefensiveHorse:
                button.DataContext = PlayerModel.DefensiveHorseCommand;
                targetArea         = horse1Area;
                break;

            case CardCategory.OffensiveHorse:
                button.DataContext = PlayerModel.OffensiveHorseCommand;
                targetArea         = horse2Area;
                break;

            default:
                throw new ArgumentException("Cannot install non-equips to equip area.");
            }

            button.Width   = targetArea.Width;
            button.Height  = targetArea.Height;
            button.Opacity = 0;

            if (IsEquipmentDockEmpty)
            {
                equipmentArea.Visibility = Visibility.Visible;
                this.UpdateLayout();
                handCardArea.RearrangeCards();
            }

            if (targetArea.Children.Count != 0)
            {
                throw new ArgumentException("Duplicate equip not allowed.");
            }
            targetArea.Children.Clear();
            targetArea.Children.Add(button);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = targetArea.TranslatePoint(new Point(targetArea.Width / 2, targetArea.Height / 2),
                                                       ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard         storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation    animation2 = new DoubleAnimation();

            animation1.From     = new Thickness(-100d, 0d, 0d, 0d);
            animation1.To       = new Thickness(0d, 0d, 0d, 0d);
            animation2.To       = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, button);
            Storyboard.SetTarget(animation2, button);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(ToggleButton.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(ToggleButton.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Ejemplo n.º 23
0
        private static ThicknessAnimation GetThicknessAnimation(Visibility visibility, FrameworkElement frameworkElement)
        {
            var slideType = GetSlideType(frameworkElement);

            if (slideType == SlideType.None)
            {
                return(null);
            }

            var animation = new ThicknessAnimation
            {
                Duration          = new Duration(TimeSpan.FromMilliseconds(AnimationDuration)),
                DecelerationRatio = 0.7
            };
            var width  = frameworkElement.ActualWidth;
            var height = 30;//frameworkElement.ActualHeight;

            if (visibility == Visibility.Collapsed || visibility == Visibility.Hidden)
            {
                //Slide Out
                switch (slideType)
                {
                case SlideType.Bottom:
                    animation.From = frameworkElement.Margin;
                    animation.To   = new Thickness(0, 0, 0, -height);
                    break;

                case SlideType.Left:
                    animation.From = frameworkElement.Margin;
                    animation.To   = new Thickness(-width, 0, 0, 0);
                    break;

                case SlideType.Right:
                    animation.From = frameworkElement.Margin;
                    animation.To   = new Thickness(0, 0, -width, 0);
                    break;

                case SlideType.Top:
                    animation.From = frameworkElement.Margin;
                    animation.To   = new Thickness(0, -height, 0, 0);
                    break;
                }
            }
            else
            {
                //Slide In
                switch (slideType)
                {
                case SlideType.Bottom:
                    animation.From = new Thickness(0, 0, 0, -height);
                    animation.To   = new Thickness(0);
                    break;

                case SlideType.Left:
                    animation.From = new Thickness(-width, 0, 0, 0);
                    animation.To   = new Thickness(0);
                    break;

                case SlideType.Right:
                    animation.From = new Thickness(0, 0, -width, 0);
                    animation.To   = new Thickness(0);
                    break;

                case SlideType.Top:
                    animation.From = new Thickness(0, -height, 0, 0);
                    animation.To   = new Thickness(0);
                    break;
                }
            };
            return(animation);
        }
Ejemplo n.º 24
0
        private void ToFull()
        {
            _fullTimer.Interval = TimeSpan.FromSeconds(7);
            //анимация отъезда назад
            var widthAnimation = new DoubleAnimation
            {
                To       = _mediaElements[_currentFull].ActualWidth,
                Duration = TimeSpan.FromSeconds(1)
            };
            var heightAnimation = new DoubleAnimation
            {
                To       = _mediaElements[_currentFull].ActualHeight,
                Duration = TimeSpan.FromSeconds(1)
            };

            var marginAnimation = new ThicknessAnimation(_previewPosition, TimeSpan.FromSeconds(1));

            var storyBoard = new Storyboard()
            {
                Children = new TimelineCollection {
                    widthAnimation, heightAnimation, marginAnimation
                }
            };

            FullBorder.VerticalAlignment   = VerticalAlignment.Top;
            FullBorder.HorizontalAlignment = HorizontalAlignment.Left;
            Storyboard.SetTarget(widthAnimation, FullBorder);
            Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(WidthProperty));
            Storyboard.SetTarget(heightAnimation, FullBorder);
            Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(HeightProperty));
            Storyboard.SetTarget(marginAnimation, FullBorder);
            Storyboard.SetTargetProperty(marginAnimation, new PropertyPath(MarginProperty));
            storyBoard.Completed += (s, e) => {
                //задержка перед показом нового ролика 2 сек
                FullBorder.Visibility = Visibility.Collapsed;
                var t = new DispatcherTimer();
                t.Interval = TimeSpan.FromSeconds(2);
                t.Tick    += (tt, t1) =>
                {
                    //выезд нового ролика
                    var p = _mediaElements[_currentFull].TransformToVisual(this).Transform(new Point(0, 0));
                    _previewPosition      = new Thickness(p.X, p.Y, 0, 0);
                    FullBorder.Visibility = Visibility.Visible;
                    var newWidthAnimation = new DoubleAnimation
                    {
                        To       = 400,
                        Duration = TimeSpan.FromSeconds(2)
                    };
                    var newHeightAnimation = new DoubleAnimation
                    {
                        To       = 225,
                        Duration = TimeSpan.FromSeconds(2)
                    };
                    var newMarginAnimation = new ThicknessAnimation(new Thickness(Root.ActualWidth / 2 - 200, Root.ActualHeight / 2 - 112.5, 0, 0), TimeSpan.FromSeconds(2))
                    {
                        From = _previewPosition
                    };
                    Storyboard.SetTarget(newWidthAnimation, FullBorder);
                    Storyboard.SetTargetProperty(newWidthAnimation, new PropertyPath(WidthProperty));
                    Storyboard.SetTarget(newHeightAnimation, FullBorder);
                    Storyboard.SetTargetProperty(newHeightAnimation, new PropertyPath(HeightProperty));
                    Storyboard.SetTarget(newMarginAnimation, FullBorder);
                    Storyboard.SetTargetProperty(newMarginAnimation, new PropertyPath(MarginProperty));
                    var newStory = new Storyboard()
                    {
                        Children = new TimelineCollection {
                            newHeightAnimation, newWidthAnimation, newMarginAnimation
                        }
                    };
                    FullMedia.Source       = _mediaElements[_currentFull].Source;
                    FullBorder.BorderBrush = new SolidColorBrush(Colors.Orange);
                    _currentFull++;
                    if (_currentFull == _currentCountVideos)
                    {
                        _currentFull = 0;
                    }
                    FullBorder.BeginStoryboard(newStory);
                    t.Stop();
                };
                t.Start();
            };
            FullBorder.BeginStoryboard(storyBoard);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 改变数字
        /// </summary>
        /// <param name="num">数字</param>
        public void ChangeNum(int num)
        {
            ThicknessAnimation an = new ThicknessAnimation
            {
                From     = nums.Margin,
                Duration = new Duration(TimeSpan.FromMilliseconds(500))
            };

            switch (num)
            {
            case 9:
                an.To = new Thickness(0, 0, 0, -6);
                break;

            case 8:
                an.To = new Thickness(0, 0, 0, -56);
                break;

            case 7:
                an.To = new Thickness(0, 0, 0, -106);
                break;

            case 6:
                an.To = new Thickness(0, 0, 0, -156);
                break;

            case 5:
                an.To = new Thickness(0, 0, 0, -206);
                break;

            case 4:
                an.To = new Thickness(0, 0, 0, -256);
                break;

            case 3:
                an.To = new Thickness(0, 0, 0, -306);
                break;

            case 2:
                an.To = new Thickness(0, 0, 0, -356);
                break;

            case 1:
                an.To = new Thickness(0, 0, 0, -406);
                break;

            case 0:
                an.To = new Thickness(0, 0, 0, -456);
                break;

            case -1:
                an.To = new Thickness(0, 0, 0, -515);
                break;

            case -2:
                an.To = new Thickness(0, 0, 0, -565);
                break;

            case -3:
                an.To = new Thickness(0, 0, 0, -600);
                break;

            default:
                break;
            }

            nums.BeginAnimation(MarginProperty, an);
        }
Ejemplo n.º 26
0
        public void FadeIn(string title, string value)
        {
            if (Active || string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(value))
            {
                return;
            }

            Active              = true;
            TitleText.Text      = title;
            TitleTextDummy.Text = title;
            ValueText.Text      = value;
            ValueTextDummy.Text = value;

            Measure(new Size(350, 36));
            Arrange(new Rect(new Size(350, 36)));

            TitleText.Width = TitleTextDummy.ActualWidth;
            ValueText.Width = ValueTextDummy.ActualWidth;

            BackgroundBlack.Width = TitleTextDummy.ActualWidth + 20;
            Farbverlauf.Width     = TitleTextDummy.ActualWidth + 20;
            FadeInColor.Width     = BackgroundBlack.Width;
            Main.Width            = BackgroundBlack.Width + 18;

            TitleText.Margin = new Thickness(18, 0.666, 0, 0);
            ValueText.Margin = new Thickness(18, 0.666, 332, 0);

            double rm1 = Main.Width - 18 - TitleTextDummy.ActualWidth;
            double rm2 = Main.Width - 23 - ValueTextDummy.ActualWidth;

            mainAnimation = new Storyboard();
            ThicknessAnimation titleAnimation = new ThicknessAnimation(new Thickness(18, 0.666, rm1, 0), new Thickness(18, 0.666, Main.Width - 18, 0), new Duration(TimeSpan.FromMilliseconds(500)));

            titleAnimation.BeginTime = TimeSpan.FromSeconds(3);
            Storyboard.SetTarget(titleAnimation, TitleText);
            Storyboard.SetTargetProperty(titleAnimation, new PropertyPath(MarginProperty));

            ThicknessAnimation valueAnimation = new ThicknessAnimation(new Thickness(18, 0.666, 332, 0), new Thickness(18, 0.666, rm2, 0), new Duration(TimeSpan.FromMilliseconds(500)));

            valueAnimation.BeginTime = TimeSpan.FromMilliseconds(3500);
            Storyboard.SetTarget(valueAnimation, ValueText);
            Storyboard.SetTargetProperty(valueAnimation, new PropertyPath(MarginProperty));

            DoubleAnimation widthAnimation1 = new DoubleAnimation(TitleText.Width + 20, ValueText.Width + 20, new Duration(TimeSpan.FromSeconds(1)));

            widthAnimation1.BeginTime = TimeSpan.FromSeconds(3);
            Storyboard.SetTarget(widthAnimation1, BackgroundBlack);
            Storyboard.SetTargetProperty(widthAnimation1, new PropertyPath(WidthProperty));

            DoubleAnimation widthAnimation2 = new DoubleAnimation(TitleText.Width + 20, ValueText.Width + 20, new Duration(TimeSpan.FromSeconds(1)));

            widthAnimation2.BeginTime = TimeSpan.FromSeconds(3);
            Storyboard.SetTarget(widthAnimation2, Farbverlauf);
            Storyboard.SetTargetProperty(widthAnimation2, new PropertyPath(WidthProperty));

            mainAnimation.Children.Add(titleAnimation);
            mainAnimation.Children.Add(valueAnimation);
            mainAnimation.Children.Add(widthAnimation1);
            mainAnimation.Children.Add(widthAnimation2);

            mainAnimation.Completed += mainAnimation_Completed;

            Storyboard sb = FindResource("FadeIn") as Storyboard;

            sb.Completed += sb1_Completed;
            sb.Begin();
        }
Ejemplo n.º 27
0
        internal static void Margin(FrameworkElement element, Thickness to, TimeSpan timeSpan)
        {
            var timeline = new ThicknessAnimation(to, new Duration(timeSpan));

            element.BeginAnimation(FrameworkElement.MarginProperty, timeline);
        }
Ejemplo n.º 28
0
 private void Image_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (Settings.Opacity == 0.0)
     {
         Thickness bt  = Browser.Margin;
         Thickness bt2 = Browser.Margin;
         bt2.Top    = ActualHeight;
         bt2.Bottom = bt.Top - ActualHeight;
         ThicknessAnimation da2 = new ThicknessAnimation()
         {
             Duration       = new Duration(TimeSpan.FromMilliseconds(512)),
             From           = bt,
             To             = bt2,
             EasingFunction = new SineEase()
         };
         Storyboard.SetTarget(da2, Browser);
         Storyboard.SetTargetProperty(da2, new PropertyPath(WebBrowser.MarginProperty));
         DoubleAnimation settingsshow = new DoubleAnimation()
         {
             From           = 0.0,
             To             = 1.0,
             Duration       = new Duration(TimeSpan.FromMilliseconds(512)),
             EasingFunction = new SineEase()
         };
         Storyboard.SetTarget(settingsshow, Settings);
         Storyboard.SetTargetProperty(settingsshow, new PropertyPath(Grid.OpacityProperty));
         storyboard = new Storyboard();
         storyboard.Children.Add(da2);
         storyboard.Children.Add(settingsshow);
         storyboard.Begin();
         SideGrid.Visibility = System.Windows.Visibility.Collapsed;
     }
     else
     {
         Thickness bt  = Browser.Margin;
         Thickness bt2 = Browser.Margin;
         bt2.Top    = 0;
         bt2.Bottom = 0;
         ThicknessAnimation da2 = new ThicknessAnimation()
         {
             Duration       = new Duration(TimeSpan.FromMilliseconds(512)),
             From           = bt,
             To             = bt2,
             EasingFunction = new SineEase()
         };
         Storyboard.SetTarget(da2, Browser);
         Storyboard.SetTargetProperty(da2, new PropertyPath(WebBrowser.MarginProperty));
         DoubleAnimation settingsshow = new DoubleAnimation()
         {
             From           = 1.0,
             To             = 0.0,
             Duration       = new Duration(TimeSpan.FromMilliseconds(512)),
             EasingFunction = new SineEase()
         };
         Storyboard.SetTarget(settingsshow, Settings);
         Storyboard.SetTargetProperty(settingsshow, new PropertyPath(Grid.OpacityProperty));
         storyboard = new Storyboard();
         storyboard.Children.Add(da2);
         storyboard.Children.Add(settingsshow);
         storyboard.Begin();
         SideGrid.Visibility = System.Windows.Visibility.Visible;
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Does the collapse transition.
        /// </summary>
        /// <param name="smooth">if set to <c>true</c> [smooth].</param>
        private void DoCollapseTransition(bool smooth)
        {
            if (smooth)
            {
                IsHitTestVisible = false;
            }

            _TriggerButton.Visibility = Visibility.Visible;

            // Find the selected list box item.
            SurfaceListBoxItem selectedItem = GetSelectedItem();

            if (selectedItem == null)
            {
                return;
            }

            SurfaceScrollViewer sv = _ListBox.FindVisualChild <SurfaceScrollViewer>();
            double offset          = selectedItem.TransformToVisual(sv).Transform(new Point()).Y + sv.VerticalOffset;

            sv.PanningMode = PanningMode.None;

            if (!smooth)
            {
                _ListBox.Height = selectedItem.ActualHeight;
                _ListBox.Margin = new Thickness();
                sv.ScrollToVerticalOffset(offset);
                SizeChanged += ListBox_SizeChanged;
                return;
            }

            Storyboard storyboard = new Storyboard();

            DoubleAnimation height = new DoubleAnimation();

            Storyboard.SetTarget(height, _ListBox);
            Storyboard.SetTargetProperty(height, new PropertyPath(ListBox.HeightProperty));
            height.To             = selectedItem.ActualHeight;
            height.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            height.Duration = _ExpandDuration;
            storyboard.Children.Add(height);

            ThicknessAnimation margin = new ThicknessAnimation();

            Storyboard.SetTarget(margin, _ListBox);
            Storyboard.SetTargetProperty(margin, new PropertyPath(ListBox.MarginProperty));
            margin.To             = new Thickness();
            margin.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            margin.Duration = _ExpandDuration;
            storyboard.Children.Add(margin);

            DoubleAnimation verticalOffset = new DoubleAnimation();

            Storyboard.SetTarget(verticalOffset, this.FindVisualChild <ScrollViewerOffsetMediator>());
            Storyboard.SetTargetProperty(verticalOffset, new PropertyPath(ScrollViewerOffsetMediator.VerticalOffsetProperty));
            verticalOffset.To             = offset;
            verticalOffset.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            verticalOffset.Duration = _ExpandDuration;
            storyboard.Children.Add(verticalOffset);

            ScrollBar scrollbar = this.FindVisualChild <ScrollBar>();

            if (scrollbar != null)
            {
                DoubleAnimation scroll = new DoubleAnimation();
                Storyboard.SetTarget(scroll, scrollbar);
                Storyboard.SetTargetProperty(scroll, new PropertyPath(UIElement.OpacityProperty));
                scroll.To             = 0;
                scroll.EasingFunction = new SineEase {
                    EasingMode = EasingMode.EaseOut
                };
                scroll.Duration = _ExpandDuration;
                storyboard.Children.Add(scroll);
            }

            height.Completed += (sender, e) =>
            {
                IsHitTestVisible = true;
                SizeChanged     += ListBox_SizeChanged;
            };

            storyboard.Begin(this, true);
        }
Ejemplo n.º 30
0
 private void InitializeResources()
 {
     // Resource - [buttonStyle] Style
     var r_0_s_bo = this[typeof(Button)];
     Style r_0_s = new Style(typeof(Button), r_0_s_bo as Style);
     Setter r_0_s_S_0 = new Setter(Button.BackgroundProperty, new SolidColorBrush(new ColorW(255, 140, 0, 255)));
     r_0_s.Setters.Add(r_0_s_S_0);
     this.Add("buttonStyle", r_0_s);
     // Resource - [Image] BitmapImage
     BitmapImage r_1_bm = new BitmapImage();
     r_1_bm.TextureAsset = "Images/MonoGameLogo";
     this.Add("Image", r_1_bm);
     // Resource - [TetrisWindowBackground] SolidColorBrush
     this.Add("TetrisWindowBackground", new SolidColorBrush(new ColorW(0, 0, 0, 255)));
     // Resource - [TetrisForeground] SolidColorBrush
     this.Add("TetrisForeground", new SolidColorBrush(new ColorW(255, 255, 255, 255)));
     // Resource - [TitleResource] String
     this.Add("TitleResource", "Basic UI Example");
     // Resource - [TetrisBorderStyle] Style
     Style r_5_s = new Style(typeof(Border));
     Setter r_5_s_S_0 = new Setter(Border.SnapsToDevicePixelsProperty, true);
     r_5_s.Setters.Add(r_5_s_S_0);
     Setter r_5_s_S_1 = new Setter(Border.BackgroundProperty, new ResourceReferenceExpression("TetrisWindowBackground"));
     r_5_s.Setters.Add(r_5_s_S_1);
     Setter r_5_s_S_2 = new Setter(Border.BorderBrushProperty, new ResourceReferenceExpression("TetrisBorderBrush"));
     r_5_s.Setters.Add(r_5_s_S_2);
     Setter r_5_s_S_3 = new Setter(Border.BorderThicknessProperty, new Thickness(1F));
     r_5_s.Setters.Add(r_5_s_S_3);
     Setter r_5_s_S_4 = new Setter(Border.OpacityProperty, 0.9F);
     r_5_s.Setters.Add(r_5_s_S_4);
     this.Add("TetrisBorderStyle", r_5_s);
     // Resource - [DataTemplateKey(GameData.TestTreeDataItem)] DataTemplate
     Func<UIElement, UIElement> r_6_dtFunc = r_6_dtMethod;
     this.Add(typeof(GameData.TestTreeDataItem), new DataTemplate(typeof(GameData.TestTreeDataItem), r_6_dtFunc));
     // Resource - [CustomWindowTemplate] ControlTemplate
     Func<UIElement, UIElement> r_7_ctFunc = r_7_ctMethod;
     ControlTemplate r_7_ct = new ControlTemplate(r_7_ctFunc);
     this.Add("CustomWindowTemplate", r_7_ct);
     // Resource - [buttonAnimStyle] Style
     var r_8_s_bo = this[typeof(Button)];
     Style r_8_s = new Style(typeof(Button), r_8_s_bo as Style);
     Setter r_8_s_S_0 = new Setter(Button.WidthProperty, 200F);
     r_8_s.Setters.Add(r_8_s_S_0);
     Setter r_8_s_S_1 = new Setter(Button.MarginProperty, new Thickness(0F, 1F, 0F, 1F));
     r_8_s.Setters.Add(r_8_s_S_1);
     Setter r_8_s_S_2 = new Setter(Button.SnapsToDevicePixelsProperty, false);
     r_8_s.Setters.Add(r_8_s_S_2);
     EventTrigger r_8_s_ET_0 = new EventTrigger(Button.MouseEnterEvent);
     r_8_s.Triggers.Add(r_8_s_ET_0);
     BeginStoryboard r_8_s_ET_0_AC_0 = new BeginStoryboard();
     r_8_s_ET_0_AC_0.Name = "r_8_s_ET_0_AC_0";
     r_8_s_ET_0.AddAction(r_8_s_ET_0_AC_0);
     Storyboard r_8_s_ET_0_AC_0_SB = new Storyboard();
     r_8_s_ET_0_AC_0.Storyboard = r_8_s_ET_0_AC_0_SB;
     r_8_s_ET_0_AC_0_SB.Name = "r_8_s_ET_0_AC_0_SB";
     ThicknessAnimation r_8_s_ET_0_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_8_s_ET_0_AC_0_SB_TL_0.Name = "r_8_s_ET_0_AC_0_SB_TL_0";
     r_8_s_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_8_s_ET_0_AC_0_SB_TL_0.From = new Thickness(0F, 1F, 0F, 1F);
     r_8_s_ET_0_AC_0_SB_TL_0.To = new Thickness(0F, 5F, 0F, 5F);
     SineEase r_8_s_ET_0_AC_0_SB_TL_0_EA = new SineEase();
     r_8_s_ET_0_AC_0_SB_TL_0.EasingFunction = r_8_s_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_8_s_ET_0_AC_0_SB_TL_0, Button.MarginProperty);
     r_8_s_ET_0_AC_0_SB.Children.Add(r_8_s_ET_0_AC_0_SB_TL_0);
     FloatAnimation r_8_s_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     r_8_s_ET_0_AC_0_SB_TL_1.Name = "r_8_s_ET_0_AC_0_SB_TL_1";
     r_8_s_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_8_s_ET_0_AC_0_SB_TL_1.To = 220F;
     SineEase r_8_s_ET_0_AC_0_SB_TL_1_EA = new SineEase();
     r_8_s_ET_0_AC_0_SB_TL_1.EasingFunction = r_8_s_ET_0_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_8_s_ET_0_AC_0_SB_TL_1, Button.WidthProperty);
     r_8_s_ET_0_AC_0_SB.Children.Add(r_8_s_ET_0_AC_0_SB_TL_1);
     EventTrigger r_8_s_ET_1 = new EventTrigger(Button.MouseLeaveEvent);
     r_8_s.Triggers.Add(r_8_s_ET_1);
     BeginStoryboard r_8_s_ET_1_AC_0 = new BeginStoryboard();
     r_8_s_ET_1_AC_0.Name = "r_8_s_ET_1_AC_0";
     r_8_s_ET_1.AddAction(r_8_s_ET_1_AC_0);
     Storyboard r_8_s_ET_1_AC_0_SB = new Storyboard();
     r_8_s_ET_1_AC_0.Storyboard = r_8_s_ET_1_AC_0_SB;
     r_8_s_ET_1_AC_0_SB.Name = "r_8_s_ET_1_AC_0_SB";
     ThicknessAnimation r_8_s_ET_1_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_8_s_ET_1_AC_0_SB_TL_0.Name = "r_8_s_ET_1_AC_0_SB_TL_0";
     r_8_s_ET_1_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_8_s_ET_1_AC_0_SB_TL_0.From = new Thickness(0F, 5F, 0F, 5F);
     r_8_s_ET_1_AC_0_SB_TL_0.To = new Thickness(0F, 1F, 0F, 1F);
     SineEase r_8_s_ET_1_AC_0_SB_TL_0_EA = new SineEase();
     r_8_s_ET_1_AC_0_SB_TL_0.EasingFunction = r_8_s_ET_1_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_8_s_ET_1_AC_0_SB_TL_0, Button.MarginProperty);
     r_8_s_ET_1_AC_0_SB.Children.Add(r_8_s_ET_1_AC_0_SB_TL_0);
     FloatAnimation r_8_s_ET_1_AC_0_SB_TL_1 = new FloatAnimation();
     r_8_s_ET_1_AC_0_SB_TL_1.Name = "r_8_s_ET_1_AC_0_SB_TL_1";
     r_8_s_ET_1_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_8_s_ET_1_AC_0_SB_TL_1.To = 200F;
     SineEase r_8_s_ET_1_AC_0_SB_TL_1_EA = new SineEase();
     r_8_s_ET_1_AC_0_SB_TL_1.EasingFunction = r_8_s_ET_1_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_8_s_ET_1_AC_0_SB_TL_1, Button.WidthProperty);
     r_8_s_ET_1_AC_0_SB.Children.Add(r_8_s_ET_1_AC_0_SB_TL_1);
     this.Add("buttonAnimStyle", r_8_s);
     // Resource - [Sounds] SoundSourceCollection
     var r_9_sounds = new SoundSourceCollection();
     r_9_sounds.Add(new SoundSource { SoundType = SoundType.ButtonsClick, SoundAsset = "Click" });
     SoundManager.Instance.AddSound("Click");
     r_9_sounds.Add(new SoundSource { SoundType = SoundType.TextBoxKeyPress, SoundAsset = "KeyPress" });
     SoundManager.Instance.AddSound("KeyPress");
     r_9_sounds.Add(new SoundSource { SoundType = SoundType.TabControlMove, SoundAsset = "Move" });
     SoundManager.Instance.AddSound("Move");
     r_9_sounds.Add(new SoundSource { SoundType = SoundType.TabControlSelect, SoundAsset = "Select" });
     SoundManager.Instance.AddSound("Select");
     this.Add("Sounds", r_9_sounds);
     // Resource - [TetrisBorderBrush] SolidColorBrush
     this.Add("TetrisBorderBrush", new SolidColorBrush(new ColorW(114, 176, 218, 255)));
     // Resource - [DataTemplateKey(GameData.CustomWindow)] DataTemplate
     Func<UIElement, UIElement> r_11_dtFunc = r_11_dtMethod;
     this.Add(typeof(GameData.CustomWindow), new DataTemplate(typeof(GameData.CustomWindow), r_11_dtFunc));
     ImageManager.Instance.AddImage("Images/MonoGameLogo");
     FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
 }
        private void OnOpened(object sender, EventArgs e)
        {
            Keyboard.Focus(SearchBox);

            switch (taskbarEdge)
            {
            case Edge.Top:
                Placement = PlacementMode.Bottom;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(10, 0, 10, 10);
                break;

            case Edge.Left:
                Placement = PlacementMode.Right;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(0, 10, 10, 10);
                break;

            case Edge.Right:
                Placement = PlacementMode.Left;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(10, 10, 0, 10);
                break;

            case Edge.Bottom:
                Placement = PlacementMode.Top;
                PopupBorder.BorderThickness = new Thickness(1, 1, 1, 0);
                PopupMarginBorder.Margin    = new Thickness(10, 10, 10, 0);
                break;
            }

            Height = Properties.Settings.Default.popupSize.Height;
            Width  = Properties.Settings.Default.popupSize.Width;

            QuinticEase ease = new QuinticEase
            {
                EasingMode = EasingMode.EaseOut
            };

            int             modifier = taskbarEdge == Edge.Right || taskbarEdge == Edge.Bottom ? 1 : -1;
            Duration        duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.4);
            DoubleAnimation outer    = new DoubleAnimation(modifier * 150, 0, duration)
            {
                EasingFunction = ease
            };
            DependencyProperty outerProp = taskbarEdge == Edge.Bottom || taskbarEdge == Edge.Top ? TranslateTransform.YProperty : TranslateTransform.XProperty;

            translateTransform?.BeginAnimation(outerProp, outer);

            DoubleAnimation opacity = new DoubleAnimation(0, 1, duration)
            {
                EasingFunction = ease
            };

            PopupMarginBorder?.BeginAnimation(OpacityProperty, opacity);

            duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.8);
            ThicknessAnimation inner = new ThicknessAnimation(new Thickness(0), duration)
            {
                EasingFunction = ease
            };

            if (taskbarEdge == Edge.Top)
            {
                inner.From = new Thickness(0, -50, 0, 50);
            }
            else if (taskbarEdge == Edge.Right)
            {
                inner.From = new Thickness(50, 0, -50, 0);
            }
            else if (taskbarEdge == Edge.Bottom)
            {
                inner.From = new Thickness(0, 50, 0, -50);
            }
            else if (taskbarEdge == Edge.Left)
            {
                inner.From = new Thickness(-50, 0, 50, 0);
            }
            ContentGrid?.BeginAnimation(MarginProperty, inner);
        }
Ejemplo n.º 32
0
 private void InitializeResources()
 {
     // Resource - [ToolTipText] String
     this.Add("ToolTipText", "Click to open message box");
     // Resource - [TitleResource] String
     this.Add("TitleResource", "Basic UI Example");
     // Resource - [logoSunburn] BitmapImage
     BitmapImage r_2_bm = new BitmapImage();
     r_2_bm.TextureAsset = "Images/SunBurn";
     this.Add("logoSunburn", r_2_bm);
     // Resource - [buttonStyle] Style
     var r_3_s_bo = this[typeof(Button)];
     Style r_3_s = new Style(typeof(Button), r_3_s_bo as Style);
     Setter r_3_s_S_0 = new Setter(Button.BackgroundProperty, new SolidColorBrush(new ColorW(255, 140, 0, 255)));
     r_3_s.Setters.Add(r_3_s_S_0);
     Setter r_3_s_S_1 = new Setter(Button.WidthProperty, 200F);
     r_3_s.Setters.Add(r_3_s_S_1);
     Setter r_3_s_S_2 = new Setter(Button.PaddingProperty, new Thickness(2F));
     r_3_s.Setters.Add(r_3_s_S_2);
     this.Add("buttonStyle", r_3_s);
     // Resource - [logoEmptyKeys] BitmapImage
     BitmapImage r_4_bm = new BitmapImage();
     r_4_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall";
     this.Add("logoEmptyKeys", r_4_bm);
     // Resource - [buttonAnimStyle] Style
     var r_5_s_bo = this[typeof(Button)];
     Style r_5_s = new Style(typeof(Button), r_5_s_bo as Style);
     Setter r_5_s_S_0 = new Setter(Button.WidthProperty, 200F);
     r_5_s.Setters.Add(r_5_s_S_0);
     Setter r_5_s_S_1 = new Setter(Button.MarginProperty, new Thickness(0F, 1F, 0F, 1F));
     r_5_s.Setters.Add(r_5_s_S_1);
     Setter r_5_s_S_2 = new Setter(Button.SnapsToDevicePixelsProperty, false);
     r_5_s.Setters.Add(r_5_s_S_2);
     EventTrigger r_5_s_ET_0 = new EventTrigger(Button.MouseEnterEvent);
     r_5_s.Triggers.Add(r_5_s_ET_0);
     BeginStoryboard r_5_s_ET_0_AC_0 = new BeginStoryboard();
     r_5_s_ET_0_AC_0.Name = "r_5_s_ET_0_AC_0";
     r_5_s_ET_0.AddAction(r_5_s_ET_0_AC_0);
     Storyboard r_5_s_ET_0_AC_0_SB = new Storyboard();
     r_5_s_ET_0_AC_0.Storyboard = r_5_s_ET_0_AC_0_SB;
     r_5_s_ET_0_AC_0_SB.Name = "r_5_s_ET_0_AC_0_SB";
     ThicknessAnimation r_5_s_ET_0_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_5_s_ET_0_AC_0_SB_TL_0.Name = "r_5_s_ET_0_AC_0_SB_TL_0";
     r_5_s_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_5_s_ET_0_AC_0_SB_TL_0.From = new Thickness(0F, 1F, 0F, 1F);
     r_5_s_ET_0_AC_0_SB_TL_0.To = new Thickness(0F, 5F, 0F, 5F);
     SineEase r_5_s_ET_0_AC_0_SB_TL_0_EA = new SineEase();
     r_5_s_ET_0_AC_0_SB_TL_0.EasingFunction = r_5_s_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_5_s_ET_0_AC_0_SB_TL_0, Button.MarginProperty);
     r_5_s_ET_0_AC_0_SB.Children.Add(r_5_s_ET_0_AC_0_SB_TL_0);
     FloatAnimation r_5_s_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     r_5_s_ET_0_AC_0_SB_TL_1.Name = "r_5_s_ET_0_AC_0_SB_TL_1";
     r_5_s_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_5_s_ET_0_AC_0_SB_TL_1.To = 220F;
     SineEase r_5_s_ET_0_AC_0_SB_TL_1_EA = new SineEase();
     r_5_s_ET_0_AC_0_SB_TL_1.EasingFunction = r_5_s_ET_0_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_5_s_ET_0_AC_0_SB_TL_1, Button.WidthProperty);
     r_5_s_ET_0_AC_0_SB.Children.Add(r_5_s_ET_0_AC_0_SB_TL_1);
     EventTrigger r_5_s_ET_1 = new EventTrigger(Button.MouseLeaveEvent);
     r_5_s.Triggers.Add(r_5_s_ET_1);
     BeginStoryboard r_5_s_ET_1_AC_0 = new BeginStoryboard();
     r_5_s_ET_1_AC_0.Name = "r_5_s_ET_1_AC_0";
     r_5_s_ET_1.AddAction(r_5_s_ET_1_AC_0);
     Storyboard r_5_s_ET_1_AC_0_SB = new Storyboard();
     r_5_s_ET_1_AC_0.Storyboard = r_5_s_ET_1_AC_0_SB;
     r_5_s_ET_1_AC_0_SB.Name = "r_5_s_ET_1_AC_0_SB";
     ThicknessAnimation r_5_s_ET_1_AC_0_SB_TL_0 = new ThicknessAnimation();
     r_5_s_ET_1_AC_0_SB_TL_0.Name = "r_5_s_ET_1_AC_0_SB_TL_0";
     r_5_s_ET_1_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_5_s_ET_1_AC_0_SB_TL_0.From = new Thickness(0F, 5F, 0F, 5F);
     r_5_s_ET_1_AC_0_SB_TL_0.To = new Thickness(0F, 1F, 0F, 1F);
     SineEase r_5_s_ET_1_AC_0_SB_TL_0_EA = new SineEase();
     r_5_s_ET_1_AC_0_SB_TL_0.EasingFunction = r_5_s_ET_1_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetProperty(r_5_s_ET_1_AC_0_SB_TL_0, Button.MarginProperty);
     r_5_s_ET_1_AC_0_SB.Children.Add(r_5_s_ET_1_AC_0_SB_TL_0);
     FloatAnimation r_5_s_ET_1_AC_0_SB_TL_1 = new FloatAnimation();
     r_5_s_ET_1_AC_0_SB_TL_1.Name = "r_5_s_ET_1_AC_0_SB_TL_1";
     r_5_s_ET_1_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
     r_5_s_ET_1_AC_0_SB_TL_1.To = 200F;
     SineEase r_5_s_ET_1_AC_0_SB_TL_1_EA = new SineEase();
     r_5_s_ET_1_AC_0_SB_TL_1.EasingFunction = r_5_s_ET_1_AC_0_SB_TL_1_EA;
     Storyboard.SetTargetProperty(r_5_s_ET_1_AC_0_SB_TL_1, Button.WidthProperty);
     r_5_s_ET_1_AC_0_SB.Children.Add(r_5_s_ET_1_AC_0_SB_TL_1);
     this.Add("buttonAnimStyle", r_5_s);
     // Resource - [MessageBoxButtonYes] String
     this.Add("MessageBoxButtonYes", "Yes!");
     // Resource - [Sounds] SoundSourceCollection
     var r_7_sounds = new SoundSourceCollection();
     r_7_sounds.Add(new SoundSource { SoundType = SoundType.ButtonsClick, SoundAsset = "Click" });
     SoundManager.Instance.AddSound("Click");
     r_7_sounds.Add(new SoundSource { SoundType = SoundType.TextBoxKeyPress, SoundAsset = "KeyPress" });
     SoundManager.Instance.AddSound("KeyPress");
     r_7_sounds.Add(new SoundSource { SoundType = SoundType.TabControlMove, SoundAsset = "Move" });
     SoundManager.Instance.AddSound("Move");
     r_7_sounds.Add(new SoundSource { SoundType = SoundType.TabControlSelect, SoundAsset = "Select" });
     SoundManager.Instance.AddSound("Select");
     this.Add("Sounds", r_7_sounds);
     ImageManager.Instance.AddImage("Images/SunBurn");
     ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall");
     FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
     FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular");
 }
Ejemplo n.º 33
0
        public void PageLeave()
        {
            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 1,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = ContentGrid.Margin,
                To   = new Thickness(
                    ContentGrid.Margin.Left + 50,
                    ContentGrid.Margin.Top,
                    ContentGrid.Margin.Right - 50,
                    ContentGrid.Margin.Bottom),
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };

            MarginAnimation.Completed += delegate
            {
                DispatcherTimer Timer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(0.5)
                };
                Timer.Tick += delegate
                {
                    DoubleAnimation FadeAnimation = new DoubleAnimation()
                    {
                        From           = 1,
                        To             = 0,
                        Duration       = TimeSpan.FromSeconds(1),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseIn
                        }
                    };
                    FadeAnimation.Completed += delegate
                    {
                        LeaveAction?.Invoke();
                    };
                    this.BeginAnimation(OpacityProperty, FadeAnimation);
                    Timer.Stop();
                };
                TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                {
                    From = TitleGrid.Margin,
                    To   = new Thickness(
                        TitleGrid.Margin.Left + 50,
                        TitleGrid.Margin.Top,
                        TitleGrid.Margin.Right - 50,
                        TitleGrid.Margin.Bottom),
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                Timer.Start();
            };
            ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            ContentGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }