Пример #1
0
 void IDiagramInitialization.InitializeDiagram(Diagram diagram)
 {
     if (null == diagram.Subject)
     {
         Store store = diagram.Store;
         ReadOnlyCollection <Catalog> catalogs = store.ElementDirectory.FindElements <Catalog>(false);
         if (catalogs.Count != 0)
         {
             Catalog catalog = catalogs[0];
             diagram.Associate(catalog);
             foreach (Schema schema in catalog.SchemaCollection)
             {
                 foreach (Table table in schema.TableCollection)
                 {
                     Diagram.FixUpDiagram(catalog, table);
                 }
                 foreach (ReferenceConstraintTargetsTable fkLink in store.ElementDirectory.FindElements <ReferenceConstraintTargetsTable>(false))
                 {
                     Table sourceTable;
                     if (null != (sourceTable = fkLink.ReferenceConstraint.SourceTable) &&
                         schema == sourceTable.Schema)
                     {
                         Diagram.FixUpDiagram(catalog, fkLink);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Adds the <see cref="Diagram"/> specified by <paramref name="diagram"/> to this <see cref="MultiDiagramDocView"/>.
        /// </summary>
        /// <param name="diagram">The <see cref="Diagram"/> to be added to this <see cref="MultiDiagramDocView"/>.</param>
        /// <param name="selectAsCurrent">Indicates whether focus should be given to the new <see cref="Diagram"/>.</param>
        public void AddDiagram(Diagram diagram, bool selectAsCurrent)
        {
            if (diagram == null)
            {
                throw new ArgumentNullException("diagram");
            }
            DiagramView designer = CreateDiagramView();

            diagram.Associate(designer);
            AddDesigner(designer, selectAsCurrent);
        }
Пример #3
0
 void IDiagramInitialization.InitializeDiagram(Diagram diagram)
 {
     if (null == diagram.Subject)
     {
         Store store = diagram.Store;
         ReadOnlyCollection <BarkerErModel> barkerModels = store.ElementDirectory.FindElements <BarkerErModel>(false);
         if (barkerModels.Count != 0)
         {
             BarkerErModel model = barkerModels[0];
             diagram.Associate(model);
             foreach (EntityType entity in model.EntityTypeCollection)
             {
                 Diagram.FixUpDiagram(model, entity);
             }
             foreach (BarkerErModelContainsBinaryAssociation link in store.ElementDirectory.FindElements <BarkerErModelContainsBinaryAssociation>(false))
             {
                 if (link.BarkerErModel == model)
                 {
                     FixUpDiagram(model, link);
                 }
             }
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Activate the specified <paramref name="diagram"/>
 /// </summary>
 /// <param name="diagram">The <see cref="Diagram"/> to activate</param>
 /// <returns>true if the diagram is successfully activated</returns>
 public bool ActivateDiagram(Diagram diagram)
 {
     if (diagram != null)             // Sanity check
     {
         bool  calledShow = false;
         Store spyOnStore = myStore;
         Store testStore  = diagram.Store;
         if (spyOnStore == null)
         {
             // Either the window has never been shown, or it is not currently
             // active. Pre-check the store against the current selection to
             // see if showing the window will actually initialize to the correct store.
             IMonitorSelectionService selectionService;
             ModelingDocData          docData;
             if (null != (selectionService = (IMonitorSelectionService)ExternalServiceProvider.GetService(typeof(IMonitorSelectionService))) &&
                 null != (docData = selectionService.CurrentDocument as ModelingDocData) &&
                 testStore == (spyOnStore = docData.Store))
             {
                 calledShow = true;
                 Show();
                 spyOnStore = myStore;                         // Sanity check in case something went wrong
             }
             else
             {
                 return(false);
             }
         }
         if (testStore == spyOnStore)
         {
             DiagramView diagramView        = myDiagramView;
             Diagram     oldDiagram         = diagramView.Diagram;
             bool        reselectOldDiagram = false;
             if (oldDiagram != null)
             {
                 reselectOldDiagram = oldDiagram == diagram;
                 if (!reselectOldDiagram)
                 {
                     myDisassociating = true;
                     try
                     {
                         oldDiagram.Disassociate(diagramView);
                     }
                     finally
                     {
                         myDisassociating = false;
                     }
                 }
             }
             if (!reselectOldDiagram)
             {
                 MultiDiagramDocView.DeactivateMouseActions(diagram.ActiveDiagramView);
                 diagram.Associate(diagramView);
             }
             AdjustVisibility(true, false);
             if (!calledShow)
             {
                 calledShow = true;
                 Show();
             }
             if (reselectOldDiagram && diagramView.Selection.PrimaryItem != null)
             {
                 OnSelectionChanging(EventArgs.Empty);
                 OnSelectionChanged(EventArgs.Empty);
             }
             else
             {
                 SetSelectedComponents(new object[] { diagram });
             }
             DiagramClientView clientView;
             if (calledShow &&
                 !(clientView = diagramView.DiagramClientView).Focused)
             {
                 clientView.Focus();
             }
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
		/// <summary>
		/// Activate the specified <paramref name="diagram"/>
		/// </summary>
		/// <param name="diagram">The <see cref="Diagram"/> to activate</param>
		/// <returns>true if the diagram is successfully activated</returns>
		public bool ActivateDiagram(Diagram diagram)
		{
			if (diagram != null) // Sanity check
			{
				bool calledShow = false;
				Store spyOnStore = myStore;
				Store testStore = diagram.Store;
				if (spyOnStore == null)
				{
					// Either the window has never been shown, or it is not currently
					// active. Pre-check the store against the current selection to
					// see if showing the window will actually initialize to the correct store.
					IMonitorSelectionService selectionService;
					ModelingDocData docData;
					if (null != (selectionService = (IMonitorSelectionService)ExternalServiceProvider.GetService(typeof(IMonitorSelectionService))) &&
						null != (docData = selectionService.CurrentDocument as ModelingDocData) &&
						testStore == (spyOnStore = docData.Store))
					{
						calledShow = true;
						Show();
						spyOnStore = myStore; // Sanity check in case something went wrong
					}
					else
					{
						return false;
					}
				}
				if (testStore == spyOnStore)
				{
					DiagramView diagramView = myDiagramView;
					Diagram oldDiagram = diagramView.Diagram;
					bool reselectOldDiagram = false;
					if (oldDiagram != null)
					{
						reselectOldDiagram = oldDiagram == diagram;
						if (!reselectOldDiagram)
						{
							myDisassociating = true;
							try
							{
								oldDiagram.Disassociate(diagramView);
							}
							finally
							{
								myDisassociating = false;
							}
						}
					}
					if (!reselectOldDiagram)
					{
						MultiDiagramDocView.DeactivateMouseActions(diagram.ActiveDiagramView);
						diagram.Associate(diagramView);
					}
					AdjustVisibility(true, false);
					if (!calledShow)
					{
						calledShow = true;
						Show();
					}
					if (reselectOldDiagram && diagramView.Selection.PrimaryItem != null)
					{
						OnSelectionChanging(EventArgs.Empty);
						OnSelectionChanged(EventArgs.Empty);
					}
					else
					{
						SetSelectedComponents(new object[] { diagram });
					}
					DiagramClientView clientView;
					if (calledShow &&
						!(clientView = diagramView.DiagramClientView).Focused)
					{
						clientView.Focus();
					}
					return true;
				}
			}
			return false;
		}
Пример #6
0
		/// <summary>
		/// Adds the <see cref="Diagram"/> specified by <paramref name="diagram"/> to this <see cref="MultiDiagramDocView"/>.
		/// </summary>
		/// <param name="diagram">The <see cref="Diagram"/> to be added to this <see cref="MultiDiagramDocView"/>.</param>
		/// <param name="selectAsCurrent">Indicates whether focus should be given to the new <see cref="Diagram"/>.</param>
		public void AddDiagram(Diagram diagram, bool selectAsCurrent)
		{
			if (diagram == null)
			{
				throw new ArgumentNullException("diagram");
			}
			DiagramView designer = CreateDiagramView();
			diagram.Associate(designer);
			AddDesigner(designer, selectAsCurrent);
		}