示例#1
0
        private static void IsPressedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
        {
            InformationSourcePanel panel = (InformationSourcePanel)depObj;

            if (!panel.IsPressed && panel.Parent != null)
            {
                animate = new ThicknessAnimation()
                {
                    From     = animationClock != null ? (Thickness)animate.GetCurrentValue(animate.From, animate.To, animationClock) : new Thickness(0, 0, 0, 0),
                    To       = new Thickness(-350, 0, 0, 0),
                    Duration = TimeSpan.FromSeconds(0.8),
                };
                animationClock     = animate.CreateClock();
                animate.Completed += (o, s) => {
                    if (!panel.IsPressed)
                    {
                        RemoveUserControl((Panel)LogicalTreeHelper.GetParent(panel), panel);
                    }
                };
                panel.BeginAnimation(MarginProperty, animate);
            }
            else if (panel.IsPressed && panel.Parent != null)
            {
                var parent = (Panel)LogicalTreeHelper.GetParent(panel);
                List <UserControl> userControls = parent.Children.OfType <UserControl>().ToList();
                animate = new ThicknessAnimation()
                {
                    From     = animationClock != null ? (Thickness)animate.GetCurrentValue(animate.From, animate.To, animationClock) : userControls.Count == 1 ? new Thickness(-350, 0, 0, 0) : new Thickness(-700, 0, 0, 0),
                    To       = new Thickness(0, 0, 0, 0),
                    Duration = TimeSpan.FromSeconds(userControls.Count > 1 ? 1 : 0.8),
                };
                animationClock     = animate.CreateClock();
                animate.Completed += (o, s) => {
                    if (userControls.Count > 1)
                    {
                        RemoveUserControl(parent, userControls[0]);
                    }
                };
                panel.BeginAnimation(MarginProperty, animate);
            }
        }
示例#2
0
        private void OpenListInformationSources(object sender, RoutedEventArgs e)
        {
            if (!informationSourcePanel.IsPressed)
            {
                if (!grid.Children.Contains(informationSourcePanel))
                {
                    Grid.SetRow(informationSourcePanel, 1);
                    Grid.SetColumn(informationSourcePanel, 1);
                    grid.Children.Add(informationSourcePanel);
                }
                else if (grid.Children.Contains(informationSourcePanel))
                {
                    informationSourcePanel.BeginAnimation(MarginProperty, null);
                }

                ChangeButtonBackgroundColor((sender as Button).Name);
                informationSourcePanel.IsPressed = true;
            }
            else if (informationSourcePanel.IsPressed)
            {
                (sender as Button).Background    = new SolidColorBrush(Color.FromRgb(182, 182, 182));
                informationSourcePanel.IsPressed = false;
            }
        }