How to create own (dynamic) thumbnailpanel? (1 Viewer)

eightyf

Portal Member
May 14, 2007
23
3
54
Munich
Home Country
Germany Germany
Hi,
so I made the PluginsTutorial and it works just fine.
But now I want to create a dynamic thumbnailpanel (those of you, who know kaleidescape - that's the direction I'm heading for).
Since I need full control of the thumbs' properties (including position, order, etc.) I guess I cannot use MPs thumbnailpanel/facadeview.
I had moderate success using the GUIImage function, but this only works if there is a
Code:
<control>
<type>image</type>
<id>whatever</id>
...
</control>
code in the corresponding XML file - that means a control for every single thumb in the XML-code.
That's not a feasable option and it is not very flexible either.
So here are a few questions:
- can there be instances of one GUIImage, so that I would only need one Image-control (sort of as a reference, where size etc. are stored)?
- how can I create AND display a GUIImage without having an according control in the XML-file?
I tried
Code:
GUIImage testImage = new GUIImage(GetID,20,500,200,50,75,"texture path",0);
But to no avail. I don't get error messages, but the image simply will not be displayed.

Those are probably quite basic questions, but as a beginner, I need some place to start ;-)

Thank you for your help
André
 

Inker

Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Hi eightyf,

    Sorry I had to pop out of IRC last night.

    Anyways, there should be a children property on the GUIWindow, which has an Add(GUIControl control) method.

    So something like:
    Code:
    GUIImage testImage = new GUIImage(GetID,20,500,200,50,75,"texture path",0);
    this.Children.Add(testImage);
    should work.
     

    eightyf

    Portal Member
    May 14, 2007
    23
    3
    54
    Munich
    Home Country
    Germany Germany
    Hi Inker,
    thanks for your reply - unfortunately it doesn't work.
    Just to get this right: you want to add the GUIImage to the window (as a child), so that it's displayed correctly. Has any element of the GUIclass to be a child of the window????
    What makes things a little bit difficult, it's hard to check if the Image was either not created or not displayed or has some other error (e.g. a forgotten texture).
    Regards
    André
     

    eightyf

    Portal Member
    May 14, 2007
    23
    3
    54
    Munich
    Home Country
    Germany Germany
    OK, I got the images displayed, using the suggested method (this.Children.Add).
    Dunno, why it didn't work earlier.
    Now I got other problems, but those seem to be caused by somelack of basic C# knowledge (What happens now, is that the images are displayed, but I cannot access them from any other location in the code, than where they are created - like I said, basic stuff).
    Guess it's time to get some good OOP and C# tuts ;-)
    Or maybe someone from this community can tell me, where I went wrong...
    Thanks
    André
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Well, if you instanciate them within a Method (the controls) then that reference is only existing until the method returns.

    But, since you add them to the Childrens node (which is a List<GuiControls> I think) you can access them from there like so Children[n] where n is the index number of the control which you wish to receive.

    Be aware that this List also contains all the other controls on your page, including the ones imported from various common xmls. Because of this, I would suggest creating your own List<GuiImage> as a class member (declare outside of a method) and then add them there. This way you can get quick access.

    Code:
    List<GuiImage> myThumbnails = null;
    
    private void Foo()
    {
        if(myThumbnails == null) myThumbnails = new List<GuiImage>();
        GuiImage newImage = new GuiImage(blabla here);
        myThumbnails.Add(newImage);
        Childen.Add(newImage);
    }
    
    private void Fooo()
    {
        GuiImage existingImage = myThumbnails[0];
        // do somethign with the image here, like set a new filename
    }

    I really suggest you read up on OO and .NET in general :)
     

    eightyf

    Portal Member
    May 14, 2007
    23
    3
    54
    Munich
    Home Country
    Germany Germany
    I really suggest you read up on OO and .NET in general :)
    Why should I do such a silly thing, when there are helpful and competent guys like you to help me ;-)
    You could at least have said, that I have to use the System.Collection tsk, tsk, tsk....
    No honestly, that did the trick, you really helped me a lot and ended hours and days of try and error.
    Thank you very, very much! IOU
    André
     

    mbuzina

    Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    Another suggestion would be:

    Try to inherit from the Facade Control to make yourself a customized GUI Control. I am not 100% sure what you are trying to accomplish, but directly adding items to the Window is "bad style". Better design your own control, add this to the window using a XML file and add you items to the control. Seperate Data Logic from Display Logic. (So reading up on OO, App Design etc. is not a bad thing ;-) )
     

    eightyf

    Portal Member
    May 14, 2007
    23
    3
    54
    Munich
    Home Country
    Germany Germany
    mbuzina,
    that's about what Inker suggested in the IRC, but I honjestly do not feel fit enough, to implement my own control from the source.
    I will try (if this ever gets accomplished) to make this thing as "skinnable" as possible.
    for further information on what I am trying to make, watch the "experience kaleidescape video" HERE.
    As a matter of fact, MP is yet pretty close to this anyway, so I hope, that this can be done.
    If you are interested and / or want to share your knowledge, I'd be glad to hear from you (or Inker, of course).
    andre.dufresne (at) tv-people (dot) de
     

    Users who are viewing this thread

    Top Bottom