Ejemplo n.º 1
0
        /// <summary>
        /// Handles the <see cref="E:BrowseFile_RunWorkerCompleted" /> event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RunWorkerCompletedEventArgs"/> instance containing the event data.</param>
        void OnBrowseFile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!_directoryComputerImporter.IsValid)
            {
                //DialogHelper.Warning(_directoryComputerImporter.Message);
                DialogHelper.Warning("The data format is invalid.");
                FilePath = string.Empty;
            }
            else
            {
                var itemNote = _directoryComputerImporter.DirectoryComputerCollections
                               .FirstOrDefault(c => c.Id == CurrentDirectoryNode.NodeId);
                bool hasNewItem = false;
                CurrentDirectoryNode.IsExpanded = true;
                CommandManager.InvalidateRequerySuggested();
                XamDataTreeBuilder.AppendTree(CurrentDirectoryNode, itemNote,
                                              _directoryComputerImporter.DirectoryComputerCollections, ref hasNewItem);
                ApplicationContext.ImportNodesExpanded = new List <int>();
                //Expanded all node has child imported node
                XamDataTreeBuilder.ExpandedPathNode(CurrentDirectoryNode);
                XamDataTreeBuilder.ExpandedChildNode(CurrentDirectoryNode);
                XamDataTreeBuilder.SetNodeExpandedState(_view.DataTreeImport.Nodes);
                //Clear data
                ApplicationContext.ImportNodes         = new ObservableCollection <DirectoryNode>();
                ApplicationContext.ImportNodesExpanded = new List <int>();
                if (!hasNewItem)
                {
                    DialogHelper.Warning("All nodes existed in directory.");
                    FilePath = string.Empty;
                }
                CommandManager.InvalidateRequerySuggested();
            }
            var bgBrowseFile = sender as BackgroundWorker;

            if (bgBrowseFile != null)
            {
                bgBrowseFile.DoWork             += OnBrowseFile_Dowork;
                bgBrowseFile.RunWorkerCompleted += OnBrowseFile_RunWorkerCompleted;
            }
            VisibleSimulate       = Visibility.Collapsed;
            _mainViewModel.IsBusy = false;
        }
Ejemplo n.º 2
0
 private void ReloadData(int folderId)
 {
     DataTreeImportSource = XamDataTreeBuilder.MakeTree(folderId, out _currentDirectoryNode);
     // CurrentDirectoryNode.NodeColor = "#264A50";
 }