Browse Source

- Rewrite Dependency Matrix Control to WinForms

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6224 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Tomáš Linhart 16 years ago
parent
commit
f11afb62df
  1. 1
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 6
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs
  3. 139
      src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs
  4. 6
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  5. 4
      src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml

1
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj

@ -92,6 +92,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

6
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs

@ -10,11 +10,5 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
public class DependencyMatrixControl : MatrixControl<INode> public class DependencyMatrixControl : MatrixControl<INode>
{ {
static DependencyMatrixControl()
{
DefaultStyleKeyProperty.OverrideMetadata(
typeof(DependencyMatrixControl),
new FrameworkPropertyMetadata(typeof(DependencyMatrixControl)));
}
} }
} }

139
src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs

@ -2,103 +2,50 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows.Forms;
using System.Windows.Controls; using System.Drawing;
using System.Windows.Media;
namespace ICSharpCode.CodeQualityAnalysis.Controls namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
public class MatrixControl<TValue> : Grid public class MatrixControl<TValue> : DataGridView
{ {
public Matrix<TValue> Matrix { get; set; } public Matrix<TValue> Matrix { get; set; }
/// <summary> public MatrixControl()
/// TODO: Needs to be reworked for DataBinding and to XAML {
/// </summary> AllowUserToAddRows = false;
public void DrawMatrix() AllowUserToDeleteRows = false;
{ AllowUserToResizeRows = false;
DrawHeaders(); EnableHeadersVisualStyles = false;
}
for (int i = 0; i < Matrix.HeaderRows.Count; i++) {
RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); public void DrawMatrix()
{
for (int j = 0; j < Matrix.HeaderColumns.Count; j++) { DrawHeaders();
ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
for (int i = 0; i < Matrix.HeaderRows.Count; i++) {
var val = Matrix.EvaluateCell(Matrix.HeaderRows[i], Matrix.HeaderColumns[j]);
for (int j = 0; j < Matrix.HeaderColumns.Count; j++) {
var label = new Label { Content = val }; var val = Matrix.EvaluateCell(Matrix.HeaderRows[i], Matrix.HeaderColumns[j]);
var style = new Style(); this[i, j].Value = val.ToString();
}
style.Setters.Add(new Setter }
{ }
Property = Grid.RowProperty,
Value = i + 1 protected void DrawHeaders()
}); {
foreach (var headerColumn in Matrix.HeaderColumns) {
style.Setters.Add(new Setter var column = new DataGridViewTextBoxColumn();
{ column.HeaderText = headerColumn.Value.ToString();
Property = Grid.ColumnProperty, this.Columns.Add(column);
Value = j + 1 }
});
foreach (var headerRow in Matrix.HeaderRows) {
label.Style = style; var row = new DataGridViewRow();
row.HeaderCell.Value = headerRow.Value.ToString();
Children.Add(label); this.Rows.Add(row);
} }
} }
} }
protected void DrawHeaders()
{
RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
for (int i = 0; i < Matrix.HeaderRows.Count; i++) {
var label = new Label { Content = Matrix.HeaderRows[i].Value.ToString() };
var style = new Style();
style.Setters.Add(new Setter
{
Property = Grid.RowProperty,
Value = i + 1
});
style.Setters.Add(new Setter
{
Property = Grid.ColumnProperty,
Value = 0
});
label.Style = style;
Children.Add(label);
}
for (int i = 0; i < Matrix.HeaderColumns.Count; i++) {
var label = new Label { Content = Matrix.HeaderColumns[i].Value.ToString() };
var style = new Style();
style.Setters.Add(new Setter
{
Property = Grid.RowProperty,
Value = 0
});
style.Setters.Add(new Setter
{
Property = Grid.ColumnProperty,
Value = i + 1
});
label.Style = style;
label.LayoutTransform = new RotateTransform { Angle = -90 };
Children.Add(label);
}
}
}
} }

6
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml

@ -52,9 +52,9 @@
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Dependency Matrix"> <TabItem Header="Dependency Matrix">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True"> <WindowsFormsHost>
<Graph:DependencyMatrixControl x:Name="matrixControl"></Graph:DependencyMatrixControl> <Graph:DependencyMatrixControl x:Name="matrixControl"></Graph:DependencyMatrixControl>
</ScrollViewer> </WindowsFormsHost>
</TabItem> </TabItem>
</TabControl> </TabControl>
</Window> </Window>

4
src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml

@ -2,7 +2,5 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls" xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
> >
<Style TargetType="{x:Type Controls:DependencyMatrixControl}">
<Setter Property="ShowGridLines" Value="True" />
</Style>
</ResourceDictionary> </ResourceDictionary>
Loading…
Cancel
Save