Exemplo n.º 1
0
        private void FileAddCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;

            System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Select the directory that you want to share.",
            };

            System.Windows.Forms.DialogResult result = dlg.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FileComponent file = new FileComponent(dlg.SelectedPath)
                {
                    Owner = entity
                };
                FileController.Add(file);
            }

            FileTreeView.UnselectAll();
        }
Exemplo n.º 2
0
        private void ScanFolder(IFolder folder)
        {
            var result = Scanner.Scan(folder);

            var confirmed = Input.ProcessResult(folder.Name, result);

            if (confirmed.Count() > 0)
            {
                IEnumerable <IFile> files = confirmed
                                            .Where(r => r.Result == ScanResult.New)
                                            .Select(sr => new File()
                {
                    FileName     = Path.GetFileNameWithoutExtension(sr.Path),
                    Extension    = sr.Extension,
                    FileLocation = sr.Path,
                    Root         = folder.AsFolder(),
                    RootId       = folder.Id,
                    FileSize     = new FileInfo(sr.Path).Length
                                   //- to list must be done, otherwise the following population will be lost
                }).ToList();

                //- populate required entity tree
                foreach (var file in files)
                {
                    IMediaFile media = Factory.GetMediaFile(file);
                    file.Media = media;
                    IMediaMetaData meta = Factory.GetMediaMetaData(media);
                    media.MetaData = meta;
                }

                var processed = FileController.Add(files, folder.Id);

                Broadcaster.SendNewMediaMessage(processed.Select(f => f.Media));

                HasChanged = true;
            }
        }