This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add association class creation to designer
- Loading branch information
Showing
48 changed files
with
3,508 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > | ||
<xsl:output method="html" encoding="utf-16"/> | ||
<xsl:template match="activity"> | ||
<head> | ||
<title>Activity Monitor Log</title> | ||
<style type="text/css"> | ||
body{ text-align: left; width: 100%; font-family: Verdana, sans-serif; } | ||
|
||
table{ border: none; border-collapse: separate; width: 100%; } | ||
|
||
tr.title td{ font-size: 24px; font-weight: bold; } | ||
|
||
th{ background: #d0d0d0; font-weight: bold; font-size: 10pt; text-align: left; } | ||
tr{ background: #eeeeee} | ||
td, th{ font-size: 8pt; padding: 1px; border: none; } | ||
|
||
tr.info td{} | ||
tr.warning td{background-color:yellow;color:black} | ||
tr.error td{background-color:red;color:black} | ||
|
||
span {text-decoration:underline} | ||
a:hover{text-transform:uppercase;color: #9090F0;} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<table> | ||
<tr class="title"> | ||
<td colspan="7">Activity Monitor Log</td> | ||
</tr> | ||
<tr> | ||
<td colspan="2">infos</td> | ||
<td colspan="5"><xsl:value-of select="count(entry[type='Information'])"/></td> | ||
</tr> | ||
<tr> | ||
<td colspan="2">warnings</td> | ||
<td colspan="5"><xsl:value-of select="count(entry[type='Warning'])"/></td> | ||
</tr> | ||
<tr> | ||
<td colspan="2">errors</td> | ||
<td colspan="5"><xsl:value-of select="count(entry[type='Error'])"/></td> | ||
</tr> | ||
<tr> | ||
<th width="20">#</th> | ||
<th width="50">Type</th> | ||
<th>Description</th> | ||
<th width="280">GUID</th> | ||
<th>Hr</th> | ||
<th>Source</th> | ||
<th>Time (UTC)</th> | ||
</tr> | ||
<xsl:apply-templates/> | ||
</table> | ||
|
||
</body> | ||
</xsl:template> | ||
|
||
<xsl:template match="entry"> | ||
<!-- example | ||
<entry> | ||
<record>136</record> | ||
<time>2004/02/26 00:42:59.706</time> | ||
<type>Error</type> | ||
<source>Microsoft Visual Studio</source> | ||
<description>Loading UI library</description> | ||
<guid>{00000000-0000-0000-0000-000000000000}</guid> | ||
<hr>800a006f</hr> | ||
<path></path> | ||
</entry> | ||
--> | ||
<xsl:choose> | ||
|
||
<xsl:when test="type='Information'"> | ||
<tr id="info" class="info"> | ||
<td><xsl:value-of select="record"/></td> | ||
<td></td> | ||
<xsl:call-template name="row"/> | ||
</tr> | ||
</xsl:when> | ||
|
||
<xsl:when test="type='Warning'"> | ||
<tr id="warning" class="warning"> | ||
<td><xsl:value-of select="record"/></td> | ||
<td>Warning</td> | ||
<xsl:call-template name="row"/> | ||
</tr> | ||
</xsl:when> | ||
|
||
<xsl:when test="type='Error'"> | ||
<tr id="error" class="error"> | ||
<td><xsl:value-of select="record"/></td> | ||
<td>ERROR</td> | ||
<xsl:call-template name="row"/> | ||
</tr> | ||
</xsl:when> | ||
|
||
</xsl:choose> | ||
|
||
</xsl:template> | ||
|
||
<xsl:template name="row"> | ||
<td id="description"><xsl:value-of select="description"/><xsl:if test="path"><br/>          <xsl:value-of select="path"/></xsl:if></td> | ||
<td id="guid"><xsl:value-of select="guid"/></td> | ||
<td id="hr"><xsl:value-of select="hr"/></td> | ||
<td><xsl:value-of select="source"/></td> | ||
<td><xsl:value-of select="time"/></td> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
||
using Microsoft.VisualStudio.Modeling.Diagrams; | ||
|
||
using Sawczyn.EFDesigner.EFModel.Annotations; | ||
|
||
namespace Sawczyn.EFDesigner.EFModel | ||
{ | ||
internal class ClassShapeDragData | ||
{ | ||
private readonly RectangleD initialBoundingBox; | ||
private readonly double cursorXOffset; | ||
private readonly double cursorYOffset; | ||
private readonly List<BidirectionalConnector> priorHighlightedConnectors = new List<BidirectionalConnector>(); | ||
|
||
public ClassShape ClassShape { get; } | ||
|
||
public ClassShapeDragData([NotNull] ClassShape classShape, PointD startingMousePosition) | ||
{ | ||
ClassShape = classShape ?? throw new ArgumentNullException(nameof(classShape)); | ||
|
||
cursorXOffset = startingMousePosition.X - classShape.AbsoluteBoundingBox.Left; | ||
cursorYOffset = startingMousePosition.Y - classShape.AbsoluteBoundingBox.Top; | ||
initialBoundingBox = classShape.AbsoluteBoundingBox; | ||
} | ||
|
||
private RectangleD BoundingBoxWithMouseAt(PointD mousePosition) | ||
{ | ||
double left = mousePosition.X - cursorXOffset; | ||
double top = mousePosition.Y - cursorYOffset; | ||
RectangleD boundingBox = new RectangleD(left, top, initialBoundingBox.Width, initialBoundingBox.Height); | ||
|
||
return boundingBox; | ||
} | ||
|
||
public List<BidirectionalConnector> GetBidirectionalConnectorsUnderShape(PointD mousePosition) | ||
{ | ||
ModelClass modelClass = (ModelClass)ClassShape?.ModelElement; | ||
|
||
if (modelClass == null) | ||
return new List<BidirectionalConnector>(); | ||
|
||
RectangleD boundingBox = BoundingBoxWithMouseAt(mousePosition); | ||
|
||
List<Guid> connectionObjectsWithAssociationClass = modelClass.Store.ElementDirectory.AllElements | ||
.OfType<ModelClass>() | ||
.Where(x => x.IsAssociationClass) | ||
.Select(x => x.DescribedAssociationElementId) | ||
.ToList(); | ||
|
||
List<BidirectionalConnector> connectors = ClassShape.Store.ElementDirectory.AllElements | ||
.OfType<BidirectionalConnector>() | ||
.Where(c => ((BidirectionalAssociation)c.ModelElement).SourceMultiplicity == Multiplicity.ZeroMany | ||
&& ((BidirectionalAssociation)c.ModelElement).TargetMultiplicity == Multiplicity.ZeroMany | ||
&& !connectionObjectsWithAssociationClass.Contains(((BidirectionalAssociation)c.ModelElement).Id) | ||
&& c.Diagram.Id == ClassShape.Diagram.Id | ||
&& c.AbsoluteBoundingBox.IntersectsWith(boundingBox)) | ||
.ToList(); | ||
|
||
Debug.WriteLine($"{connectors.Count} potential drop target(s)"); | ||
return connectors; | ||
} | ||
|
||
internal void HighlightActionableClassShapes(PointD mousePosition) | ||
{ | ||
List<BidirectionalConnector> connectors = GetBidirectionalConnectorsUnderShape(mousePosition); | ||
HighlightedShapesCollection highlightedShapes = ClassShape.Diagram.ActiveDiagramView.DiagramClientView.HighlightedShapes; | ||
|
||
DiagramItem classShapeItem = new DiagramItem(ClassShape); | ||
|
||
if (highlightedShapes.Contains(classShapeItem)) | ||
{ | ||
highlightedShapes.Remove(classShapeItem); | ||
ClassShape.Invalidate(); | ||
} | ||
|
||
foreach (BidirectionalConnector connector in priorHighlightedConnectors) | ||
{ | ||
highlightedShapes.Remove(new DiagramItem(connector)); | ||
connector.Invalidate(); | ||
} | ||
|
||
priorHighlightedConnectors.Clear(); | ||
|
||
if (connectors.Any()) | ||
{ | ||
priorHighlightedConnectors.AddRange(connectors); | ||
|
||
highlightedShapes.Add(classShapeItem); | ||
ClassShape.Invalidate(); | ||
|
||
foreach (BidirectionalConnector connector in connectors.Where(c => !highlightedShapes.Contains(new DiagramItem(c)))) | ||
{ | ||
highlightedShapes.Add(new DiagramItem(connector)); | ||
connector.Invalidate(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Dsl/CustomCode/ModelElement Interfaces/ICompartmentShapeMouseTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.VisualStudio.Modeling; | ||
using Microsoft.VisualStudio.Modeling.Diagrams; | ||
|
||
namespace Sawczyn.EFDesigner.EFModel | ||
{ | ||
public interface ICompartmentShapeMouseTarget | ||
{ | ||
void MoveCompartmentItem(ModelElement dragFrom, DiagramMouseEventArgs e); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/Dsl/CustomCode/ModelElement Interfaces/IMouseActionTarget.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.