Skip to content

Commit

Permalink
grouping and sorting for parameter list
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed Oct 13, 2023
1 parent aec1123 commit 950d54b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public ReadResult Read(SnoopableContext context, object @object)
var doubleValue = parameter.AsDouble();
(value as ValueContainer<double>).SetValueTyped(context, doubleValue);
break;
case StorageType.None:
break;
}
return new ReadResult(value.ValueAsString, "[ByParam] " + value.TypeName, value.CanBeSnooped, value);

Expand All @@ -63,6 +65,7 @@ private IValueContainer CreateValueContainer(StorageType storageType)
{
switch (storageType)
{
case StorageType.None:
case StorageType.String:
return new ValueContainer<string>();
case StorageType.Integer:
Expand All @@ -71,6 +74,7 @@ private IValueContainer CreateValueContainer(StorageType storageType)
return new ValueContainer<double>();
case StorageType.ElementId:
return new ValueContainer<ElementId>();

}
throw new NotImplementedException();
}
Expand Down
15 changes: 6 additions & 9 deletions sources/RevitDBExplorer/Domain/DataModel/SnoopableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ public SnoopableObject(Document document, object @object, IEnumerable<SnoopableO
}
}
if (@object is Parameter parameter)
{
NamePrefixIcon = Icon.Empty;
if (parameter.Id.Value() > -1)
{
NamePrefixIcon = Icon.ProjectParameter;
}
if (parameter.IsShared)
{
NamePrefixIcon = parameter.GetOrgin() switch
{
NamePrefixIcon = Icon.SharedParameter;
}
ParameterOrgin.Project => Icon.ProjectParameter,
ParameterOrgin.Shared => Icon.SharedParameter,
_ => Icon.Empty
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ internal class SnoopableParameter : SnoopableItem


public override string Name => parameter.Definition.Name;
public ParameterOrgin Orgin { get; }


public SnoopableParameter(SnoopableObject parent, Parameter parameter) : base(parent, new ParameterAccessor(parameter))
{
this.parameter = parameter;
this.parameter = parameter;
this.Orgin = parameter.GetOrgin();
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md

namespace Autodesk.Revit.DB
{
internal enum ParameterOrgin { Shared, Project, BuiltIn }

internal static class ParameterExtensions
{
public static ParameterOrgin GetOrgin(this Parameter parameter)
{
var result = ParameterOrgin.BuiltIn;
if (parameter.Id.Value() > -1)
{
result = ParameterOrgin.Project;
}
if (parameter.IsShared)
{
result = ParameterOrgin.Shared;
}
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ internal sealed class ListItemForParameter : ListItem<SnoopableParameter>
{
public ListItemForParameter(SnoopableParameter left, SnoopableParameter right, Action askForReload, bool doCompare) : base(left, right, askForReload, doCompare)
{

SortingKey = $"{(int)SnoopableItem.Orgin}_{SnoopableItem.Name}";
GroupingKey = SnoopableItem.Orgin.ToString();
}


}
}

0 comments on commit 950d54b

Please sign in to comment.