Commit 9153f31e by 陶然

添加默认旋转

parent 8e27b1a4
......@@ -64,6 +64,7 @@
this.btnCanon = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnEditor = new System.Windows.Forms.Button();
this.cbxTurn = new System.Windows.Forms.ComboBox();
this.vspCamView = new Kivii.Sample.ImageUploader.Controls.VideoSourcePlayer();
this.plLeft.SuspendLayout();
this.gbSample.SuspendLayout();
......@@ -422,6 +423,7 @@
//
// plDisplay
//
this.plDisplay.Controls.Add(this.cbxTurn);
this.plDisplay.Controls.Add(this.btnEditor);
this.plDisplay.Controls.Add(this.btnCamearTurn);
this.plDisplay.Controls.Add(this.lbDisplay);
......@@ -534,6 +536,23 @@
this.btnEditor.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnEditor.Click += new System.EventHandler(this.btnEditor_Click);
//
// cbxTurn
//
this.cbxTurn.Dock = System.Windows.Forms.DockStyle.Right;
this.cbxTurn.Font = new System.Drawing.Font("宋体", 16F);
this.cbxTurn.FormattingEnabled = true;
this.cbxTurn.Items.AddRange(new object[] {
"不旋转",
"顺时针90°",
"顺时针180°",
"顺时针270°"});
this.cbxTurn.Location = new System.Drawing.Point(347, 0);
this.cbxTurn.Margin = new System.Windows.Forms.Padding(4);
this.cbxTurn.Name = "cbxTurn";
this.cbxTurn.Size = new System.Drawing.Size(181, 41);
this.cbxTurn.TabIndex = 33;
this.cbxTurn.SelectedIndexChanged += new System.EventHandler(this.cbxTurn_SelectedIndexChanged);
//
// vspCamView
//
this.vspCamView.Dock = System.Windows.Forms.DockStyle.Fill;
......@@ -618,6 +637,7 @@
private System.Windows.Forms.Button btnCanon;
private System.Windows.Forms.Button btnShot;
private System.Windows.Forms.Button btnEditor;
private System.Windows.Forms.ComboBox cbxTurn;
}
}
......@@ -116,6 +116,7 @@ namespace Kivii.Sample.ImageUploader
tbxUserName.Enabled = notLogin;
tbxPassword.Enabled = notLogin;
cbxResolution.Enabled = !notLogin;
cbxTurn.Enabled = !notLogin;
btnSwitch.Enabled = !notLogin;
tbxReportId.Enabled = !notLogin;
btnReportId.Enabled = !notLogin;
......@@ -185,6 +186,25 @@ namespace Kivii.Sample.ImageUploader
//lbCurrentSampleQuantity.Text = currentReport.SampleQuantityUnit;
}
}
private void ImageRotateFlip(RotateFlipType flipType = RotateFlipType.RotateNoneFlipNone)
{
if (currentPhoto == null) return;
if (currentPhoto.Image == null) return;
int index = 0;
var photo = photos.FirstOrDefault(o => o.Image == currentPhoto.Image);
if (photo != null)
{
index = photos.IndexOf(photo);
if (index <= -1) index = 0;
deleteSnapshot(photo);
}
currentPhoto.Image.RotateFlip(flipType);
var editedPhoto = new DbFile(currentPhoto.Image, currentPhoto.Name);
addSnapshot(editedPhoto, index);
showSnapshot(editedPhoto);
}
#endregion
#region 相机控件调用
......@@ -626,7 +646,7 @@ namespace Kivii.Sample.ImageUploader
private void FrmMain_Load(object sender, EventArgs e)
{
initFormCtlEnable(true);
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword);
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword,cbxTurn);
initCameras();
tbxPassword.Focus();
this.WindowState = FormWindowState.Maximized;
......@@ -649,7 +669,7 @@ namespace Kivii.Sample.ImageUploader
task.Success(resp =>
{
initFormCtlEnable(false);
setDefault(tbxServiceUrl, tbxUserName, tbxPassword);
setDefault(tbxServiceUrl, tbxUserName, tbxPassword,cbxTurn);
if (videoDevice == null) initCameras();
if (videoDevice == null)
{
......@@ -769,6 +789,12 @@ namespace Kivii.Sample.ImageUploader
{
MessageBox.Show(ex.Message, "相机模组未初始化");
}
finally
{
var index = cbxTurn.SelectedIndex;
if (index <= -1) index = 0;
ImageRotateFlip((RotateFlipType)index);
}
}
else
......@@ -780,19 +806,7 @@ namespace Kivii.Sample.ImageUploader
{
if (currentPhoto == null) return;
if (currentPhoto.Image == null) return;
int index = 0;
var photo = photos.FirstOrDefault(o => o.Image == currentPhoto.Image);
if (photo != null)
{
index = photos.IndexOf(photo);
if (index <= -1) index = 0;
deleteSnapshot(photo);
}
currentPhoto.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
var editedPhoto = new DbFile(currentPhoto.Image, currentPhoto.Name);
addSnapshot(editedPhoto, index);
showSnapshot(editedPhoto);
ImageRotateFlip(RotateFlipType.Rotate90FlipNone);
}
private void PictureBox_Click(object sender, EventArgs e)
{
......@@ -1015,5 +1029,10 @@ namespace Kivii.Sample.ImageUploader
Thread.Sleep(50);
showSnapshot(photo);
}
private void cbxTurn_SelectedIndexChanged(object sender, EventArgs e)
{
setDefault(cbxTurn);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment