示例#1
0
        private void p_Disposed(object sender, EventArgs e)
        {
            FormMain.fActiveWebCams.Remove(new KeyValuePair <string, string>(fUser, MonikerName));

            var distributor = Distributor;

            if (distributor != null)
            {
                Distributor = null;
                ActiveWebCams.Stop(MonikerName);
                distributor.Dispose();
            }

            var enumerator = fEnumerator;

            if (enumerator != null)
            {
                fEnumerator = null;

                try
                {
                    enumerator.Dispose();
                }
                catch
                {
                }
            }

            base.OnClosed(e);
        }
示例#2
0
 static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         using (var form = new FormMain())
             Application.Run();
     }
     finally
     {
         ActiveWebCams.Stop();
         SoundEnumerator.Stop();
     }
 }
示例#3
0
        private void startWebCamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // creates a copy of the userList, so the Show of the forms will
            // not cause problems when there are other events (which are processed
            // in the middle of the following foreach.
            var userList = listUsers.SelectedItems.OfType <string>().ToList();

            foreach (string userItem in userList)
            {
                string       user = userItem.Substring(0, userItem.LastIndexOf(" - "));
                WebCamInfo[] availableWebCams;

                if (user == fNickName)
                {
                    availableWebCams = ActiveWebCams.ListAllWebCams();
                }
                else
                {
                    availableWebCams = fClient.ListWebCams(user);
                }

                if (availableWebCams == null)
                {
                    MessageBox.Show("User " + user + " is no more connected.");
                    continue;
                }

                WebCamInfo webCamInfo;
                switch (availableWebCams.Length)
                {
                case 0:
                    MessageBox.Show("User " + user + " has no active web-cams.");
                    continue;

                case 1:
                    webCamInfo = availableWebCams[0];
                    break;

                default:
                    webCamInfo = p_SelectWebCam(availableWebCams);

                    if (webCamInfo == null)
                    {
                        continue;
                    }

                    break;
                }

                string     displayName = webCamInfo.DisplayName;
                string     monikerName = webCamInfo.InternalName;
                FormWebCam form;
                fActiveWebCams.TryGetValue(new KeyValuePair <string, string>(user, monikerName), out form);
                if (form != null)
                {
                    form.BringToFront();
                    continue;
                }

                IFastEnumerator <byte[]> enumerator;
                try
                {
                    if (user == fNickName)
                    {
                        enumerator = ActiveWebCams.Start(webCamInfo);
                        continue;
                    }
                    else
                    {
                        enumerator = fClient.ReceiveWebCam(user, webCamInfo);
                    }
                }
                catch
                {
                    continue;
                }

                if (enumerator == null)
                {
                    continue;
                }

                form = new FormWebCam(user, displayName, monikerName, enumerator);
                form.Show();
            }
        }
示例#4
0
 public IFastEnumerator <byte[]> GetWebCamEnumerator(WebCamInfo webCamInfo)
 {
     return(ActiveWebCams.GetWebCamEnumerator(webCamInfo));
 }