File Window Layout: question on XAML markup

Started by Ger, April 21, 2025, 09:47:01 AM

Previous topic - Next topic

Ger

I have a Category structure looking like this:
Collection
   |#Who
   |John
   |Mary
   |#n/a

In the file window layout, I want to show whether the file exists in a category under #Who or not. If the image is in #Who|#n/a, I want to flag that as well.

This works:
{File.Categories.Direct|contains:Collection|#Who|#n/a,isna, {File.Categories.Direct|contains:Collection|#Who,yes,no;
     pereplace:yes==WHO;
     pereplace:no==NoWho;
  };
     pereplace:isna==WHO=n/a;
}


However, if I want to add XAML, this only works for isna:

{File.Categories.Direct|contains:Collection|#Who|#n/a,isna, {File.Categories.Direct|contains:Collection|#Who,yes,no;
     pereplace:yes==<Run FontFamily="Consolas" Background="#008000" Foreground="#ffffff">&#160~;WHO&#160~;</Run>;
     pereplace:no==<Run FontFamily="Consolas" Background="#008000" Foreground="#ffffff">&#160~;NoWHO&#160~;</Run>;
  };
     pereplace:isna==<Run FontFamily="Consolas" Background="#ff0000" Foreground="#ffffff">&#160~;Who=n/a&#160~;</Run>;
}

For the yes and no values, the XAML text is displayed verbatim.

What am I doing wrong? And maybe I'm choosing the wrong solution here - happy to learn another way to solve this.


Mario

Use VarToy to see what your variable produces.
Use the Edit > Preferences > File Window Tip to try your variable (select a file which fails in the File Window before opening this dialog) to see if your XMAL produces an error message.

Ger

I used Vartoy to get the function working (without the XAML). It shows nicely WHO, NoWho and Who=n/a for the corresponding images.

In both FileWindow Tip and FileWindow Layout I tried the XAML markup. Only the prereplace:isna is displaying correctly; the other show the XAML statement verbatim.

Mario


Ger

That's what i figured. The XAML for isna 
pereplace:isna==<Run FontFamily="Consolas"
Background="#ff0000"
Foreground="#ffffff">&#160~;Who=n/a&#160~;</Run>;

is showing fine; the other two are just displaying literal text (<Run FontFam....)


Mario

When the markup code is displayed as text, the code is not OK. Check for missing <, simplify the variable until you can see the issue.

Ger

I tried rebuilding and simplyfing the XAML, but the first two statements don't seem to be accepted:

{File.Categories.Direct|contains:Collection|#Who|#n/a,isna, {File.Categories.Direct|contains:Collection|#Who,yes,no;
    pereplace:yes==<Run Background="#ff0000">Y</Run>;
    pereplace:no==<Run Background="#0000ff">N</Run>;
 };
    pereplace:isna==<Run FontFamily="Consolas" Background="#ff0000" Foreground="#ffffff">&#160~;n/a who&#160~;</Run>;
}

The evaluation is correct; the XAML for isna is correct; I only don't get the formatting working.

Mario

#7
If the XAML engine emits the source XAML code, it does not like the XAML for some reason.
Any warnings in the log file? Search for W>

Copy & paste the different XAML variants your expression produces into the File Window Tip (use Notepad to remove line breaks to make the XAML one row). Any error messages displayed?

Ger

I see two warning messages (but not sure they're relevant):

W> IMEnginePerformanceMonitor: Failed to query performance (1) data for drive D: (status 800007d5)  'V:\develop\IMatch5\src\IMEngine\IMEnginePerformanceMonitor.cpp(470)'
and
W> IMEnginePerformanceMonitor: Failcounter for drive D: is 5  'V:\develop\IMatch5\src\IMEngine\IMEnginePerformanceMonitor.cpp(531)'

Full debug log attached.

Using File Window tip shows the same output as the FileWindow layout in the previous post.

sinus

Maybe you could try something like this in the File Window Tip, and then enhance it.

{File.Categories.Direct|contains:Collection|#Who|#n/a,isna,{File.Categories.Direct|contains:Collection|#Who,yes,no};pereplace:yes==<Run Background='#00ff00' FontSize='18pt' FontWeight='Bold' >case yes</Run>;pereplace:no==<Run FontSize='18pt' FontWeight='Bold'>case no</Run>}
I do not understand this fully, like isna.
Best wishes from Switzerland! :-)
Markus

Mario

Nothing related in the log file.
Please input your email and 2025 license key in Edit > Preferences > Application. Else the built-in Updater App cannot work.
I don't steal or sell your data or use this information in any malicious way.

Ger

Thanks Markus,
Quote from: sinus on April 22, 2025, 01:24:02 PMMaybe you could try something like this in the File Window Tip, and then enhance it.


This works for the case yes and case no; but there's no formatting for the isna value.

What I wanted to achieve (but it obviously is not that straightforward) is to have three different status values for an image:
1. The image does not exist in the category hierarchy Collection|#Who at all
2. The image exists in the category Collection|#Who|#n/a
3. The image exists in a child of the category hierarchy Collection|#Who| (but not in #n/a)


Mario

Maybe the complexity/nesting limit has been reached. Most likely pereplace can be used only once per variable, as the last argument. Because the results of the inner variable are parsed and escaped before being handed over to the outer variable.

sinus

My last try:

{File.Categories.Direct|contains:Collection|#Who|#n/a,isna,{File.Categories.Direct|contains:Collection|#Who,yes,no};pereplace:yes==<Run FontFamily='Arial' Background='#ff00dd' Foreground='#00ff00'>WHO</Run>;pereplace:no==<Run FontFamily='Arial' Background='#000000' Foreground='#ffffff'>NoWHO</Run>;pereplace:isna==<Run FontFamily='Arial' Background='#ff0000' Foreground='#ffffff'>Who=n/a</Run>;}

I do not understand isna anyway, sorry.
If something like this does not work, I guess, it is, like Mario pointed out.
Best wishes from Switzerland! :-)
Markus

Ger

Markus,
That's great! I think your solution is doing the trick. You copied the xaml for isna at the same level as the other xaml markup.

Because "my" solution worked without XAML, I kept that nested model, but that seems not necessary.


Markus,
what i wanted to achieve is having an indicator that shows:
- an image that has a person that is named (WHO)
- an image that has NO person (ISNA - Is Not Applicable)
- an image that still requires to be checked for WHO (NO WHO)

For that I started to play a bit to see whether this could be done - and obviously i CAN be done!

Mario

Now, try something like this in another DAM... ;D

Ger

No:

- I don't HAVE another DAM
- I don't NEED another DAM
- I don't WANT another DAM

:)

Mario

Quote from: Ger on April 22, 2025, 05:28:23 PMNo:

- I don't HAVE another DAM
- I don't NEED another DAM
- I don't WANT another DAM

:)


sinus

Cool, Ger!

I thought also, this should work. I tried out the variables in Design&Print, because there it is very easy and we have instant results. 
And I know, that variables are really very powerful, Mario made it possible.  :)

I hope, you can achieve, what you wanted and thanks for your explanations! 
Best wishes from Switzerland! :-)
Markus

Ger

Markus, 
The funny part is that I was just playing to see whether it was possible; I will probably not use that layout extensively (instead, work with category formulas or so). 
But it's simply good to see it can work :)