开发者

Dock Windows Forms (tabbed chat interface)

开发者 https://www.devze.com 2023-02-28 01:39 出处:网络
Edit for those who say to use tab control I would love to use a tab control; yet i have no idea how to go about linking the tab control up from the main form.I would assume that I would have to do so

Edit for those who say to use tab control

I would love to use a tab control; yet i have no idea how to go about linking the tab control up from the main form. I would assume that I would have to do something like this:

  1. Create Form with a blank TabControl on it, no pages created.
  2. Create a CustomuserControl (Add -> user Control), with my controls on it.
  3. When a new chat comes in, create a tab control Item, Tab Control Page, add the Custom Control to the Tab Control Page. Add the tab control handle to the hash table, so that when new messages come in, they can be referenced in the proper control.

But, i am so not sure how to do this. For example, I know that I can create custom events inside of the User Control, so that, for example, if each control has a 'bold' button, i can each page that has that control on it, to actually USE the button.

Yet i also need to register message callbacks, so that I can use a MessageGrabber to send data to it, and tha'ts not assigned inside of the UserControl, that's assigned programatically when a new window comes in; but since I have no controls to reference, i can't assign.


KISS Philosophy

Wouldn't it be easier to just create the form, like i do now, and then just dock that form within a window or something? So that, in essence, it's still creating the form, but it's also a separate window?


Original Question

Okay, so i'm stumped (which isn't that big of a surprise when it comes to complex C# logic lol)! What i'm trying to do is the following:

Goal: Setup tabbed chatting for new chat application.

Completed: Open new window whenever a chat message is received, or a user requests a new chat from the roster. This is working perfectly, and opens only a window when the user doesn't already have the chat open. Nice and happy there.

Problem: I dont want windows. Well, i do want A window, but, i do not want tons of separate windows. For example, our Customer Service team may have about 10 active IM windows going at one time, i do not want them to have to have 10 windows tiled there lol. I'd rather they have a single Private IM window, and all 10 tabs docked within the window.

Logic: This is my logic here, which may be flawed, i do apologize:

  • OnMessage: Open new开发者_高级运维 chat window if one doesn't already exist; if one exists, open it as a tab within the current chat window.
  • SendMessage: ^^ ditto ^^

Code Examples:

if (!Util.ChatForms.ContainsKey(msg.From.Bare))
            {
                RosterNode rn = rosterControl1.GetRosterItem(msg.From);
                string nick = msg.From.Bare;
                if (rn != null)
                    nick = rn.Text;
                frmChat f = new frmChat(msg.From, xmpp, nick);
                f.Show();
                f.IncomingMessage(msg);
                return;
            }

Note on above: The Util. function just keeps tracks of what windows are opened inside of a hashtable, that way, when messages come in, they route to the proper window. That is added with the:

Util.ChatForms.Add(m_Jid.Bare.ToLower(), this);

Command in the frmChat() form.

Library in Use: agsxmpp from: http://www.ag-software.de/agsxmpp-sdk/download/

Problem: How can i convert this code to open inside of tabs, instead of windows? Can someone please give me some ideas, and help with that. I just can't seem to wrap my head around that concept.


Use TabControl

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号