CLR limits

Started by stanl, August 03, 2013, 07:09:14 AM

Previous topic - Next topic

stanl

I am looking into incorporating a .net listview control into a WB app via the CLR. The Out-Gridview through Powershell, while nice as final output and easy to implement, lacks most of the features of a real grid. I came across this link
http://www.componentowl.com/better-listview
and it looks feasible via the CLR.  I guess the main question is since the listview will be part of a windows form and not a WB dialog... how much control will I have over it.
At the risk of embarrassment from something really stupid, I will stop here.

stanl

Preliminary. As I understand it something like the BetterListView (which registers in the GAC under several versions of the Namespace, and it is commented out in the code below) has to be constructed as an abstract class following, I assume, the same hierarchy as the .net Listview.  The code below is my best shot at creating the types needed to support building the BetterListView control. Completely lost as to building the constructor...  but somehow have to assign it as a component to the designer then initialize()???
Code (WINBATCH) Select

ObjectClrOption("use","System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
ObjectClrOption("use","System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
ObjectClrOption("use","System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
ObjectClrOption("use","System.Workflow.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
ObjectClrOption("use","System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
;for future use
;ObjectClrOption("use","BetterListViewExpress-net40cp, Version=3.7.6.0, Culture=neutral, PublicKeyToken=e6c91a3add447be2")
oToolBox = ObjectClrNew('System.Drawing.Design.ToolboxItem')
oDesign = ObjectClrNew('System.ComponentModel.Design.IDesigner')
oFormDesigner = ObjectClrNew('System.Windows.Forms.Design.ControlDesigner')
oBase = ObjectClrNew('System.ComponentModel.Design.Serialization.CodeDomSerializer')

Message("","Debug")
Exit 

td

Took a very brief glance at the documentation and it appears work more or less like any FCL control you would drop into a standard FCL form.  It has a simple default constructor with no parameters.  It is certainly possible create a form using WinBatch's CLR support and I see no reason why you couldn't drop your control into one.  The big problem is that WinBatch has no mechanism for supporting delegates and no delegates means no event handling.  Without events you would be hard pressed to respond to user interaction with your control. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on August 05, 2013, 06:56:09 AM
I see no reason why you couldn't drop your control into one.
I understood everything but this. I tried to just create a constructor for the control and it errored. Assuming I create a Windows.Form size it and make it visible. I further assume I would have to create a object under Windows.Froms.Control and then assign the listview to the object.
As for event-handling. There are only a few, like onscroll, while there are properties like allowuseredit. Probably at this point I am more interested in drilling down the hierarchy just to get a good grasp on initializing an displaying a control.
Thanks for looking. 

td

Quote from: stanl on August 05, 2013, 09:47:46 AM

I understood everything but this. I tried to just create a constructor for the control and it errored.

The documentation you provided a link for listed only the default constructor and you don't need to create a ctor.  You just need to use it by calling ObjectClrNew. :)

Quote
Assuming I create a Windows.Form size it and make it visible. I further assume I would have to create a object under Windows.Froms.Control and then assign the listview to the object.
As for event-handling.

Generally, controls are added to a form by calling the Add method of the form's Controls collection.

Quote
There are only a few, like onscroll, while there are properties like allowuseredit. Probably at this point I am more interested in drilling down the hierarchy just to get a good grasp on initializing an displaying a control.
Thanks for looking.

Are we looking at the same documentation?   It looked like ~50 events to me. Perhaps you meant that you were only interested in few events or something.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

All of these fail with TypeName Not Found.
Code (WINBATCH) Select


ObjectClrOption("use","BetterListViewExpress-net35cp, Version=3.7.6.0, Culture=neutral, PublicKeyToken=e6c91a3add447be2")
;oListView = ObjectClrNew('ComponentOwl.BetterListView','BetterListView')
;oListView = ObjectClrNew('BetterListView')
oListView = ObjectClrNew('BetterListViewExpress-net35cp','BetterListView')



td

The first parameter to ObjectClrNew should be namespace+type name where 'type name' is a class, structure or enumeration name. So it should be something like this

Code (winbatch) Select

ObjectClrNew("ComponentOwl.BetterListView.BetterListView" )
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Thanks... at least one of my attempts was close.  As for the events, I think I originally looked at the on... events and just went blank.
As for moving forward. You indicated that once I create the BetterListView object and a Windows.Forms.Control I add the former to the latter...  first question: do I then set all properties based on the Listview, or are some required to be set by the control?

td

The BetterListView class has  the Control class in its class hierarchy so all the public members of the control class should be available to the BetterListView class.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl