示例#1
0
        /// <summary>
        /// Tack the changes in CurrentPath so we correctly can update the
        /// IsCurrentItem property on the child Items
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void CurrentDirectoryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BreadCrumb breadCrumb = d as BreadCrumb;

            if (e.NewValue != null)
            {
                BreadCrumbItem path = e.NewValue as BreadCrumbItem;

                foreach (object item in breadCrumb.Items)
                {
                    (item as BreadCrumbItem).IsCurrentItem = false;
                }

                path.IsCurrentItem = true;

                if (breadCrumb.Items.Count > 0)
                {
                    breadCrumb.IsAtHomeDirectory = (path == breadCrumb.Items[0]);
                }
                else
                {
                    breadCrumb.IsAtHomeDirectory = true;
                }

                // Don't trigger directory changed event while closing
                if (!breadCrumb._isClosing)
                {
                    breadCrumb.RaiseDirectoryChanged(path);
                }
            }
        }
示例#2
0
 /// <summary>
 /// Used for switching directories or for adding a new directory to the list of children
 /// </summary>
 /// <param name="path"></param>
 private void CloseToDirectory(BreadCrumbItem breadCrumbItem)
 {
     if (Items.Contains(breadCrumbItem))
     {
         // This is what we aim for
         TargetDirectory = breadCrumbItem;
         CloseCurrentDirectory();
     }
 }
示例#3
0
        public void CloseToDirectory(object directory)
        {
            BreadCrumbItem breadCrumbItem = null;

            if (crossRef.Keys.Contains(directory))
            {
                breadCrumbItem = crossRef[directory];
            }

            if (breadCrumbItem != null)
            {
                CloseToDirectory(breadCrumbItem);
            }
        }
示例#4
0
        /// <summary>
        /// Triggered when the close animation for a BreadCrumbItem is completed.
        /// The logic triggers the next animation in the chain until TargetPath is
        /// reached.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DirectoryCloseComplete(object sender, BreadCrumbEventArgs e)
        {
            e.BreadCrumbItem.Closed -= DirectoryCloseComplete;

            crossRef.Remove(e.BreadCrumbItem.Tag);
            Items.Remove(e.BreadCrumbItem);

            BreadCrumbItem nextInChain = Items[Items.Count - 1] as BreadCrumbItem;

            if (TargetDirectory == nextInChain)
            {
                _isClosing = false;
            }

            CurrentDirectory = nextInChain;

            CloseCurrentDirectory();
        }
示例#5
0
        public void AddDirectory(string caption, object directory)
        {
            if (!crossRef.Keys.Contains(directory))
            {
                BreadCrumbItem breadCrumbItem = new BreadCrumbItem()
                {
                    Header = caption, Tag = directory
                };

                breadCrumbItem.Clicked += new BreadCrumbEventHandler(BreadCrumbItemClicked);
                CurrentDirectory        = breadCrumbItem;
                Items.Add(breadCrumbItem);
                crossRef.Add(directory, breadCrumbItem);
            }
            else
            {
                CloseToDirectory(directory);
            }
        }
示例#6
0
        private void RaiseDirectoryChanged(BreadCrumbItem breadCrumbItem)
        {
            BreadCrumbDirectoryEventArgs args = new BreadCrumbDirectoryEventArgs(DirectoryChangedEvent, breadCrumbItem.Tag);

            this.RaiseEvent(args);
        }
示例#7
0
        private void RaisePreviewDirectoryClosing(BreadCrumbItem breadCrumbItem)
        {
            BreadCrumbDirectoryEventArgs args = new BreadCrumbDirectoryEventArgs(PreviewDirectoryCloseToEvent, breadCrumbItem.Tag);

            this.RaiseEvent(args);
        }
示例#8
0
 public BreadCrumbEventArgs(RoutedEvent routedEvent, BreadCrumbItem path)
     : base(routedEvent)
 {
     this.BreadCrumbItem = path;
 }