コード例 #1
0
        public MainViewModel()
        {
            Messenger.Default.Register <string>(this, "Object_DropInMainArchiverField", (path) =>
            {
                if (System.IO.Path.GetExtension(path) == ".rar" || System.IO.Path.GetExtension(path) == ".7z")
                {
                    System.Windows.MessageBox.Show("Поддерживаемый формат разархивации - zip");
                    return;
                }
                ArchivationProgressWindow archivationProgressWindow = new ArchivationProgressWindow();
                archivationProgressWindow.Show();

                archiveManager.HandleObject(path, new Progress <ProgressInfo>(info => archivationProgressWindow.ChangeProgress(info)));
            });

            Messenger.Default.Register <string>(this, "Object_DropInFileExplorer", (path) =>
            {
                AddNewFilesOrDirectories(path);
            });

            Messenger.Default.Register <System.Windows.Controls.TreeViewItem>(this, "TreeViewItem_Expanded", (item) =>
            {
                FileSystemElementViewModel element = (FileSystemElementViewModel)item.Header;

                if (!element.Element.IsFile)
                {
                    foreach (var subElement in element.SubFileSystemElements)
                    {
                        if (fileManager.AddSubElements(subElement.Element))
                        {
                            subElement.InitializeChildren();
                        }
                    }
                }
                else
                {
                    Process.Start(element.Element.Info.FullName);
                }
            });

            Messenger.Default.Register <object>(this, "Theme_Changed", (obj) =>
            {
                ClearField.Execute(obj);
            });
        }
コード例 #2
0
        private void AddNewFilesOrDirectories(string path) //здесь есть ошибка
        {
            try
            {
                if (path != null)
                {
                    ClearField.Execute(new Object());

                    fileManager        = new FileManager(path);
                    FileSystemElements = new ObservableCollection <FileSystemElementViewModel>
                                             (fileManager.Elements.Select(el => new FileSystemElementViewModel(el)));

                    Watch <FileSystemElement, FileSystemElementViewModel>(fileManager.Elements, FileSystemElements, el => el.Element);

                    RaisePropertyChanged(nameof(FileSystemElements));
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Неверный выбор елемента по пути " + path);
            }
        }