Commit 5aade965 by Neo Turing

升级优化

parent 92ad8192
......@@ -9,5 +9,9 @@ namespace Kivii.Sample.ImageUploader
internal class Configs
{
public const string TableUiSetting = "ui_settings";
public const string RouteFilesUploadAndDownload = "/Storages";
public const string RouteReportRequest = "/Restful/Kivii.Lims.Entities.Report/Query";
}
}
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Sample.ImageUploader.Entities
{
internal class Report:EntityWithMetadata
{
public string ReportId { get; set; }
public string SupplierName { get; set; }
public string DemanderName { get; set; }
public string PayerName { get; set; }
#region 样品相关,和sample冗余
[ApiMember(Description = "样品Kvid")]
[IgnoreUpdate]
[Required]
public Guid SampleKvid { get; set; }
/// <summary>
/// 样品名称
/// </summary>
[ApiMember(Description = "样品名称")]
[StringLength(200), Required]
public string SampleName { get; set; }
/// <summary>
/// 样品名称
/// </summary>
[ApiMember(Description = "样品编号")]
//[SerialNumber]
[StringLength(50), Default("")]
public string SampleSerialNumber { get; set; }
/// <summary>
/// 样品批次号
/// </summary>
[ApiMember(Description = "样品批次号")]
[StringLength(200), Default("")]
public string SampleBatchNumber { get; set; }
/// <summary>
/// 样品品牌
/// </summary>
[ApiMember(Description = "样品品牌")]
[StringLength(200), Default("")]
public string SampleBrand { get; set; }
/// <summary>
/// 样品规格型号
/// </summary>
[ApiMember(Description = "样品规格型号")]
[StringLength(200), Default("")]
public string SampleModel { get; set; }
/// <summary>
/// 样品数量
/// </summary>
[ApiMember(Description = "样品数量")]
[DecimalLength(10, 2), Default(0)]
public decimal SampleQuantity { get; set; }
/// <summary>
/// 数量单位,老数据的样品数量和单位记到metadata中了
/// </summary>
[ApiMember(Description = "样品数量单位")]
[StringLength(50), Default("")]
public string SampleQuantityUnit { get; set; }
/// <summary>
/// 样品品级
/// </summary>
[ApiMember(Description = "样品品级")]
[StringLength(200), Default("")]
public string SampleGrade { get; set; }
/// <summary>
/// 安全类别
/// </summary>
[ApiMember(Description = "安全类别")]
[StringLength(200), Default("")]
public string SampleGradeSafety { get; set; }
/// <summary>
/// 功能等级
/// </summary>
[ApiMember(Description = "功能等级")]
[StringLength(200), Default("")]
public string SampleGradeFunction { get; set; }
[ApiMember(Description = "生产单位Kvid")]
[DefaultEmptyGuid]
public Guid SampleManufacturerKvid { get; set; }
[ApiMember(Description = "生产单位")]
[StringLength(100), Default("")]
public string SampleManufacturerName { get; set; }
[ApiMember(Description = "生产单位联系人Kvid")]
[DefaultEmptyGuid]
[IgnoreUpdate]
public Guid SampleManufacturerContactKvid { get; set; }
[ApiMember(Description = "生产单位联系人姓名")]
[StringLength(50), Default("")]
public string SampleManufacturerContactName { get; set; }
[ApiMember(Description = "生产单位联系人电话")]
[StringLength(50), Default("")]
//正则表达式验证:(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})
public string SampleManufacturerContactNumber { get; set; }
[ApiMember(Description = "生产单位地址")]
[StringLength(200), Default("")]
public string SampleManufacturerAddress { get; set; }
#endregion
#region 样品来源相关,和SampleSource冗余
[DefaultEmptyGuid]
public Guid SampleSourceKvid { get; set; }
/// <summary>
/// 样品来源编号,计划编号,快递号等
/// </summary>
[ApiMember(Description = "来源编号")]
[StringLength(200), Default("")]
public string SampleSourceBatchNumber { get; set; }
#endregion
#region 报告受理,编制,审核,签发人员信息
/// <summary>
/// 受理人Kvid
/// </summary>
[DefaultEmptyGuid]
public Guid OperatorKvid { get; set; }
/// <summary>
/// 受理人姓名,不一定是Creator(从第三方系统进来的报告)
/// </summary>
[ApiMember(Description = "受理人")]
[StringLength(20), Default("")]
public string OperatorName { get; set; }
/// <summary>
/// 主检人
/// </summary>
[ApiMember(Description = "主检人")]
[StringLength(50), Default("")]
public string ManagerName { get; set; }
/// <summary>
/// 主检人Kvid
/// </summary>
[DefaultEmptyGuid]
public Guid ManagerKvid { get; set; }
/// <summary>
/// 编制人Kvid
/// </summary>
[DefaultEmptyGuid]
public Guid PreparerKvid { get; set; }
/// <summary>
/// 编制人姓名
/// </summary>
[ApiMember(Description = "编制人")]
[StringLength(50), Default("")]
public string PreparerName { get; set; }
/// <summary>
/// 审核人Kvid
/// </summary>
[DefaultEmptyGuid]
public Guid ReviewerKvid { get; set; }
/// <summary>
/// 审核人姓名
/// </summary>
[ApiMember(Description = "审核人")]
[StringLength(50), Default("")]
public string ReviewerName { get; set; }
/// <summary>
/// 签发人Kvid
/// </summary>
[DefaultEmptyGuid]
public Guid IssuerKvid { get; set; }
/// <summary>
/// 签发人姓名
/// </summary>
[ApiMember(Description = "签发人")]
[StringLength(50), Default("")]
public string IssuerName { get; set; }
#endregion
}
}
......@@ -57,7 +57,7 @@
this.plVsp = new System.Windows.Forms.Panel();
this.plRight = new System.Windows.Forms.Panel();
this.gbPhotoList = new System.Windows.Forms.GroupBox();
this.flpPhotosTaken = new System.Windows.Forms.FlowLayoutPanel();
this.flpPhotos = new System.Windows.Forms.FlowLayoutPanel();
this.gbUploading = new System.Windows.Forms.GroupBox();
this.btnUpload = new System.Windows.Forms.Button();
this.ckbCompress = new System.Windows.Forms.CheckBox();
......@@ -89,9 +89,8 @@
this.plLeft.Controls.Add(this.gbCamView);
this.plLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.plLeft.Location = new System.Drawing.Point(0, 0);
this.plLeft.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.plLeft.Name = "plLeft";
this.plLeft.Size = new System.Drawing.Size(430, 1022);
this.plLeft.Size = new System.Drawing.Size(287, 681);
this.plLeft.TabIndex = 0;
//
// gbSample
......@@ -109,11 +108,9 @@
this.gbSample.Controls.Add(this.btnReportId);
this.gbSample.Controls.Add(this.tbxReportId);
this.gbSample.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbSample.Location = new System.Drawing.Point(0, 430);
this.gbSample.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbSample.Location = new System.Drawing.Point(0, 287);
this.gbSample.Name = "gbSample";
this.gbSample.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbSample.Size = new System.Drawing.Size(430, 274);
this.gbSample.Size = new System.Drawing.Size(287, 182);
this.gbSample.TabIndex = 3;
this.gbSample.TabStop = false;
this.gbSample.Text = "查询样品";
......@@ -122,10 +119,9 @@
//
this.lbCurrentSampleQuantity.AutoSize = true;
this.lbCurrentSampleQuantity.Font = new System.Drawing.Font("宋体", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbCurrentSampleQuantity.Location = new System.Drawing.Point(84, 236);
this.lbCurrentSampleQuantity.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbCurrentSampleQuantity.Location = new System.Drawing.Point(56, 157);
this.lbCurrentSampleQuantity.Name = "lbCurrentSampleQuantity";
this.lbCurrentSampleQuantity.Size = new System.Drawing.Size(140, 24);
this.lbCurrentSampleQuantity.Size = new System.Drawing.Size(97, 16);
this.lbCurrentSampleQuantity.TabIndex = 18;
this.lbCurrentSampleQuantity.Text = "__________";
//
......@@ -133,10 +129,9 @@
//
this.lbSampleQuantity.AutoSize = true;
this.lbSampleQuantity.Font = new System.Drawing.Font("宋体", 9F);
this.lbSampleQuantity.Location = new System.Drawing.Point(4, 242);
this.lbSampleQuantity.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSampleQuantity.Location = new System.Drawing.Point(3, 161);
this.lbSampleQuantity.Name = "lbSampleQuantity";
this.lbSampleQuantity.Size = new System.Drawing.Size(89, 18);
this.lbSampleQuantity.Size = new System.Drawing.Size(59, 12);
this.lbSampleQuantity.TabIndex = 17;
this.lbSampleQuantity.Text = "样品数量:";
//
......@@ -144,10 +139,9 @@
//
this.lbCurrentBrand.AutoSize = true;
this.lbCurrentBrand.Font = new System.Drawing.Font("宋体", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbCurrentBrand.Location = new System.Drawing.Point(84, 198);
this.lbCurrentBrand.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbCurrentBrand.Location = new System.Drawing.Point(56, 132);
this.lbCurrentBrand.Name = "lbCurrentBrand";
this.lbCurrentBrand.Size = new System.Drawing.Size(140, 24);
this.lbCurrentBrand.Size = new System.Drawing.Size(97, 16);
this.lbCurrentBrand.TabIndex = 16;
this.lbCurrentBrand.Text = "__________";
//
......@@ -155,10 +149,9 @@
//
this.lbBrand.AutoSize = true;
this.lbBrand.Font = new System.Drawing.Font("宋体", 9F);
this.lbBrand.Location = new System.Drawing.Point(4, 204);
this.lbBrand.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbBrand.Location = new System.Drawing.Point(3, 136);
this.lbBrand.Name = "lbBrand";
this.lbBrand.Size = new System.Drawing.Size(71, 18);
this.lbBrand.Size = new System.Drawing.Size(47, 12);
this.lbBrand.TabIndex = 15;
this.lbBrand.Text = "商 标:";
//
......@@ -166,10 +159,9 @@
//
this.lbCurrentBatchNumber.AutoSize = true;
this.lbCurrentBatchNumber.Font = new System.Drawing.Font("宋体", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbCurrentBatchNumber.Location = new System.Drawing.Point(84, 162);
this.lbCurrentBatchNumber.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbCurrentBatchNumber.Location = new System.Drawing.Point(56, 108);
this.lbCurrentBatchNumber.Name = "lbCurrentBatchNumber";
this.lbCurrentBatchNumber.Size = new System.Drawing.Size(140, 24);
this.lbCurrentBatchNumber.Size = new System.Drawing.Size(97, 16);
this.lbCurrentBatchNumber.TabIndex = 14;
this.lbCurrentBatchNumber.Text = "__________";
//
......@@ -177,10 +169,9 @@
//
this.lbBatchNumber.AutoSize = true;
this.lbBatchNumber.Font = new System.Drawing.Font("宋体", 9F);
this.lbBatchNumber.Location = new System.Drawing.Point(4, 168);
this.lbBatchNumber.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbBatchNumber.Location = new System.Drawing.Point(3, 112);
this.lbBatchNumber.Name = "lbBatchNumber";
this.lbBatchNumber.Size = new System.Drawing.Size(89, 18);
this.lbBatchNumber.Size = new System.Drawing.Size(59, 12);
this.lbBatchNumber.TabIndex = 13;
this.lbBatchNumber.Text = "批号货号:";
//
......@@ -188,10 +179,9 @@
//
this.lbCurrentSampleName.AutoSize = true;
this.lbCurrentSampleName.Font = new System.Drawing.Font("宋体", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbCurrentSampleName.Location = new System.Drawing.Point(84, 123);
this.lbCurrentSampleName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbCurrentSampleName.Location = new System.Drawing.Point(56, 82);
this.lbCurrentSampleName.Name = "lbCurrentSampleName";
this.lbCurrentSampleName.Size = new System.Drawing.Size(140, 24);
this.lbCurrentSampleName.Size = new System.Drawing.Size(97, 16);
this.lbCurrentSampleName.TabIndex = 12;
this.lbCurrentSampleName.Text = "__________";
//
......@@ -199,10 +189,9 @@
//
this.lbSampleName.AutoSize = true;
this.lbSampleName.Font = new System.Drawing.Font("宋体", 9F);
this.lbSampleName.Location = new System.Drawing.Point(4, 129);
this.lbSampleName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSampleName.Location = new System.Drawing.Point(3, 86);
this.lbSampleName.Name = "lbSampleName";
this.lbSampleName.Size = new System.Drawing.Size(89, 18);
this.lbSampleName.Size = new System.Drawing.Size(59, 12);
this.lbSampleName.TabIndex = 11;
this.lbSampleName.Text = "样品名称:";
//
......@@ -210,10 +199,9 @@
//
this.lbCurrentReportId.AutoSize = true;
this.lbCurrentReportId.Font = new System.Drawing.Font("宋体", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbCurrentReportId.Location = new System.Drawing.Point(84, 87);
this.lbCurrentReportId.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbCurrentReportId.Location = new System.Drawing.Point(56, 58);
this.lbCurrentReportId.Name = "lbCurrentReportId";
this.lbCurrentReportId.Size = new System.Drawing.Size(140, 24);
this.lbCurrentReportId.Size = new System.Drawing.Size(97, 16);
this.lbCurrentReportId.TabIndex = 10;
this.lbCurrentReportId.Text = "__________";
//
......@@ -221,10 +209,9 @@
//
this.lbReportId.AutoSize = true;
this.lbReportId.Font = new System.Drawing.Font("宋体", 9F);
this.lbReportId.Location = new System.Drawing.Point(4, 93);
this.lbReportId.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbReportId.Location = new System.Drawing.Point(3, 62);
this.lbReportId.Name = "lbReportId";
this.lbReportId.Size = new System.Drawing.Size(71, 18);
this.lbReportId.Size = new System.Drawing.Size(47, 12);
this.lbReportId.TabIndex = 9;
this.lbReportId.Text = "报告号:";
//
......@@ -232,23 +219,23 @@
//
this.btnReportId.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnReportId.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnReportId.Location = new System.Drawing.Point(302, 32);
this.btnReportId.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnReportId.Location = new System.Drawing.Point(201, 21);
this.btnReportId.Name = "btnReportId";
this.btnReportId.Size = new System.Drawing.Size(124, 52);
this.btnReportId.Size = new System.Drawing.Size(83, 35);
this.btnReportId.TabIndex = 8;
this.btnReportId.Text = "查询报告";
this.btnReportId.UseVisualStyleBackColor = false;
this.btnReportId.Click += new System.EventHandler(this.btnReportId_Click);
//
// tbxReportId
//
this.tbxReportId.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbxReportId.Location = new System.Drawing.Point(4, 30);
this.tbxReportId.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbxReportId.Location = new System.Drawing.Point(3, 20);
this.tbxReportId.Multiline = true;
this.tbxReportId.Name = "tbxReportId";
this.tbxReportId.Size = new System.Drawing.Size(288, 50);
this.tbxReportId.Size = new System.Drawing.Size(193, 35);
this.tbxReportId.TabIndex = 7;
this.tbxReportId.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbxReportId_KeyPress);
//
// gbLogin
//
......@@ -261,11 +248,9 @@
this.gbLogin.Controls.Add(this.tbxServiceUrl);
this.gbLogin.Controls.Add(this.lblUrl);
this.gbLogin.Dock = System.Windows.Forms.DockStyle.Bottom;
this.gbLogin.Location = new System.Drawing.Point(0, 704);
this.gbLogin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbLogin.Location = new System.Drawing.Point(0, 469);
this.gbLogin.Name = "gbLogin";
this.gbLogin.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbLogin.Size = new System.Drawing.Size(430, 318);
this.gbLogin.Size = new System.Drawing.Size(287, 212);
this.gbLogin.TabIndex = 2;
this.gbLogin.TabStop = false;
this.gbLogin.Text = "系统登录";
......@@ -275,10 +260,9 @@
this.btnLogout.BackColor = System.Drawing.Color.LavenderBlush;
this.btnLogout.Font = new System.Drawing.Font("宋体", 15F);
this.btnLogout.ForeColor = System.Drawing.Color.Crimson;
this.btnLogout.Location = new System.Drawing.Point(285, 249);
this.btnLogout.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnLogout.Location = new System.Drawing.Point(190, 166);
this.btnLogout.Name = "btnLogout";
this.btnLogout.Size = new System.Drawing.Size(136, 60);
this.btnLogout.Size = new System.Drawing.Size(91, 40);
this.btnLogout.TabIndex = 31;
this.btnLogout.Text = "退 出";
this.btnLogout.UseVisualStyleBackColor = false;
......@@ -289,10 +273,9 @@
this.btnLogin.BackColor = System.Drawing.Color.MintCream;
this.btnLogin.Font = new System.Drawing.Font("宋体", 15F);
this.btnLogin.ForeColor = System.Drawing.Color.DarkGreen;
this.btnLogin.Location = new System.Drawing.Point(8, 249);
this.btnLogin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnLogin.Location = new System.Drawing.Point(5, 166);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(268, 60);
this.btnLogin.Size = new System.Drawing.Size(179, 40);
this.btnLogin.TabIndex = 30;
this.btnLogin.Text = "登 录";
this.btnLogin.UseVisualStyleBackColor = false;
......@@ -301,41 +284,38 @@
// tbxPassword
//
this.tbxPassword.Font = new System.Drawing.Font("宋体", 12F);
this.tbxPassword.Location = new System.Drawing.Point(4, 198);
this.tbxPassword.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbxPassword.Location = new System.Drawing.Point(3, 132);
this.tbxPassword.Name = "tbxPassword";
this.tbxPassword.PasswordChar = '*';
this.tbxPassword.Size = new System.Drawing.Size(415, 35);
this.tbxPassword.Size = new System.Drawing.Size(278, 26);
this.tbxPassword.TabIndex = 29;
this.tbxPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbxPassword_KeyPress);
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Font = new System.Drawing.Font("宋体", 12F);
this.lblPassword.Location = new System.Drawing.Point(3, 170);
this.lblPassword.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblPassword.Location = new System.Drawing.Point(2, 113);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(94, 24);
this.lblPassword.Size = new System.Drawing.Size(63, 16);
this.lblPassword.TabIndex = 28;
this.lblPassword.Text = "密 码:";
//
// tbxUserName
//
this.tbxUserName.Font = new System.Drawing.Font("宋体", 12F);
this.tbxUserName.Location = new System.Drawing.Point(4, 126);
this.tbxUserName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbxUserName.Location = new System.Drawing.Point(3, 84);
this.tbxUserName.Name = "tbxUserName";
this.tbxUserName.Size = new System.Drawing.Size(415, 35);
this.tbxUserName.Size = new System.Drawing.Size(278, 26);
this.tbxUserName.TabIndex = 27;
//
// lblUser
//
this.lblUser.AutoSize = true;
this.lblUser.Font = new System.Drawing.Font("宋体", 12F);
this.lblUser.Location = new System.Drawing.Point(3, 98);
this.lblUser.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblUser.Location = new System.Drawing.Point(2, 65);
this.lblUser.Name = "lblUser";
this.lblUser.Size = new System.Drawing.Size(94, 24);
this.lblUser.Size = new System.Drawing.Size(63, 16);
this.lblUser.TabIndex = 26;
this.lblUser.Text = "用户名:";
//
......@@ -343,20 +323,18 @@
//
this.tbxServiceUrl.BackColor = System.Drawing.SystemColors.Window;
this.tbxServiceUrl.Font = new System.Drawing.Font("宋体", 12F);
this.tbxServiceUrl.Location = new System.Drawing.Point(4, 54);
this.tbxServiceUrl.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tbxServiceUrl.Location = new System.Drawing.Point(3, 36);
this.tbxServiceUrl.Name = "tbxServiceUrl";
this.tbxServiceUrl.Size = new System.Drawing.Size(415, 35);
this.tbxServiceUrl.Size = new System.Drawing.Size(278, 26);
this.tbxServiceUrl.TabIndex = 25;
//
// lblUrl
//
this.lblUrl.AutoSize = true;
this.lblUrl.Font = new System.Drawing.Font("宋体", 12F);
this.lblUrl.Location = new System.Drawing.Point(3, 26);
this.lblUrl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblUrl.Location = new System.Drawing.Point(2, 17);
this.lblUrl.Name = "lblUrl";
this.lblUrl.Size = new System.Drawing.Size(94, 24);
this.lblUrl.Size = new System.Drawing.Size(63, 16);
this.lblUrl.TabIndex = 22;
this.lblUrl.Text = "地 址:";
//
......@@ -368,10 +346,8 @@
this.gbCamView.Dock = System.Windows.Forms.DockStyle.Top;
this.gbCamView.Font = new System.Drawing.Font("宋体", 10F);
this.gbCamView.Location = new System.Drawing.Point(0, 0);
this.gbCamView.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbCamView.Name = "gbCamView";
this.gbCamView.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbCamView.Size = new System.Drawing.Size(430, 430);
this.gbCamView.Size = new System.Drawing.Size(287, 287);
this.gbCamView.TabIndex = 0;
this.gbCamView.TabStop = false;
this.gbCamView.Text = "相机视图";
......@@ -380,10 +356,9 @@
//
this.btnSwitch.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnSwitch.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSwitch.Location = new System.Drawing.Point(302, 369);
this.btnSwitch.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnSwitch.Location = new System.Drawing.Point(201, 246);
this.btnSwitch.Name = "btnSwitch";
this.btnSwitch.Size = new System.Drawing.Size(124, 52);
this.btnSwitch.Size = new System.Drawing.Size(83, 35);
this.btnSwitch.TabIndex = 4;
this.btnSwitch.Text = "切换相机";
this.btnSwitch.UseVisualStyleBackColor = false;
......@@ -393,10 +368,9 @@
//
this.cbxResolution.Font = new System.Drawing.Font("宋体", 20F);
this.cbxResolution.FormattingEnabled = true;
this.cbxResolution.Location = new System.Drawing.Point(4, 369);
this.cbxResolution.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.cbxResolution.Location = new System.Drawing.Point(3, 246);
this.cbxResolution.Name = "cbxResolution";
this.cbxResolution.Size = new System.Drawing.Size(288, 48);
this.cbxResolution.Size = new System.Drawing.Size(193, 35);
this.cbxResolution.TabIndex = 1;
this.cbxResolution.SelectedIndexChanged += new System.EventHandler(this.cbxResolution_SelectedIndexChanged);
//
......@@ -404,10 +378,9 @@
//
this.plVsp.Controls.Add(this.vspCamView);
this.plVsp.Dock = System.Windows.Forms.DockStyle.Top;
this.plVsp.Location = new System.Drawing.Point(4, 27);
this.plVsp.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.plVsp.Location = new System.Drawing.Point(3, 19);
this.plVsp.Name = "plVsp";
this.plVsp.Size = new System.Drawing.Size(422, 334);
this.plVsp.Size = new System.Drawing.Size(281, 223);
this.plVsp.TabIndex = 0;
//
// plRight
......@@ -415,48 +388,43 @@
this.plRight.Controls.Add(this.gbPhotoList);
this.plRight.Controls.Add(this.gbUploading);
this.plRight.Dock = System.Windows.Forms.DockStyle.Right;
this.plRight.Location = new System.Drawing.Point(1066, 0);
this.plRight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.plRight.Location = new System.Drawing.Point(711, 0);
this.plRight.Name = "plRight";
this.plRight.Size = new System.Drawing.Size(350, 1022);
this.plRight.Size = new System.Drawing.Size(233, 681);
this.plRight.TabIndex = 1;
//
// gbPhotoList
//
this.gbPhotoList.Controls.Add(this.flpPhotosTaken);
this.gbPhotoList.Controls.Add(this.flpPhotos);
this.gbPhotoList.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbPhotoList.Font = new System.Drawing.Font("宋体", 10F);
this.gbPhotoList.Location = new System.Drawing.Point(0, 0);
this.gbPhotoList.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbPhotoList.Name = "gbPhotoList";
this.gbPhotoList.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbPhotoList.Size = new System.Drawing.Size(350, 874);
this.gbPhotoList.Size = new System.Drawing.Size(233, 582);
this.gbPhotoList.TabIndex = 2;
this.gbPhotoList.TabStop = false;
this.gbPhotoList.Text = "已拍照片";
//
// flpPhotosTaken
// flpPhotos
//
this.flpPhotosTaken.AutoScroll = true;
this.flpPhotosTaken.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.flpPhotosTaken.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flpPhotosTaken.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpPhotosTaken.Location = new System.Drawing.Point(4, 27);
this.flpPhotosTaken.Margin = new System.Windows.Forms.Padding(0);
this.flpPhotosTaken.Name = "flpPhotosTaken";
this.flpPhotosTaken.Size = new System.Drawing.Size(342, 843);
this.flpPhotosTaken.TabIndex = 2;
this.flpPhotos.AutoScroll = true;
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.Location = new System.Drawing.Point(3, 19);
this.flpPhotos.Margin = new System.Windows.Forms.Padding(0);
this.flpPhotos.Name = "flpPhotos";
this.flpPhotos.Size = new System.Drawing.Size(227, 560);
this.flpPhotos.TabIndex = 2;
//
// gbUploading
//
this.gbUploading.Controls.Add(this.btnUpload);
this.gbUploading.Controls.Add(this.ckbCompress);
this.gbUploading.Dock = System.Windows.Forms.DockStyle.Bottom;
this.gbUploading.Location = new System.Drawing.Point(0, 874);
this.gbUploading.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbUploading.Location = new System.Drawing.Point(0, 582);
this.gbUploading.Name = "gbUploading";
this.gbUploading.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbUploading.Size = new System.Drawing.Size(350, 148);
this.gbUploading.Size = new System.Drawing.Size(233, 99);
this.gbUploading.TabIndex = 1;
this.gbUploading.TabStop = false;
this.gbUploading.Text = "操作台";
......@@ -465,23 +433,22 @@
//
this.btnUpload.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnUpload.Font = new System.Drawing.Font("宋体", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUpload.Location = new System.Drawing.Point(81, 63);
this.btnUpload.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnUpload.Location = new System.Drawing.Point(54, 42);
this.btnUpload.Name = "btnUpload";
this.btnUpload.Size = new System.Drawing.Size(172, 74);
this.btnUpload.Size = new System.Drawing.Size(115, 49);
this.btnUpload.TabIndex = 3;
this.btnUpload.Text = "上传";
this.btnUpload.UseVisualStyleBackColor = false;
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
//
// ckbCompress
//
this.ckbCompress.AutoSize = true;
this.ckbCompress.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ckbCompress.Location = new System.Drawing.Point(81, 12);
this.ckbCompress.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ckbCompress.Location = new System.Drawing.Point(54, 8);
this.ckbCompress.Name = "ckbCompress";
this.ckbCompress.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.ckbCompress.Size = new System.Drawing.Size(185, 40);
this.ckbCompress.Size = new System.Drawing.Size(125, 28);
this.ckbCompress.TabIndex = 2;
this.ckbCompress.Text = "图片压缩";
this.ckbCompress.UseVisualStyleBackColor = true;
......@@ -491,10 +458,9 @@
this.plMain.Controls.Add(this.gbPhotoView);
this.plMain.Controls.Add(this.gbOperating);
this.plMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.plMain.Location = new System.Drawing.Point(430, 0);
this.plMain.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.plMain.Location = new System.Drawing.Point(287, 0);
this.plMain.Name = "plMain";
this.plMain.Size = new System.Drawing.Size(636, 1022);
this.plMain.Size = new System.Drawing.Size(424, 681);
this.plMain.TabIndex = 2;
//
// gbPhotoView
......@@ -503,10 +469,8 @@
this.gbPhotoView.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbPhotoView.Font = new System.Drawing.Font("宋体", 10F);
this.gbPhotoView.Location = new System.Drawing.Point(0, 0);
this.gbPhotoView.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbPhotoView.Name = "gbPhotoView";
this.gbPhotoView.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbPhotoView.Size = new System.Drawing.Size(636, 874);
this.gbPhotoView.Size = new System.Drawing.Size(424, 582);
this.gbPhotoView.TabIndex = 1;
this.gbPhotoView.TabStop = false;
this.gbPhotoView.Text = "选中照片";
......@@ -515,10 +479,9 @@
//
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, 4, 4, 4);
this.ptbPhotoDisplay.Location = new System.Drawing.Point(3, 19);
this.ptbPhotoDisplay.Name = "ptbPhotoDisplay";
this.ptbPhotoDisplay.Size = new System.Drawing.Size(628, 843);
this.ptbPhotoDisplay.Size = new System.Drawing.Size(418, 560);
this.ptbPhotoDisplay.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.ptbPhotoDisplay.TabIndex = 2;
this.ptbPhotoDisplay.TabStop = false;
......@@ -528,11 +491,9 @@
this.gbOperating.Controls.Add(this.btnDelete);
this.gbOperating.Controls.Add(this.btnShot);
this.gbOperating.Dock = System.Windows.Forms.DockStyle.Bottom;
this.gbOperating.Location = new System.Drawing.Point(0, 874);
this.gbOperating.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbOperating.Location = new System.Drawing.Point(0, 582);
this.gbOperating.Name = "gbOperating";
this.gbOperating.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gbOperating.Size = new System.Drawing.Size(636, 148);
this.gbOperating.Size = new System.Drawing.Size(424, 99);
this.gbOperating.TabIndex = 0;
this.gbOperating.TabStop = false;
this.gbOperating.Text = "操作台";
......@@ -543,13 +504,13 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.btnDelete.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnDelete.Font = new System.Drawing.Font("宋体", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnDelete.Location = new System.Drawing.Point(404, 42);
this.btnDelete.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnDelete.Location = new System.Drawing.Point(269, 28);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(207, 98);
this.btnDelete.Size = new System.Drawing.Size(138, 65);
this.btnDelete.TabIndex = 2;
this.btnDelete.Text = "删除";
this.btnDelete.UseVisualStyleBackColor = false;
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnShot
//
......@@ -557,10 +518,9 @@
this.btnShot.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnShot.Font = new System.Drawing.Font("宋体", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnShot.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.btnShot.Location = new System.Drawing.Point(36, 42);
this.btnShot.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnShot.Location = new System.Drawing.Point(24, 28);
this.btnShot.Name = "btnShot";
this.btnShot.Size = new System.Drawing.Size(207, 98);
this.btnShot.Size = new System.Drawing.Size(138, 65);
this.btnShot.TabIndex = 1;
this.btnShot.Text = "拍照";
this.btnShot.UseVisualStyleBackColor = false;
......@@ -570,22 +530,20 @@
//
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(422, 334);
this.vspCamView.Size = new System.Drawing.Size(281, 223);
this.vspCamView.TabIndex = 0;
this.vspCamView.Text = "vspCamView";
this.vspCamView.VideoSource = null;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1416, 1022);
this.ClientSize = new System.Drawing.Size(944, 681);
this.Controls.Add(this.plMain);
this.Controls.Add(this.plRight);
this.Controls.Add(this.plLeft);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "FrmMain";
this.Text = "样品拍照采集";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
......@@ -649,7 +607,7 @@
private System.Windows.Forms.CheckBox ckbCompress;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnShot;
private System.Windows.Forms.FlowLayoutPanel flpPhotosTaken;
private System.Windows.Forms.FlowLayoutPanel flpPhotos;
private System.Windows.Forms.PictureBox ptbPhotoDisplay;
}
}
......
......@@ -3,16 +3,19 @@ using Kivii.Messaging;
using Kivii.Sample.ImageUploader.Entities;
using Kivii.Video;
using Kivii.Video.DirectShow;
using Kivii.Web;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace Kivii.Sample.ImageUploader
{
......@@ -26,6 +29,8 @@ namespace Kivii.Sample.ImageUploader
private int currentCameraIndex = 0;
private int cameraQuantity = 0;//相机数量
private List<Photo> photos = new List<Photo>();
private Report currentReport = null;
public FrmMain()
{
......@@ -88,11 +93,11 @@ namespace Kivii.Sample.ImageUploader
btnReportId.Enabled = !notLogin;
btnShot.Enabled = !notLogin;
btnDelete.Enabled = !notLogin;
btnUpload.Enabled = !notLogin;
btnLogout.Enabled = !notLogin;
if (notLogin)
{
btnUpload.Enabled = !notLogin;
cbxResolution.SelectedIndex = -1;
//cbxResolution.Items.Clear();
currentCameraIndex = 0;
......@@ -105,7 +110,35 @@ namespace Kivii.Sample.ImageUploader
lbCurrentBatchNumber.Text = "__________";
lbCurrentSampleQuantity.Text = "__________";
ptbPhotoDisplay.Image = null;
flpPhotosTaken.Controls.Clear();
flpPhotos.Controls.Clear();
}
else
{
tbxReportId.Focus();
}
}
private void showCurrentReport()
{
if (currentReport == null)
{
btnUpload.Enabled = false;
tbxReportId.Text = string.Empty;
lbCurrentReportId.Text = "__________";
lbCurrentSampleName.Text = "__________";
lbCurrentBrand.Text = "__________";
lbCurrentBatchNumber.Text = "__________";
lbCurrentSampleQuantity.Text = "__________";
}
else
{
btnUpload.Enabled = true;
tbxReportId.Text = string.Empty;
lbCurrentReportId.Text = currentReport.ReportId;
lbCurrentSampleName.Text = currentReport.SampleName;
lbCurrentBrand.Text = currentReport.SampleBrand;
lbCurrentBatchNumber.Text = currentReport.SampleBatchNumber;
lbCurrentSampleQuantity.Text = currentReport.SampleQuantityUnit;
}
}
#endregion
......@@ -138,9 +171,15 @@ namespace Kivii.Sample.ImageUploader
private void switchCamera()
{
if (videoDevice == null) initCameras();
if (videoDevice == null)
{
MessageBox.Show("没有找到视频采集设备");
return;
}
if (videoDevice.IsRunning)
{
Disconnect();
disconnect();
}
if (currentCameraIndex + 1 > cameraQuantity - 1) currentCameraIndex = 0;
else currentCameraIndex = currentCameraIndex + 1;
......@@ -184,7 +223,7 @@ namespace Kivii.Sample.ImageUploader
}
}
private void Connect(int selectedIndex = 0)
private void connect(int selectedIndex = 0)
{
if (videoDevice == null) return;
if ((videoCapabilities != null) && (videoCapabilities.Length != 0))
......@@ -193,9 +232,10 @@ namespace Kivii.Sample.ImageUploader
}
vspCamView.VideoSource = videoDevice;
vspCamView.Start();
tbxReportId.Focus();
}
private void Disconnect()
private void disconnect()
{
if (vspCamView.VideoSource != null)
{
......@@ -204,6 +244,175 @@ namespace Kivii.Sample.ImageUploader
vspCamView.VideoSource = null;
}
}
private void showSnapshot(Photo photo)
{
if (InvokeRequired)
{
Invoke(new Action<Photo>(showSnapshot), photo);
}
else
{
try
{
//清空 ptbPhotoDisplay 中的图片
ptbPhotoDisplay.Image = null;
if (photo == null) return;
var snapshot = photo.Image;
ptbPhotoDisplay.Image = snapshot;
// 遍历 flpPhotosTaken 中的控件,将之前选中的 SplitContainer 边框改为默认
foreach (Control control in flpPhotos.Controls)
{
if (control is SplitContainer container)
{
container.BorderStyle = BorderStyle.None;
if (container.Panel1.Controls[0] is PictureBox pic && pic.Image == snapshot)
{
container.BorderStyle = BorderStyle.FixedSingle;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("无法正常显示照片," + ex.Message);
}
}
}
private void addSnapshot(Photo photo)
{
if (InvokeRequired)
{
Invoke(new Action<Photo>(addSnapshot), photo);
}
else
{
if (photo == null) return;
var snapshot = photo.Image;
// 创建图片 PictureBox 控件
var pic = new PictureBox();
pic.SizeMode = PictureBoxSizeMode.Zoom;
pic.Dock = DockStyle.Fill;
pic.Image = snapshot;
// 添加图片点击动作
pic.Click += PictureBox_Click;
// 创建图片名称的 Label 控件
Label lbName = new Label();
string name = string.Empty;
name = photo.Name.IsNullOrEmpty() ? photo.Name = DateTime.Now.ToString("mmssfff") : photo.Name;
lbName.Text = name;
lbName.Dock = DockStyle.Fill;
lbName.TextAlign = ContentAlignment.MiddleCenter;
// 创建 SplitContainer 控件
SplitContainer container = new SplitContainer();
var size = new Size();
size.Width = flpPhotos.Width - 8;
size.Height = size.Width / 16 * 9;
container.Size = size;
container.Dock = DockStyle.Top;
container.Orientation = Orientation.Horizontal;
container.SplitterWidth = 1;
container.SplitterDistance = 100;
//container.Panel1.Padding = new Padding(0, 10, 0, 0);
container.Panel1.Controls.Add(pic);
container.Panel2.Controls.Add(lbName);
// 将 SplitContainer 添加到 flpPhotosTaken 中
flpPhotos.Controls.Add(container);
// 改变排序,将新增的添加到顶部
flpPhotos.Controls.SetChildIndex(container, 0);
// 将拍摄的照片对象添加到集合中
photos.Add(photo);
}
}
private void deleteSnapshot(Photo photo)
{
if (InvokeRequired)
{
Invoke(new Action<Photo>(deleteSnapshot), photo);
}
else
{
if (photo == null) return;
var snapshot = photo.Image;
// 查找并移除对应的 splitContainer
foreach (Control control in flpPhotos.Controls)
{
if (control is SplitContainer container)
{
container.BorderStyle = BorderStyle.None;
if (container.Panel1.Controls[0] is PictureBox pic && pic.Image == snapshot)
{
flpPhotos.Controls.Remove(container);
}
}
}
// 将拍摄的照片对象添加到集合中
photos.Remove(photo);
}
}
#endregion
#region k5业务请求
private void getReport(string reportId)
{
if (_client == null)
{
MessageBox.Show("未连接");
return;
}
if (reportId.IsNullOrEmpty())
{
currentReport = null;
showCurrentReport();
return;
}
var request = new ReportRequest();
request.ReportId = reportId;
var task = _client.GetAsync(request);
task.Success(resp =>
{
if (resp != null)
{
if (resp.Results.IsNullOrEmpty())
{
MessageBox.Show($"未找到此编号:{tbxReportId.Text}");
tbxReportId.Text = "";
currentReport = null;
}
else
{
currentReport = resp.Results[0];
}
}
else
{
MessageBox.Show("服务器无响应");
tbxReportId.Text = "";
currentReport = null;
}
showCurrentReport();
}, true);
task.Error(err =>
{
tbxReportId.Text = "";
var msg = err.GetResponseStatus().Message;
MessageBox.Show($"服务器请求错误,{msg}");
showCurrentReport();
return;
}, true);
}
#endregion
private void FrmMain_Load(object sender, EventArgs e)
......@@ -211,6 +420,7 @@ namespace Kivii.Sample.ImageUploader
initFormCtlEnable(true);
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword);
initCameras();
tbxPassword.Focus();
}
private void btnLogin_Click(object sender, EventArgs e)
......@@ -231,6 +441,10 @@ namespace Kivii.Sample.ImageUploader
setDefault(tbxServiceUrl, tbxUserName, tbxPassword);
Thread.Sleep(100);
if (videoDevice == null) initCameras();
if (videoDevice == null)
{
return;
}
// 默认选择第一个分辨率
cbxResolution.SelectedIndex = 0;
}, true);
......@@ -261,7 +475,7 @@ namespace Kivii.Sample.ImageUploader
_client = null;
Thread.Sleep(100);
initFormCtlEnable();
Disconnect();
disconnect();
});
task.Error(err =>
{
......@@ -272,13 +486,13 @@ namespace Kivii.Sample.ImageUploader
private void cbxResolution_SelectedIndexChanged(object sender, EventArgs e)
{
Disconnect();
if(cbxResolution.SelectedIndex>=0) Connect(cbxResolution.SelectedIndex);
disconnect();
if (cbxResolution.SelectedIndex >= 0) connect(cbxResolution.SelectedIndex);
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Disconnect();
disconnect();
}
private void btnSwitch_Click(object sender, EventArgs e)
......@@ -288,63 +502,30 @@ namespace Kivii.Sample.ImageUploader
private void btnShot_Click(object sender, EventArgs e)
{
try
if (videoDevice != null && vspCamView.IsRunning)
{
if (videoDevice != null && vspCamView.IsRunning)
// 捕获当前帧
Bitmap bitmap = (Bitmap)vspCamView.GetCurrentVideoFrame().Clone();
var picName = string.Empty;
string reportId = string.Empty;
if (currentReport != null)
{
// 捕获当前帧
Bitmap bitmap = vspCamView.GetCurrentVideoFrame();
ptbPhotoDisplay.Image = bitmap;
// 创建图片 PictureBox 控件
PictureBox pictureBox = new PictureBox();
pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox.Dock = DockStyle.Fill;
pictureBox.Image = bitmap;
// 添加图片点击动作
pictureBox.Click += PictureBox_Click;
// 创建图片名称的 Label 控件
Label nameLabel = new Label();
String name = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
nameLabel.Text = name;
nameLabel.Dock = DockStyle.Fill;
nameLabel.TextAlign = ContentAlignment.MiddleCenter;
// 创建 SplitContainer 控件
SplitContainer splitContainer = new SplitContainer();
splitContainer.Size = new Size(210, 140);
splitContainer.Orientation = Orientation.Horizontal;
splitContainer.SplitterWidth = 1;
splitContainer.SplitterDistance = 100;
splitContainer.Panel1.Padding = new Padding(0, 10, 0, 0);
splitContainer.Panel1.Controls.Add(pictureBox);
splitContainer.Panel2.Controls.Add(nameLabel);
// 将 SplitContainer 添加到 flpPhotosTaken 中
flpPhotosTaken.Controls.Add(splitContainer);
// 改变排序,将新增的添加到顶部
flpPhotosTaken.Controls.SetChildIndex(splitContainer, 0);
// 将拍摄的照片对象添加到集合中
photos.Add(new Photo(bitmap, name));
// 遍历 flpPhotosTaken 中的控件,将之前选中的 SplitContainer 边框改为默认
foreach (Control control in flpPhotosTaken.Controls)
{
if (control is SplitContainer controlContainer)
{
controlContainer.BorderStyle = BorderStyle.None;
}
}
// 为新添加的 SplitContainer 添加边框
splitContainer.BorderStyle = BorderStyle.FixedSingle;
reportId = currentReport.ReportId;
}
if (!reportId.IsNullOrEmpty())
{
picName = reportId + "_";
}
picName += DateTime.Now.ToString("mmssfff");
var photo = new Photo(bitmap, picName);
addSnapshot(photo);
Thread.Sleep(50);
showSnapshot(photo);
}
catch (Exception ex)
else
{
MessageBox.Show("无法拍照" + ex.Message);
MessageBox.Show("没有找到视频采集设备");
}
}
......@@ -353,24 +534,91 @@ namespace Kivii.Sample.ImageUploader
// 获取点击的 PictureBox 中的图片
PictureBox pictureBox = (PictureBox)sender;
// 遍历 flpPhotosTaken 中的控件,找到对应的 SplitContainer,并为其设置边框样式
foreach (Control control in flpPhotosTaken.Controls)
var photo = photos.FirstOrDefault(o => o.Image == pictureBox.Image);
if (photo != null) showSnapshot(photo);
}
private void btnDelete_Click(object sender, EventArgs e)
{
Bitmap currentPhoto = (Bitmap)ptbPhotoDisplay.Image;
if (currentPhoto == null) return;
var photo = photos.FirstOrDefault(o => o.Image == currentPhoto);
if (photo != null) deleteSnapshot(photo);
Thread.Sleep(50);
if (!photos.IsNullOrEmpty())
{
if (control is SplitContainer splitContainer)
showSnapshot(photos.Last());
}
else
{
showSnapshot(null);
}
}
private void btnReportId_Click(object sender, EventArgs e)
{
if (_client == null)
{
MessageBox.Show("未连接");
return;
}
//if (tbxReportId.Text.IsNullOrEmpty()) return;
getReport(tbxReportId.Text);
}
private void tbxReportId_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 13) return;
btnReportId_Click(null, null);
}
private void tbxPassword_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 13) return;
btnLogin_Click(null, null);
}
private void btnUpload_Click(object sender, EventArgs e)
{
if (_client == null)
{
MessageBox.Show("未连接");
return;
}
if (currentReport == null) return;
var count = photos.Count;
if (count == 0) return;
var path = Path.Combine(KiviiContext.GetTemporaryFilePath("Kivii"), "Client", "Caches", "Uploader", "Images");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
for (int i = count - 1; i >= 0; i--)
{
var photo = photos[i];
if (photo.Image == null) continue;
string filename = Path.Combine(path, photo.Name + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg");
photo.Image.Save(filename);
if (!File.Exists(filename)) continue;
var request = new FileRequest();
request.OwnerKvid = currentReport.Kvid;
request.FolderPath = "/Samples/Images";
var response = _client.PostFileWithRequest<FileResponse>(new FileInfo(filename), request);
if (response.Results != null && response.Results.Count >= 1)
{
// 如果 SplitContainer 包含点击的 PictureBox,则设置其边框,否则设置为默认
if (splitContainer.Panel1.Controls.Count > 0 && splitContainer.Panel1.Controls[0] == pictureBox)
if (photo != null) deleteSnapshot(photo);
Thread.Sleep(50);
if (!photos.IsNullOrEmpty())
{
splitContainer.BorderStyle = BorderStyle.FixedSingle;
showSnapshot(photos.Last());
}
else
{
splitContainer.BorderStyle = BorderStyle.None;
showSnapshot(null);
}
}
}
// 在界面中的 PictureBox 中显示该图片
ptbPhotoDisplay.Image = (Bitmap)pictureBox.Image;
}
}
}
......@@ -31,6 +31,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.5, Version=5.6.2024.1160, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Kivii.Common.5.6.2024.1160\lib\net45\Kivii.Common.V4.5.dll</HintPath>
......@@ -68,6 +77,7 @@
<DependentUpon>VideoSourcePlayer.cs</DependentUpon>
</Compile>
<Compile Include="Entities\Photo.cs" />
<Compile Include="Entities\Report.cs" />
<Compile Include="Entities\UiSetting.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
......@@ -77,6 +87,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Requests.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
......@@ -91,6 +102,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
\ No newline at end of file
using Kivii.Sample.ImageUploader.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Sample.ImageUploader
{
[Route(Configs.RouteReportRequest, "Get,Post")]
internal class ReportRequest : IReturn<RestfulQueryResponse<Report>>
{
public string ReportId { get; set; }
}
[Route(Configs.RouteFilesUploadAndDownload, "Get,Post")]
public class FileRequest : FileRequestBase, IReturn<FileResponse>
{
}
public class FileRequestBase
{
public bool Override { get; set; }
public string Description { get; set; }
public Guid OwnerKvid { get; set; }
public string OwnerName { get; set; }
public string Name { get; set; }
public string FolderPath { get; set; }
public string Tags { get; set; }
}
public class DbFile : Entity
{
public string Name { get; set; }
public string Extension { get; set; }
public long Length { get; set; }
public DateTime PublishTime { get; set; }
public string RemoteUrl { get; set; }
public decimal Version { get; set; }
public string Folder { get; set; }
public string VirtualPath { get; set; }
public string OwnerName { get; set; }
public Guid OwnerKvid { get; set; }
public string Tags { get; set; }
public Guid CreatorKvid { get; set; }
public string CreatorName { get; set; }
}
public class FileResponse : RestfulCreateResponse<DbFile>
{
public bool success
{
get
{
return ResponseStatus == 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