Ejemplo n.º 1
0
        /// <summary>
        /// Switches the current center node for the one passed in as a parameter.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">Arguments describing the routed event.</param>
        private static void OnSwitchCenterNodeCommand(object sender, ExecutedRoutedEventArgs e)
        {
            PhotoExplorerControl  photoExplorer = sender as PhotoExplorerControl;
            PhotoExplorerBaseNode nextNode      = e.Parameter as PhotoExplorerBaseNode;

            var pNode = nextNode as PhotoExplorerPhotoNode;
            PhotoExplorerBaseNode overrideNode = null;

            if (pNode != null)
            {
                if (pNode.Photo != null)// && pNode.Photo.PhotoUrlBig.Contains("profile"))
                {
                    if (pNode.RelatedNodes.Count == 1)
                    {
                        overrideNode = pNode.RelatedNodes[0];
                    }
                }
            }

            if (photoExplorer != null && nextNode != null)
            {
                if (nextNode == photoExplorer.CenterNode)
                {
                    if (photoExplorer.CenterNode.Content != null)
                    {
                        ServiceProvider.ViewManager.NavigationCommands.NavigateToContentCommand.Execute(photoExplorer.CenterNode.Content);
                    }
                }
                else
                {
                    photoExplorer.CenterNode = overrideNode ?? nextNode;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes the collection changed handler from the old center node's related nodes collection when the center node changes.
        /// </summary>
        /// <param name="args">Arguments describing the change event.</param>
        private void CenterNodePropertyChanged(DependencyPropertyChangedEventArgs args)
        {
            PhotoExplorerBaseNode oldNode = args.OldValue as PhotoExplorerBaseNode;

            if (oldNode != null)
            {
                oldNode.RelatedNodes.CollectionChanged -= new NotifyCollectionChangedEventHandler(this.OnRelatedNodesCollectionChanged);
            }

            PhotoExplorerBaseNode newNode = args.NewValue as PhotoExplorerBaseNode;

            if (newNode != null)
            {
                newNode.RelatedNodes.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnRelatedNodesCollectionChanged);
            }

            this.UpdateDisplayedNodes();
        }