Пример #1
0
        public void LoadData()
        {
            if (canLoadData)
            {
                string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                            Properties.Resources.ComponentsFile);

                ComponentsRepository componentsRepository = new ComponentsRepository(path);
                ComponentslistViewModel.CreateAllComponents(componentsRepository);

                canLoadData = false;
            }
        }
        public void CreateAllComponents(ComponentsRepository componentsRepository)
        {
            this.componentsRepository = componentsRepository;

            componentsList = new List<ComponentViewModel>();

            foreach (Component component in componentsRepository.Components)
            {
                ComponentViewModel compVM = new ComponentViewModel(component);
                compVM.ReportDragEvent += compVM_ReportDragEvent;

                componentsList.Add(compVM);
            }

            Components = new ObservableCollection<ComponentViewModel>(componentsList);
        }
 protected override void OnDispose()
 {
     if (componentsRepository != null)
     {
         componentsRepository.Dispose();
         componentsRepository = null;
     }
 }