Esempio n. 1
0
 private void AddFolder(string name, IFolderViewModel folder)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Folders.Add(name.ToLower(), folder);
     });
 }
Esempio n. 2
0
        private IFolderViewModel MergeFolders(IFolderViewModel root,
                                              string[] dirs,
                                              string accumulatedPath,
                                              List <IFolderViewModel> PathItems)
        {
            IFolderViewModel nextRoot = null;

            int i = 1;

            for (; i < dirs.Length; i++)
            {
                accumulatedPath = accumulatedPath + "/" + dirs[i];

                if (root.Folders.TryGetValue(dirs[i].ToLower(), out nextRoot) == false)
                {
                    (root as FolderViewModel).LoadFolders();     // Refresh children of this node

                    // Find Folder in which we will have to insert this
                    if (root.Folders.TryGetValue(dirs[i].ToLower(), out nextRoot) == false)
                    {
                        return(root);
                    }
                }

                PathItems.Add(nextRoot);
                root = nextRoot;
            }

            return(root);
        }
Esempio n. 3
0
 /// <summary>
 /// Adds the folder item into the collection of sub-folders of this folder.
 /// </summary>
 /// <param name="item"></param>
 public void AddFolder(IFolderViewModel item)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         Folders.Add(item.FolderName.ToLower(), item);
     });
 }
Esempio n. 4
0
 public PokemonDragDropData(PokemonViewModel data, DragDropActions allowedActions,
     IFolderViewModel source, int pmIndex)
 {
     this.Pokemon = data;
     this.AllowedActions = allowedActions;
     this.SourceFolder = source;
     this.PokemonIndexInFolder = pmIndex;
 }
Esempio n. 5
0
        public FolderCreationView GetFolderCreationView(IFolderViewModel parent)
        {
            var view = new FolderCreationView(_container.Resolve <IFolderCreationViewModel>(new ParameterOverride("parent", parent)));

            SetOwner(view);

            return(view);
        }
Esempio n. 6
0
        public PokemonViewModel(IFolderViewModel folderViewModel, PokemonCustomInfo model)
        {
            this.Folder = folderViewModel;
              this._model = model;
              InitializeCommand();

              PropertyChangedEventManager.AddListener(Model, this, "PokemonTypeId");
        }
Esempio n. 7
0
        private void PopulateRoot()
        {
            IFolderViewModel rootFolder = _serviceFactory.Make <IFolderViewModel>(_fileSystemService.ReadRootFolder());

            rootFolder.IsExpanded = true;

            RootFolderCollection.Clear();
            RootFolderCollection.Add(rootFolder);
        }
        public FolderCreationViewModel(IAppServices appServices,
                                       IFolderViewModel parent)
            : base(appServices)
        {
            var logger = appServices.GetLogger <FolderCreationViewModel>();

            logger.Log(LoggingLevel.Debug, "mememe");
            _logger = logger;
            _parent = parent;
            SetupCommands();
        }
Esempio n. 9
0
        public FolderPanel(IFolderViewModel viewModel, IPanelFactory panelFactory)
        {
            _panelFactory = panelFactory;

            DataContext = viewModel;

            XamlReader.Load(this);

            _panelFactory = panelFactory;

            DataContext = viewModel;

            InitializeEvents();

            GridLayoutPanel.Content = ContentGridLayout;
        }
Esempio n. 10
0
        /// <summary>
        /// Get all child entries for a given path entry
        /// </summary>
        /// <param name="childFolders"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        private static IFolderViewModel Expand(ObservableSortedDictionary <string, IFolderViewModel> childFolders, string path)
        {
            if (string.IsNullOrEmpty(path) || childFolders.Count == 0)
            {
                return(null);
            }

            string folderName = path;

            if (path.Contains('/') || path.Contains('\\'))
            {
                int idx = path.IndexOfAny(new char[] { '/', '\\' });
                folderName = path.Substring(0, idx);
                path       = path.Substring(idx + 1);
            }
            else
            {
                path = null;
            }

            // bugfix: Folder names on windows are case insensitiv
            //var results = childFolders.Where<IFolderViewModel>(folder => string.Compare(folder.FolderName, folderName, true) == 0);
            IFolderViewModel results;

            childFolders.TryGetValue(folderName.ToLower(), out results);
            if (results != null)
            {
                IFolderViewModel fvm = results;

                var folder = fvm as FolderViewModel;  // Cast this to access internal setter
                folder.IsExpanded = true;

                var retVal = BrowserViewModel.Expand(fvm.Folders, path);
                if (retVal != null)
                {
                    return(retVal);
                }
                else
                {
                    return(fvm);
                }
            }

            return(null);
        }
Esempio n. 11
0
        private static void Item_Expanded(object sender, RoutedEventArgs e)
        {
            var uiElement = sender as TreeViewItem;

            // Sanity check just in case this was somehow send by something else
            if (uiElement == null)
            {
                return;
            }

            IFolderViewModel f = null;

            if (uiElement.DataContext is KeyValuePair <string, IFolderViewModel> )
            {
                var item = ((KeyValuePair <string, IFolderViewModel>)uiElement.DataContext);

                f = item.Value;

                // Message Expand only for those who have 1 dummy folder below
                if (f.ChildFolderIsDummy == false)
                {
                    return;
                }
            }

            ICommand changedCommand = TreeViewItemExpanded.GetCommand(uiElement);

            // There may not be a command bound to this after all
            if (changedCommand == null || f == null)
            {
                return;
            }

            // Check whether this attached behaviour is bound to a RoutedCommand
            if (changedCommand is RoutedCommand)
            {
                // Execute the routed command
                (changedCommand as RoutedCommand).Execute(f, uiElement);
            }
            else
            {
                // Execute the Command as bound delegate
                changedCommand.Execute(f);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Expand folder for the very first time (using the process background viewmodel).
        /// </summary>
        /// <param name="expandedItem"></param>
        private void ExpandDummyFolder(IFolderViewModel expandedItem)
        {
            if (expandedItem != null && mIsExpanding == false)
            {
                if (expandedItem.ChildFolderIsDummy == true)
                {
                    mIsExpanding = true;

                    mExpandProcessor.StartProcess(() =>
                    {
                        expandedItem.ClearFolders();                    // Requery sub-folders of this item
                        (expandedItem as FolderViewModel).LoadFolders();

                        ////expandedItem.IsSelected = true;
                        ////SelectedFolder = expandedItem.FolderPath;
                    }, ExpandProcessinishedEvent, "This process is already running.");
                }
            }
        }
Esempio n. 13
0
 public void CloseFolder(IFolderViewModel folder)
 {
     if (folder.IsOpen)
       {
     folder.IsOpen = false;
     OpenWindows.Remove(folder);
       }
 }
Esempio n. 14
0
 public void OpenFolder(IFolderViewModel folder)
 {
     if (!folder.IsOpen)
       {
     folder.IsOpen = true;
     OpenWindows.Add(folder);
       }
 }
Esempio n. 15
0
        private static void MoveItemTo(IFolderViewModel folder, int destIndex, 
            PokemonDragDropData data)
        {
            //remove the origin item to prevent exceeding the size
            data.SourceFolder.RemovePokemon(data.Pokemon);

            //adjust index if it is movement within a folder
            if (folder == data.SourceFolder && destIndex > data.PokemonIndexInFolder)
                destIndex--;

            folder.InsertPokemon(destIndex, data.Pokemon);
        }
Esempio n. 16
0
 private static void SubstitueItem(IFolderViewModel folder, int destIndex, 
     PokemonDragDropData data)
 {
     folder.Pokemons[destIndex].RemoveSelf();
     folder.InsertPokemon(destIndex, data.Pokemon.Clone());
 }
Esempio n. 17
0
        private static void SwapItem(IFolderViewModel folder, int swapIndex, 
            PokemonDragDropData data)
        {
            PokemonViewModel pokemon = data.Pokemon;
            int originalIndex = data.PokemonIndexInFolder;
            PokemonViewModel swapPokemon = folder.Pokemons[swapIndex];

            folder.RemovePokemon(swapPokemon);
            data.SourceFolder.RemovePokemon(pokemon);
            if (data.SourceFolder == folder && swapIndex < originalIndex)//swap within a folder
            {
                folder.InsertPokemon(swapIndex, pokemon);
                folder.InsertPokemon(originalIndex, swapPokemon);
                /*
                if (swapIndex < originalIndex)
                {
                }
                else
                {
                    folder.InsertPokemon(originalIndex, swapPokemon);
                    folder.InsertPokemon(swapIndex, pokemon);
                }
                 */
            }
            else//swap between folders
            {
                data.SourceFolder.InsertPokemon(originalIndex, swapPokemon);
                folder.InsertPokemon(swapIndex, pokemon);
            }
        }
Esempio n. 18
0
 private static void CopyItemTo(IFolderViewModel folder, int destIndex, 
     PokemonDragDropData data)
 {
     folder.InsertPokemon(destIndex, data.Pokemon.Clone());
 }