📄 cecamera.cs
字号:
// 没有足够的存储空间存储相片或者视频的异常.
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
catch (InvalidOperationException ex)
{
// 未知错误
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
}
private void menuModeStill_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.menuMode.MenuItems.Count; i++)
{
this.menuMode.MenuItems[i].Checked = false;
}
this.menuModeStill.Checked = true;
validateFileNameInput();
this.checkResolution.Enabled = true;
this.checkVideoTimeLimit.Checked = false;
this.checkVideoTimeLimit.Enabled = false;
}
private void menuModeVideoOnly_Click(object sender, System.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, System.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;
}
}
}
/// <summary>
/// Checks the selected menu item of "Still Quality".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuStillQualityDefault_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
{
this.menuStillQuality.MenuItems[i].Checked = false;
}
this.menuStillQualityDefault.Checked = true;
}
/// <summary>
/// Checks the selected menu item of "Still Quality".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuStillQualityLow_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
{
this.menuStillQuality.MenuItems[i].Checked = false;
}
this.menuStillQualityLow.Checked = true;
}
/// <summary>
/// Checks the selected menu item of "Still Quality".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuStillQualityNormal_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
{
this.menuStillQuality.MenuItems[i].Checked = false;
}
this.menuStillQualityNormal.Checked = true;
}
/// <summary>
/// Checks the selected menu item of "Still Quality".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuStillQualityHigh_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < this.menuStillQuality.MenuItems.Count; i++)
{
this.menuStillQuality.MenuItems[i].Checked = false;
}
this.menuStillQualityHigh.Checked = true;
}
/// <summary>
/// Checks the selected menu item of "Video Types".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
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;
}
/// <summary>
/// Checks the selected menu item of "Video Types".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
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;
}
/// <summary>
/// Checks the selected menu item of "Video Types".
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
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;
}
/// <summary>
/// Resets all settings as the default value and updates UI.
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuReset_Click(object sender, System.EventArgs e)
{
this.ResetOptions();
}
/// <summary>
/// Display a message box for program information.
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">Event arguments</param>
private void menuAbout_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Windows Mobile照相机捕获示例,汉化&注释:Eric.", this.Text);
}
private void menuExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
/// <summary>
/// 重新设置所有的设置为默认设置.
/// </summary>
private void ResetOptions()
{
// CheckBoxs 置为非选择状态
this.checkInitialDirectory.Checked = false;
this.checkDefaultFileName.Checked = false;
this.checkTitle.Checked = false;
this.checkResolution.Checked = false;
this.checkVideoTimeLimit.Checked = false;
this.checkVideoTimeLimit.Enabled = false;
// 默认设置
this.textInitialDirectory.Text = cecameraDefaultInitialDirectory;
this.textDefaultFileName.Text = cecameraDefaultPictureFileName;
this.textTitle.Text = cecameraDefaultTitle;
this.textResolutionWidth.Text = cecameraDefaultResolutionWidth;
this.textResolutionHeight.Text = cecameraDefaultResolutionHeight;
this.textVideoTimeLimit.Text = cecameraDefaultVideoTimeLimit;
// textbox设置为不可选状态
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>
/// string转换成integer.
/// </summary>
/// <param name="value">字符串变量</param>
/// <param name="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;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -