Skip to content

Commit 6d995a0

Browse files
committed
use named control binding to remove redundant property
1 parent 9d0d410 commit 6d995a0

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

AvaGui/ViewModels/ImageTableViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,11 @@ public List<Bitmap> Images
154154
List<Bitmap> images;
155155

156156
[Reactive]
157-
public int SelectedImageIndex { get; set; }
157+
public int SelectedImageIndex { get; set; } = -1;
158158

159159
public UIG1Element32? SelectedG1Element
160160
=> SelectedImageIndex == -1 || Parent.G1Elements.Count == 0 ? null : new UIG1Element32(SelectedImageIndex, GetImageName(Parent, SelectedImageIndex), Parent.G1Elements[SelectedImageIndex]);
161161

162-
[Reactive]
163-
public Color BackgroundColour { get; set; } = Colors.Magenta;
164-
165162
public static string GetImageName(ILocoObject locoObj, int counter)
166163
{
167164
ILocoImageTableNames? its = null;

AvaGui/ViewModels/ObjectEditorViewModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,10 @@ public void SelectedObjectChanged()
6767
{
6868
if (CurrentObject?.LocoObject != null)
6969
{
70-
var oldImageTableColour = Colors.Magenta;
71-
if (ExtraContentViewModel is ImageTableViewModel itvm)
72-
{
73-
oldImageTableColour = itvm.BackgroundColour;
74-
}
75-
7670
StringTableViewModel = new(CurrentObject.LocoObject.StringTable);
7771
ExtraContentViewModel = CurrentObject.LocoObject.Object is SoundObject
7872
? new SoundViewModel(CurrentObject.LocoObject)
79-
: new ImageTableViewModel(CurrentObject.LocoObject, Model.PaletteMap) { BackgroundColour = oldImageTableColour };
73+
: new ImageTableViewModel(CurrentObject.LocoObject, Model.PaletteMap);
8074
}
8175
else
8276
{

AvaGui/Views/MainWindow.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
</DockPanel>
155155
<Button.Flyout >
156156
<Flyout>
157-
<ColorView IsColorModelVisible="False" IsColorSpectrumVisible="False" IsComponentSliderVisible="False" IsColorComponentsVisible="False" Name="ImageBackgroundColorView" Color="{Binding BackgroundColour}" />
157+
<ColorView Name="ImageBackgroundColorView" IsColorModelVisible="False" IsColorSpectrumVisible="False" IsColorComponentsVisible="False" />
158158
</Flyout>
159159
</Button.Flyout>
160160
</Button>
@@ -165,7 +165,7 @@
165165
</StackPanel>
166166
</Border>
167167
<Border BorderThickness="1" BorderBrush="Gray" CornerRadius="4">
168-
<ListBox ItemsSource="{Binding Images}" SelectedIndex="{Binding SelectedImageIndex}" Background="{Binding BackgroundColour, ConverterParameter={x:Static Brushes.Transparent}, Converter={StaticResource ColorToBrushConverter}}">
168+
<ListBox ItemsSource="{Binding Images}" SelectedIndex="{Binding SelectedImageIndex}" Background="{Binding #ImageBackgroundColorView.Color, ConverterParameter={x:Static Brushes.Transparent}, Converter={StaticResource ColorToBrushConverter}}">
169169
<ListBox.ItemsPanel>
170170
<ItemsPanelTemplate>
171171
<WrapPanel/>

0 commit comments

Comments
 (0)