예제 #1
0
파일: ChatWindow.cs 프로젝트: Helen1987/edu
        public ChatWindow(SimpleChat simpleChat, PeerUser peerUserObject)
        {
            if (simpleChat == null)
            {
                throw new ArgumentNullException("simpleChat");
            }

            if (peerUserObject == null)
            {
                throw new ArgumentNullException("peerUserObject");
            }

            InitializeComponent();

            this.chatClient =
                ChannelFactory<ISimpleChatService>.CreateChannel(
                new WSHttpBinding(), peerUserObject.Address);

            this.simpleChatOwner = simpleChat;

            this.peerUser = peerUserObject;

            string chatWith = null;

            if (!string.IsNullOrEmpty(peerUserObject.UserName))
            {
                chatWith = this.peerUser.UserName;
            }
            else
            {
                chatWith = this.peerUser.Address.Uri.Host;
            }

            Text = string.Format(
                CultureInfo.CurrentCulture,
                Resources.ChattingWithMessage,
                simpleChat.UserName,
                chatWith);
            Owner = simpleChat;

            StartPosition = FormStartPosition.CenterParent;
            Show();
            chatText.Focus();
        }
예제 #2
0
 public ChatService(SimpleChat simpleChat)
 {
     this.simpleChat = simpleChat;
 }