Results 1 to 4 of 4

Thread: adding control after panel is loaded

  1. #1
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    345

    adding control after panel is loaded

    In response to the other thread I had, the last question was how to set properties/text/etc to a specific screen after the panel is already loaded. Since that has been answered, I have come up with a new question:
    How would I go about adding a control to the panel on a specific screen?
    Ex
    Code:
    //initialize has been run already and panel has been loaded already successfully
    private void button1click(OMControl sender, int screen)
    {
          //add button dynamically to screen
          addtoscreen(screen);
    }
    private void addtoscreen(int screen)
    {
          OMImage picbox = New OMImage();
          picbox.Name = "NewPicbox"
          //add this to the screen that it was called from
          //tried:  p.addControl(((OMImage)manager[screen][picbox.Name]));
    }
    But like what happened before it adds to the panel on a different screen other than the one I clicked it from. The above code didn't say any errors in the editor? Is it possible to add to a panel already loaded on a specific screen?

  2. #2
    Raw Wave
    Auto Apps:loading...
    justchat_1's Avatar
    Join Date
    Jul 2008
    Location
    Boston, Ma or NY,NY
    Posts
    2,359
    Good Questions...the new website is going to have a code snippets database with snippets of code for lots of different tasks-so questions like this will be perfect.

    Code:
    //For plugins with only one panel:
    manager[screen].addControl(controlName);
    
    //For plugins with more then one panel:
    manager[screen,panelName].addControl(controlName);
    
    //And if adding more then one control-this may be easiest:
    OMPanel p=manager[screen,panelName];
    p.addControl(firstControl);
    p.addControl(secondControl);

  3. #3
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    345
    Cleared that right up, awesome. Here is another that might be worth asking/answering in terms of I can't figure it out but also for snippets...

    What's the equivalent of a new painteventhandler in OM, if there is one (to draw to the controls)? Normally you would use a new painteventhandler and capture the object and paintevent args. The actual new painteventhandler gives you acceess to the controls graphics object.

    I noticed that OM has a rendertext and renderparams, but can't figure out how they are used, if at all in this case of painting to controls.

  4. #4
    Raw Wave
    Auto Apps:loading...
    justchat_1's Avatar
    Join Date
    Jul 2008
    Location
    Boston, Ma or NY,NY
    Posts
    2,359
    Quote Originally Posted by detlion1643 View Post
    Cleared that right up, awesome. Here is another that might be worth asking/answering in terms of I can't figure it out but also for snippets...

    What's the equivalent of a new painteventhandler in OM, if there is one (to draw to the controls)? Normally you would use a new painteventhandler and capture the object and paintevent args. The actual new painteventhandler gives you acceess to the controls graphics object.

    I noticed that OM has a rendertext and renderparams, but can't figure out how they are used, if at all in this case of painting to controls.
    The best way to do this (for a few reasons) would be to extend the control you need to do custom drawing on and override the Render method.

    Code:
    class MainMenuButton:OMButton
    {
            public override void Render(OpenMobile.Graphics.Graphics g, renderingParams e)
            {
                base.Render(g, e);
                g.DrawImage(icon.image, left + 48, top+18, 92, 92);
                if (ourTextTex == null)
                    ourTextTex = g.GenerateTextTexture(0, 0, width, 34, ourText, localFont, eTextFormat.Bold, Alignment.CenterCenter, Color.White, Color.Gray);
                g.DrawImage(ourTextTex, left, top + 112, width, 34);
            }
    }
    By doing it this way you can add custom properties, decide when or if the base control does its drawing and even have a re-usable component for other plugins or panels.

Similar Threads

  1. The WinXPe Colab Installation instructions
    By darkslyde in forum WinNT Based
    Replies: 1
    Last Post: 02-17-2008, 05:59 PM
  2. Replace Civic 96-98 heater control panel with 99-00 panel
    By PredatorCoder in forum Fabrication
    Replies: 69
    Last Post: 04-24-2007, 05:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •