Jump to content
LaunchBox Community Forums

XAML Tips and Tricks


Recommended Posts

I have another noob api question if someone wouldn't mind helping me out please.

Is it possible to achieve the following:

 public class Class1 : ISystemEventsPlugin, IGameMenuItemPlugin
    {
        public bool SupportsMultipleGames => false;

        public string Caption => null;

        public Image IconImage => null;

        public bool ShowInLaunchBox => false;

        public bool ShowInBigBox => false;

        public bool GetIsValidForGame(IGame selectedGame)
        {
            return true;
        }

        public bool GetIsValidForGames(IGame[] selectedGames)
        {
            return false;
        }

        public void OnEventRaised(string GameStarting)
        {
            if (GameStarting == "GameStarting")
            {
                MessageBox.Show(selectedGame.ApplicationPath); //Here
            }
        }

        public void OnSelected(IGame selectedGame)
        {
            return;
        }

        public void OnSelected(IGame[] selectedGames)
        {
            return;
        }

I want to be able to get selectedGame info on GameStarting event. 

I have tried different things but haven't managed to achieve it. Im not asking for someone to write me the code, maybe just point me in the right direction please?

Im leaning towards using a GameMenuItem plugin and Play() but if a user wants to use the "Launch With" option from the game menu then my plugin im bodging together wont do anything on game launch.

Link to comment
Share on other sites

2 minutes ago, jayjay said:

I have another noob api question if someone wouldn't mind helping me out please.

Is it possible to achieve the following:


 public class Class1 : ISystemEventsPlugin, IGameMenuItemPlugin
    {
        public bool SupportsMultipleGames => false;

        public string Caption => null;

        public Image IconImage => null;

        public bool ShowInLaunchBox => false;

        public bool ShowInBigBox => false;

        public bool GetIsValidForGame(IGame selectedGame)
        {
            return true;
        }

        public bool GetIsValidForGames(IGame[] selectedGames)
        {
            return false;
        }

        public void OnEventRaised(string GameStarting)
        {
            if (GameStarting == "GameStarting")
            {
                MessageBox.Show(selectedGame.ApplicationPath); //Here
            }
        }

        public void OnSelected(IGame selectedGame)
        {
            return;
        }

        public void OnSelected(IGame[] selectedGames)
        {
            return;
        }

I want to be able to get selectedGame info on GameStarting event. 

I have tried different things but haven't managed to achieve it. Im not asking for someone to write me the code, maybe just point me in the right direction please?

Im leaning towards using a GameMenuItem plugin and Play() but if a user wants to use the "Launch With" option from the game menu then my plugin im bodging together wont do anything on game launch.

Use the OnSelected methods to store the selected games in a private variable, which you can then refer to from the GameStarting event.

  • Like 1
Link to comment
Share on other sites

12 minutes ago, Jason Carr said:

Use the OnSelected methods to store the selected games in a private variable, which you can then refer to from the GameStarting event.

The code I was going to post but edited for fear of embarrassment was:

 

public class Class1 : ISystemEventsPlugin, IGameMenuItemPlugin
    {
        public string AppPath { get; private set; }

        public bool SupportsMultipleGames => false;

        public string Caption => null;

        public Image IconImage => null;

        public bool ShowInLaunchBox => true;

        public bool ShowInBigBox => false;

        public bool GetIsValidForGame(IGame selectedGame)
        {
            return true;
        }

        public bool GetIsValidForGames(IGame[] selectedGames)
        {
            return false;
        }

        public void OnEventRaised(string GameStarting)
        {
            if (GameStarting == "GameStarting")
            {
                MessageBox.Show(AppPath);
            }
        }

        public void OnSelected(IGame selectedGame)
        {
            string AppPath = selectedGame.ApplicationPath;
        }

        public void OnSelected(IGame[] selectedGames)
        {
            return;
        }
    }

But my message box was always blank. Was I on the right track or have I just embarrassed myself again lol. That's a rhetorical question, don't answer that. 

Anyway Thanks @Jason Carr. I'll keep trying. 

Link to comment
Share on other sites

6 hours ago, wallmachine said:

@Jason Carr with VisibleCount you shouldn't see popping/images coming from the side? values 3 between 8 cause this or am I doing something wrongimage.thumb.png.497a0b6c41a313d162b541e4943489be.png

 

VisibleCount="4"

 

If you see images popping in, you just need to increase the visible count. The visible count should be slightly larger than what is actually displayed on the screen.

Link to comment
Share on other sites

3 hours ago, Jason Carr said:

If you see images popping in, you just need to increase the visible count. The visible count should be slightly larger than what is actually displayed on the screen.

if i increase the visiblecount then more display on the wheel and you also get  a little preview image of the next clear logo, or is this something not achievable yet? I've played with every combination of
CurveAmount="" CameraZPosition="" VisibleCount="" PageSize="" Spacing="" ItemZPosition="" SelectedItemZPosition="" RotationAmount="" Margin="" Padding=""

image.thumb.png.9fe99e6392f1188a1a19805ebd5ce743.png

Link to comment
Share on other sites

3 minutes ago, wallmachine said:

if i increase the visiblecount then more display on the wheel and you also get  a little preview image of the next clear logo, or is this something not achievable yet? I've played with every combination of
CurveAmount="" CameraZPosition="" VisibleCount="" PageSize="" Spacing="" ItemZPosition="" SelectedItemZPosition="" RotationAmount="" Margin="" Padding=""

image.thumb.png.9fe99e6392f1188a1a19805ebd5ce743.png

I'm very confused by what you mean here. You don't use VisibleCount to change how many are actually displayed in the wheel; it's only used on the backend to define how many need rendered at any one time. If you're looking to make the wheels smaller or larger or have more or less items displayed, it's the Camera properties that you need to adjust.

Link to comment
Share on other sites

1 hour ago, Jason Carr said:

I'm very confused by what you mean here. You don't use VisibleCount to change how many are actually displayed in the wheel; it's only used on the backend to define how many need rendered at any one time. If you're looking to make the wheels smaller or larger or have more or less items displayed, it's the Camera properties that you need to adjust.

even if you change the camera properties things will still get cut off or youll still see the image of the next logo, is it not possible to set the property spacing evenly for the entire wheel as the logos get closer to the end of the screen as the rotationamount brings the logo closer on one side or even set the property for each logo appearing on the screen. Is it possible to scale the clear logos as they appear so spacing for different sized images is equal?

image.thumb.png.ba470ea44fff036b6aa8cc7c70f6c533.png

Edited by wallmachine
Link to comment
Share on other sites

Does anyone know how to determine if TextGamesView is in the "game list" or "game details" mode? I have a plugin I'd like to behave differently depending on this. I looked and looked and couldn't find a flag for this info. I currently have a kluge in place, but it does not always work. @Jason Carr -- unless I'm just overlooking it, is this something you would consider adding to the plugin framework, or exposing as a bindable property in TextGamesView.

Link to comment
Share on other sites

4 hours ago, eatkinola said:

Does anyone know how to determine if TextGamesView is in the "game list" or "game details" mode? I have a plugin I'd like to behave differently depending on this. I looked and looked and couldn't find a flag for this info. I currently have a kluge in place, but it does not always work. @Jason Carr -- unless I'm just overlooking it, is this something you would consider adding to the plugin framework, or exposing as a bindable property in TextGamesView.

You can bind to the IsInGameDetails property. :)

  • Thanks 1
Link to comment
Share on other sites

On 9/8/2018 at 2:15 PM, eatkinola said:

Awesome, I'll check it out. Thanks!

@Jason Carr: Unfortunately, the IsInGameDetails binding does not update when navigating from the games list to games details. I've included an example below. Maybe I'm still overlooking something, but if not would you please consider repairing this binding? It'd be even better if this binding was also accessible from within child elements such as the TextListViewModel used in GamesViewModelBase. In the example, the yellow IsGameMenu custom flag is a kluge I use to get the info I need -- though it's a theme-specific fix and does not work in themes with more games views than the text list view. @faeran is trying to use some of my controls in his theme, and I'd like to fix this for him (and just get rid of that kluge which would make me feel better :).

game-menu-list.thumb.jpg.a97f08a7203982123ad4c6b2af90d570.jpggame-menu-details.thumb.jpg.301095ca4507f1aee63a8390d912b5cb.jpg

Link to comment
Share on other sites

19 hours ago, eatkinola said:

@Jason Carr: Unfortunately, the IsInGameDetails binding does not update when navigating from the games list to games details. I've included an example below. Maybe I'm still overlooking something, but if not would you please consider repairing this binding? It'd be even better if this binding was also accessible from within child elements such as the TextListViewModel used in GamesViewModelBase. In the example, the yellow IsGameMenu custom flag is a kluge I use to get the info I need -- though it's a theme-specific fix and does not work in themes with more games views than the text list view. @faeran is trying to use some of my controls in his theme, and I'd like to fix this for him (and just get rid of that kluge which would make me feel better :).

game-menu-list.thumb.jpg.a97f08a7203982123ad4c6b2af90d570.jpggame-menu-details.thumb.jpg.301095ca4507f1aee63a8390d912b5cb.jpg

I see; yeah, the property is not currently a proper binding, so it won't update correctly when it's used in a XAML binding. Hopefully I can address this soon. :)

  • Like 1
Link to comment
Share on other sites

Hi all, fairly new here and still learning the ropes of xaml. IT's fun to see what you can do with it, though. I saw wallmachine's question and I thought I'd add my own two cents to help. I've found that, like Jason said, setting your VisibleCount higher than what you actually want on screen eliminates the flickering. Specifically, add 3 to the number of images you want shown and that should do it. I had that same problem for a while until I did some searching here on the boards and found the answer. I hope that helps you!

I do have a couple questions of my own if anyone can help, and I apologize for the unnecessary threads, I wasn't aware before that this was the place to ask for coding help. Anyway, I've been working on a theme, and there are a couple little things I was wondering about that I couldn't figure out how to do. First, and I feel silly asking but the method seems to elude me, is how do you center text within a textbox? TextAlignment and HorizontalAlignment don't work, I've tried them both. The text is always left-aligned no matter what. Here's the relevant bit of code from my HorizontalWheel2GamesView:

 

TextBlock Text="{Binding Path=SelectedGame.ReleaseDate, StringFormat=yyyy}" Foreground="Red" FontSize="60" FontFamily="Eurostile LT" Margin="496,945,0,0"></TextBlock>
        <TextBlock Name="Genre" Text="{Binding Path=SelectedGame.GenresString}" Foreground="#FFFFFF" FontSize="32" FontFamily="Eurostile LT" Margin="445,1010,0,0" TextAlignment="Center" HorizontalAlignment="Center"></TextBlock>
        <TextBlock Text="{Binding Path=SelectedGame.Notes}" Foreground="#FFFFFF" FontSize="30" FontFamily="Eurostile LT Condensed" Margin="790,915,0,0" Width="800" Height="175" TextWrapping="Wrap"></TextBlock>

 

And here are screens of the view to show what I mean:

ttFKmf.jpg

 

aKF7Ov.jpg

 

The genre item is what I'm trying to center, under the year, but the text in the textbox always stays left-aligned and I'm not sure how to fix it. I admit I'm fairly new to xaml so I may have overlooked something. Second question is this: is there any way to customize the Additional Apps/Versions menu on the game details page? As in changing the highlight color, font and font size, etc.? I've changed every style xaml file in the solution, but none of them seem to affect it. Or the lock/unlock keypad and keyboard on the settings page, which I'd also like to customize if I could. Here are a couple shots of my game details page to show how the AA/V menu contrasts with the rest of the page:

 

GcFGOu.jpg

 

UKzzDX.jpg

 

Thanks for any help you guys can give, and I apologize if any of these questions have been answered already.

Edited by Jair
Link to comment
Share on other sites

18 minutes ago, Jair said:

Hi all, fairly new here and still learning the ropes of xaml. IT's fun to see what you can do with it, though. I saw wallmachine's question and I thought I'd add my own two cents to help. I've found that, like Jason said, setting your VisibleCount higher than what you actually want on screen eliminates the flickering. Specifically, add 3 to the number of images you want shown and that should do it. I had that same problem for a while until I did some searching here on the boards and found the answer. I hope that helps you!

This doesn't work if you are using RotationAmount the new feature.

Link to comment
Share on other sites

5 hours ago, Jair said:

The text is always left-aligned no matter what. Here's the relevant bit of code from my HorizontalWheel2GamesView

I suspect it is because you are relying on the Margin property to position your control on the screen. This will not scale well at all for different display sizes or DPI settings. Much more reliable than Margin (or Padding) is to layout your view using Grid controls, which may be nested.

Link to comment
Share on other sites

9 hours ago, wallmachine said:

This doesn't work if you are using RotationAmount the new feature.

Oh ok, didn't know that. thanks, as I haven't tried rotating any of my wheels yet.

4 hours ago, eatkinola said:

I suspect it is because you are relying on the Margin property to position your control on the screen. This will not scale well at all for different display sizes or DPI settings. Much more reliable than Margin (or Padding) is to layout your view using Grid controls, which may be nested.

I didn't know that about margin, and I haven't really used padding. But what about translate? I use that too sometimes. I was just never sure how to get the fine positional control with grids to make small adjustments to make sure things are in the right spot.

Link to comment
Share on other sites

6 hours ago, Jair said:

But what about translate? I use that too sometimes.

Too much use of translations might also cause problems with scaling. Now if you want to design your them for a very specific resolution, don't worry too much about that. But if you want it to work across multiple resolutions (e.g., look similar on an HD vs 4K display), I do encourage you to look into using Grid elements. You can nest grids within grids, and you can use relative sizing for rows and columns, e.g., tell columns 1-3 to use 20, 20, and 60% of available width (which is determined by the parent of the grid). For grids, look into the use of "*" (star) sizing.

Link to comment
Share on other sites

3 hours ago, eatkinola said:

Too much use of translations might also cause problems with scaling. Now if you want to design your them for a very specific resolution, don't worry too much about that. But if you want it to work across multiple resolutions (e.g., look similar on an HD vs 4K display), I do encourage you to look into using Grid elements. You can nest grids within grids, and you can use relative sizing for rows and columns, e.g., tell columns 1-3 to use 20, 20, and 60% of available width (which is determined by the parent of the grid). For grids, look into the use of "*" (star) sizing.

Thanks, I'll keep that in mind. faeran's been helping me learn grids and I think I'm starting to get the hang of it after some practice with them today. It does sound better to make the theme more flexible for different resolutions since you never know what the person will be using.

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...