コード例 #1
0
        public virtual IEditCommand CreateAddCommand(IKnowledgeViewModel viewModel, SemanticNetworkNode semanticNetworkNode, IInventorApplication application)
        {
            var conceptViewModel = viewModel as Concept;

            if (conceptViewModel != null)
            {
                return(new AddConceptCommand(conceptViewModel, semanticNetworkNode, application));
            }

            var statementViewModel = viewModel as StatementViewModel;

            if (statementViewModel != null)
            {
                return(new AddStatementCommand(statementViewModel, semanticNetworkNode, application));
            }

            return(null);
        }
コード例 #2
0
        public virtual IEditCommand CreateEditCommand(IKnowledgeViewModel viewModel, SemanticNetworkNode semanticNetworkNode, IInventorApplication application, IViewModelFactory viewModelFactory)
        {
            var conceptViewModel = viewModel as Concept;

            if (conceptViewModel != null)
            {
                var previousVersion = new Concept(conceptViewModel.BoundObject);
                return(new EditConceptCommand(conceptViewModel, previousVersion, semanticNetworkNode, application));
            }

            var statementViewModel = viewModel as StatementViewModel;

            if (statementViewModel != null)
            {
                var previousVersion = viewModelFactory.CreateStatementByInstance(statementViewModel.BoundStatement, application.CurrentLanguage);
                return(new EditStatementCommand(statementViewModel, previousVersion, semanticNetworkNode, application));
            }

            return(null);
        }
コード例 #3
0
        private void addKnowledgeClick(object sender, RoutedEventArgs e)
        {
            Type type         = null;
            var  selectedItem = SelectedItem;

            if (selectedItem is ConceptNode || selectedItem is SemanticNetworkConceptsNode)
            {
                type = typeof(Semantics.Concepts.Concept);
            }
            else if (selectedItem is StatementNode || selectedItem is SemanticNetworkStatementsNode)
            {
                var statementTypesDialog = new SelectStatementTypeDialog
                {
                    Owner = _owner,
                };
                statementTypesDialog.Initialize(_application.CurrentLanguage, _application.SemanticNetwork);
                if (statementTypesDialog.ShowDialog() == true)
                {
                    type = statementTypesDialog.SelectedType;
                }
            }
            if (type == null)
            {
                return;
            }

            IKnowledgeViewModel viewModel = _viewModelFactory.CreateByCoreType(type, _application.CurrentLanguage);
            var editDialog = viewModel.CreateEditDialog(_owner, _application.SemanticNetwork, _application.CurrentLanguage);

            if (editDialog.ShowDialog() == true)
            {
                var command = _commandsFactory.CreateAddCommand(viewModel, _semanticNetworkNode, _application);
                if (command != null)
                {
                    _changeController.Perform(command);
                }
            }
        }