コード例 #1
0
        private void ChangeConvertPanel(bool toState)
        {
            if (isOpen == toState)
            {
                return;
            }

            if (!toState)
            {
                ThisWindow.BeginAnimation(Window.WidthProperty, WindowClosingAnim);
                SaveColumn.BeginAnimation(ColumnDefinition.WidthProperty, GridClosingAnim);
            }
            else
            {
                ThisWindow.BeginAnimation(Window.WidthProperty, WindowOpeningAnim);
                SaveColumn.BeginAnimation(ColumnDefinition.WidthProperty, GridOpeningAnim);
            }
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();
            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.Fant);
            mainDispatcher = this.Dispatcher;
            DataContext    = vm;

            GridOpeningAnim.Duration = TimeSpan.FromSeconds(duration);
            GridClosingAnim.Duration = TimeSpan.FromSeconds(duration);

            GridOpeningAnim.From = new GridLength(0, GridUnitType.Star);
            GridOpeningAnim.To   = new GridLength(563, GridUnitType.Star);

            GridClosingAnim.From = new GridLength(563, GridUnitType.Star);
            GridClosingAnim.To   = new GridLength(0, GridUnitType.Star);


            QuarticEase easer = new QuarticEase();

            easer.EasingMode = EasingMode.EaseOut;

            GridOpeningAnim.EasingFunction   = easer;
            GridClosingAnim.EasingFunction   = easer;
            WindowOpeningAnim.EasingFunction = easer;
            WindowClosingAnim.EasingFunction = easer;
            SaveMessageClose.EasingFunction  = easer;
            SaveMessageOpen.EasingFunction   = easer;

            ThisWindow.BeginAnimation(Window.WidthProperty, WindowClosingAnim);
            SaveColumn.BeginAnimation(ColumnDefinition.WidthProperty, GridClosingAnim);
            SuccessfulSaveMessage.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, SaveMessageClose);
            FailedSaveMessage.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, SaveMessageClose);

            vm.PropertyChanged += (source, args) =>
            {
                if (args.PropertyName == "SaveSuccess")
                {
                    mainDispatcher.BeginInvoke(new Action(() => ChangeSaveMessageVisibility(vm.SaveSuccess)));
                }
            };
        }