make the listbox look not terrible

This commit is contained in:
Benjamin Popp
2018-12-09 19:54:41 -06:00
parent f8aef7220c
commit bc74eda3e5
3 changed files with 44 additions and 10 deletions

View File

@@ -415,5 +415,6 @@ namespace HavenSoft.Gen3Hex.Tests {
// TODO putting a new anchor with the same name: delete any run that starts at that anchor, repoint everything from the old location to the new location
// TODO undo/redo
// TODO file load/save (metadata file / TOML)
}
}

View File

@@ -203,7 +203,15 @@ namespace HavenSoft.Gen3Hex.WPF.Controls {
var anchor = (Core.ViewModels.DataFormats.Anchor)ViewPort[p.X, p.Y].Format;
var panel = new StackPanel { Background = Solarized.Theme.Background };
var menu = new Popup { Placement = PlacementMode.Mouse, Child = panel, StaysOpen = false };
var menu = new Popup {
Placement = PlacementMode.Mouse,
Child = new Border {
BorderBrush = Solarized.Brushes.Blue,
BorderThickness = new Thickness(1),
Child = panel,
},
StaysOpen = false,
};
if (anchor.Sources.Count > 1) {
panel.Children.Add(new Button {
@@ -225,16 +233,14 @@ namespace HavenSoft.Gen3Hex.WPF.Controls {
}));
}
} else {
panel.Children.Add(new ScrollViewer {
panel.Children.Add(new ListBox {
MaxHeight = 120,
Content = new ListBox {
ItemsSource = anchor.Sources.Select(source => source.ToString("X2")).ToList(),
}.SetEvent(Selector.SelectionChangedEvent, (sender, e) => {
var source = anchor.Sources[((ListBox)sender).SelectedIndex].ToString("X2");
ViewPort.Goto.Execute(source);
menu.IsOpen = false;
}),
});
ItemsSource = anchor.Sources.Select(source => source.ToString("X2")).ToList(),
}.SetEvent(Selector.SelectionChangedEvent, (sender, e) => {
var source = anchor.Sources[((ListBox)sender).SelectedIndex].ToString("X2");
ViewPort.Goto.Execute(source);
menu.IsOpen = false;
}));
}
menu.IsOpen = true;

View File

@@ -407,5 +407,32 @@
</Setter.Value>
</Setter>
</Style>
<!-- ListBox Style -->
<Style TargetType="ListBox">
<Setter Property="Background" Value="{DynamicResource Backlight}"/>
<Setter Property="Foreground" Value="{DynamicResource Primary}"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Padding="5,3" BorderThickness="1" Background="Transparent">
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{solarized:Theme Blue}"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>