示例#1
0
        private DashboardFolderViewModel FindParentFolder(DashboardFolderViewModel parent, ObservableCollection<DashboardItemViewModel> observableCollection, DashboardItemViewModel folderVm)
        {
            foreach (DashboardItemViewModel item in observableCollection)
            {
                if (item.Equals(folderVm))
                { return parent; }
                else
                {
                    if (item is DashboardFolderViewModel )
                    {
                        DashboardFolderViewModel subFolder = (item as DashboardFolderViewModel );
                        DashboardFolderViewModel result = this.FindParentFolder(subFolder, subFolder.Items, folderVm);
                        if (result != null) return result;
                    }

                }
            }
            return null;
        }
示例#2
0
        private void RecurseLoadDashboard(List<InfDashboard> items, ObservableCollection<DashboardItemViewModel> parentList, long parentId)
        {
            List<InfDashboard> childs = (from i in items where i.IdParent == parentId orderby i.Ordre select i).ToList();
            foreach (InfDashboard child in childs)
            {
                if (child.InfCodeDashboard.Code.Equals("FOLDER"))
                {
                    DashboardFolderViewModel folder = new DashboardFolderViewModel();
                    folder.Model = child;
                    folder.DisplayName = child.Libelle;
                    parentList.Add(folder);
                    this.RecurseLoadDashboard(items, folder.Items, child.Id);
                }

                if (child.InfCodeDashboard.Code.Equals("TABLE"))
                {
                    DashboardTableViewModel table = new DashboardTableViewModel();
                    table.Model = child;
                    table.DisplayName = child.Libelle;
                    parentList.Add(table);

                }
            }
        }
示例#3
0
        public void AddFolder()
        {
            DbSet<InfCodeDashboard> datasCodeDashboard = _dataService.GetDbSet<InfCodeDashboard>();
            DbSet<InfDashboard> datasDashboard = _dataService.GetDbSet<InfDashboard>();
            DashboardDialogFolderViewModel vm = new DashboardDialogFolderViewModel();
            DashboardDialogFolderView v = new DashboardDialogFolderView();
            v.DataContext = vm;
            v.Owner = System.Windows.Application.Current.MainWindow;
            Nullable<Boolean> result = v.ShowDialog();
            if (result.HasValue && result.Value == true)
            {
                InfDashboard dashboardFolder = new InfDashboard();
                dashboardFolder.Code = vm.FolderName;
                dashboardFolder.Libelle = vm.FolderName;
                dashboardFolder.IdParent = -1;
                dashboardFolder.InfCodeDashboard = (from c in datasCodeDashboard where c.Code.Equals("FOLDER") select c).FirstOrDefault();
                dashboardFolder.Ordre = this.Items.Count +1;
                datasDashboard.Add(dashboardFolder);
                IEnumerable<DbEntityValidationResult> results =  _dataService.DataContext.GetValidationErrors();
                _dataService.DataContext.SaveChanges();

                DashboardFolderViewModel folder = new DashboardFolderViewModel();
                folder.DisplayName = vm.FolderName;
                folder.Model = dashboardFolder;
                this.Items.Add(folder);
                this.FillOrder();
            }
        }