wintin Forum Index wintin
Wintin Discussion Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Addin Exploration

 
Post new topic   Reply to topic    wintin Forum Index -> Addins
View previous topic :: View next topic  
Author Message
phillogic



Joined: 27 Apr 2004
Posts: 6

PostPosted: Wed Apr 28, 2004 8:51 am    Post subject: Addin Exploration Reply with quote

Hello again. I am now modifying the sample "test addin";I have added a ReceivedText event handler to the test addin command/service. What I want to be able to do is route input text (from the mud) to a secondary pop up window, which if not already created, is created at this time.

As far as I know the only way to display text to a window is to use the interpreter service, but that just displays text to the main window. How do I display text to other popup windows? How would I make a window at runtime using the "#addinTest" command and populate it with text from the mud?

Essentially Iam trying to mimic the #window and #popup command. If you could direct me as to where in the orignal source #window or #popup were implemented that would prove most useful. Once again thank you for your time.
Back to top
View user's profile Send private message AIM Address MSN Messenger
william
Site Admin


Joined: 07 Dec 2003
Posts: 539

PostPosted: Wed Apr 28, 2004 9:56 am    Post subject: Reply with quote

Phil

The windows etc are managed by the Workbench service. The idea is to keep all the knowledge of the Magic library within that service, to make it easy to swap out at a later date if necessary. As an aside, the Workbench service isn't structured as well as it should be - I didn't have that clear an idea of what I wanted when I wrote it, and it shows.

The Workbench service implements an IViewManager interface. That has public methods NewPad and NewFloatingPad, which will create a #popup style window, either docked or undocked. The window is created with an embedded control. In this case you would want to use a Putty control, which will do the ANSI colouring and so on. The #popup command is implemented in the Workbench service, and does exactly that: the creation is in AddPadFilter(). Here's an annotated copy of some code to set up the window that I've adapted from there:

-------

// Create the window and get a handle to the underlying putty control
// (I have simplified the code here)
ManagedPuttyControl pc;
NewFloatingPad((pc = new ManagedPuttyPanel()), title);


// Set this up as a 'passive' control that will not telnet to the mud itself
IPuttyStore puttyStore = (IPuttyStore) ServiceManager.Services.GetService(typeof(IPuttyStore));
pc.NullSession(puttyStore);

// If the user types a key into the window, reflect it back into the input control
pc.KeyPressed += new ManagedPuttyControl.KeyPressedEventHandler(OnPuttyKeyPressed);

---------

If you keep a handle to the putty control, pc, you can then write text to it with pc.Outstring()


Hope this helps. I should probably encapsulate it into a method in the workbench service as it's something that addon writers would find useful.

regards

William
Back to top
View user's profile Send private message Send e-mail
phillogic



Joined: 27 Apr 2004
Posts: 6

PostPosted: Thu Apr 29, 2004 3:00 am    Post subject: Reply with quote

Hey William.

I have looked at the workbench service code and I now have a pretty good understanding of how the window and popup commands work etc. Thank you for your guidance.

I have a few other questions ,not related to an ADDIN, but regarding the putty control. How do the "putty control" and "putty store" relate to each other? Is there some way of using a null putty control object without a putty store object? Could it be possible to use the putty control outside of wintin in another .Net application like for example a strip down telnet application where the putty control is used exclusively for displaying the ANSI colors etc?
I would be grateful for any suggestions you may have.
Back to top
View user's profile Send private message AIM Address MSN Messenger
william
Site Admin


Joined: 07 Dec 2003
Posts: 539

PostPosted: Sat May 01, 2004 10:23 am    Post subject: Reply with quote

By design, Putty keeps its settings in the Windows registry. The design assumption is that there's one 'master' set of settings per machine. The underlying code is pretty nicely abstracted, though, and I modified it to call an IPuttyStore interface to save and retrieve the settings. PuttyStore is an implementation of that interface which saves the settings to an xml file.

You can certainly re-use PuttyControl in other applications. It shouldn't be too hard. You will need to provide an implementation of IPuttyStore, though - either mine or one of your own.

It would be good to package PuttyControl as a project of its own and write some notes on how to use it. It could do with some tidying up of the interface as well. I don't have time to do this right now, but let me know if you're interested in volunteering Smile
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    wintin Forum Index -> Addins All times are GMT
Page 1 of 1

 
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