Jump to content
LaunchBox Community Forums

XAML Tips and Tricks


Recommended Posts

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. 

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

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
Link to comment
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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

@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
Link to comment
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.

Link to comment
Share on other sites

  • 3 weeks later...
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">

 

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