Jump to content
LaunchBox Community Forums

Add Custom Fields right-click option to open a hyperlink with your default web browser (How To)


Recommended Posts

I had always wanted to add a hyperlink in LaunchBox to the Internet Pinball Database (IPDB) for each of my Visual Pinball tables. (i.e. https://www.ipdb.org/machine.cgi?id=760).  I had thought about putting them in the Wiki or YouTube fields, but that was an ugly work around.

Playing around recently, I figured out that a simple-ish change to GameDetailsView.xaml will add right-click options to Custom Field(s).  With the changes below, right clicking on a custom field and selecting "Go to webpage" will open your default web browser to whatever hyperlink page you have in that particular custom field.

In my VPX setup, I also added a custom field for "Table" that would hold a link to the tables’ download webpage.  (to see if there are any updates or for whatever reason)

Obviously you can put in any valid hyperlink you want.  The only pain is you have to enter the hyperlink(s) for each table/game individually.

image.thumb.png.1743b0da90090eab2438595a658557ed.png

Pict of Right-Click on the IPDB link.

 

Custom Field - Right-Click

I'll use @faeran's Default Plus theme as an example.  Create a copy of the themes folder and open the xaml in Notepad++ (easiest for this demo, but you can use any editor you want)

D:\LaunchBox\LBThemes\Default Plus - Copy\Views\GameDetailsView.xaml

 

Below the last "xmlns" entry (line 10) insert a new line.  (here, we're adding a new Reference and calling it "web")

xmlns:web="clr-namespace:Unbroken.LaunchBox.Windows.Desktop.Commands;assembly=LaunchBox"

 

Just before the closing of "UserControl.Resources" (line 34 [after inserting the above]), inset a new line.  

<web:WebLinkCommand x:Key="WebCommand" /> 

(Here we're creating a static resource which we're calling "WebCommand".) 

 

So far, it should look like this:

image.thumb.png.52eed0cd3d3d0f3c3d02cbbb95194c96.png

 

Now search for and go to CustomFields (or scroll to line 1334 [after inserting the above 2 lines]).  A few lines down, click once on the 2nd "<TextBlock..." line.  (line 1345)  This is the line that will contain Text="{Binding Value}"  Press Ctrl+K to comment out that line.  (That may only work because of a plugin I installed. Don't recall.  If it doesn't work, add   <!--   to the beginning of the line, and   -->   to the end).

<!-- This line is a comment -->

 

Below this [now] commented line, inset the following

<TextBlock Grid.Column="2" Text="{Binding Value}" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.ForegroundBrush}" TextWrapping="Wrap" TextAlignment="Right">
    <TextBlock.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Go to webpage" Padding="0,5,60,5" Command="{StaticResource WebCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBlock}, Path=Text}" />
        </ContextMenu>
    </TextBlock.ContextMenu>
</TextBlock>

Here we're replacing the original TextBlock with a new one that gives right-click options.  If you want it to say something different when you right-click, just replace the Header text ("Go to webpage").

 

Here's what the whole CustomFields section will look like (well, left half of it)

image.thumb.png.91661d3032af855c94ede34e300712f8.png

 

Save and close.  Start LaunchBox and tell it to use this theme. 

If you have a custom field that's not a hyperlink or is an invalid link, if you right-click and select "Go", you'll get a message box telling you it's an invalid URL.


Enjoy.

  • Like 2
Link to comment
Share on other sites

This is most interesting indeed. I must study this when I've got some time to hand. I use the Bad Old Monkey theme myself.

I use Additional Apps to pop up Arcade Italia (and Progetto Emma when it's not in maintenance!)  game information web pages for my arcade and other games. A bit tedious to set up but practical for me with my very small LaunchBox set of 807 games (arcade and other systems).

  • Like 1
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...