public DashboardTableViewModel()
        {
            this.TreeContextMenuItems = new System.Collections.ObjectModel.ObservableCollection<ContextMenuItem>();

            ContextMenuItem contextMenuItemRemoveTable = new ContextMenuItem();
            contextMenuItemRemoveTable.DisplayName = "Supprimer cete table";
            contextMenuItemRemoveTable.Command = new DelegateCommand(new Action (delegate(){
                IDashboardService dashboardService = ServiceLocator.Current.GetInstance<IDashboardService>();
                dashboardService.RemoveTable(this);
            }));
            contextMenuItemRemoveTable.DashboardItem = this;
            this.TreeContextMenuItems.Add(contextMenuItemRemoveTable);
        }
示例#2
0
 public DashboardService(IEventAggregator eventAggregator,IDataService dataService)
 {
     this._dataService = dataService;
     this._eventAggregator = eventAggregator;
      //   this.AddItemCommand= new DelegateCommand(AddItem);
     this.RemoveItemCommand = new DelegateCommand(RemoveItem);
     this.Items = new ObservableCollection<DashboardItemViewModel>();
     _dispatcher = System.Windows.Application.Current.MainWindow.Dispatcher;
     this.OpenItemCommand = new DelegateCommand(OpenItem);
     this.TreeContextMenuItems = new ObservableCollection<ContextMenuItem>();
     ContextMenuItem contextMenuItemAddFolder = new ContextMenuItem();
     contextMenuItemAddFolder.DisplayName = "Ajouter un dossier";
     contextMenuItemAddFolder.Command = new DelegateCommand(AddFolder);
     contextMenuItemAddFolder.DashboardItem = null;
     this.TreeContextMenuItems.Add(contextMenuItemAddFolder);
 }
        public DashboardFolderViewModel()
        {
            this._dataService = ServiceLocator.Current.GetInstance<IDataService>();
            this.Items = new ObservableCollection<DashboardItemViewModel>();
            this.TreeContextMenuItems = new ObservableCollection<ContextMenuItem>();
            IDashboardService dashboardService = ServiceLocator.Current.GetInstance<IDashboardService>();
            ContextMenuItem contextMenuItemAddFolder = new ContextMenuItem();
            contextMenuItemAddFolder.DisplayName = "Ajouter un dossier";
            contextMenuItemAddFolder.Command = new DelegateCommand(AddFolder);
            contextMenuItemAddFolder.DashboardItem = this;
            this.TreeContextMenuItems.Add(contextMenuItemAddFolder);

            ContextMenuItem contextMenuItemRemoveFolder = new ContextMenuItem();
            contextMenuItemRemoveFolder.DisplayName = "Supprimer ce dossier";
            contextMenuItemRemoveFolder.Command = new DelegateCommand(RemoveFolder);
            contextMenuItemRemoveFolder.DashboardItem = this;
            this.TreeContextMenuItems.Add(contextMenuItemRemoveFolder);

            ContextMenuItem contextMenuItemAddTable = new ContextMenuItem();
            contextMenuItemAddTable.DisplayName = "Ajouter une table";
            contextMenuItemAddTable.DashboardItem = null;
            this.TreeContextMenuItems.Add(contextMenuItemAddTable);
            foreach (EntitySchemaInfo schema in _dataService.SchemaInfos)
            {
                ContextMenuItem contextMenuItemSchema = new ContextMenuItem();
                contextMenuItemSchema.DisplayName = schema.SchemaName;
                contextMenuItemSchema.DashboardItem = null;
                contextMenuItemAddTable.Items.Add(contextMenuItemSchema);
                List<EntityTableInfo> tbls = (from t in schema.TableInfos orderby t.DisplayName select t).ToList();
                foreach (EntityTableInfo table in tbls)
                {
                    ContextMenuItem contextMenuItemTable = new ContextMenuItem();
                    contextMenuItemTable.DisplayName = table.DisplayName;
                    contextMenuItemTable.DashboardItem = null;
                    contextMenuItemTable.Command = new DelegateCommand(new Action(delegate()
                    {
                        dashboardService.AddTable(this, table);
                    }));
                    contextMenuItemSchema.Items.Add(contextMenuItemTable);
                }

            }
        }
示例#4
0
        public void Initialize()
        {
            this._eventAggregator.GetEvent<SplashEvent>().Publish("Initialisation du tableau de bord ...");

            DbSet<InfCodeDashboard> datasCodeDashboard = _dataService.GetDbSet<InfCodeDashboard>();
            IQueryable<InfCodeDashboard> query = (from d in datasCodeDashboard where d.Code == "TABLE" select d);

            if (query.Count() == 0)
            {
                InfCodeDashboard codeTable = new InfCodeDashboard();
                codeTable.Code = "TABLE";
                codeTable.Libelle = "Table de la base de donnée";
                datasCodeDashboard.Add(codeTable);
                _dataService.DataContext.SaveChanges();
            }
            if ((from d in datasCodeDashboard where d.Code == "FOLDER" select d).Count() == 0)
            {
                InfCodeDashboard codeTable = new InfCodeDashboard();
                codeTable.Code = "FOLDER";
                codeTable.Libelle = "Dossier";
                datasCodeDashboard.Add(codeTable);
                _dataService.DataContext.SaveChanges();
            }
               _dispatcher.Invoke(new Action(delegate()
            {
                this.LoadDashboard();
                ContextMenuItem contextMenuItemAddTable = new ContextMenuItem();
                contextMenuItemAddTable.DisplayName = "Ajouter une table";
                contextMenuItemAddTable.DashboardItem = null;
                this.TreeContextMenuItems.Add(contextMenuItemAddTable);

                foreach (EntitySchemaInfo schema in _dataService.SchemaInfos)
                {
                    ContextMenuItem contextMenuItemSchema = new ContextMenuItem();
                    contextMenuItemSchema.DisplayName = schema.SchemaName;
                    contextMenuItemSchema.DashboardItem = null;
                    contextMenuItemAddTable.Items.Add(contextMenuItemSchema);
                    List<EntityTableInfo> tbls = (from t in schema.TableInfos orderby t.DisplayName  select t).ToList();
                    foreach (EntityTableInfo table in tbls)
                    {
                        ContextMenuItem contextMenuItemTable = new ContextMenuItem();
                        contextMenuItemTable.DisplayName = table.DisplayName;
                        contextMenuItemTable.DashboardItem = null;
                        contextMenuItemTable.Command = new DelegateCommand(new Action(delegate() {
                            this.AddTable(null, table);
                        }));
                        contextMenuItemSchema.Items.Add(contextMenuItemTable);
                    }

                }
            }));
        }