Jump to content
LaunchBox Community Forums
Jason Carr

XAML Tips and Tricks

Recommended Posts

Thanks, I'll check it out. Haven't seen the pause screen come up in Big Box yet, how does that work?

Share this post


Link to post
Share on other sites
15 minutes ago, Jair said:

Thanks, I'll check it out. Haven't seen the pause screen come up in Big Box yet, how does that work?

You have to go into BigBox settings and set the key/button you want to trigger the pause screen. Look in the Automation options. It is also currently only available in the beta version. 

Share this post


Link to post
Share on other sites
Posted (edited)

Can we not interact with pause menu user controls like we can with BB user controls? 

Ohh my user control loads and unloads on pause and resume. Iv lost my hard on.

Edited by jayjay

Share this post


Link to post
Share on other sites
Posted (edited)

Hi everybody ! Me again with a question 😋

Is it possible to create a separate XAML file, placed at the root of the theme folder, which contains different hex color codes for each platform?

For example :
In the separated XAML, call (for exemple) "Colorful.xaml" , something like :
 

if platform is "Nintendo Game Boy" > custom color="#ffffff"
if platform is "Nintendo Game Boy Advence" > custom color="#454fd2"
if platform is "Nintendo Game Boy Color" > custom color="#754d8s"
... and so on

In main Game or Plarform view, used this color , like : 
 

<TextBlock Text="My Text here" Foreground="{Binding Hex Color Code, depending active platform}" />

I want the XAML code to be separated into an external file, because that makes only one list of platform/color to maintain!
Ideas ? Tracks ? @Jason Carr and all code guru ? 🥰

Edit : and a default color ! If no Platform specified.

Edited by viking

Share this post


Link to post
Share on other sites
4 hours ago, viking said:

Hi everybody ! Me again with a question 😋

Is it possible to create a separate XAML file, placed at the root of the theme folder, which contains different hex color codes for each platform?

For example :
In the separated XAML, call (for exemple) "Colorful.xaml" , something like :
 


if platform is "Nintendo Game Boy" > custom color="#ffffff"
if platform is "Nintendo Game Boy Advence" > custom color="#454fd2"
if platform is "Nintendo Game Boy Color" > custom color="#754d8s"
... and so on

In main Game or Plarform view, used this color , like : 
 


<TextBlock Text="My Text here" Foreground="{Binding Hex Color Code, depending active platform}" />

I want the XAML code to be separated into an external file, because that makes only one list of platform/color to maintain!
Ideas ? Tracks ? @Jason Carr and all code guru ? 🥰

 

I think it is possible, but honestly I'm no longer the greatest XAML guru around here. It would probably take me a couple of hours to figure it out, all considering. I know @eatkinola has done some pretty advanced stuff like this in the past. :)

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
4 hours ago, Jason Carr said:

I want the XAML code to be separated into an external file, because that makes only one list of platform/color to maintain! Ideas ? Tracks ?

Hey @viking looking forward to see what you're putting together. I'm pretty sure you'll need a converter to do this. Using data triggers would work, but it would lead to very messy repetitive xaml and not the clean centralized code you're trying to write. I cannot think of a clean, xaml-only way to do this (maybe someone else can). This example from stackoverflow looks promising; you can define stuff in an xaml resource file like you want. You would need to code a converter, however would be a pretty simple piece of code.

https://stackoverflow.com/a/20280045

Then your xaml view file would say something like this:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://siteoforigin:,,,/Themes/VikingsCoolTheme/Views/Styles/Colorful.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Canvas Name="Canvas">
        ...
        <TextBlock Text="My colorful text" Foreground="{Binding ActivePlatform.Name, Converter={StaticResource PlatformColorConverter}}" />
        ...
    </Canvas>
</UserControl>

Your xaml resource file Colorful.xaml would look something like this:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:colorful="clr-namespace:Viking.Colorful;assembly=Viking.Colorful">
    ...
    <colorful:PlatformColorConverter x:Key="PlatformColorConverter" />
    ...
    <SolidColorBrush x:Key="Color_Atari 2600" Color="Red" />
    <SolidColorBrush x:Key="Color_Atari 5200" Color="Blue" />
    ...
</ResourceDictionary>

You would place the Viking.Colorful.dll (which defines the converter) in the theme's Plugins directory. I've not tested any of this and might have made some typos, but something like it should work.

P.s. The stackoverflow solution will need some tweaking since you won't be adding your color definitions to the App.xaml but rather a separate xaml file. You'd have to reference that xaml file specifically, but I'm sure it could be done.

Edited by eatkinola
one more thing
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

@eatkinola Man ! that's an answer! !! Thx 😍

OK, I will try to play and adapt all that.
But ... I am totally noob in code, for the converter plugin itself. It's OK for XAML part, but I don't have any clue for the plugin.
Basically, I work in die and retry style ! Do you have a link to a tutorial "step-by-step" on creating a plugin? I dont find anything online.
(Source file format? Code format? How to export to DLL? ...)

Edited by viking
  • The Cake is a Lie 1

Share this post


Link to post
Share on other sites
7 hours ago, viking said:

@eatkinola Man ! that's an answer! !! Thx 😍

OK, I will try to play and adapt all that.
But ... I am totally noob in code, for the converter plugin itself. It's OK for XAML part, but I don't have any clue for the plugin.
Basically, I work in die and retry style ! Do you have a link to a tutorial "step-by-step" on creating a plugin? I dont find anything online.
(Source file format? Code format? How to export to DLL? ...)

I can write the code for you. If you don't mind, I'll integrate it with my themer library and you can use it from there. The library already has some logic for handling platforms with different naming conventions, e.g., some users prefer "Nintendo Entertainment System" while others prefer "Nintendo NES". I have a way to insulate from these differences. I'll pm you.

Share this post


Link to post
Share on other sites
Posted (edited)

If you want, but I want to learn !I I'll try first by myself 😉 

Edit : and it must have a default color. If Platform syntaxe have a problem. 

Edited by viking
  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, viking said:

If you want, but I want to learn !I I'll try first by myself 😉

Awesome! I also practice the "die and retry" style. It's the best way to learn.

Share this post


Link to post
Share on other sites

CityHunter is my favorite theme. I would like to change the font Streamster for Lazer84

Someone could help me do that.
Appreciate!

Share this post


Link to post
Share on other sites
4 minutes ago, JoeViking245 said:

string Time = DateTime.Now.ToString("h:mm tt");
7:46 AM

 

string Time = DateTime.Now.ToString("HH:mm");

07:46

Thanks for your response, where in the line should I put this string? This is the line;

<TextBlock Text="{Binding CurrentTime}" FontFamily="LAUNCHBOX_ROOT_FOLDER/Themes/NeonDeluxeArcade/Beon.ttf#Beon" Foreground="#A8FFF3" TextAlignment="Right" FontSize="40" TextWrapping="Wrap">

 

Share this post


Link to post
Share on other sites

You cannot use that code as he provided C#, you need a pure XAML solution

  • Thanks 1

Share this post


Link to post
Share on other sites

Oh snap!  lol.   Umm... might try:

<TextBlock Text=DateTime.Now.ToString("h:mm tt") FontFamily="LAUNCHBOX_ROOT_FOLDER/Themes/NeonDeluxeArcade/Beon.ttf#Beon" Foreground="#A8FFF3" TextAlignment="Right" FontSize="40" TextWrapping="Wrap">

The code is for C# which is what Jason's code is written.  May also pass to Theme xmal codes.

  • Thanks 1

Share this post


Link to post
Share on other sites

Lol thanks anyway, I noticed setting my language to Netherlands it will display 24 hours but I dont like software displaying in my native language, do you english speaking people hate 24 hour clocks or are you used to them? 

Share this post


Link to post
Share on other sites
3 minutes ago, Mr. RetroLust said:

Lol thanks anyway, I noticed setting my language to Netherlands it will display 24 hours but I dont like software displaying in my native language, do you english speaking people hate 24 hour clocks or are you used to them? 

Fine by me. ;)

image.png.a5b29ff10dcf504bdacbb18b6a957cbd.png

  • Like 1

Share this post


Link to post
Share on other sites
<TextBlock Text="{Binding Date, StringFormat=h:mm tt}" FontFamily="LAUNCHBOX_ROOT_FOLDER/Themes/NeonDeluxeArcade/Beon.ttf#Beon" Foreground="#A8FFF3" TextAlignment="Right" FontSize="40" TextWrapping="Wrap">

This Yankee prefers 12hr AM/PM. 😁

  • Haha 1

Share this post


Link to post
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
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...