コード例 #1
0
        /// <summary>
        /// Creates a relationship based on the given data.
        /// </summary>
        /// <param name="info">Info specifying the relationship to create.</param>
        public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info)
		{
			if( info.Source == null || info.Target == null )
				return;
				
			if( info.Source.ShapeElement == null || info.Target.ShapeElement == null )
				return;
				
			if( info.Source.ShapeElement.Element == null || info.Target.ShapeElement.Element == null )
				return;
				
			if (!info.Source.ShapeElement.TakesPartInRelationship)
                return;

			// gather creatable shapes
			System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = this.GetCreatableRelationships(info);
			System.Guid shapeToCreate = System.Guid.Empty;

			if( shapesPossible.Count == 0 )
				return;
			else if (shapesPossible.Count == 1)
                shapeToCreate = shapesPossible[0].DomainClassId;
			else
			{
				// let user choose what shape type he wants to create
				DslEditorSelection::SelectGenericViewModel<DslEditorSelection::SearchRSType.SearchRSTypeStruct> selectionViewModel
                            = new DslEditorSelection.SelectGenericViewModel<DslEditorSelection::SearchRSType.SearchRSTypeStruct>(
                                this.ViewModelStore, shapesPossible,
                                new DslEditorSelection.GenericSearchDelegate<DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Search),
                                new DslEditorSelection.GenericSortDelegate<DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Sort));

                // show dialog
                bool? result = this.GlobalServiceProvider.Resolve<DslEditorServices::IUIVisualizerService>().ShowDialog("SelectRSTypePopup", selectionViewModel);
                if (result == true && selectionViewModel.SelectedElement != null)
                {
                    shapeToCreate = selectionViewModel.SelectedElement.Value.DomainClassId;
                }

                selectionViewModel.Dispose();
                System.GC.Collect();
			}
			
			if( shapeToCreate == System.Guid.Empty )
				return;
				
			this.CreateRelationship(info, shapeToCreate);
			
			
        }
コード例 #2
0
        /// <summary>
        /// Creates a relationship based on the given data.
        /// </summary>
        /// <param name="info">Info specifying the relationship to create.</param>
        public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info)
        {
            if (info.Source == null || info.Target == null)
            {
                return;
            }

            if (info.Source.ShapeElement == null || info.Target.ShapeElement == null)
            {
                return;
            }

            if (info.Source.ShapeElement.Element == null || info.Target.ShapeElement.Element == null)
            {
                return;
            }

            if (!info.Source.ShapeElement.TakesPartInRelationship)
            {
                return;
            }

            // gather creatable shapes
            System.Collections.Generic.List <DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = this.GetCreatableRelationships(info);
            System.Guid shapeToCreate = System.Guid.Empty;

            if (shapesPossible.Count == 0)
            {
                return;
            }
            else if (shapesPossible.Count == 1)
            {
                shapeToCreate = shapesPossible[0].DomainClassId;
            }
            else
            {
                // let user choose what shape type he wants to create
                DslEditorSelection::SelectGenericViewModel <DslEditorSelection::SearchRSType.SearchRSTypeStruct> selectionViewModel
                    = new DslEditorSelection.SelectGenericViewModel <DslEditorSelection::SearchRSType.SearchRSTypeStruct>(
                          this.ViewModelStore, shapesPossible,
                          new DslEditorSelection.GenericSearchDelegate <DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Search),
                          new DslEditorSelection.GenericSortDelegate <DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Sort));

                // show dialog
                bool?result = this.GlobalServiceProvider.Resolve <DslEditorServices::IUIVisualizerService>().ShowDialog("SelectRSTypePopup", selectionViewModel);
                if (result == true && selectionViewModel.SelectedElement != null)
                {
                    shapeToCreate = selectionViewModel.SelectedElement.Value.DomainClassId;
                }

                selectionViewModel.Dispose();
                System.GC.Collect();
            }

            if (shapeToCreate == System.Guid.Empty)
            {
                return;
            }

            this.CreateRelationship(info, shapeToCreate);
        }