logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Foffa  
#1 Posted : Friday, February 7, 2020 2:34:04 PM(UTC)
Foffa

Rank: Newbie

Groups: Registered
Joined: 1/30/2020(UTC)
Posts: 6
Norway

Thanks: 1 times
Hi

I have setup a XML Data sources in vMix where I am getting this data from an online powerlifting competition software.

<lofter>
<id>10539</id>
<navn>Caroline Hoff Hansen</navn>
<runde>2</runde>
<vekt>95.0</vekt>
<ovelse>Benkpress</ovelse>
<ovelse_kort>BP</ovelse_kort>
<kategori>Åpen</kategori>
<vektklasse>52</vektklasse>
<klokke> </klokke>
<klokke_minutter> </klokke_minutter>
<klubb>Arendal SVK</klubb>
<plassering>1</plassering>
<total>90</total>
<total_prognose>95</total_prognose>
<poeng>777.02</poeng>
<poeng_prognose>816.74</poeng_prognose>
<prognose_plassering>1</prognose_plassering>
<prognose_loft>1</prognose_loft>
<prognose_tekst>1.</prognose_tekst>
<rekorder> </rekorder>
<forsok1>90.0</forsok1>
<forsok1_status>G</forsok1_status>
<forsok2>95.0</forsok2>
<forsok2_status>D</forsok2_status>
<forsok3> </forsok3>
<forsok3_status>D</forsok3_status>
<best_kb> </best_kb>
<best_bp>90.0</best_bp>
<best_ml> </best_ml>
</lofter>

PS this data will change when it is the next lifters turn.

I have created a GT Title where this data are beeing used, but I am trying
to achieve when the forsok1_status has a value of G then forsok1 get a
green box. If forsok1_status has a value of U then forsok1 get a red box.
If forsok1_status has a value of D then
forsok1 get no box only display the value from forsok1. I am trying the title look like this (se attachment)

title.jpg (37kb) downloaded 3 time(s).

Getting it to display forsok1 was easy, but getting the red or green box behind forsok1 based on if forsok1_status is G or D was not easy
When I google around a read something by using XAML, but I am not sure how to use that in my case.

Hope someone can help
doggy  
#2 Posted : Friday, February 7, 2020 6:28:34 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 post(s)
With GT titles one could add colorImages to the title (as textbackground) and toggle their visibility according to the data with a script if your license allows it

With XAML titles one can have codebehind incorporated in the title that checks the data and changes background colors accordingly

By data is meant what is contained in a textbox in the title
difference in approach between GT and XAML title ; with GT you need a title and a separate script , with XAML The title is holding the script
Foffa  
#3 Posted : Tuesday, November 21, 2023 8:33:16 PM(UTC)
Foffa

Rank: Newbie

Groups: Registered
Joined: 1/30/2020(UTC)
Posts: 6
Norway

Thanks: 1 times
How to make XAML title that checks the data source if the value is G then the box is green. If the value is U then the box is red. If the value is D then the box is white?
doggy  
#4 Posted : Tuesday, November 21, 2023 10:00:40 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 post(s)
Originally Posted by: Foffa Go to Quoted Post
How to make XAML title that checks the data source if the value is G then the box is green. If the value is U then the box is red. If the value is D then the box is white?


How much time do you have to learn XAML (WPF) and its codebehind coding language using visual studio?

But original post is 4 years old and one can do more now in vMix

You are better off using a GT title and use the SetColor function using a script that reads the value of a textbox (linked to the datasource) and change a shape's color accordingly

some code example
https://forums.vmix.com/...in-GT-Designer#post99908



color changing shapes in GT title
Foffa  
#5 Posted : Friday, November 24, 2023 6:17:09 AM(UTC)
Foffa

Rank: Newbie

Groups: Registered
Joined: 1/30/2020(UTC)
Posts: 6
Norway

Thanks: 1 times
Hi Doggy

Are you talking about going to settings and then scripting. Add a script and assign a shortcut with function scriptstart?

I am new to vMix scripting. I did look at the documentation for shortcut function reference , but I could not find out how the script will read the value "forsok3_status" from the XML. If the value is G then SetColor (Green), if value is U then SetColor (Red) or if value is D then SetValue white. Also when the lifter is done and judges have ruled whether it is a good lift or no lift. The XML source will get data for the next lifter. Will the title reflect that or do I need to run the shortcut agian?

I tried to see if there where a video tutorial showing how to pull data from XML and setcolor based on value, but I could not find one. Such a video tutorial would be very helpful.
I did look at the video "color changing shapes in GT title", but this show how to set colour manual or if the datasource have a HEX value. Not how to do this with script.

If vMix or someone could make such a video tutorial. That would helped me very much.

Here is the XML URL - https://no.powerliftingl...xml.php?id=1189&uc=1 XPath=lofter
The text is in norwegian, but forsok1_status means attempt1_status
So if anyone can help me. I would be very grateful.

It was very easy to get the data into title from data source, but I would like to show the audience if it is a good lift (green), No lift (red) or attempt lift (white)
doggy  
#6 Posted : Friday, November 24, 2023 7:37:32 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 post(s)
Originally Posted by: Foffa Go to Quoted Post
Are you talking about going to settings and then scripting. Add a script and assign a shortcut with function scriptstart?

vb.net scripting !



Quote:

but I could not find out how the script will read the value "forsok3_status" from the XML. If the value is G then SetColor (Green), if value is U then SetColor (Red) or if value is D then SetValue white. Also when the lifter is done and judges have ruled whether it is a good lift or no lift. The XML source will get data for the next lifter. Will the title reflect that or do I need to run the shortcut agian?


Multiple examples can be found in the "scripting for dummies" post in this forum

While with a script one can read directly form an XML file its much easier to read the data through title textbox linked to a datasource with the vMix specific function for it
Link the "forsok1_status" from the datasource to a "invisible" textbox and read it
Then do an if.. then.. else or a do ... case to determing the corresponding color wanted
set shape's color based on outcome
Loop the sequence so its constantly checks for it

Code:

do while true

'read the content of TextBoxName.Text
Dim TheStatus as string  = Input.Find("Title Name.gtzip").Text("TextBoxName.Text") 

If TheStatus = "G"  'set green
    API.Function("SetColor",Input:="Title Name.gtzip",SelectedName:="RectangleName.Fill.Color",Value:="#00FF00")
else if TheStatus = "U"  'set red
    API.Function("SetColor",Input:="Title Name.gtzip",SelectedName:="RectangleName.Fill.Color",Value:="#FF0000")
else if TheStatus  = "D"  'set white
    API.Function("SetColor",Input:="Title Name.gtzip",SelectedName:="RectangleName.Fill.Color",Value:="#FFFFFF")
else  'set transparent 
    API.Function("SetColor",Input:="Title Name.gtzip",SelectedName:="RectangleName.Fill.Color",Value:="#00000000")
end if

Sleep(2000)
Loop


possible improvements to this script:
- only perform colorchange whne TheStatus has changed
- Use extra for... next loop to have all 3 statuses checked and shape colors changed instead of 3 scripts each for one status
Foffa  
#7 Posted : Saturday, November 25, 2023 4:32:10 AM(UTC)
Foffa

Rank: Newbie

Groups: Registered
Joined: 1/30/2020(UTC)
Posts: 6
Norway

Thanks: 1 times
Hi

Thank you. I was able to make it work for forsok1. Now I am trying to take it to the next level.
If TextBlock forsok1_status.Text and/or forsok2_status.Text contain "G" then box_forsok1 and/or box_forsok2 is Green and Text colour for TextBlock forsok1.Text and/or forsok2.Text is black
If TextBlock forsok1_status.Text and/or forsok2_status.Text contain "U" then box_forsok1 and/or box_forsok2 is Red and Text colour for TextBlock forsok1.Text and/or forsok2.Text is black
Else box_forsok1 and/or box_forsok2 is transparent and Text colour for TextBlock forsok1.Text and/or forsok2.Text is white
(I dropped the white box, as it made it easier to see the weight for the current lift when the box was transparent)

I tried this code and it worked for the fill color for box_forsok1 and box_forsok2, but maby there is a better way to write the code. I did try to use SetTextColour, but was not able to get it to work


do while true

'read the content of TextBoxName.Text
Dim TheStatus1 as string = Input.Find("test.gtzip").Text("forsok1_status.Text")
Dim Thestatus2 as string = Input.Find("test.gtzip").Text("forsok2_status.Text")

If TheStatus1 = "G" 'set green
API.Function("SetColor",Input:="test.gtzip",SelectedName:="box_forsok1.Fill.Color",Value:="#00FF00")

Else if TheStatus1 = "U" 'set red
API.Function("SetColor",Input:="test.gtzip",SelectedName:="box_forsok1.Fill.Color",Value:="#FF0000")

end if

If TheStatus2 = "G" 'set green
API.Function("SetColor",Input:="test.gtzip",SelectedName:="box_forsok2.Fill.Color",Value:="#00FF00")

else if TheStatus2 = "U" 'set red
API.Function("SetColor",Input:="test.gtzip",SelectedName:="box_forsok2.Fill.Color",Value:="#FF0000")

else 'set transparent
API.Function("SetColor",Input:="test.gtzip",SelectedName:="box_forsok2.Fill.Color",Value:="#00000000")
end if

Sleep(2000)
Loop
doggy  
#8 Posted : Saturday, November 25, 2023 4:41:22 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 post(s)
Originally Posted by: Foffa Go to Quoted Post
Hi
I tried this code and it worked for the fill color for box_forsok1 and box_forsok2, but maby there is a better way to write the code. I did try to use SetTextColour, but was not able to get it to work


Yes there are a few ways to better streamline the goal for which each programmer will have a preference
Of course SetTextColour is not working in your case as it applies to setting the color of text !!!

btw the TheStatus1 checkign will not change color or turns transparen it not match "G" or "U"
Foffa  
#9 Posted : Saturday, November 25, 2023 5:56:47 AM(UTC)
Foffa

Rank: Newbie

Groups: Registered
Joined: 1/30/2020(UTC)
Posts: 6
Norway

Thanks: 1 times
Whats is the syntax if I want to change text colour for datasource forsok1.text when TheStatus1 is "G" or "U"?
doggy  
#10 Posted : Saturday, November 25, 2023 6:11:05 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 post(s)
Originally Posted by: Foffa Go to Quoted Post
Whats is the syntax if I want to change text colour for datasource forsok1.text when TheStatus1 is "G" or "U"?


Whats is the syntax if I want to change text colour forsok1.text

Pls check shortcut reference list !!! Also check spelling (lowercases and uppercases) !!

Code:
API.Function("SetTextColour",Input:="test.gtzip",SelectedName:="forsok1_status.Text",Value:="#00FF00")
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.