コード例 #1
0
        private void FillWithFiles(AddExistingFileViewModel viewModel)
        {
            var contentFolder = GlueState.Self.ContentDirectory;

            var files = FileManager.GetAllFilesInDirectory(contentFolder, null, int.MaxValue);

            foreach (var file in files)
            {
                // make this thing relative:
                var relativeFile = FileManager.MakeRelative(file, contentFolder);

                // Feb 22, 2019
                // Initially I thought
                // I'd only show files that
                // aren't already added to the
                // current element, but files can
                // be added multiple times to an element
                // using different converters. Even though
                // it's rare, we want to still support it so
                // don't filter out files that are already added.

                viewModel.UnfilteredFileList.Add(relativeFile);
            }
            viewModel.ContentFolder = contentFolder;
            viewModel.RefreshFilteredList();
        }
コード例 #2
0
        public void AddExistingFileClick()
        {
            var viewModel = new AddExistingFileViewModel();

            FillWithFiles(viewModel);


            var window = new AddExistingFileWindow();

            window.DataContext = viewModel;

            var result = window.ShowDialog();

            if (result == true)
            {
                var    element             = GlueState.Self.CurrentElement;
                string directoryOfTreeNode = EditorLogic.CurrentTreeNode.GetRelativePath();
                bool   userCancelled       = false;

                foreach (var file in viewModel.Files)
                {
                    TaskManager.Self.AddSync(() =>
                    {
                        AddSingleFile(file, ref userCancelled, element, directoryOfTreeNode);
                    }, $"Adding file {file}");
                }
            }
        }