Skip to content

Commit

Permalink
save loaded and appended models
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Nov 22, 2021
1 parent 214f0a5 commit 2dc8ae9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
10 changes: 10 additions & 0 deletions FModel/ViewModels/ModelViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public async Task LoadExport(UObject export)

ModelAndCam p;
if (AppendMode && CanAppend)
{
p = SelectedModel;
_loadedModels.Add(new ModelAndCam(export) {IsVisible = false});
}
else
{
p = new ModelAndCam(export);
Expand Down Expand Up @@ -505,6 +508,13 @@ public class ModelAndCam : ViewModel
public Geometry3D ZAxis { get; set; }
public int TriangleCount { get; set; }

private bool _isVisible = true;
public bool IsVisible
{
get => _isVisible;
set => SetProperty(ref _isVisible, value);
}

private MeshGeometryModel3D _selectedGeometry; // selected material
public MeshGeometryModel3D SelectedGeometry
{
Expand Down
9 changes: 1 addition & 8 deletions FModel/Views/ModelViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@
</Grid.ColumnDefinitions>

<TextBlock Grid.Row="0" Grid.Column="0" Text="Models" VerticalAlignment="Center" Margin="0 0 0 10" />
<ComboBox Grid.Row="0" Grid.Column="2" ItemsSource="{Binding ModelViewer.LoadedModelsView, IsAsync=True}"
SelectedItem="{Binding ModelViewer.SelectedModel, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Export.Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ModelsComboBox}" />

<TextBlock Grid.Row="1" Grid.Column="0" Text="Triangles" VerticalAlignment="Center" Margin="0 0 0 10" />
<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding ModelViewer.SelectedModel.TriangleCount, FallbackValue=0, StringFormat={}{0:### ### ### ###}}" VerticalAlignment="Center" HorizontalAlignment="Right" />
Expand Down
19 changes: 19 additions & 0 deletions FModel/Views/Resources/Resources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,25 @@
</Style.Triggers>
</Style>

<Style x:Key="ModelsComboBox" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="ItemsSource" Value="{Binding ModelViewer.LoadedModelsView, IsAsync=True}" />
<Setter Property="SelectedItem" Value="{Binding ModelViewer.SelectedModel, Mode=TwoWay}" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Export.Name}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolToVisibilityConverter}}" />
</Style>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="MaterialsListBox" TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="ItemsSource" Value="{Binding ModelViewer.SelectedModel.Group3d, IsAsync=True}" />
<Setter Property="SelectedItem" Value="{Binding ModelViewer.SelectedModel.SelectedGeometry}" />
Expand Down

0 comments on commit 2dc8ae9

Please sign in to comment.