Ejemplo n.º 1
0
        /// <summary>
        /// Begins an asynchronous join operation on the underlying <see cref="ChatProxy">ChatProxy</see>
        /// which will call the OnEndJoin() method on completion
        /// </summary>
        /// <param name="p">The <see cref="Common.Person">chatter</see> to try and join with</param>
        public void Connect(Person p)
        {
            InstanceContext site = new InstanceContext(this);

            proxy = new ChatProxy(site);
            IAsyncResult iar = proxy.BeginJoin(p, new AsyncCallback(OnEndJoin), null);
        }
Ejemplo n.º 2
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lstChatters.Items.Clear();
            NickDialog nickDlg = new NickDialog();

            if (nickDlg.ShowDialog() == DialogResult.OK)
            {
                myNick = nickDlg.txtNick.Text;
                nickDlg.Close();
            }

            txtMessage.Focus();
            Application.DoEvents();
            InstanceContext site = new InstanceContext(this);

            proxy = new ChatProxy(site);

            IAsyncResult iar = proxy.BeginJoin(myNick, new AsyncCallback((thisIar) =>
            {
                try
                {
                    string[] list = proxy.EndJoin(thisIar);

                    pwDlg.Invoke((Action)(() =>
                    {
                        if (list == null)
                        {
                            pwDlg.ShowError("Error: Username already exist!");
                            ExitChatSession();
                        }
                        else
                        {
                            pwDlg.Close();
                            ShowConnectMenuItem(false);
                            foreach (string name in list)
                            {
                                lstChatters.Items.Add(name);
                            }
                            AppendText("Connected at " + DateTime.Now.ToString() + " with user name " + myNick + Environment.NewLine);
                        }
                    }));
                }
                catch (Exception ex)
                {
                    pwDlg.Invoke((Action)(() =>
                    {
                        pwDlg.ShowError("Error: Cannot connect to chat!");
                        ExitChatSession();
                    }));
                }
            }), null);

            pwDlg = new PleaseWaitDialog();
            pwDlg.ShowDialog();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// �����ϱ�
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InstanceContext site = new InstanceContext(this);
              proxy = new ChatProxy(site);
              lstChatters.Items.Clear();
              NickDialog nickDlg = new NickDialog();
              if (nickDlg.ShowDialog() == DialogResult.OK)
              {
            myNick = nickDlg.txtNick.Text;
            nickDlg.Close();
              }

              txtMessage.Focus();

              IAsyncResult iar = proxy.BeginJoin(myNick, new AsyncCallback(OnEndJoin), null);
              pwDlg = new PleaseWaitDialog();
              pwDlg.ShowDialog();
        }
Ejemplo n.º 4
0
        private void OnConnect(object sender, RoutedEventArgs args)
        {
            InstanceContext site = new InstanceContext(this);
            proxy = new ChatProxy(site);

            // Get Local IP Address
            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            myNick = localIPs[1].ToString();

            // Use IP Address as a user name
            IAsyncResult iar = proxy.BeginJoin(myNick, new AsyncCallback(OnEndJoin), null);

            // DisEnable "Connect" button & Enable "Disconnect" button
            // when client is connected with server
            Connect.IsEnabled = false;
            Connect.Visibility = Visibility.Collapsed;

            Disconnect.IsEnabled = true;
            Disconnect.Visibility = Visibility.Visible;

            #region Fade in
            // Create a storyboard to contain the animations.
            Storyboard storyboard = new Storyboard();
            TimeSpan duration = new TimeSpan(0, 0, 5);

            // Create a DoubleAnimation to fade the not selected option control
            DoubleAnimation animation = new DoubleAnimation();

            animation.From = 1.0;
            animation.To = 0.0;
            animation.Duration = new Duration(duration);
            // Configure the animation to target de property Opacity
            Storyboard.SetTargetName(animation, SayHello.Name);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
            // Add the animation to the storyboard
            storyboard.Children.Add(animation);

            // Begin the storyboard
            storyboard.Begin(this);

            #endregion
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Begins an asynchronous join operation on the underlying <see cref="ChatProxy">ChatProxy</see>
 /// which will call the OnEndJoin() method on completion
 /// </summary>
 /// <param name="p">The <see cref="Common.Person">chatter</see> to try and join with</param>
 public void Connect(Person p)
 {
     InstanceContext site = new InstanceContext(this);
     proxy = new ChatProxy(site);
     IAsyncResult iar = proxy.BeginJoin(p, new AsyncCallback(OnEndJoin), null);
 }