⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cecamera.cs

📁 绝对可用的PDA摄像头调用程序。并可以任意设置保存目录。
💻 CS
📖 第 1 页 / 共 2 页
字号:
            }
            this.menuModeStill.Checked = true;

            validateFileNameInput();

            this.checkResolution.Enabled = true;
            this.checkVideoTimeLimit.Checked = false;
            this.checkVideoTimeLimit.Enabled = false;
        }

        private void menuModeVideoOnly_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuMode.MenuItems.Count; i++)
            {
                this.menuMode.MenuItems[i].Checked = false;
            }
            this.menuModeVideoOnly.Checked = true;

            validateFileNameInput();

            this.checkResolution.Checked = false;
            this.checkResolution.Enabled = false;
            this.checkVideoTimeLimit.Enabled = true;
        }

        private void menuModeVideoWithAudio_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuMode.MenuItems.Count; i++)
            {
                this.menuMode.MenuItems[i].Checked = false;
            }
            this.menuModeVideoWithAudio.Checked = true;

            validateFileNameInput();

            this.checkResolution.Checked = false;
            this.checkResolution.Enabled = false;
            this.checkVideoTimeLimit.Enabled = true;     
        }

        /// <summary>
        /// Verifies the filename to be consistent with the camera mode.
        /// </summary>
        private void validateFileNameInput()
        {
            if (this.menuModeStill.Checked)
            {
                if (textDefaultFileName.Text == null || textDefaultFileName.Text.Length == 0 ||
                    textDefaultFileName.Text.Equals(cecameraDefaultVideoFileName))
                {
                    this.textDefaultFileName.Text = cecameraDefaultPictureFileName;
                }
            }
            else
            {
                if (textDefaultFileName.Text == null || textDefaultFileName.Text.Length == 0 ||
                    textDefaultFileName.Text.Equals(cecameraDefaultPictureFileName))
                {
                    textDefaultFileName.Text = cecameraDefaultVideoFileName;
                }
            }
        }

        private void menuStillQualityDefault_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
            {
                this.menuStillQuality.MenuItems[i].Checked = false;
            }
            this.menuStillQualityDefault.Checked = true;
        }

        private void menuStillQualityLow_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
            {
                this.menuStillQuality.MenuItems[i].Checked = false;
            }
            this.menuStillQualityLow.Checked = true;
        }

        private void menuStillQualityNormal_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
            {
                this.menuStillQuality.MenuItems[i].Checked = false;
            }
            this.menuStillQualityNormal.Checked = true;
        }

        private void menuStillQualityHigh_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
            {
                this.menuStillQuality.MenuItems[i].Checked = false;
            }
            this.menuStillQualityHigh.Checked = true;
        }

        private void menuVideoTypesAll_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuVideoTypes.MenuItems.Count; i++)
            {
                this.menuVideoTypes.MenuItems[i].Checked = false;
            }
            this.menuVideoTypesAll.Checked = true;
        }

        private void menuVideoTypesStandard_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.menuVideoTypes.MenuItems.Count; i++)
            {
                this.menuVideoTypes.MenuItems[i].Checked = false;
            }
            this.menuVideoTypesStandard.Checked = true;
        }

        private void menuVideoTypesMessaging_Click(object sender, EventArgs e)
        {
           for (int i = 0; i < this.menuVideoTypes.MenuItems.Count; i++)
            {
                this.menuVideoTypes.MenuItems[i].Checked = false;
            }
            this.menuVideoTypesMessaging.Checked = true;
        }

        private void menuReset_Click(object sender, EventArgs e)
        {
            this.ResetOptions();
        }

        private void menuAbout_Click(object sender, EventArgs e)
        {
            MessageBox.Show("CECamera Version 1.0\n\nSimple sample for CameraCaptureDialog.", this.Text);
        }

        private void menuExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// Resets all settings as the default value and updates UI.
        /// </summary>
        private void ResetOptions()
        {
            // Uncheck all checkboxs to specify the options using the default value
            this.checkInitialDirectory.Checked = false;
            this.checkDefaultFileName.Checked = false;
            this.checkTitle.Checked = false;
            this.checkResolution.Checked = false;
            this.checkVideoTimeLimit.Checked = false;
            this.checkVideoTimeLimit.Enabled = false;

            // Set the default value for the options
            this.textInitialDirectory.Text = cecameraDefaultInitialDirectory;
            this.textDefaultFileName.Text = cecameraDefaultPictureFileName;
            this.textTitle.Text = cecameraDefaultTitle;
            this.textResolutionWidth.Text = cecameraDefaultResolutionWidth;
            this.textResolutionHeight.Text = cecameraDefaultResolutionHeight;
            this.textVideoTimeLimit.Text = cecameraDefaultVideoTimeLimit;

            // Disable the edit controls since specify using default settings
            this.textInitialDirectory.Enabled = false;
            this.textDefaultFileName.Enabled = false;
            this.textTitle.Enabled = false;
            this.textResolutionWidth.Enabled = false;
            this.textResolutionHeight.Enabled = false;
            this.textVideoTimeLimit.Enabled = false;

            // Checks the menu item of "Mode" as default item
            for (int i = 0; i < this.menuMode.MenuItems.Count; i++)
            {
                this.menuMode.MenuItems[i].Checked = false;
            }
            this.menuModeStill.Checked = true;

            // Checks the menu item of "Still Quality" as default item
            for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
            {
                this.menuStillQuality.MenuItems[i].Checked = false;
            }
            this.menuStillQualityDefault.Checked = true;

            // Checks the menu item of "Video Types" as default item
            for (int i = 0; i < this.menuVideoTypes.MenuItems.Count; i++)
            {
                this.menuVideoTypes.MenuItems[i].Checked = false;
            }
            this.menuVideoTypesAll.Checked = true;
        }

        /// <summary>
        /// Converts the string to an integer.
        /// </summary>
        /// <param name="value">A string to convert</param>
        /// <param name="result">A integer of the converted result</param>
        /// <returns>true if converts successfully; otherwise, false.</returns>
        private static bool ConvertStringToInt(string value, ref int result)
        {
            try
            {
                result = Convert.ToInt32(value, NumberFormatInfo.CurrentInfo);
            }
            catch (FormatException)
            {
                return false;
            }
            catch (OverflowException)
            {
                return false;
            }

            return true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string title = this.Text;
            string assemblyFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            DirectoryInfo currentSelected = new DirectoryInfo(assemblyFolder);
            fm_folder_dialog fbd = new fm_folder_dialog();
            fbd.SelectedPath = currentSelected.FullName;
            fbd.Description = "选择保存文件目录";
            this.Text = String.Empty; // 隐藏窗体标题
            fbd.ShowDialog(); // 显示新的窗体
            if (fbd.DialogResult == DialogResult.Yes)
            {
                textInitialDirectory.Text = fbd.SelectedPath;
            }
            this.Text = title; // 恢复窗体标题
            fbd.Dispose();
           // textInitialDirectory.Text = currentSelected.FullName;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -