Exemplo n.º 1
0
        private static Task <EventArgs> PositionChanged(NodesControl nodesControl, NodeViewModel viewModel, string propertyName, Action action = null)
        {
            DoubleAnimation  speedDoubleAni = null;
            DependencyObject dObject        = nodesControl.ItemContainerGenerator.ContainerFromItem(viewModel);

            if (propertyName == nameof(NodeViewModel.X))
            {
                speedDoubleAni =
                    new DoubleAnimation(viewModel.OldX, (double)(viewModel.X), new Duration(new TimeSpan(0, 0, 3)));
                Storyboard.SetTargetProperty(speedDoubleAni, new PropertyPath(Canvas.LeftProperty));
            }
            if (propertyName == nameof(NodeViewModel.Y))
            {
                speedDoubleAni =
                    new DoubleAnimation(viewModel.OldY, (double)(viewModel.Y), new Duration(new TimeSpan(0, 0, 3)));

                Storyboard.SetTargetProperty(speedDoubleAni, new PropertyPath(Canvas.TopProperty));
            }

            Storyboard.SetTarget(speedDoubleAni, dObject);
            Storyboard story = new Storyboard();

            story.Children.Add(speedDoubleAni);


            story.Completed += (a, b) => nodesControl.Story_Completed(nodesControl);

            story.Begin();

            return(null);
        }
Exemplo n.º 2
0
        private static void Reselect(NodesControl nodesControl, NodeViewModel viewModel)
        {
            foreach (var item in nodesControl.Items)
            {
                if (viewModel != ((NodeViewModel)item))
                {
                    (item as NodeViewModel).IsSelected = false;
                }
            }

            nodesControl.Dispatcher.InvokeAsync(() => nodesControl.SelectedObject = viewModel,
                                                System.Windows.Threading.DispatcherPriority.Background, default);
        }
Exemplo n.º 3
0
        private void Story_Completed(NodesControl nodesControl)
        {
            bool removed = false;

            while (Removals.TryPop(out NodeViewModel pop))
            {
                removed |= (nodesControl.ItemsSource as ICollection <NodeViewModel>).ToList().Remove(pop);
            }

            if (removed)
            {
                var list = nodesControl.ItemsSource;
                nodesControl.ItemsSource = null;
                nodesControl.ItemsSource = list;
            }
        }
Exemplo n.º 4
0
 public AddXCommand(NodesControl nodesControl)
 {
     this.nodesControl = nodesControl;
 }