コード例 #1
0
        private async void NavigatorPathChanged(object sender,
            NavigatorNodeCommandArgument e)
        {
            if (e.CommandType == NavigatorNodeCommandType.None) return;

            DataSource.CutNavigatorFromIndex(e.Index);
            if (e.CommandType == NavigatorNodeCommandType.Reduce)
            {
                StopImageChangingDispatcher();
                Frame.Navigate(typeof(PageExplorer), null);
            }
            else if (e.CommandType == NavigatorNodeCommandType.Change)
            {
                StorageFolder lastStorageFolder = DataSource.CurrentStorageFolder;
                if (lastStorageFolder != null)
                {
                    var results = await lastStorageFolder.GetItemsAsync();
                    string changedNode = e.Path.Split('\\').LastOrDefault();
                    foreach (var item in results)
                    {
                        if (item is StorageFolder && item.Name == changedNode)
                        {
                            StorageFolder storageFolder = (StorageFolder)item;
                            DataSource.NavigatorStorageFolders.Add(storageFolder);
                            break;
                        }
                    }
                }
                StopImageChangingDispatcher();
                Frame.Navigate(typeof(PageExplorer), null);
            }
        }
コード例 #2
0
        public void NavigatorPathChanged(
            DependencyPropertyChangedEventArgs e)
        {
            NavigatorNodeCommandArgument argument =
                new NavigatorNodeCommandArgument(
                    _currentIndex,
                    (string)e.NewValue,
                    _commandType);

            int index = 0,
                size  = ItemListArray.Count();
            List <NavigatorNode> nodes = new List <NavigatorNode>();

            foreach (string value in argument.Path.Split('\\').Where(value => !string.IsNullOrWhiteSpace(value)))
            {
                NavigatorNodeCommand command = new NavigatorNodeCommand();
                command.Command += (sender, args) =>
                {
                    _currentIndex = args.Index;

                    _commandType = args.CommandType;
                    switch (_commandType)
                    {
                    case NavigatorNodeCommandType.Reduce:
                        string newPath = Path.Substring(0, Path.IndexOf(args.Path, StringComparison.Ordinal) + args.Path.Length);
                        Path = newPath;
                        break;

                    case NavigatorNodeCommandType.ShowList:
                        double positionX = args.PointerPositionX;
                        if (_popupList != null && ItemListArray[_currentIndex].Count > 0)
                        {
                            _listBoxDropDown.ItemsSource = ItemListArray[_currentIndex];
                            _popupList.Margin            = new Thickness(positionX - _popupList.Width, ActualHeight, 0, -342.0);
                            _popupList.IsOpen            = true;
                            _droppedButton = args.Button;
                            _droppedButton.BeginShowAnimation();
                        }
                        break;
                    }
                };
                if (index < size)
                {
                    nodes.Add(new NavigatorNode(index, value, command, Background, index == size - 1, ItemListArray[index]));
                }
                index++;
            }

            _path       = nodes;
            ItemsSource = _path;
            if (NPathChanged != null)
            {
                NPathChanged(this, argument);
            }
        }
コード例 #3
0
ファイル: Navigator.cs プロジェクト: CasaTeam/MetroExplorer
        public void NavigatorPathChanged(
            DependencyPropertyChangedEventArgs e)
        {
            NavigatorNodeCommandArgument argument =
                new NavigatorNodeCommandArgument(
                    _currentIndex,
                    (string)e.NewValue,
                    _commandType);

            int index = 0,
                size = ItemListArray.Count();
            List<NavigatorNode> nodes = new List<NavigatorNode>();
            foreach (string value in argument.Path.Split('\\').Where(value => !string.IsNullOrWhiteSpace(value)))
            {
                NavigatorNodeCommand command = new NavigatorNodeCommand();
                command.Command += (sender, args) =>
                {
                    _currentIndex = args.Index;

                    _commandType = args.CommandType;
                    switch (_commandType)
                    {
                        case NavigatorNodeCommandType.Reduce:
                            string newPath = Path.Substring(0, Path.IndexOf(args.Path, StringComparison.Ordinal) + args.Path.Length);
                            Path = newPath;
                            break;
                        case NavigatorNodeCommandType.ShowList:
                            double positionX = args.PointerPositionX;
                            if (_popupList != null && ItemListArray[_currentIndex].Count > 0)
                            {
                                _listBoxDropDown.ItemsSource = ItemListArray[_currentIndex];
                                _popupList.Margin = new Thickness(positionX - _popupList.Width, ActualHeight, 0, -342.0);
                                _popupList.IsOpen = true;
                                _droppedButton = args.Button;
                                _droppedButton.BeginShowAnimation();
                            }
                            break;
                    }

                };
                if (index < size)
                    nodes.Add(new NavigatorNode(index, value, command, Background, index == size - 1, ItemListArray[index]));
                index++;
            }

            _path = nodes;
            ItemsSource = _path;
            if (NPathChanged != null)
                NPathChanged(this, argument);
        }
コード例 #4
0
        private void ListBoxDropDownSelectionChanged(
            object sender,
            SelectionChangedEventArgs e)
        {
            _commandType = NavigatorNodeCommandType.Change;

            IEnumerable <string> splitedPath = Path.Split('\\').Take(_currentIndex + 1);
            string newPath = splitedPath.Aggregate(string.Empty, (current, next) => next + "\\")
                             + (string.IsNullOrWhiteSpace(((string)e.AddedItems.FirstOrDefault())) ?
                                string.Empty : (string)(e.AddedItems.FirstOrDefault()));
            NavigatorNodeCommandArgument argument =
                new NavigatorNodeCommandArgument(_currentIndex, newPath, _commandType);

            if (NPathChanged != null)
            {
                NPathChanged(this, argument);
            }
        }
コード例 #5
0
        private async void NavigatorPathChanged(object sender,
                                                NavigatorNodeCommandArgument e)
        {
            if (e.CommandType == NavigatorNodeCommandType.None)
            {
                return;
            }

            DataSource.CutNavigatorFromIndex(e.Index);
            if (e.CommandType == NavigatorNodeCommandType.Reduce)
            {
                StopImageChangingDispatcher();
                Frame.Navigate(typeof(PageExplorer), null);
            }
            else if (e.CommandType == NavigatorNodeCommandType.Change)
            {
                StorageFolder lastStorageFolder = DataSource.CurrentStorageFolder;
                if (lastStorageFolder != null)
                {
                    var results = await lastStorageFolder.GetItemsAsync();

                    string changedNode = e.Path.Split('\\').LastOrDefault();
                    foreach (var item in results)
                    {
                        if (item is StorageFolder && item.Name == changedNode)
                        {
                            StorageFolder storageFolder = (StorageFolder)item;
                            DataSource.NavigatorStorageFolders.Add(storageFolder);
                            break;
                        }
                    }
                }
                StopImageChangingDispatcher();
                Frame.Navigate(typeof(PageExplorer), null);
            }
        }
コード例 #6
0
ファイル: Navigator.cs プロジェクト: CasaTeam/MetroExplorer
        private void ListBoxDropDownSelectionChanged(
            object sender,
            SelectionChangedEventArgs e)
        {
            _commandType = NavigatorNodeCommandType.Change;

            IEnumerable<string> splitedPath = Path.Split('\\').Take(_currentIndex + 1);
            string newPath = splitedPath.Aggregate(string.Empty, (current, next) => next + "\\")
                + (string.IsNullOrWhiteSpace(((string)e.AddedItems.FirstOrDefault())) ?
                string.Empty : (string)(e.AddedItems.FirstOrDefault()));
            NavigatorNodeCommandArgument argument =
                new NavigatorNodeCommandArgument(_currentIndex, newPath, _commandType);
            if (NPathChanged != null)
                NPathChanged(this, argument);
        }