コード例 #1
0
        public TableTreeViewItemViewModel(BrowserViewModel browser, DocumentServiceViewModel documentService, DiffDataTable diffTable)
            : base(browser)
        {
            this.documentService                     = documentService;
            this.Source                              = diffTable;
            this.Source.PropertyChanged             += DiffType_PropertyChanged;
            this.Source.SourceItem1.PropertyChanged += SourceItem1_PropertyChanged;
            this.Source.SourceItem2.PropertyChanged += SourceItem2_PropertyChanged;
            this.header1                             = diffTable.Header1;
            this.header2                             = diffTable.Header2;
            this.ViewCommand                         = new DelegateCommand(this.View);
            this.IsActivated                         = diffTable.DiffState != DiffState.Unchanged;
            this.Target                              = diffTable;

            foreach (var item in diffTable.Childs)
            {
                var viewModel = new TableTreeViewItemViewModel(browser, documentService, diffTable: item);
                viewModel.PropertyChanged += ChildViewModel_PropertyChanged;
                this.Items.Add(viewModel);
                if (this.IsActivated == false && viewModel.DiffState != DiffState.Unchanged)
                {
                    this.IsActivated = true;
                }
            }
            this.Dispatcher.InvokeAsync(() =>
            {
                if (this.DiffState != DiffState.Unchanged && this.Parent != null)
                {
                    this.Parent.IsExpanded = true;
                }
            });
        }
コード例 #2
0
        private async void Import(TableTreeViewItemViewModel viewModel)
        {
            try
            {
                var dataTable    = viewModel.Source.ExportTable2();
                var dataBaseName = this.cremaAppHost.DataBaseName;
                var dataBase     = await this.DataBaseContext.Dispatcher.InvokeAsync(() => this.DataBaseContext[dataBaseName]);

                var comment = await this.GetCommentAsync(viewModel.DisplayName);

                if (comment == null)
                {
                    return;
                }

                var dialog = new ProgressViewModel
                {
                    DisplayName = viewModel.DisplayName
                };
                await dialog.ShowDialogAsync(() => dataBase.ImportAsync(this.authenticator, dataTable.DataSet, comment));
            }
            catch (Exception e)
            {
                await AppMessageBox.ShowErrorAsync(e);
            }
        }
コード例 #3
0
        protected override void OnSelectionChanged(EventArgs e)
        {
            base.OnSelectionChanged(e);

            if (this.selectedTable != null)
            {
                this.selectedTable.PropertyChanged -= SelectedTable_PropertyChanged;
            }
            this.propertyService.SelectedObject = this.SelectedItem;
            this.selectedTable = this.SelectedItem as TableTreeViewItemViewModel;
            if (this.selectedTable != null)
            {
                this.selectedTable.PropertyChanged += SelectedTable_PropertyChanged;
            }
            this.NotifyOfPropertyChange(nameof(this.CanImport));
        }
コード例 #4
0
        public void UpdateItemsSource()
        {
            var compositionService = this.ServiceProvider.GetService(typeof(ICompositionService)) as ICompositionService;

            var typesCategory = new CategoryTreeViewItemViewModel("types");

            compositionService.SatisfyImportsOnce(typesCategory);
            foreach (var item in this.dataSet.Types)
            {
                var viewModel = new TypeTreeViewItemViewModel(this, this.documentService, diffType: item);
                compositionService.SatisfyImportsOnce(viewModel);
                typesCategory.Items.Add(viewModel);
            }
            this.Items.Add(typesCategory);

            var templatesCategory = new CategoryTreeViewItemViewModel("templates");

            compositionService.SatisfyImportsOnce(templatesCategory);
            foreach (var item in this.dataSet.Tables)
            {
                if (item.TemplatedParent != null)
                {
                    continue;
                }
                var viewModel = new TemplateTreeViewItemViewModel(this, this.documentService, diffTemplate: item.Template);
                compositionService.SatisfyImportsOnce(viewModel);
                templatesCategory.Items.Add(viewModel);
            }
            this.Items.Add(templatesCategory);

            var tablesCategory = new CategoryTreeViewItemViewModel("tables");

            compositionService.SatisfyImportsOnce(tablesCategory);
            foreach (var item in this.dataSet.Tables)
            {
                var viewModel = new TableTreeViewItemViewModel(this, this.documentService, diffTable: item);
                compositionService.SatisfyImportsOnce(viewModel);
                tablesCategory.Items.Add(viewModel);
            }
            this.Items.Add(tablesCategory);
        }