Conditional enumeration of Width x Height

Started by Darius1968, July 12, 2022, 09:18:41 PM

Previous topic - Next topic

Darius1968

I'm trying to enumerate the Width x Height of a file in one of the columns of a tabular layout.  But, I want it to be silent, if the value for either is 0, eg., for a text file. 

So far, I have this code: 
{File.Width|is:0,,{File.Width|prefix:<Run FontSize="9pt" Foreground="#DBA6A6">;postfix:</Run>} x {File.Height|prefix:<Run FontSize="9pt" Foreground="#DBA6A6">;postfix:</Run>}}
...Which gives me the silence for the case of a text file, but doesn't display properly for a photo or a video, for instance. 
What is wrong with the expression? 

Thanks. 

Mario

Checked your variable in the VarToy for different file types? What's the result and how does it differ?
When I paste your variable into VarToy and select an image, I get

<Run FontSize="9pt" Foreground="#DBA6A6">4.000</Run> x <Run FontSize="9pt" Foreground="#DBA6A6">6.000</Run>

Is this what you have intended?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

Pasting that code into VarToy doesn't work, as VarToy doesn't seem to work well in the presence of XAML formatting. 

However, what you show as your result is what I get in my actual tabular layout, which is only but half of what I'm trying to achieve: 
As you can see (in your result), you get the enumeration of the file's width and height, but you don't get it with the intended text formatting (size and color). 

So, what do I have to do with that code to make it so that the width and height are output with the intended text formatting? 

Mario

QuotePasting that code into VarToy doesn't work, as VarToy doesn't seem to work well in the presence of XAML formatting. 

VarToy does not do or care for any XAML formatting. It displays what comes out of your variable.
If the result makes sense when you plug it into your other XAML, is totally up to you.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

But, what is wrong with the code given that it doesn't format the text to the size and color that I want, but rather, it just spits out the Run statements along with the value of the variable? 

JohnZeman

This version of your code seems to work ok.

<Run FontSize="9pt" Foreground="#DBA6A6">{File.Width|is:0,,{File.Width}}</Run>   {File.Width|is:0,,x}   <Run FontSize="9pt" Foreground="#DBA6A6">{File.Height|is:0,,{File.Height}}</Run>

Darius1968

#6
Thanks, John :) ... It does!