Commit 4cf4d563 by 陶然

init

parent e124ac10
......@@ -48,7 +48,6 @@
this.cbxResolution = new System.Windows.Forms.ComboBox();
this.btnSwitch = new System.Windows.Forms.Button();
this.plVsp = new System.Windows.Forms.Panel();
this.vspCamView = new Kivii.Sample.ImageUploader.Controls.VideoSourcePlayer();
this.plRight = new System.Windows.Forms.Panel();
this.gbPhotoList = new System.Windows.Forms.GroupBox();
this.flpPhotos = new System.Windows.Forms.FlowLayoutPanel();
......@@ -56,7 +55,7 @@
this.btnUpload = new System.Windows.Forms.Button();
this.plMain = new System.Windows.Forms.Panel();
this.gbPhotoView = new System.Windows.Forms.GroupBox();
this.ptbPhotoDisplay = new System.Windows.Forms.PictureBox();
this.panel1 = new System.Windows.Forms.Panel();
this.plDisplay = new System.Windows.Forms.Panel();
this.cbxTurn = new System.Windows.Forms.ComboBox();
this.btnEditor = new System.Windows.Forms.Button();
......@@ -66,6 +65,8 @@
this.btnShot = new System.Windows.Forms.Button();
this.btnCanon = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.picDisPlay = new Kivii.Sample.ImageUploader.Controls.PanelEx();
this.vspCamView = new Kivii.Sample.ImageUploader.Controls.VideoSourcePlayer();
this.plLeft.SuspendLayout();
this.gbSample.SuspendLayout();
this.plSearchReport.SuspendLayout();
......@@ -77,7 +78,7 @@
this.gbUploading.SuspendLayout();
this.plMain.SuspendLayout();
this.gbPhotoView.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ptbPhotoDisplay)).BeginInit();
this.panel1.SuspendLayout();
this.plDisplay.SuspendLayout();
this.gbOperating.SuspendLayout();
this.SuspendLayout();
......@@ -318,17 +319,6 @@
this.plVsp.Size = new System.Drawing.Size(370, 350);
this.plVsp.TabIndex = 0;
//
// vspCamView
//
this.vspCamView.Dock = System.Windows.Forms.DockStyle.Fill;
this.vspCamView.Location = new System.Drawing.Point(0, 0);
this.vspCamView.Margin = new System.Windows.Forms.Padding(4);
this.vspCamView.Name = "vspCamView";
this.vspCamView.Size = new System.Drawing.Size(370, 350);
this.vspCamView.TabIndex = 0;
this.vspCamView.Text = "vspCamView";
this.vspCamView.VideoSource = null;
//
// plRight
//
this.plRight.Controls.Add(this.gbPhotoList);
......@@ -360,6 +350,7 @@
this.flpPhotos.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.flpPhotos.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flpPhotos.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpPhotos.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.flpPhotos.Location = new System.Drawing.Point(4, 27);
this.flpPhotos.Margin = new System.Windows.Forms.Padding(0);
this.flpPhotos.Name = "flpPhotos";
......@@ -407,7 +398,7 @@
//
// gbPhotoView
//
this.gbPhotoView.Controls.Add(this.ptbPhotoDisplay);
this.gbPhotoView.Controls.Add(this.panel1);
this.gbPhotoView.Controls.Add(this.plDisplay);
this.gbPhotoView.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbPhotoView.Font = new System.Drawing.Font("宋体", 10F);
......@@ -420,17 +411,14 @@
this.gbPhotoView.TabStop = false;
this.gbPhotoView.Text = "选中照片";
//
// ptbPhotoDisplay
// panel1
//
this.ptbPhotoDisplay.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.ptbPhotoDisplay.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbPhotoDisplay.Location = new System.Drawing.Point(4, 27);
this.ptbPhotoDisplay.Margin = new System.Windows.Forms.Padding(4);
this.ptbPhotoDisplay.Name = "ptbPhotoDisplay";
this.ptbPhotoDisplay.Size = new System.Drawing.Size(804, 831);
this.ptbPhotoDisplay.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.ptbPhotoDisplay.TabIndex = 4;
this.ptbPhotoDisplay.TabStop = false;
this.panel1.Controls.Add(this.picDisPlay);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(4, 27);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(804, 831);
this.panel1.TabIndex = 4;
//
// plDisplay
//
......@@ -563,6 +551,28 @@
this.btnDelete.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// picDisPlay
//
this.picDisPlay.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.picDisPlay.Dock = System.Windows.Forms.DockStyle.Fill;
this.picDisPlay.EnableSelection = false;
this.picDisPlay.Location = new System.Drawing.Point(0, 0);
this.picDisPlay.Name = "picDisPlay";
this.picDisPlay.SelectionBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
this.picDisPlay.Size = new System.Drawing.Size(804, 831);
this.picDisPlay.TabIndex = 5;
//
// vspCamView
//
this.vspCamView.Dock = System.Windows.Forms.DockStyle.Fill;
this.vspCamView.Location = new System.Drawing.Point(0, 0);
this.vspCamView.Margin = new System.Windows.Forms.Padding(4);
this.vspCamView.Name = "vspCamView";
this.vspCamView.Size = new System.Drawing.Size(370, 350);
this.vspCamView.TabIndex = 0;
this.vspCamView.Text = "vspCamView";
this.vspCamView.VideoSource = null;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
......@@ -590,7 +600,7 @@
this.gbUploading.ResumeLayout(false);
this.plMain.ResumeLayout(false);
this.gbPhotoView.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.ptbPhotoDisplay)).EndInit();
this.panel1.ResumeLayout(false);
this.plDisplay.ResumeLayout(false);
this.plDisplay.PerformLayout();
this.gbOperating.ResumeLayout(false);
......@@ -628,7 +638,6 @@
private System.Windows.Forms.FlowLayoutPanel flpPhotos;
private System.Windows.Forms.Panel plSearchReport;
private System.Windows.Forms.RichTextBox rtbMessage;
private System.Windows.Forms.PictureBox ptbPhotoDisplay;
private System.Windows.Forms.Panel plDisplay;
private System.Windows.Forms.Label lbDisplay;
private System.Windows.Forms.Button btnCamearTurn;
......@@ -637,6 +646,8 @@
private System.Windows.Forms.Button btnShot;
private System.Windows.Forms.Button btnEditor;
private System.Windows.Forms.ComboBox cbxTurn;
private System.Windows.Forms.Panel panel1;
private Controls.PanelEx picDisPlay;
}
}
......@@ -23,11 +23,15 @@ using System.Windows.Forms;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;
using Kivii.Canon;
using Kivii.Controls;
using PictureBox = System.Windows.Forms.PictureBox;
using Image = System.Drawing.Image;
namespace Kivii.Sample.ImageUploader
{
public partial class FrmMain : Form
{
private float _zoom = 0f;
private JsonServiceClient _client = null;
private FilterInfoCollection videoDevices;
......@@ -38,11 +42,13 @@ namespace Kivii.Sample.ImageUploader
private List<DbFile> photos = new List<DbFile>();
private Report currentReport = null;
private DbFile currentPhoto = null;
private Rectangle Rectangle = new Rectangle(0, 0, 540, 960);
//private CanonForm canonForm = null;
public FrmMain()
{
InitializeComponent();
picDisPlay.SelectionBounds = Rectangle;
}
......@@ -142,7 +148,8 @@ namespace Kivii.Sample.ImageUploader
//lbCurrentBrand.Text = "__________";
//lbCurrentBatchNumber.Text = "__________";
//lbCurrentSampleQuantity.Text = "__________";
ptbPhotoDisplay.Image = null;
SetSelectionImage(null);
//picDisPlay.BackgroundImage = null;
flpPhotos.Controls.Clear();
currentReport = null;
currentPhoto = null;
......@@ -205,6 +212,47 @@ namespace Kivii.Sample.ImageUploader
addSnapshot(editedPhoto, index);
showSnapshot(editedPhoto);
}
private void resizePictureBox()
{
if (picDisPlay.BackgroundImage == null) return;
int width, height;
if (_zoom == 0f)
{
float wzoom = (float)picDisPlay.Width / (float)picDisPlay.BackgroundImage.Width;
float hzoom = (float)picDisPlay.Height / (float)picDisPlay.BackgroundImage.Height;
_zoom = wzoom < hzoom ? wzoom : hzoom;
}
else if (_zoom > 5f) _zoom = 5f;
else if (_zoom < 0.1f) _zoom = 0.1f;
width = (int)((float)picDisPlay.BackgroundImage.Width * _zoom);
height = (int)((float)picDisPlay.BackgroundImage.Height * _zoom);
picDisPlay.Width = width;
picDisPlay.Height = height;
var rect = new Rectangle(picDisPlay.SelectionBounds.X, picDisPlay.SelectionBounds.Y, (int)(Rectangle.Width * _zoom), (int)(Rectangle.Height * _zoom));
picDisPlay.SelectionBounds = rect;
int x=0, y=0;
//if (panel1.Width <= width) x = 0;
//else x = (panel1.Width - width) / 2;
//if (panel1.Height <= height) y = 0;
//else y = (panel1.Height - height) / 2;
picDisPlay.Location = new System.Drawing.Point(x, y);
}
public Image GetSelectionImage()
{
return picDisPlay.GetSelectionImage(_zoom);
}
public void SetSelectionImage(Image img)
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() => SetSelectionImage(img)));
return;
}
picDisPlay.BackgroundImage = img;
//resizePictureBox();
}
#endregion
#region 相机控件调用
......@@ -340,13 +388,15 @@ namespace Kivii.Sample.ImageUploader
try
{
//清空 ptbPhotoDisplay 中的图片
ptbPhotoDisplay.Image = null;
SetSelectionImage(null);
//picDisPlay.BackgroundImage = null;
lbDisplay.Text = "";
currentPhoto = null;
if (photo == null) return;
currentPhoto = photo;
var snapshot = photo.Image;
ptbPhotoDisplay.Image = snapshot;
SetSelectionImage(snapshot);
//picDisPlay.BackgroundImage = snapshot;
if (photo.Kvid != Guid.Empty) lbDisplay.Text = $"[已上传]{photo.Name}";
else lbDisplay.Text = photo.Name;
lbDisplay.TextAlign = ContentAlignment.MiddleCenter;
......@@ -357,7 +407,7 @@ namespace Kivii.Sample.ImageUploader
if (control is SplitContainer container)
{
container.BorderStyle = BorderStyle.None;
if (container.Panel1.Controls[0] is PictureBox pic && pic.Image == snapshot)
if (container.Panel1.Controls[0] is System.Windows.Forms.PictureBox pic && pic.Image == snapshot)
{
container.BorderStyle = BorderStyle.Fixed3D;
}
......@@ -370,6 +420,7 @@ namespace Kivii.Sample.ImageUploader
{
MessageBox.Show("无法正常显示照片," + ex.Message);
}
}
}
......@@ -650,6 +701,7 @@ namespace Kivii.Sample.ImageUploader
initCameras();
tbxPassword.Focus();
this.WindowState = FormWindowState.Maximized;
//picDisPlay.EnableSelection = true;
}
private void btnLogin_Click(object sender, EventArgs e)
......@@ -753,34 +805,6 @@ namespace Kivii.Sample.ImageUploader
}
picName += DateTime.Now.ToString("mmssfff");
var photo = new DbFile(bitmap, picName);
//if (chbRectify.Checked)
//{
// Bitmap temp = photo.Image.Clone() as Bitmap;
// var _counter = new BlobCounter();
// _counter.FilterBlobs = true;
// _counter.MinWidth = photo.Image.Width / 4;
// _counter.MinHeight = photo.Image.Height / 4;
// FiltersSequence seq = new FiltersSequence();
// seq.Add(Grayscale.CommonAlgorithms.BT709); //First add grayScaling filter
// seq.Add(new OtsuThreshold()); //Then add binarization(thresholding) filter
// temp = seq.Apply(temp);
// _counter.ProcessImage(temp);
// temp.Dispose();
// var blobs = _counter.GetObjectsInformation();
// if (blobs != null && blobs.Length > 0)
// {
// var corners = PointsCloud.FindQuadrilateralCorners(_counter.GetBlobsEdgePoints(blobs[0]));
// var rect = blobs[0].Rectangle;
// QuadrilateralTransformation quadTransformer = new QuadrilateralTransformation();
// quadTransformer.SourceQuadrilateral = corners; //Set corners for transforming card
// quadTransformer.AutomaticSizeCalculaton = true;
// photo.Image = quadTransformer.Apply(photo.Image);
// //ResizeBilinear resizer = new ResizeBilinear(rect.Width, rect.Height);
// }
//}
addSnapshot(photo);
Thread.Sleep(50);
showSnapshot(photo);
......@@ -794,6 +818,13 @@ namespace Kivii.Sample.ImageUploader
var index = cbxTurn.SelectedIndex;
if (index <= -1) index = 0;
ImageRotateFlip((RotateFlipType)index);
if (picDisPlay.EnableSelection)
{
resizePictureBox();
var editImage = new Bitmap(GetSelectionImage());
setBackgroundImage(editImage);
}
}
}
......@@ -819,7 +850,7 @@ namespace Kivii.Sample.ImageUploader
private void btnDelete_Click(object sender, EventArgs e)
{
Bitmap currentPhoto = (Bitmap)ptbPhotoDisplay.Image;
Bitmap currentPhoto = (Bitmap)picDisPlay.BackgroundImage;
if (currentPhoto == null) return;
var photo = photos.FirstOrDefault(o => o.Image == currentPhoto);
if (photo != null)
......
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