File tree Expand file tree Collapse file tree 2 files changed +67
-2
lines changed
Expand file tree Collapse file tree 2 files changed +67
-2
lines changed Original file line number Diff line number Diff line change 119119 </Button>
120120 </Grid>
121121
122- <ListBox x:Name="listOnlineTemplates" Margin="6,5,0,0" Height="340 "
122+ <ListBox x:Name="listOnlineTemplates" Margin="6,5,0,0" Height="310 "
123123 Background="{DynamicResource ThemeMainBackgroundColor}"
124124 Foreground="{DynamicResource ThemeButtonForeground}"
125125 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
126- d:ItemsSource="{d:SampleData ItemCount=4}">
126+ d:ItemsSource="{d:SampleData ItemCount=4}"
127+ PreviewMouseDown="listOnlineTemplates_PreviewMouseDown"
128+ SelectionChanged="listOnlineTemplates_SelectionChanged">
129+ <ListBox.ItemContainerStyle>
130+ <Style TargetType="ListBoxItem">
131+ <Setter Property="BorderBrush" Value="Transparent"/>
132+ <Setter Property="BorderThickness" Value="2"/>
133+ <Style.Triggers>
134+ <Trigger Property="IsSelected" Value="True">
135+ <Setter Property="BorderBrush" Value="Green"/>
136+ </Trigger>
137+ </Style.Triggers>
138+ </Style>
139+ </ListBox.ItemContainerStyle>
127140 <ListBox.ItemTemplate>
128141 <DataTemplate>
129142 <StackPanel Orientation="Vertical" Margin="3">
144157 </DataTemplate>
145158 </ListBox.ItemTemplate>
146159 </ListBox>
160+ <Label x:Name="lblSelectedTemplate"
161+ Content=""
162+ BorderBrush="{DynamicResource ThemeGridGreenText}"
163+ BorderThickness="0"
164+ Foreground="{DynamicResource ThemeButtonForeground}"
165+ Margin="6,5,0,0"
166+ Padding="5,3,5,3"
167+ FontSize="11"
168+ Height="25"/>
147169 </StackPanel>
148170 </Grid>
149171</Window>
Original file line number Diff line number Diff line change @@ -639,6 +639,49 @@ private int FindMatchingBrace(string json, int openBraceIndex)
639639 }
640640
641641 return -1;
642+ } // FindMatchingBrace
643+
644+
645+ private void listOnlineTemplates_PreviewMouseDown(object sender, MouseButtonEventArgs e)
646+ {
647+ // Get the item that was clicked
648+ var listBox = sender as ListBox;
649+ if (listBox == null) return;
650+
651+ // Find the ListBoxItem that was clicked
652+ var clickedElement = e.OriginalSource as DependencyObject;
653+ while (clickedElement != null && clickedElement != listBox)
654+ {
655+ if (clickedElement is ListBoxItem)
656+ {
657+ var clickedItem = clickedElement as ListBoxItem;
658+
659+ // If the clicked item is already selected, deselect it
660+ if (clickedItem.IsSelected)
661+ {
662+ listBox.SelectedItem = null;
663+ e.Handled = true;
664+ return;
665+ }
666+ break;
667+ }
668+ clickedElement = VisualTreeHelper.GetParent(clickedElement);
669+ }
642670 }
671+
672+ private void listOnlineTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
673+ {
674+ if (listOnlineTemplates.SelectedItem is OnlineTemplateItem selectedTemplate)
675+ {
676+ lblSelectedTemplate.Content = selectedTemplate.Name;
677+ lblSelectedTemplate.BorderThickness = new Thickness(1);
678+ }
679+ else
680+ {
681+ lblSelectedTemplate.Content = "None";
682+ lblSelectedTemplate.BorderThickness = new Thickness(0);
683+ }
684+ }
685+
643686 } // class NewProject
644687} // namespace UnityLauncherPro
You can’t perform that action at this time.
0 commit comments