Jump to content
LaunchBox Community Forums

NJDave71's HelperControl Functionality Integrated


Jason Carr

Recommended Posts

Hello all, sorry for another massive callout in the span of a couple days lol. ;)

@NJDave71 has generously contributed the code to his HelperControl plugin for Big Box themes and I've integrated it into Big Box, so going forward, the control itself will no longer be needed. However, themes will not be automatically changed to use the new built-in controls (sans for TotalGamesCount as mentioned in the other thread).

There is no rush on this as the code for these features hasn't been changed, only integrated into Big Box, so there is no harm in continuing to use the HelperControl, at least for now. These new changes will be out in 9.4-beta-9, which should be out shortly, but it's not out quite yet.

The controls and examples are below.

RemoveNewLineConverter and ScrollableTextBlock

Previously ScrollableTextBlock was already available in Big Box without the HelperControl, but it's a vertical scrolling TextBlock instead of a horizontal scrolling TextBlock like the HelperControl, so the name of the control in Big Box is now HorizontalScrollableTextBlock. RemoveNewLineConverter is new and simply removes new lines from text; it's typically used for the scrolling descriptions, which is why they are together here in this example:

xmlns:wpf="clr-namespace:Unbroken.LaunchBox.Wpf;assembly=Unbroken.LaunchBox.Wpf"
xmlns:controls="clr-namespace:Unbroken.LaunchBox.Wpf.Controls;assembly=Unbroken.LaunchBox.Wpf"
<UserControl.Resources>
    <wpf:RemoveNewLineConverter x:Key="RemoveNewLineConverter" />
</UserControl.Resources>
<controls:HorizontalScrollableTextBlock TextWrapping="Wrap" Text="{Binding Notes, Converter={StaticResource RemoveNewLineConverter}}" FontSize="46" Height="50" ScrollSpeed="100" />

FindStringConverter

FindStringConverter is used largely to convert string values to different values. For example, to show an image based on the value of a field:

xmlns:wpf="clr-namespace:Unbroken.LaunchBox.Wpf;assembly=Unbroken.LaunchBox.Wpf"
<UserControl.Resources>
    <wpf:FindStringConverter x:Key="FindStringConverter" />
</UserControl.Resources>
<Image>
    <Image.Style>
        <Style TargetType="{x:Type Image}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ActiveGame.PlayMode, Converter={StaticResource FindStringConverter}, ConverterParameter='Single Player'}" Value="True">
                    <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Default/Single Player.png"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=ActiveGame.PlayMode, Converter={StaticResource FindStringConverter}, ConverterParameter='Cooperative'}" Value="True">
                    <Setter Property="Source" Value="pack://siteoforigin:,,,/Themes/Default/Cooperative.png"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Image.Style>
</Image>

Thanks again to @NJDave71 for his code. :)

@faeran @Mr. RetroLust @RetroHumanoid @wallmachine @eatkinola @bbweiners @keltoigael @Jack. @y2guru @whoozwah @SNAK3ATER @Rincewind @CriticalCid @shro2016 @broskiplays @Grila @NJDave71 @Hexxxer @PhillsDoodles @Zombeaver @Omen @Cookz718 @viking @OrochiMishima @nosh @ea4492 @Maddoc1007 @vsilvalopes @damageinc86 @walter10h @skainlurmis @Scottad @Nyny77 @Sithel @Akezhar @Thanos Reigns

  • Like 2
  • Thanks 1
  • Game On 1
Link to comment
Share on other sites

2 hours ago, faeran said:

Hey @Jason Carr. Tried this out tonight with Beta 9. Unfortunately, unable to get the FIndStringConverter to work. It's unable to find FindStringConverter. It only seems to be able to find the ImageToSourceConverter in the namespace. 

image.thumb.png.a5bd269a5597a4ec84762add4f8fdab1.pngimage.thumb.png.fb20d4d57bc633f689ef7e1679b79738.png

I see. Somehow I managed to exclude the file from the project; sorry for that. I've fixed it for the next beta, which should be out tomorrow.

  • Thanks 1
Link to comment
Share on other sites

Hello all, @Maddoc1007 pointed out to me that the ScrollableTextBlock control wasn't working as expected when converting it over from the HelperControl version. This is because I hadn't realized that there were significant differences between the existing ScrollableTextBlock control in Big Box and @NJDave71's HelperControl version. As of 9.4-beta-11, which I just put out, there are now two available versions of this control:

  • ScrollableTextBlock - The same control as what used to be included in Big Box, used for vertical scrolling text
  • HorizontalScrollableTextBlock - The control from @NJDave71's HelperControl, used for horizontal scrolling text

Sorry for the confusion on this. I've updated the examples in the first post of this topic to match the correct new usage. When converting your themes over to use the built-in scrollable text block control instead of the HelperControl version, you'll need to use HorizontalScrollableTextBlock instead of ScrollableTextBlock for the tag element.

Link to comment
Share on other sites

How to replace the HelperControl using LB 9.4 Release

 

Replace the ScrollableTextBlock with HorizontalScrollableTextBlock

Remove
    xmlns:HelperControl="clr-namespace:HelperControl;assembly=HelperControl_v4"  
 
Add
    xmlns:wpf="clr-namespace:Unbroken.LaunchBox.Wpf;assembly=Unbroken.LaunchBox.Wpf"
    xmlns:controls="clr-namespace:Unbroken.LaunchBox.Wpf.Controls;assembly=Unbroken.LaunchBox.Wpf"
    
Remove
    <HelperControl:RemoveNewLineConverter x:Key="NoNewline"/>

Add
    <wpf:RemoveNewLineConverter x:Key="RemoveNewLineConverter" />

Replace Canvas Name ScrollingTextBlockCanvas with HorizontalScrollableTextBlockCanvas
Replace HelperControl:ScrollableTextBlock with controls:HorizontalScrollableTextBlock
Replace StaticResource NoNewline with  StaticResource RemoveNewLineConverter

 

Replace TotalGamesCount with GamesCount

Remove
    xmlns:HelperControl="clr-namespace:HelperControl;assembly=HelperControl_v4"  

Replace
<HelperControl:TotalGamesCount FontFamily="{StaticResource FontHead}"  Foreground="#75c8f7" FontSize="31" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0" />
<TextBlock Text="{Binding GamesCount}" FontFamily="{StaticResource FontHead}"  Foreground="#75c8f7" FontSize="31" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0" />

Replace FindString with FindStringConverter

Remove
    xmlns:HelperControl="clr-namespace:HelperControl;assembly=HelperControl_v4"
Add    
    xmlns:wpf="clr-namespace:Unbroken.LaunchBox.Wpf;assembly=Unbroken.LaunchBox.Wpf"


Remove
    <HelperControl:FindString x:Key="FindInString"/>
Add
    <wpf:FindStringConverter x:Key="FindStringConverter" />
    

Search for "FindInString" and replace it with "FindStringConverter"
 

 

Edited by NJDave71
  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Hi @NJDave71 !

For a new theme, I'm trying to set up a Rating stars, based on community rating.
To use a DataTrigger> Setter, I need data by .5 incremental  (0.5 - 1.0 - 1.5 - ...)
But the community rating are more like :  3.2564

Does your FindStringConverter can do that ?
Round values by 0.5 incrementing ?
If so, with which code ?

Thx !!!

Link to comment
Share on other sites

Hello @viking

The Aeon Nox uses the StringFormat to set the Decimal places.  Take a Look at the "CoverFlowWithDetailsGamesView" and find 

  <MultiBinding StringFormat="{}pack://siteoforigin:,,,/Themes/Aeon Nox/Images/etc/score/{0:F1}.png">
       <Binding Path="ActiveGame.CommunityOrLocalStarRating" />
   </MultiBinding>

I have set mine to 1 decimal 3.2564 becomes 3.2.  There are 52 images,
Hope this gives you some insight.   

Edited by NJDave71
Link to comment
Share on other sites

Thx @NJDave71 .

I tried StringFormat too.
Whis this :    Binding="{Binding ActiveGame.CommunityStarRating, StringFormat=\{0:n1\}}"   
I have the same result as you =  3.2564 becomes 3.2.
But 52 images for the stars is too mutch !

I also found in the Microsoft doc the StringFormat {G4} which should round to the nearest .5.
But it does not work. I do not know why ... Maybe a bad syntax.

I'm going to take a look at Aeon Nox Redux! Thx!

Link to comment
Share on other sites

Thx @NJDave71.
I found a way, completely based on your work on Aeon Nox. 
Thx man ! Your code is very inspiring!

<StackPanel  Grid.Column="2" Grid.Row="8">
                <TextBlock x:Name="Stars" Visibility="Collapsed">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}pack://siteoforigin:,,,/Themes/Colorful/Colorful_img/Stars/{0:F1}.png">
                            <Binding Path="ActiveGame.CommunityOrLocalStarRating" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <Image Source="{Binding Text, ElementName=Stars}" x:Name="RatingStars" Grid.Column="2" Grid.Row="8" HorizontalAlignment="Center" 		VerticalAlignment="Stretch" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" >
                </Image>
            </StackPanel>

 

  • Thanks 1
Link to comment
Share on other sites

  • 11 months later...

Hi, I am trying to use the horizontalscrollabletextblock on a theme I am working on and whilst it is working it seems to be cutting off most of the notes text passed a certain character limit. Is there a maximum number of characters this control supports and is there anyway to increase it? Based on what I am seeing I suspect it is stopping at around 256 characters.

Edited by shro2016
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...