KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

NameSpace
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 05, 2005 1:14 pm    Post subject: NameSpace Reply with quote

Ok, I have gone through the documentation, and I am not a programmer by any means.

I am still having problems understanding the proper way to construct different items.

Currently I am trying to remove an item from a listview, but am having problems with the proper way to write it.

Here is what I think I understand.

$System = CreateObject("Kixforms.System")

This loads the Kixforms.dll into memory and allows reference to the different objects created within.....

$Form1 = $System.Form()

By referencing the object .Form from the DLL we have giving ourselves an object that can be referenced by the variable $Form1

I then create another variable using

$ImageList = $System.ImageList

So now I have an obect that I can reference of $ImageList

The $ImageList allows me to add list of icons using the .AddStrip, but I don't know where this comes from as the documentation does not list this as a direct propertie of ImageList, but rather part of ImageCollection.

So not being a programmer, I take the code of others and make it work, because that is what they have done.

I however would like to understand how to read the documentation in respect to namespace.

What I think really confuses me is when I see something like this in the documentation...
Quote:

Kixforms.Net Class Library

ImageList.Images Property
Gets the ImageCollection for this image list. Use Images(index), where index the image index number, to return a specific image from the collection.

public ImageCollection Images {get;}


How do I read that in such a way to understand what I am looking at?

Hope this isn't to off the wall to understand what I am asking for.

Thanks all.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Dec 05, 2005 1:39 pm    Post subject: Reply with quote

nope - not off-the-wall stuff at all. ok, there are a couple of things going on here - one is actually a bit of incorrect documentation on my part. this here:

Gets the ImageCollection for this image list. Use Images(index), where index the image index number, to return a specific image from the collection.

specifically this here:

Images(index)

is wrong - I will correct this right now. it should be this:

Images.Item(index)

Basically, the System namespace is used to:

1) Create objects
2) Access enumerations

So, like you pointed out - to create an ImageList:

$ImageList = $System.ImageList()

To access an enumeration, you use the System namespace as well, for example, to set the ColorDepth of the imagelist:

$ImageList.ColorDepth = $System.ColorDepth_Depth8Bit

And that is pretty much all there is to the System namespace. The tricky part (I guess) is where Objects can return references to other objects - I think thats the part that can get confusing - and unless one really knows and understands the "object model" of library - can cause much headache.

In your example, the ImageList has a "property" called "Images" that returns a reference to an "ImageCollection" - heres the docs:

ImageList.Images Property

Gets the ImageCollection for this image list. Use Images(index), where index the image index number, to return a specific image from the collection.

public ImageCollection Images {get;}

Unfortunately for me (us) - the tool I use to create the documentation for Kixforms.Net uses funky .net language for its syntax examples - the developers of the next version of the tool promise that language filtering will be in the next release - that way I can select VB.NET style syntax - which is the closest to Kixtart syntax (i think).

Anyway - one you know that the Images property returns an ImagesCollection, you can just reference the ImageCollection object to understand what properties and methods that object supports - and so on and so on ...

$= $ImageList.Images.AddStrip(...)

the above syntax could also be used like this:

$ImageCollection = $ImageList.Images
$= $ImageCollection.AddStrip(...)

-Shawn
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 05, 2005 1:59 pm    Post subject: Reply with quote

That helps..

I think that I really should have asked something even more basic.

What are the differences between

Methods
Members
Properties

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Dec 05, 2005 2:05 pm    Post subject: Reply with quote

hehee, thats a good question... and sometimes the lines are blurred - but with COM, there is the concept of a property, which can be "get" and "set" and the syntax usually looks like this:

$Object.Property [ = value ]

The [ ] indicates that this property can be set and get. If it looked like this:

$Object.Property = Value

It (usually) means that this is a write-only value, which one hardly ever sees, and this:

$Object.Property

Means that the property is readonly.

A method is analogous to a function call, that can take parameters, and looks like this:

$retval = $Object.Method(parm1, parm2, ...)

Methods are just like function calls in Kixtart. They can take lots of parms and return a return value.

Members is the "collective" name for all properties and methods that an object supports.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 05, 2005 3:53 pm    Post subject: Reply with quote

So if I understand correctly...

Code:
$ListView1 = $System.ListView()
$ListView1.Height = 30
$ListView1.Left = 3
$ListView1.Top = 4
$ListView1.Width = 450
$ListView1.View = $System.View_SmallIcon
$ListView1.SmallImageList = $ImageList


$ListView1 = $System.ListView() = Creating a listview object to be placed on the form.
.Height, .Left, .Top, .Width = properties defining the look of the object
$ListView1.View = A enumeration that affects how things are displayed. However what I don't understand here is why we are referencing directly against the system object, and not constructing it to the Listview object i.e. $ListView1.View = SmallIcon (or somesuch).
$ListView1.SmallImageList = Is a property that then references the ImageList Class. This then references the ImageList object that was created with this code.
Code:
$ImageList = $System.ImageList
$ImageList.ImageSize = $System.size(20,20)
$nul= $ImageList.Images.AddStrip($System.Bitmap.FromBase64String(BitmapString()))

So we again work ourselves through with the creation of an ImageList object, we then state what the size of the images are (yet again we are referencing the $system object instead of the currently object and I am not sure why).
But, then we are working with the Images property of ImageList, which of course leads us to the ImageCollection Class. That class then has the property of AddStrip in which we can an image to our ImageList.

That then leads us to
Code:
For $i = 0 To $ImageList.Images.Count - 1
   $ListItem = $ListView1.Items.Add($System.ListViewItem())
   $ListItem.ImageIndex = $i
Next

Here it is saying in the ImageList object, look at the Images property, which we know refrences the ImageCollection Class, and get the property of Count which returns the total number of items/images in the collection, and subtract 1.
It goes on to say then that variable $ListItem is = to the Item Property of the ListView object, which in return references us back to the ListViewItemCollection Class, of which there is a property of Add. Now again I am not sure why, but we reference the ListViewItem Class.
Finally now that we have written a shorthand version of the above line, we add an image at the ImageIndex of $i

Is this basically it? And if so, how do you keep it all straight? I am lost even as I type all of this in and have the documentation right next to me.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Dec 05, 2005 4:34 pm    Post subject: Reply with quote

ok, let me answer the first part first. I know what saying - why are we using the System object to specify thigs like - the Size of the items, and using it to specify enum values, etc. Like this:

$ImageList.ImageSize = $System.Size(16,16)

You know that in Kixforms classic, I provided tons of different ways to specify things - like this:

$ImageList.ImageSize = $System.Size(16,16)

$ImageList.ImageSize = 16,16

and with enums, one has these options ...

$ListView.View = 1
$ListView.View = "Details"
$ListView.View = $System.View.Details

they (really) all mean the same thing. Well, with Kixforms.Net I lost some of this flexibility (kinda sorta, will explain more later) ... with .NET and COM, if I specify that a property accepts a value of a certain type, then one is bound to that type. For example with size, the only way to specify a size (which is really two values - a width and a height), obviously this requires more than a single Integer to specify. So in Kixforms.Net - the only acceptable "value" for the ImageSize property is an object of type "Size" ...

But - one still needs a way to create (or instantiate) this object that represents a "size" - so that is the purpose of the System namespace - to create instances of objects.

$ImageList.ImageSize = $System.Size(16,16)

The common System object (to me) was the only place that made sense - for creating objects out of thin-air. Kixtart needs a handle to something, to create things.

If one wanted to specify things like Size using other forms of syntax, like this:

$ImageList.ImageSize = 16,16

What you are really doing here is assigning an array of two Integers to the ImageSize property (which Kixtart has no problem creating, because its a builtin feature). With the way Kixforms.Net is developed right now, this syntax will throw an error. Why - because an array of two integers is not a "Size" ... .Net is getting strict with us. Could this syntax be supported if I changed things under the covers though ? Yes it could - but I made a judgement call early on that I wouldn't ... you may ask why ?

Well - in order to support this "varying" kind of input to properties, one needs to specify that every property is of type VARIANT - which is a fuzzy type, a non-specific type. The big reason I chose not to do this was because many of the Language Sensitive editors dont deal too well with these fuzzy types - they dont (can't) tell you what type of value is being expected (because there is no specific single type).

Do I regret making this call - sometimes - because now Kixforms.Net lacks the flexibility that Kixforms classic has. Is it too late to change ? Definitely not - and I've thought about abandoning this strict typing many (many) times.

Will I change things ? I dont know yet. If I did loosen the typing - it wouldn't break any existing scripts.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Mon Dec 05, 2005 10:54 pm    Post subject: Reply with quote

Shawn, couldn't you just use:
Code:
$ImageList.ImageSize.Height = 16
$ImageList.ImageSize.Width = 16

In KiXforms.Net?

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Dec 05, 2005 11:29 pm    Post subject: Reply with quote

hehee, sneaky basta - you might think so but no - that doesn't work (doesn't work like that in real .net either). 100 Kixforms points to anyone that can explain why this doesn't work.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Dec 06, 2005 12:44 am    Post subject: Reply with quote

.Height / .Width are not supported enumerations for the ImageList property?
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Dec 06, 2005 12:50 am    Post subject: Reply with quote

hehee, close but no cigar.

hint ...

this doesn't work:

$ImageList.ImageSize.Width = 16

but this would work (if it were supported, which it aint):

$ImageList.ImageWidth = 16
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Dec 06, 2005 1:09 am    Post subject: Reply with quote

Imagesize directly calls the Size Class, where you could do a $system.size.height = 16
$system.size.width = 16
or $system.size(16,16)

So any call to Imagesize must be written as if you were using $system.size directly?

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Dec 06, 2005 1:35 am    Post subject: Reply with quote

ja, I think you kinda got it ...

The problem is - the "Size" object knows absolutely nothing about the ImageList object, so this statement here:

$ImageList.ImageSize.Width = 16

What this is really saying is:

The ImageSize property is returning a "Size" object, and that this statement is in turn setting the Width of that Size object to 16 - but the question becomes - does the Size object "know enough" to go back to the ImageList object, and actually tell it to change its image width to 16.

No it doesn't (it cant) - because the Size object is a general purpose object, and its not tied to any specific object - the Size object knows not from which it came.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Dec 06, 2005 1:46 am    Post subject: Reply with quote

Yea 75 points for me (mostly right). Very Happy
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Tue Dec 06, 2005 2:17 am    Post subject: Reply with quote

shawn, why you pulled the size object and it's knowledge to this game?

I would be more technical and say what really is the cause instead of this kinda bedtime story. Wink

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Tue Dec 06, 2005 2:24 am    Post subject: Reply with quote

to explain my comment.
sure the imagelist does not know but it does not need to.

that's what the dots are for!

$imagelist.imageSize.width = 16

kixtart passes a value to the width property of the size object of imagelist.imageSize.
the imageSize is value is a stored object.
it does not need to know anything else but it's own values.
the imageList is the one who knows that the Size object accessed via it's imageSize method is it's own.

so indeed, it should work.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group