コード例 #1
0
        /// <summary>
        /// Updates the webcam list in the sub-context menu for webcam selection.
        /// </summary>
        /// <param name="selectWebcamMenu">The webcam sub-context menu to update.</param>
        private void UpdateWebcamList(ToolStripMenuItem selectWebcamMenu)
        {
            ToolStripItemCollection dropDownItems = selectWebcamMenu.DropDownItems;

            dropDownItems.Clear( );

            foreach (KeyValuePair <string, string> webcam in WebcamManager.GetWebcamList( ))
            {
                dropDownItems.Add(webcam.Value, null, (object sender, EventArgs handler) => WebcamManager.SelectWebcam(webcam.Key));
            }
        }
コード例 #2
0
        /// <summary>
        /// Selects the default or first webcam as the active webcam.
        /// </summary>
        private void SelectDefaultWebcam( )
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "default_webcam.txt";
            string webcamMoniker;

            if (File.Exists(path))
            {
                webcamMoniker = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "default_webcam.txt");
            }
            else
            {
                ReadOnlyDictionary <string, string> webcamDictionary = WebcamManager.GetWebcamList( );
                webcamMoniker = webcamDictionary.Any( ) ? WebcamManager.GetWebcamList( ).First( ).Key : null;
            }

            WebcamManager.RefreshWebcamList( );
            WebcamManager.SelectWebcam(webcamMoniker);
        }