コード例 #1
0
        public ConverstationWindow(Contact c, JustTalk mainWind) {
            InitializeComponent();
			this.contact = c;
			mainWindow = mainWind;
			this.Text = contact.Name + " - JustTalk";
			username = Properties.Settings.Default.Username;
			// Initialize font, colors and size
			stringBuilder = new StringBuilder(@"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}{\colortbl ;\red75\green100\blue165;\red155\green155\blue155;}\fs16");

			if(!contact.StatusMessage.Equals("Chat"))
				this.ReceiveMessage(contact.Name, contact.StatusMessage, 2);
			if(contact.Status != Status.chat)
				this.ReceiveMessage(contact.Name, messages[(int)contact.Status - 1], 2);
        }
コード例 #2
0
		// Update contact's presence information
		public void UpdateContactPresence(String jid, Status status, String statusMessage) {
			try {
				Contact contact = contacts[jid];
				Contact previous = new Contact(contact);
				contact.Status = status;
				contact.StatusMessage = statusMessage;

				// Set context menu accordingly
				if(status != Status.inviteSent && status != Status.inviteAccepted)
					contact.ContextMenuStrip = this.contactsContextMenuStrip;
				else
					contact.ContextMenuStrip = this.pendingContactContextMenuStrip;

				if(conversations.ContainsKey(jid) && previous.Status != contact.Status)		// If a conversation window is opened update it
					conversations[jid].UpdateContactPresence(status, statusMessage);
			} catch (KeyNotFoundException ex) {
				Console.WriteLine("Contact not present " + ex.StackTrace);
			}
		}
コード例 #3
0
		// Invokes a method to receive message in a conversation window, delegate is used for cross thread calls
		public void ReceiveMessage(JabberID from, string body) {
			Console.WriteLine("Gui received message from: " + from);
			if(!conversations.ContainsKey(from.User + "@" + from.Domain)) {		// Check if there is already open conversation window
				Contact c;
				if(contacts.ContainsKey(from.User + "@" + from.Domain))			// Check if sender is in Contact list
					c = contacts[from.User + "@" + from.Domain];
				else
					c = new Contact(from.User + "@" + from.Domain);
				conversations[from.User + "@" + from.Domain] = new ConverstationWindow(c, this);	// Open new conversation window
				conversations[from.User + "@" + from.Domain].Show();								// Show if new window
			} else {
				if(!conversations[from.User + "@" + from.Domain].Visible)
					conversations[from.User + "@" + from.Domain].Show();
				conversations[from.User + "@" + from.Domain].Activate();							// Just activate if already opened
			}
			conversations[from.User + "@" + from.Domain].ReceiveMessage(body);						// Receive message
		}
コード例 #4
0
		// Update contact's information
		public void UpdateContact(String jid, String name, String group, Status status) {
			Console.WriteLine("Adding: " + jid + ", " + name+ ", " + group + ", " + status);

			// Find group
			Group groupNode;
			if(group == null)										// If no group is sent use default(0)
				groupNode = (Group)contactsTreeView.Nodes[0];
			else {															// Group is sent
				if(!contactsTreeView.Nodes.ContainsKey(group)) {			// If the group doesn't exists
					Group newGroup = new Group(group);
					newGroup.ContextMenuStrip = gropupContextMenuStrip;
					contactsTreeView.Nodes.Add(newGroup);					// Make one					
				}
				groupNode = (Group)contactsTreeView.Nodes[group];	// we have Group
			}

			// Find contact
			Contact contact;
			if(contacts.ContainsKey(jid)) {					// Such contact exists
				contact = contacts[jid];					// use it
				if(contact.Parent != groupNode) {			// We should change group
					contact.Remove();						// Remove from original
					groupNode.Nodes.Add(contact);			// Add to new
				}
			} else {
				contact = new Contact(jid);			// else make it
				contacts[jid] = contact;			// Put it in the dictionary

				// Set context menu
				if(status != Status.inviteSent && status != Status.inviteAccepted)
					contact.ContextMenuStrip = this.contactsContextMenuStrip;
				else
					contact.ContextMenuStrip = this.pendingContactContextMenuStrip;

				groupNode.Nodes.Add(contact);		// and add it to gui
			}			
			contact.Name = name;
			contact.Status = status;			
		}
コード例 #5
0
		public Contact(Contact other) {
			this.JabberID = other.jabberID;
			this.Name = other.name;
			this.Status = other.status;
			this.StatusMessage = other.statusMessage;
		}