Example #1
0
 public void Execute(IPanelContent oldContent, IViewModel newNode)
 {
     if (newNode.SupportExecute())
     {
         newNode.Execute();
     }
     else
     {
         oldContent.Host.PanelContent = newNode.NavigateInto();
     }
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PanelBase"/> class.
        /// </summary>
        /// <param name="another">Another <see cref="PanelBase"/> instance to copy data from.</param>
        protected PanelBase(PanelBase another)
        {
            CanClose   = another.CanClose;
            isSelected = another.isSelected;

            PanelContent = (IPanelContent)another.PanelContent.Clone();

            // Detach from parent panel
            //	Parent = null;

            // Remove original subscribiters
            //	Closing = null;	// -= Closing;
            //	Closed = null;	// -= Closed;
        }
Example #3
0
 /// <summary>
 /// Check if the current node in the panel have parent to make sense in navigation.
 /// </summary>
 /// <param name="panel">Specific panel with node.</param>
 /// <returns>True, if the node have parent node.</returns>
 public bool CanExecute(IPanelContent panel)
 {
     return(panel != null && ((IViewModel)panel).SupportNavigateOut());
 }
Example #4
0
 public void Execute(IPanelContent panel)
 {
     // Todo: consider switching to single interface (IPanelContent or IViewModel)
     panel.Host.PanelContent = ((IViewModel)panel).NavigateOut();
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParentNodeVM" /> class.
 /// </summary>
 /// <param name="parentContent">Parent content view model.</param>
 public ParentNodeVM(IPanelContent parentContent)
 {
     ParentContent = parentContent;
     AbsolutePath  = string.Empty;
 }
Example #6
0
 /// <summary>
 /// Check if the current node have childs to make sense in navigation.
 /// </summary>
 /// <param name="oldContent">Current panel content.</param>
 /// <param name="newNode">New node for panel.</param>
 /// <returns>True, if the node have one or more child nodes.</returns>
 public bool CanExecute(IPanelContent oldContent, IViewModel newNode)
 {
     return(oldContent != null && newNode != null && (newNode.SupportExecute() || newNode.SupportNavigateInto()));
 }
Example #7
0
        /// <summary>
        /// Fetch data from corresponding folder model and its childs folder and files.
        /// </summary>
        public override void Refresh()
        {
            base.Refresh();

            IList <IViewModel> list = new List <IViewModel>();

            if (Drive.IsReady)
            {
                foreach (DirectoryInfo folder in Model.Folders(Drive.Name))
                {
                    var vm = new FolderVM(Model)
                    {
                        AbsolutePath = folder.FullName
                    };

                    vm.Refresh();
                    list.Add(vm);
                }

                foreach (FileInfo file in Model.Files(Drive.Name))
                {
                    var vm = new FileVM(Model)
                    {
                        AbsolutePath = file.FullName
                    };

                    vm.Refresh();
                    list.Add(vm);
                }
            }

            // Sorting by file extenshion and, then, by file name.
            // TODO: make it configurable
            IOrderedEnumerable <IViewModel> sortedList =
                list.OrderBy(vm => vm is FileVM)
                .ThenBy(
                    vm => (vm is FileVM)
                                                ? ((FileVM)vm).Extension.ToLowerInvariant()
                                                : string.Empty)
                .ThenBy(
                    vm => (vm is FileVM)
                                                ? ((FileVM)vm).Name.ToLowerInvariant()
                                                : string.Empty);
            // -- TODOEND --

            // TODO: remove this temporary "parent simulator" from childs collection
            // and make it separate in UI and code, but navigatable like always.
            IEnumerable <IViewModel> resultList = Enumerable.Empty <IViewModel>();

            IPanelContent fullVM = NavigateOut();
            var           parent = new ParentNodeVM(fullVM)
            {
                AbsolutePath = ((IViewModel)fullVM).AbsolutePath
            };

            resultList = Enumerable.Repeat((IViewModel)parent, 1);

            resultList = resultList.Concat(sortedList);
            // -- TODOEND --

            OnPropertyChanging("Childs");
            childs.Clear();
            childs = new ObservableCollection <IViewModel>(resultList);
            OnPropertyChanged("Childs");

            if (CurrentItemIndex == -1 && childs.Count > 0)
            {
                CurrentItemIndex = 0;
            }

            Header.Text = Name;

            var imageConverter = new FileToIconConverter
            {
                DefaultSize = 16
            };

            Header.Icon = imageConverter.GetImage(AbsolutePath, 16);
        }