Skip to content

Commit

Permalink
Fix issue #118, #111
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Otykier committed Feb 22, 2018
1 parent bd56626 commit 245b860
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 299 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -35,3 +35,11 @@
/Plugins/VisualizeRelationships/obj
/TabularEditorInstaller/Debug
/TabularEditorInstaller/Release
/~$DAX functions.xlsx
/UpgradeLog.htm
/todo.txt
/TabularEditor2.psess
/TabularEditor171122.vspx
/TabularEditor171122.vsp
/TabularEditor1.psess
/DAX functions.xlsx
552 changes: 284 additions & 268 deletions AntlrGrammars/DAXLexer.g4

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions Plugins/SimplePlugin/SimplePlugin.csproj
Expand Up @@ -30,24 +30,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug-CL1400|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug-CL1400\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-CL1400|AnyCPU'">
<OutputPath>bin\Release-CL1400\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
141 changes: 141 additions & 0 deletions Plugins/VisualizeRelationships/TableVisual.cs
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using TabularEditor.TOMWrapper;

namespace VisualizeRelationships
{
public class Diagram
{
public Diagram(Model model)
{
Tables.Clear();
TablesZOrder.Clear();
Relationships.Clear();

var i = 0;
foreach (var t in model.Tables)
{
var tv = new TableVisual(this, t, i);
Tables.Add(t, tv);
TablesZOrder.Add(tv);
i++;
}

}
public Dictionary<Table, TableVisual> Tables = new Dictionary<Table, TableVisual>();
public List<TableVisual> TablesZOrder = new List<TableVisual>();
public List<RelationshipVisual> Relationships = new List<RelationshipVisual>();

private HashSet<Relationship> DrawnRelationships = new HashSet<Relationship>();

public void Draw(Graphics gfx)
{
DrawnRelationships.Clear();
foreach(var t in TablesZOrder)
{
t.DrawRelationships(gfx);
}
for (int i = TablesZOrder.Count - 1; i >= 0; i--)
{
TablesZOrder[i].Draw(gfx);
}
}

public DiagramObject HitTest(Point pt)
{

}

public void ClearSelectedTables()
{
foreach (var t in TablesZOrder) t.Selected = false;
}

public void ClearSelectedRelationships()
{
foreach (var r in Relationships) r.Selected = false;
}

public void ClearSelected()
{
ClearSelectedTables();
ClearSelectedRelationships();
}
}

public abstract class DiagramObject
{
public DiagramObject(Diagram diagram)
{
Diagram = diagram;
}
protected readonly Diagram Diagram;
public bool Selected { get; set; }
public abstract void Select(bool multiSelect);
}

public class RelationshipVisual: DiagramObject
{
TableVisual T1 { get { return Diagram.Tables[Relationship.FromTable]; } }
TableVisual T2 { get { return Diagram.Tables[Relationship.ToTable]; } }

public RelationshipVisual(Diagram diagram, Relationship relationship) : base(diagram) {
Relationship = relationship;
}
public Relationship Relationship;
public override void Select(bool multiSelect)
{

throw new NotImplementedException();
}
}

public class TableVisual: DiagramObject
{
public TableVisual(Diagram diagram, Table table, int increment = 0): base(diagram)
{
Table = table;
X = increment * 20;
Y = increment * 10;
Width = 100;
Height = 100;
}

public override void Select(bool multiSelect)
{
throw new NotImplementedException();
}

public Table Table;
public int X;
public int Y;
public int Width;
public int Height;

public void Draw(Graphics gfx)
{

var p = new Pen(Brushes.Black, Selected ? 2 : 1);

gfx.FillRectangle(Selected ? Brushes.LightGray : Brushes.White, X, Y, Width, Height);
gfx.DrawRectangle(p, X, Y, Width, Height);
gfx.DrawString(Table.Name, SystemFonts.DefaultFont, Brushes.Black, new RectangleF(X + 2, Y + 2, Width - 4, SystemFonts.DefaultFont.SizeInPoints + 4));
}

public void DrawRelationships(Graphics gfx)
{
var rels = Table.UsedInRelationships.ToList();

}

public bool HitTest(Point pt)
{
return pt.X >= X && pt.X <= X + Width && pt.Y >= Y && pt.Y <= Y + Height;
}
}

}
4 changes: 4 additions & 0 deletions Plugins/VisualizeRelationships/packages.config
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WindowsAPICodePack-Core" version="1.1.1" targetFramework="net46" />
</packages>
1 change: 1 addition & 0 deletions TOMWrapper/TOMWrapper/Base/Rules.ttinclude
Expand Up @@ -322,6 +322,7 @@ class Rules {
if(propertyName == "Levels") return "[Browsable(false)]";
if(propertyName == "Tables") return "[Browsable(false)]";
if(propertyName == "ColumnOrigin") return "[Browsable(false)]";
if(propertyName == "IsSimpleMeasure") return "[Browsable(false)]";

if(propertyName == "StatusGraphic") return "[TypeConverter(typeof(KPIStatusGraphicConverter))]";
if(propertyName == "TrendGraphic") return "[TypeConverter(typeof(KPITrendGraphicConverter))]";
Expand Down

0 comments on commit 245b860

Please sign in to comment.