Skip to content

Commit

Permalink
allow sort by color
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 5, 2023
1 parent 1de0500 commit 5e7b7df
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
5 changes: 5 additions & 0 deletions RevitElementBipChecker/View/FrmCompareBip.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
Height="Auto"
Margin="2,0,2,0"
Background="Yellow"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -198,6 +199,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="Firebrick "
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -217,6 +219,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="SeaGreen"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -236,6 +239,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="Gray"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -252,6 +256,7 @@
</Button>
<Button
Margin="2,0,0,0"
Width="80"
Background="WhiteSmoke"
BorderThickness="0.5"
Command="{Binding PropertyCommand}"
Expand Down
31 changes: 29 additions & 2 deletions RevitElementBipChecker/View/FrmCompareBip.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
using RevitElementBipChecker.Viewmodel;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using RevitElementBipChecker.Viewmodel;

namespace RevitElementBipChecker.View
{
Expand All @@ -7,11 +14,31 @@ namespace RevitElementBipChecker.View
/// </summary>
public partial class FrmCompareBip
{
private ParameterCompareViewModel _viewModel { get; set; }

public FrmCompareBip(ParameterCompareViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
this.DataContext = viewModel;
viewModel.FrmCompareBip = this;
}

private void SortByColor(object sender, RoutedEventArgs e)
{
try
{
var button = (Button) sender;
// sort another remain order by Name
dataGrid.ItemsSource = _viewModel.Differences
.OrderByDescending(x => x?.RowColor == button?.Background)
.ThenBy(x => x.Name);
dataGrid.ScrollIntoView(dataGrid.Items[0]);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
}
}
}
4 changes: 4 additions & 0 deletions RevitElementBipChecker/View/FrmPropertyChecker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
Height="Auto"
Margin="2,0,2,0"
Background="Yellow"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -158,6 +159,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="Firebrick "
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -177,6 +179,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="SeaGreen"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand All @@ -196,6 +199,7 @@
Height="Auto"
Margin="0,0,2,0"
Background="Gray"
Click="SortByColor"
Style="{StaticResource RoundedButton}">
<Button.ToolTip>
<ToolTip
Expand Down
20 changes: 19 additions & 1 deletion RevitElementBipChecker/View/FrmPropertyChecker.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using RevitElementBipChecker.Viewmodel;
using System;
using System.Linq;
using RevitElementBipChecker.Viewmodel;
using System.Windows;
using System.Windows.Controls;

namespace RevitElementBipChecker.View
{
Expand All @@ -21,5 +24,20 @@ private void CloseClick(object sender, RoutedEventArgs e)
{
this.Close();
}
private void SortByColor(object sender, RoutedEventArgs e)
{
try
{
var button = (Button) sender;
dataGrid.ItemsSource = _viewModel.Differences
.OrderByDescending(x => x?.RowColor == button?.Background)
.ThenBy(x => x.Name);
dataGrid.ScrollIntoView(dataGrid.Items[0]);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
}
}

0 comments on commit 5e7b7df

Please sign in to comment.