예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DriveFullVM"/> class.
        /// </summary>
        /// <param name="another">Another <see cref="DriveFullVM"/> instance to copy data from.</param>
        protected DriveFullVM(DriveFullVM 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();
        }
예제 #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 DriveFullVM(Model)
            {
                AbsolutePath = Drive.Name
            };

            fullVM.Refresh();

            return(fullVM);
        }
예제 #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);
            }
        }