Ejemplo n.º 1
0
        private void ScanFileSystemForROIDocuments()
        {
            try
            {
                if (!Directory.Exists(DataDirectory))
                {
                    Directory.CreateDirectory(DataDirectory);
                }

                var roiDocList = new List <ROIDocumentViewModel>();
                foreach (var file in Directory.GetFiles(DataDirectory, "*.*", SearchOption.TopDirectoryOnly).ToList())
                {
                    var roiDocumentViewModel = new ROIDocumentViewModel
                    {
                        DocumentPath  = file,
                        DataDirectory = DataDirectory
                    };
                    roiDocList.Add(roiDocumentViewModel);
                }

                RoiDocViewModelList = new ObservableCollection <ROIDocumentViewModel>(roiDocList);
            }
            catch (Exception ex)
            {
                DialogService.Instance.ShowMessageError(ex);
            }
        }
Ejemplo n.º 2
0
        private void CloneROIDocument()
        {
            var selectedROIViewModel = SelectedRoiDocViewModelList[0];

            if (selectedROIViewModel == null)
            {
                return;
            }

            var suggestedFileNameNoExt = Path.GetFileNameWithoutExtension(FileSystemTools.GetNextAvailableFilename(Path.Combine(DataDirectory,
                                                                                                                                Path.GetFileNameWithoutExtension(selectedROIViewModel.DocumentPath) + "-copy.xml")));

            var reportName = DialogService.Instance.InputDialog("Clone Report", "", "Enter new report name:",
                                                                suggestedFileNameNoExt);

            if (string.IsNullOrEmpty(reportName))
            {
                return;
            }

            var newReportFilePath = Path.Combine(Path.GetDirectoryName(selectedROIViewModel.DocumentPath), reportName + ".xml");

            if (File.Exists(newReportFilePath))
            {
                DialogService.Instance.ShowMessageError("Error: File already exists: " + Environment.NewLine + Environment.NewLine + newReportFilePath);
            }
            else
            {
                File.Copy(SelectedRoiDocViewModelList[0].DocumentPath, newReportFilePath);
                var roiDocumentViewModel = new ROIDocumentViewModel
                {
                    DocumentPath  = newReportFilePath,
                    DataDirectory = DataDirectory,
                    ROIDocument   = { DocumentName = reportName, DateCreated = DateTime.Now, DateModified = DateTime.Now }
                };
                roiDocumentViewModel.SaveROIDocument();
                ScanFileSystemForROIDocuments();
            }
        }