Skip to content

Commit

Permalink
#16 - add info how to use Compare & Pin tool
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed Oct 1, 2023
1 parent b645208 commit 0cde818
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 13 deletions.
1 change: 1 addition & 0 deletions sources/RevitDBExplorer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
<Grid Grid.Row="2" Grid.Column="2" Margin="-2 0 0 0">
<componentList:ListView DataContext="{Binding List}" Visibility="{Binding DataContext.RightView, Converter={StaticResource EnumMatchToVisibilityConverter}, ConverterParameter=List, RelativeSource={RelativeSource AncestorType=Grid}}"/>
<componentCAndC:CommandAndControlView DataContext="{Binding CommandAndControl}" Margin="2 2 0 0" Visibility="{Binding DataContext.RightView, Converter={StaticResource EnumMatchToVisibilityConverter}, ConverterParameter=CommandAndControl, RelativeSource={RelativeSource AncestorType=Grid}}"/>
<componentList:CompareAndPinToolInfo Visibility="{Binding DataContext.RightView, Converter={StaticResource EnumMatchToVisibilityConverter}, ConverterParameter=CompareAndPinToolInfo, RelativeSource={RelativeSource AncestorType=Grid}}"/>
</Grid>

<componentBusyIndicator:BusyIndicator Grid.Row="2" Grid.Column="0" Grid.RowSpan="2" HorizontalAlignment="Left" Panel.ZIndex="1" VerticalAlignment="Bottom" Width="150" Height="26" Margin="0 0 0 0" Visibility="{Binding IsRevitBusy, Converter={StaticResource BoolToVisibilityConverter}}" />
Expand Down
17 changes: 12 additions & 5 deletions sources/RevitDBExplorer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

namespace RevitDBExplorer
{
internal enum RightView { None, List, CommandAndControl }
internal enum RightView { None, List, CommandAndControl, CompareAndPinToolInfo }

internal partial class MainWindow : Window, IAmWindowOpener, INotifyPropertyChanged
{
Expand Down Expand Up @@ -309,10 +309,17 @@ private async void Tree_SelectedItemChanged(SelectedItemChangedEventArgs eventAr
//}
}
if (eventArgs.NewOne is UtilityGroupTreeItem utilityGroupTreeItem)
{
RightView = RightView.List;
await List.PopulateListView(utilityGroupTreeItem);
return;
{
var wasSuccessful = await List.PopulateListView(utilityGroupTreeItem);
if (wasSuccessful)
{
RightView = RightView.List;
}
else
{
RightView = RightView.CompareAndPinToolInfo;
}
return;
}
RightView = RightView.None;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<UserControl x:Class="RevitDBExplorer.UIComponents.List.CompareAndPinToolInfo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:RevitDBExplorer.UIComponents.List"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Resources/Templates/All.xaml"/>
<ResourceDictionary Source="../../Resources/VectorGraphic.xaml"/>
<ResourceDictionary Source="DataTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>

<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>

<FlowDocumentScrollViewer>

<FlowDocument Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" FontFamily="Arial">
<Paragraph>
<Bold>Compare &amp; Pin tool</Bold>
</Paragraph>

<List>
<ListItem>
<Paragraph>to add an object to comparison, drag and drop object from the tree</Paragraph>
</ListItem>
<ListItem>
<Paragraph>comparison will take place only if two first objects from the list have
<Run FontWeight="Bold">the same type</Run></Paragraph>
</ListItem>
<ListItem>
<Paragraph>to remove a single object from the list, drag and drop object on the Remove button</Paragraph>
</ListItem>
<ListItem>
<Paragraph>order of objects on the list can be changed (surprise) by drag and drop</Paragraph>
</ListItem>
<ListItem>
<Paragraph>the list is shared between all instances of RDBE, this allows to compare objects from different Revit documents</Paragraph>
</ListItem>
<ListItem>
<Paragraph>you can store as many objects on the list as you want, and get easy access to them between different sessions of RDBE</Paragraph>
</ListItem>
</List>

</FlowDocument>
</FlowDocumentScrollViewer>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Windows.Controls;

// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md

namespace RevitDBExplorer.UIComponents.List
{
public partial class CompareAndPinToolInfo : UserControl
{
public CompareAndPinToolInfo()
{
InitializeComponent();
}
}
}
11 changes: 9 additions & 2 deletions sources/RevitDBExplorer/UIComponents/List/ListVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,27 @@ public async Task PopulateListView(SnoopableObjectTreeItem snoopableObjectTreeIt
ListItems = new(members.Select(x => new ListItemForSM(x, null, Reload)));
SetupListView();
}
public async Task PopulateListView(UtilityGroupTreeItem utilityGroupTreeItem)
public async Task<bool> PopulateListView(UtilityGroupTreeItem utilityGroupTreeItem)
{
if (utilityGroupTreeItem.Items?.Count < 2)
{
return;
return false;
}
Columns = columnsFor2;
var leftItem = utilityGroupTreeItem.Items[0] as SnoopableObjectTreeItem;
var rightItem = utilityGroupTreeItem.Items[1] as SnoopableObjectTreeItem;

if (leftItem.Object?.Object?.GetType() != rightItem.Object?.Object?.GetType())
{
return false;
}

var leftMembers = await ExternalExecutor.ExecuteInRevitContextAsync(x => leftItem.Object.GetMembers(x).ToList());
var rightMembers = await ExternalExecutor.ExecuteInRevitContextAsync(x => rightItem.Object.GetMembers(x).ToList());
var members = leftMembers.Zip(rightMembers, (x,y) => new ListItemForSM(x, y, Reload));
ListItems = new(members);
SetupListView();
return true;
}
private void SetupListView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ public virtual void Read()
internal class ListItemForSM : ListItem, IListItem
{
private readonly SnoopableMember leftMember;
private readonly SnoopableMember rightMember;

public override string Name => leftMember.Name;
public string Icon => $"Icon{leftMember.MemberKind}";
public DeclaringType DeclaringType => leftMember.DeclaringType;
public RevitDBExplorer.Domain.DocXml Documentation => leftMember.Documentation;
public SnoopableMember this[int i]
{
get { return leftMember; }
get
{
return i switch { 0 => leftMember, _ => rightMember };
}
}


public ListItemForSM(SnoopableMember left, SnoopableMember right, Action askForReload)
{
leftMember = left;
rightMember = right;
leftMember.SnoopableObjectChanged += () => askForReload();
SortingKey = $"{left.DeclaringType.InheritanceLevel:000}_{(int)left.MemberKind}_{left.Name}";
GroupingKey = left.DeclaringType.Name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEv
{
if (this.DataContext is BaseTreeViewModel treeView)
{
if (e.NewValue is TreeItem treeViewItemVM)
if ((e.NewValue is TreeItem treeViewItemVM))
{
treeView.RaiseSelectedItemChanged(treeViewItemVM);
}
if ((e.NewValue is null))
{
treeView.RaiseSelectedItemChanged(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using RevitDBExplorer.Domain.DataModel;
using RevitDBExplorer.Domain.DataModel;
using RevitDBExplorer.UIComponents.Trees.Base;
using RevitDBExplorer.UIComponents.Trees.Base.Items;
using RevitDBExplorer.WPF;
Expand Down Expand Up @@ -32,6 +30,10 @@ private void RemoveItems(object item)
}
else
{
if (SelectedItem != null)
{
SelectedItem.IsSelected = false;
}
rootItem.Items.Clear();
}
}
Expand Down

0 comments on commit 0cde818

Please sign in to comment.