Alternative way to write a property from enumeration

Using Microsoft Windows Presentation Foundation and Syncfusion WPF Libraries

Alternative way to write a property from enumeration

Postby PGilbert on Thu Mar 26, 2015 2:14 pm

If you do the following you get a Window:
      ⎕USING ← 'System.Windows,WPF/PresentationFramework.dll'
win ← ⎕NEW Window


if you want to change the visibility property of the window, one way of doing it is like this:
      win.Visibility ← win.Visibility.Hidden  ⍝ case 1

An alternative way is:
      win.(Visibility ← Visibility.Hidden)  ⍝ case 2

My question is: Is there another way even shorter that is possible ?
      win.Visibility.( ← .Hidden)  ⍝ Does not work but in this style


Thanks,

Pierre Gilbert
User avatar
PGilbert
 
Posts: 362
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Alternative way to write a property from enumeration

Postby norbertjurkiewicz84 on Thu Mar 26, 2015 3:15 pm

I'm sure you can assign the Visibility enumeration values directly. I'd probably stay away from this in case MS. ever decided to change them...

https://msdn.microsoft.com/en-us/librar ... 10%29.aspx

I've been using case #1 in all my WPF, WinForms and Excel OLE code. I find it to be the most readable.


Norbert
(It's the little things that make the difference :-)
User avatar
norbertjurkiewicz84
 
Posts: 55
Joined: Mon Nov 01, 2010 7:26 pm

Re: Alternative way to write a property from enumeration

Postby PGilbert on Tue Mar 31, 2015 11:29 pm

Could someone help me with this DFN function. If I do the following it does not work:

      win.Visibility←win.Visibility.Collapsed
win.Visibility{⍺←⍺.⍎⍵}'Hidden'
win.Visibility
Collapsed


which should be the same as the following that is working:
      win.Visibility←win.Visibility.⍎'Hidden'


Thanks in advance.
User avatar
PGilbert
 
Posts: 362
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Alternative way to write a property from enumeration

Postby MikeHughes on Wed Apr 01, 2015 8:04 am

Hi Pierre

the ⍺ is evaluated so you would have had something like
Win.visibility←Collapsed.⍎'Hidden'

I haven't tried it but I think it will involve
'Win.Visibility'{⍺,'.',⍺,'←',⍵}'Hidden'

Morten and I were talking this week about how nice
win.Visibility.←Hidden
to work like var+←1
would be BUT he went a little white and decided using . like this was a step a too far
User avatar
MikeHughes
 
Posts: 80
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK

Re: Alternative way to write a property from enumeration

Postby PGilbert on Wed Apr 01, 2015 12:26 pm

Hello Mike, you are answering my question. I wanted to make sure that I was not missing a contraction like you said win.Visibility.←Hidden or win.Visibility.(←Hidden) that could have made sense in the dot notation of Dyalog somehow. Using a DFN is not simplifying the code, so I will forget about that also.

Thanks again.
User avatar
PGilbert
 
Posts: 362
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Alternative way to write a property from enumeration

Postby DanB|Dyalog on Wed Apr 01, 2015 9:19 pm

One of the problems here is that the construct "{⍺←..." will never be executed because ⍺ already has a value.
Then only way I can see this work is by doing
Code: Select all
'win.Visibility'{⍎⍕⍺'←'⍺'.'⍵}'Hidden'
DanB|Dyalog
 


Return to WPF & Syncfusion

Who is online

Users browsing this forum: No registered users and 1 guest