diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj index 5e9c673639..33cce6c0b7 100644 --- a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj +++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj @@ -92,6 +92,7 @@ + diff --git a/src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs b/src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs index aebbb7f48b..07c74e0c27 100644 --- a/src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs +++ b/src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs @@ -10,11 +10,5 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls { public class DependencyMatrixControl : MatrixControl { - static DependencyMatrixControl() - { - DefaultStyleKeyProperty.OverrideMetadata( - typeof(DependencyMatrixControl), - new FrameworkPropertyMetadata(typeof(DependencyMatrixControl))); - } } } diff --git a/src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs b/src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs index b12ec59b52..9548d994e2 100644 --- a/src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs +++ b/src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs @@ -2,103 +2,50 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; +using System.Windows.Forms; +using System.Drawing; namespace ICSharpCode.CodeQualityAnalysis.Controls { - public class MatrixControl : Grid - { - public Matrix Matrix { get; set; } - - /// - /// TODO: Needs to be reworked for DataBinding and to XAML - /// - public void DrawMatrix() - { - DrawHeaders(); - - for (int i = 0; i < Matrix.HeaderRows.Count; i++) { - RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - - for (int j = 0; j < Matrix.HeaderColumns.Count; j++) { - ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); - - var val = Matrix.EvaluateCell(Matrix.HeaderRows[i], Matrix.HeaderColumns[j]); - - var label = new Label { Content = val }; - - var style = new Style(); - - style.Setters.Add(new Setter - { - Property = Grid.RowProperty, - Value = i + 1 - }); - - style.Setters.Add(new Setter - { - Property = Grid.ColumnProperty, - Value = j + 1 - }); - - label.Style = style; - - Children.Add(label); - } - } - } - - 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); - } - } - } + public class MatrixControl : DataGridView + { + public Matrix Matrix { get; set; } + + public MatrixControl() + { + AllowUserToAddRows = false; + AllowUserToDeleteRows = false; + AllowUserToResizeRows = false; + EnableHeadersVisualStyles = false; + } + + public void DrawMatrix() + { + DrawHeaders(); + + for (int i = 0; i < Matrix.HeaderRows.Count; i++) { + + for (int j = 0; j < Matrix.HeaderColumns.Count; j++) { + var val = Matrix.EvaluateCell(Matrix.HeaderRows[i], Matrix.HeaderColumns[j]); + + this[i, j].Value = val.ToString(); + } + } + } + + protected void DrawHeaders() + { + foreach (var headerColumn in Matrix.HeaderColumns) { + var column = new DataGridViewTextBoxColumn(); + column.HeaderText = headerColumn.Value.ToString(); + this.Columns.Add(column); + } + + foreach (var headerRow in Matrix.HeaderRows) { + var row = new DataGridViewRow(); + row.HeaderCell.Value = headerRow.Value.ToString(); + this.Rows.Add(row); + } + } + } } diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml index 13d3e3e0c7..83de9745ef 100644 --- a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml +++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml @@ -52,9 +52,9 @@ - - - + + + diff --git a/src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml b/src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml index fced69fe0a..844f98c2fa 100644 --- a/src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml +++ b/src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml @@ -2,7 +2,5 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls" > - + \ No newline at end of file