public SelectStudyUnitWindow(SelectStudyUnitWindowVM viewModel)
        {
            InitializeComponent();
            this.viewModel = viewModel;
            viewModel.Window = this;
            DataContext = viewModel;

            DDIImportOption importOption = viewModel.ImportOption;
            if (!importOption.CanSelectFromStudyUnit)
            {
                grid.RowDefinitions[0].Height = new GridLength(0);
            }
        }
        public SelectStudyUnitWindow(SelectStudyUnitWindowVM viewModel)
        {
            InitializeComponent();
            this.viewModel   = viewModel;
            viewModel.Window = this;
            DataContext      = viewModel;

            DDIImportOption importOption = viewModel.ImportOption;

            if (!importOption.CanSelectFromStudyUnit)
            {
                grid.RowDefinitions[0].Height = new GridLength(0);
            }
        }
Esempio n. 3
0
        public bool Read(StudyUnitVM curStudyUnit, EDOModel curEdoModel, string path)
        {
            Debug.Assert(!string.IsNullOrEmpty(path));
            if (!Validate(path))
            {
                return false;
            }

            EDOModel newEdoModel = null;

            ClearError();
            XmlReaderSettings settings = new XmlReaderSettings();
            using (XmlReader reader = XmlReader.Create(path, settings))
            {
                XDocument doc = XDocument.Load(reader);
                XElement groupElem = doc.Descendants(g + TAG_GROUP).FirstOrDefault();
                if (groupElem != null)
                {
                    newEdoModel = CreateGroupModel(groupElem);
                }
                else
                {
                    XElement studyUnitElem = doc.Descendants(s + TAG_STUDY_UNIT).FirstOrDefault();
                    if (studyUnitElem != null)
                    {
                        newEdoModel = CreateSingleModel(studyUnitElem);
                    }
                }
            }
            if (newEdoModel == null)
            {
                return false;
            }
            DDI3ImportOption importOption = new DDI3ImportOption();
            SelectStudyUnitWindowVM vm = new SelectStudyUnitWindowVM(newEdoModel, curEdoModel, curStudyUnit.StudyUnitModel, importOption);
            SelectStudyUnitWindow window = new SelectStudyUnitWindow(vm);
            window.Owner = Application.Current.MainWindow;
            bool? result = window.ShowDialog();
            if (result != true)
            {
                return false;
            }
            MergeStudyUnit(vm.FromStudyUnit, vm.ToStudyUnit, vm.ImportOption);
            return true;
        }
Esempio n. 4
0
        public bool Read(StudyUnitVM curStudyUnit, EDOModel curEdoModel, string path)
        {
            Debug.Assert(!string.IsNullOrEmpty(path));
            if (!Validate(path))
            {
                return false;
            }

            EDOModel newEdoModel = null;
            ClearError();
            XmlReaderSettings settings = new XmlReaderSettings();
            using (XmlReader reader = XmlReader.Create(path, settings))
            {
                XDocument doc = XDocument.Load(reader);
                XElement codebookElem = doc.Element(cb + TAG_CODEBOOK);
                if (codebookElem != null)
                {
                    newEdoModel = CreateSingleModel(codebookElem);
                }
            }
            if (newEdoModel == null)
            {
                return false;
            }

            DDI2ImportOption importOption = new DDI2ImportOption();
            SelectStudyUnitWindowVM vm = new SelectStudyUnitWindowVM(newEdoModel, curEdoModel, curStudyUnit.StudyUnitModel, importOption);
            SelectStudyUnitWindow window = new SelectStudyUnitWindow(vm);
            window.Owner = Application.Current.MainWindow;
            bool? result = window.ShowDialog();
            if (result != true)
            {
                return false;
            }
            StudyUnit fromStudyUnit = newEdoModel.StudyUnits[0];
            StudyUnit toStudyUnit = curEdoModel.StudyUnits[0];
            MergeStudyUnit(fromStudyUnit, toStudyUnit, vm.ImportOption);
            return true;
        }