Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed Oct 31, 2023
1 parent 923de8c commit b6cc5a4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Yet another [RevitLookup](https://github.com/jeremytammik/RevitLookup) like tool. RevitLookup was an indispensable tool to work with Revit API for many years. But now, there is a better tool for the job. Let me introduce you to Revit database explorer and its capabilities. It not only allows us to **explore** database but also to:
- **edit**, any parameter value
- **query**, with intuitive syntax that is translated into a FilteredElementCollector
- **query**, database with intuitive syntax that is translated into a FilteredElementCollector
- **script**, by running ad hoc scripts written in C#
- **visualize**, geometrical features of elements

Expand Down
12 changes: 6 additions & 6 deletions sources/RevitDBExplorer/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base;
using RevitDBExplorer.Domain.RevitDatabaseQuery;
using RevitDBExplorer.Properties;
using RevitDBExplorer.Utils;
using RevitDBScripting;

namespace RevitDBExplorer
{
public class Application : IExternalApplication, IScriptRunner
{
private static UIView UIView;
private static View View;
public static IntPtr RevitWindowHandle;
public static UIApplication UIApplication;
public static RDSController RDSController;
private static UIView UIView;
private static View View;


public Application()
{
Expand Down Expand Up @@ -59,10 +61,7 @@ public Result OnStartup(UIControlledApplication application)
UIApplication.ViewActivated += UIApplication_ViewActivated;

return Result.Succeeded;
}



}
public Result OnShutdown(UIControlledApplication application)
{
application.Idling -= Application_Idling;
Expand Down Expand Up @@ -169,6 +168,7 @@ public static string GetMouseStatus()
return "";
}


private static DateTime LastTimeWhenInCharge;
private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
{
Expand Down
4 changes: 2 additions & 2 deletions sources/RevitDBExplorer/Command.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RevitDBExplorer.Domain.Selectors;
using System.Diagnostics;

namespace RevitDBExplorer
{
Expand Down
1 change: 1 addition & 0 deletions sources/RevitDBExplorer/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Windows.Controls;
using RevitDBExplorer.Domain.RevitDatabaseQuery.Autocompletion;
using RevitDBExplorer.Properties;
using RevitDBExplorer.Utils;
using RevitDBExplorer.WPF;

// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
Expand Down
26 changes: 24 additions & 2 deletions sources/RevitDBExplorer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
using System.Windows.Threading;
using RevitDBExplorer.Augmentations;
using RevitDBExplorer.Domain;
using RevitDBExplorer.Domain.DataModel.ValueViewModels;
using RevitDBExplorer.Domain.RevitDatabaseQuery;
using RevitDBExplorer.Domain.RevitDatabaseScripting;
using RevitDBExplorer.Domain.Selectors;
using RevitDBExplorer.Properties;
using RevitDBExplorer.UIComponents.Breadcrumbs;
using RevitDBExplorer.UIComponents.List;
using RevitDBExplorer.UIComponents.List.ViewModels;
using RevitDBExplorer.UIComponents.QueryEditor;
using RevitDBExplorer.UIComponents.QueryVisualization;
using RevitDBExplorer.UIComponents.Trees.Base;
Expand Down Expand Up @@ -47,7 +49,7 @@ internal partial class MainWindow : Window, IAmWindowOpener, INotifyPropertyChan
private string newVersionLink;
private bool isWiderThan800px;
private string mouseStatus;
private string rdqGeneratedCSharpSyntax;
private string rdqGeneratedCSharpSyntax = "";


public QueryEditorViewModel QueryEditor => queryEditorVM;
Expand Down Expand Up @@ -172,9 +174,13 @@ public MainWindow()
ExplorerTree.ScriptWasGenerated += OpenRDSWithGivenScript;
UtilityTree.SelectedItemChanged += Tree_SelectedItemChanged;
UtilityTree.ScriptWasGenerated += OpenRDSWithGivenScript;
List.SelectedItemChanged += List_SelectedItemChanged;

rdvController = RevitDatabaseVisualizationFactory.CreateController();
}



private async Task InitializeAsync()
{
(IsNewVerAvailable, NewVersionLink) = await VersionChecker.CheckIfNewVersionIsAvailable();
Expand Down Expand Up @@ -280,6 +286,21 @@ private async void Tree_SelectedItemChanged(SelectedItemChangedEventArgs eventAr
}
RightView = RightView.None;
}
private void List_SelectedItemChanged(ListSelectedItemChangedEventArgs args)
{
if (args.NewOne is ListItemForMember listItemForMember)
{
var leftOne = listItemForMember[0];
var righttOne = listItemForMember[1];

if (leftOne?.ValueViewModel is DefaultPresenter { ValueContainer: { } } presenter)
{
var v = presenter.ValueContainer.GetVisualization();

//return Enumerable.Empty<DrawingVisual>();
}
}
}
bool ignoreEvents = false;
void IAmWindowOpener.Open(SourceOfObjects sourceOfObjects)
{
Expand Down Expand Up @@ -364,7 +385,8 @@ private void Window_Closed(object sender, EventArgs e)
ExplorerTree.SelectedItemChanged -= Tree_SelectedItemChanged;
ExplorerTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
UtilityTree.SelectedItemChanged -= Tree_SelectedItemChanged;
UtilityTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
UtilityTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
List.SelectedItemChanged -= List_SelectedItemChanged;
}
private void Window_Closing(object sender, EventArgs e)
{
Expand Down
12 changes: 10 additions & 2 deletions sources/RevitDBExplorer/UIComponents/List/ListVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using RevitDBExplorer.Domain.DataModel.ValueViewModels.Base;
using RevitDBExplorer.UIComponents.List.ViewModels;
using RevitDBExplorer.UIComponents.List.WPF;
using RevitDBExplorer.UIComponents.Trees.Base;
using RevitDBExplorer.UIComponents.Trees.Base.Items;
using RevitDBExplorer.WPF;

Expand Down Expand Up @@ -64,11 +65,17 @@ public IListItem ListSelectedItem
return listSelectedItem;
}
set
{
listSelectedItem = value;
{
if (listSelectedItem != value)
{
var oldOne = listSelectedItem;
listSelectedItem = value;
SelectedItemChanged?.Invoke(new ListSelectedItemChangedEventArgs(oldOne, listSelectedItem));
}
OnPropertyChanged();
}
}
public event Action<ListSelectedItemChangedEventArgs> SelectedItemChanged;
public RelayCommand KeyDown_Enter_Command { get; }
public RelayCommand ListItem_Click_Command { get; }
public RelayCommand ReloadCommand { get; }
Expand Down Expand Up @@ -381,6 +388,7 @@ private async void Reload()
}
}

internal record class ListSelectedItemChangedEventArgs(IListItem OldOne, IListItem NewOne);
internal interface IAmWindowOpener
{
void Open(SourceOfObjects sourceOfObjects);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Autodesk.Windows;
using RevitDBExplorer.Domain;

namespace RevitDBExplorer
namespace RevitDBExplorer.Utils
{
public static class ApplicationModifyTab
{
private static Autodesk.Windows.RibbonPanel ribbonPanel;
private static RibbonPanel ribbonPanel;


public static void Init(Autodesk.Windows.RibbonPanel ribbonPanel, bool visible = false)
public static void Init(RibbonPanel ribbonPanel, bool visible = false)
{
ApplicationModifyTab.ribbonPanel = ribbonPanel.Clone();
UpdateInternal(visible);
Expand All @@ -21,7 +21,7 @@ public static void Update(bool visible)

private static void UpdateInternal(bool visible)
{
if (ApplicationModifyTab.ribbonPanel is null) return;
if (ribbonPanel is null) return;

var tab = ComponentManager.Ribbon.FindTab("Modify");
if (tab is null) return;
Expand Down

0 comments on commit b6cc5a4

Please sign in to comment.