Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderFullVM"/> class.
        /// </summary>
        /// <param name="another">Another <see cref="FolderFullVM"/> instance to copy data from.</param>
        protected FolderFullVM(FolderFullVM another)
            : base(another)
        {
            // Deep copy all childs
            var childsCopy = new ObservableCollection <IViewModel>();

            foreach (IViewModel child in another.childs)
            {
                childsCopy.Add((IViewModel)child.Clone());
            }

            childs = childsCopy;

            // Deep copy all selected childs
            var selectedChildsCopy = new ObservableCollection <IViewModel>();

            foreach (IViewModel child in another.selectedChilds)
            {
                selectedChildsCopy.Add((IViewModel)child.Clone());
            }

            selectedChilds   = selectedChildsCopy;
            currentItemIndex = another.CurrentItemIndex;
            Header           = (IPanelHeader)another.Header.Clone();
        }
        /// <summary>
        /// Return default view model for node in specified path location.
        /// </summary>
        /// <param name="path">Path to node.</param>
        /// <returns>Default node view model.</returns>
        public IViewModel GetChildViewModel(string path)
        {
            switch (Model.GetEntityType(path))
            {
            case FileSystemEntityType.Directory:
                var folder = new FolderFullVM(Model)
                {
                    AbsolutePath = path
                };
                return(folder);

            // Todo: add support of FileFullVM.
            case FileSystemEntityType.File:
                var file = new FolderFullVM(Model)
                {
                    AbsolutePath = path
                };
                return(file);

            default:                     // FileSystemEntityType.Drive
                var drive = new DriveFullVM(Model)
                {
                    AbsolutePath = path
                };
                return(drive);
            }
        }
Exemple #3
0
        /// <summary>
        /// "Navigate into" action.
        /// </summary>
        /// <returns>Corresponding (or default) content view model for node in "navigated" mode.</returns>
        public virtual IPanelContent NavigateInto()
        {
            var fullVM = new FolderFullVM(Model)
            {
                AbsolutePath = Folder.FullName
            };

            fullVM.Refresh();

            return(fullVM);
        }
Exemple #4
0
        /// <summary>
        /// "Navigate out" action.
        /// </summary>
        /// <returns>Corresponding (or default) content view model for parent node in "navigated" mode.</returns>
        public override IPanelContent NavigateOut()
        {
            if (Folder.Parent != null && Folder.Parent.Parent != null)
            {
                var fullVM = new FolderFullVM(Model)
                {
                    AbsolutePath = Folder.Parent.FullName
                };
                fullVM.Refresh();

                for (int i = 0; i < fullVM.Childs.Count; i++)
                {
                    var model = fullVM.Childs[i];

                    if (model.AbsolutePath.Equals(AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
                    {
                        fullVM.CurrentItemIndex = i;
                    }
                }

                return(fullVM);
            }
            else
            {
                var fullVM = new DriveFullVM(Model)
                {
                    AbsolutePath = Folder.FullName
                };
                fullVM.Refresh();

                for (int i = 0; i < fullVM.Childs.Count; i++)
                {
                    var model = fullVM.Childs[i];

                    if (model.AbsolutePath.StartsWith(AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
                    {
                        fullVM.CurrentItemIndex = i;
                    }
                }

                return(fullVM);
            }
        }