Commit 2bbb2012 by Neo Turing

优化

parent 5ec7e266
......@@ -50,10 +50,10 @@
this.plControl.Controls.Add(this.btnSave);
this.plControl.Controls.Add(this.btnCancel);
this.plControl.Dock = System.Windows.Forms.DockStyle.Bottom;
this.plControl.Location = new System.Drawing.Point(0, 391);
this.plControl.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.plControl.Location = new System.Drawing.Point(0, 514);
this.plControl.Margin = new System.Windows.Forms.Padding(2);
this.plControl.Name = "plControl";
this.plControl.Size = new System.Drawing.Size(584, 100);
this.plControl.Size = new System.Drawing.Size(748, 100);
this.plControl.TabIndex = 0;
//
// btnSave
......@@ -65,7 +65,7 @@
this.btnSave.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.btnSave.Location = new System.Drawing.Point(0, 0);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(346, 100);
this.btnSave.Size = new System.Drawing.Size(510, 100);
this.btnSave.TabIndex = 5;
this.btnSave.Text = "保存";
this.btnSave.UseVisualStyleBackColor = false;
......@@ -76,7 +76,7 @@
this.btnCancel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnCancel.Dock = System.Windows.Forms.DockStyle.Right;
this.btnCancel.Font = new System.Drawing.Font("宋体", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(346, 0);
this.btnCancel.Location = new System.Drawing.Point(510, 0);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(238, 100);
this.btnCancel.TabIndex = 4;
......@@ -91,16 +91,16 @@
this.plImage.Dock = System.Windows.Forms.DockStyle.Fill;
this.plImage.Location = new System.Drawing.Point(0, 0);
this.plImage.Name = "plImage";
this.plImage.Size = new System.Drawing.Size(584, 391);
this.plImage.Size = new System.Drawing.Size(748, 514);
this.plImage.TabIndex = 2;
//
// imgResizer
//
this.imgResizer.BackColor = System.Drawing.Color.Transparent;
this.imgResizer.Location = new System.Drawing.Point(79, 40);
this.imgResizer.Location = new System.Drawing.Point(151, 11);
this.imgResizer.Margin = new System.Windows.Forms.Padding(2);
this.imgResizer.Name = "imgResizer";
this.imgResizer.Size = new System.Drawing.Size(430, 307);
this.imgResizer.Size = new System.Drawing.Size(430, 498);
this.imgResizer.TabIndex = 1;
this.imgResizer.Text = "imgResizer";
//
......@@ -108,15 +108,16 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 491);
this.ClientSize = new System.Drawing.Size(748, 614);
this.Controls.Add(this.plImage);
this.Controls.Add(this.plControl);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(600, 530);
this.Name = "FrmImageEditor";
this.Text = "图片裁剪";
this.Load += new System.EventHandler(this.FrmImageEditor_Load);
this.Resize += new System.EventHandler(this.FrmImageEditor_Resize);
this.plControl.ResumeLayout(false);
this.plImage.ResumeLayout(false);
this.ResumeLayout(false);
......
using Kivii.Zip.Zlib;
using Kivii.Controls;
using Kivii.Zip.Zlib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -15,6 +16,7 @@ namespace Kivii.Sample.ImageUploader
{
public partial class FrmImageEditor : Form
{
private float _zoom = 1f;
public FrmImageEditor()
{
InitializeComponent();
......@@ -50,8 +52,9 @@ namespace Kivii.Sample.ImageUploader
private void FrmImageEditor_Load(object sender, EventArgs e)
{
this.plImage.BackgroundImage = backgroundImage;
this.plImage.BackgroundImageLayout = ImageLayout.Center;
this.plImage.BackgroundImageLayout = ImageLayout.Zoom;
ImgEdited = backgroundImage;
resizePictureBox();
}
private void btnCancel_Click(object sender, EventArgs e)
{
......@@ -98,6 +101,43 @@ namespace Kivii.Sample.ImageUploader
timeImageEditor.Enabled = true;
}
#region 窗口大小发生变化
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
resizePictureBox();
}
private void resizePictureBox()
{
if (plImage.BackgroundImage == null) return;
int width, height;
if (_zoom == 0f)
{
float wzoom = (float)plImage.Width / (float)plImage.BackgroundImage.Width;
float hzoom = (float)plImage.Height / (float)plImage.BackgroundImage.Height;
_zoom = wzoom < hzoom ? wzoom : hzoom;
}
else if (_zoom > 5f) _zoom = 5f;
else if (_zoom < 0.1f) _zoom = 0.1f;
width = (int)((float)plImage.BackgroundImage.Width * _zoom);
height = (int)((float)plImage.BackgroundImage.Height * _zoom);
plImage.Width = width;
plImage.Height = height;
int x, y;
if (plImage.Width <= width) x = 0;
else x = (plImage.Width - width) / 2;
if (plImage.Height <= height) y = 0;
else y = (plImage.Height - height) / 2;
plImage.Location = new System.Drawing.Point(x, y);
// 计算控件在父容器中居中的位置
int xi = (imgResizer.Parent.Width - imgResizer.Width) / 2;
int yi = (imgResizer.Parent.Height - imgResizer.Height) / 2;
imgResizer.Location= new System.Drawing.Point(xi, yi);
}
#endregion
public static GraphicsPath createRoundRect(int x, int y, int width, int height, int radius)
{
......@@ -208,6 +248,9 @@ namespace Kivii.Sample.ImageUploader
}
private void FrmImageEditor_Resize(object sender, EventArgs e)
{
resizePictureBox();
}
}
}
......@@ -45,8 +45,10 @@
this.tbxServiceUrl = new System.Windows.Forms.TextBox();
this.lblUrl = new System.Windows.Forms.Label();
this.gbCamView = new System.Windows.Forms.GroupBox();
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,14 +58,12 @@
this.gbPhotoView = new System.Windows.Forms.GroupBox();
this.ptbPhotoDisplay = new System.Windows.Forms.PictureBox();
this.plDisplay = new System.Windows.Forms.Panel();
this.btnCamearTurn = new System.Windows.Forms.Button();
this.lbDisplay = new System.Windows.Forms.Label();
this.gbOperating = new System.Windows.Forms.GroupBox();
this.btnShot = new System.Windows.Forms.Button();
this.btnEditor = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnCamearTurn = new System.Windows.Forms.Button();
this.vspCamView = new Kivii.Sample.ImageUploader.Controls.VideoSourcePlayer();
this.cbxResolution = new System.Windows.Forms.ComboBox();
this.plLeft.SuspendLayout();
this.gbSample.SuspendLayout();
this.plSearchReport.SuspendLayout();
......@@ -107,10 +107,10 @@
//
this.rtbMessage.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbMessage.Font = new System.Drawing.Font("宋体", 14F);
this.rtbMessage.Location = new System.Drawing.Point(3, 59);
this.rtbMessage.Location = new System.Drawing.Point(3, 54);
this.rtbMessage.Margin = new System.Windows.Forms.Padding(2);
this.rtbMessage.Name = "rtbMessage";
this.rtbMessage.Size = new System.Drawing.Size(246, 137);
this.rtbMessage.Size = new System.Drawing.Size(246, 142);
this.rtbMessage.TabIndex = 20;
this.rtbMessage.Text = "";
//
......@@ -121,17 +121,17 @@
this.plSearchReport.Dock = System.Windows.Forms.DockStyle.Top;
this.plSearchReport.Location = new System.Drawing.Point(3, 17);
this.plSearchReport.Name = "plSearchReport";
this.plSearchReport.Size = new System.Drawing.Size(246, 42);
this.plSearchReport.Size = new System.Drawing.Size(246, 37);
this.plSearchReport.TabIndex = 19;
//
// tbxReportId
//
this.tbxReportId.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbxReportId.Font = new System.Drawing.Font("宋体", 14F);
this.tbxReportId.Font = new System.Drawing.Font("宋体", 12F);
this.tbxReportId.Location = new System.Drawing.Point(0, 0);
this.tbxReportId.Multiline = true;
this.tbxReportId.Name = "tbxReportId";
this.tbxReportId.Size = new System.Drawing.Size(172, 42);
this.tbxReportId.Size = new System.Drawing.Size(187, 37);
this.tbxReportId.TabIndex = 7;
this.tbxReportId.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbxReportId_KeyPress);
//
......@@ -140,9 +140,9 @@
this.btnReportId.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnReportId.Dock = System.Windows.Forms.DockStyle.Right;
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(172, 0);
this.btnReportId.Location = new System.Drawing.Point(187, 0);
this.btnReportId.Name = "btnReportId";
this.btnReportId.Size = new System.Drawing.Size(74, 42);
this.btnReportId.Size = new System.Drawing.Size(59, 37);
this.btnReportId.TabIndex = 8;
this.btnReportId.Text = "查询";
this.btnReportId.UseVisualStyleBackColor = false;
......@@ -263,16 +263,27 @@
this.gbCamView.TabStop = false;
this.gbCamView.Text = "相机视图";
//
// cbxResolution
//
this.cbxResolution.Dock = System.Windows.Forms.DockStyle.Fill;
this.cbxResolution.Font = new System.Drawing.Font("宋体", 18F);
this.cbxResolution.FormattingEnabled = true;
this.cbxResolution.Location = new System.Drawing.Point(3, 285);
this.cbxResolution.Name = "cbxResolution";
this.cbxResolution.Size = new System.Drawing.Size(187, 32);
this.cbxResolution.TabIndex = 5;
this.cbxResolution.SelectedIndexChanged += new System.EventHandler(this.cbxResolution_SelectedIndexChanged);
//
// btnSwitch
//
this.btnSwitch.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnSwitch.Dock = System.Windows.Forms.DockStyle.Right;
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(167, 273);
this.btnSwitch.Location = new System.Drawing.Point(190, 285);
this.btnSwitch.Name = "btnSwitch";
this.btnSwitch.Size = new System.Drawing.Size(82, 44);
this.btnSwitch.Size = new System.Drawing.Size(59, 32);
this.btnSwitch.TabIndex = 4;
this.btnSwitch.Text = "切换相机";
this.btnSwitch.Text = "切换";
this.btnSwitch.UseVisualStyleBackColor = false;
this.btnSwitch.Click += new System.EventHandler(this.btnSwitch_Click);
//
......@@ -282,9 +293,19 @@
this.plVsp.Dock = System.Windows.Forms.DockStyle.Top;
this.plVsp.Location = new System.Drawing.Point(3, 19);
this.plVsp.Name = "plVsp";
this.plVsp.Size = new System.Drawing.Size(246, 254);
this.plVsp.Size = new System.Drawing.Size(246, 266);
this.plVsp.TabIndex = 0;
//
// vspCamView
//
this.vspCamView.Dock = System.Windows.Forms.DockStyle.Fill;
this.vspCamView.Location = new System.Drawing.Point(0, 0);
this.vspCamView.Name = "vspCamView";
this.vspCamView.Size = new System.Drawing.Size(246, 266);
this.vspCamView.TabIndex = 0;
this.vspCamView.Text = "vspCamView";
this.vspCamView.VideoSource = null;
//
// plRight
//
this.plRight.Controls.Add(this.gbPhotoList);
......@@ -341,6 +362,7 @@
this.btnUpload.TabIndex = 3;
this.btnUpload.Text = "上传";
this.btnUpload.UseVisualStyleBackColor = false;
this.btnUpload.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
//
// plMain
......@@ -387,6 +409,18 @@
this.plDisplay.Size = new System.Drawing.Size(535, 28);
this.plDisplay.TabIndex = 3;
//
// btnCamearTurn
//
this.btnCamearTurn.Dock = System.Windows.Forms.DockStyle.Right;
this.btnCamearTurn.Location = new System.Drawing.Point(447, 0);
this.btnCamearTurn.Name = "btnCamearTurn";
this.btnCamearTurn.Size = new System.Drawing.Size(88, 28);
this.btnCamearTurn.TabIndex = 31;
this.btnCamearTurn.Text = "旋转";
this.btnCamearTurn.UseVisualStyleBackColor = true;
this.btnCamearTurn.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnCamearTurn.Click += new System.EventHandler(this.btnCamearTurn_Click);
//
// lbDisplay
//
this.lbDisplay.AutoSize = true;
......@@ -412,17 +446,17 @@
//
// btnShot
//
this.btnShot.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.btnShot.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.btnShot.Dock = System.Windows.Forms.DockStyle.Fill;
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.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnShot.Location = new System.Drawing.Point(3, 17);
this.btnShot.Name = "btnShot";
this.btnShot.Size = new System.Drawing.Size(343, 59);
this.btnShot.TabIndex = 5;
this.btnShot.Text = "拍照";
this.btnShot.UseVisualStyleBackColor = false;
this.btnShot.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnShot.Click += new System.EventHandler(this.btnShot_Click);
//
// btnEditor
......@@ -436,6 +470,7 @@
this.btnEditor.TabIndex = 4;
this.btnEditor.Text = "裁剪";
this.btnEditor.UseVisualStyleBackColor = false;
this.btnEditor.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnEditor.Click += new System.EventHandler(this.btnEditor_Click);
//
// btnDelete
......@@ -449,40 +484,9 @@
this.btnDelete.TabIndex = 2;
this.btnDelete.Text = "删除";
this.btnDelete.UseVisualStyleBackColor = false;
this.btnDelete.EnabledChanged += new System.EventHandler(this.btnEnabled_EnabledChanged);
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnCamearTurn
//
this.btnCamearTurn.Dock = System.Windows.Forms.DockStyle.Right;
this.btnCamearTurn.Location = new System.Drawing.Point(447, 0);
this.btnCamearTurn.Name = "btnCamearTurn";
this.btnCamearTurn.Size = new System.Drawing.Size(88, 28);
this.btnCamearTurn.TabIndex = 31;
this.btnCamearTurn.Text = "旋转";
this.btnCamearTurn.UseVisualStyleBackColor = true;
this.btnCamearTurn.Click += new System.EventHandler(this.btnCamearTurn_Click);
//
// vspCamView
//
this.vspCamView.Dock = System.Windows.Forms.DockStyle.Fill;
this.vspCamView.Location = new System.Drawing.Point(0, 0);
this.vspCamView.Name = "vspCamView";
this.vspCamView.Size = new System.Drawing.Size(246, 254);
this.vspCamView.TabIndex = 0;
this.vspCamView.Text = "vspCamView";
this.vspCamView.VideoSource = null;
//
// cbxResolution
//
this.cbxResolution.Dock = System.Windows.Forms.DockStyle.Fill;
this.cbxResolution.Font = new System.Drawing.Font("宋体", 20F);
this.cbxResolution.FormattingEnabled = true;
this.cbxResolution.Location = new System.Drawing.Point(3, 273);
this.cbxResolution.Name = "cbxResolution";
this.cbxResolution.Size = new System.Drawing.Size(164, 35);
this.cbxResolution.TabIndex = 5;
this.cbxResolution.SelectedIndexChanged += new System.EventHandler(this.cbxResolution_SelectedIndexChanged);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......
......@@ -122,6 +122,7 @@ namespace Kivii.Sample.ImageUploader
btnDelete.Enabled = !notLogin;
btnEditor.Enabled = !notLogin;
btnLogout.Enabled = !notLogin;
btnCamearTurn.Enabled = !notLogin;
if (notLogin)
{
......@@ -140,6 +141,8 @@ namespace Kivii.Sample.ImageUploader
//lbCurrentSampleQuantity.Text = "__________";
ptbPhotoDisplay.Image = null;
flpPhotos.Controls.Clear();
currentReport = null;
currentPhoto = null;
}
else
{
......@@ -167,7 +170,9 @@ namespace Kivii.Sample.ImageUploader
foreach (var prop in properties)
{
if (prop.GetDescription().IsNullOrEmpty()) continue;
var msg = $"{prop.GetDescription()}:{prop.GetValue(currentReport)}";
var value = prop.GetValue(currentReport);
if (value == null) continue;
var msg = $"{prop.GetDescription()}:{value}";
outputMessage(msg);
}
......@@ -493,9 +498,13 @@ namespace Kivii.Sample.ImageUploader
{
if (resp.Results.IsNullOrEmpty())
{
MessageBox.Show($"未找到此编号:{reportId}");
//MessageBox.Show($"未找到此编号:{reportId}");
tbxReportId.Text = "";
currentReport = null;
currentReport = new Report();
currentReport.ReportId = reportId;
currentReport.SampleName = "无样品报告模式";
currentReport.SampleModel = "此模式下上传的图片可在公共图片库中查看";
}
else
{
......@@ -924,8 +933,9 @@ namespace Kivii.Sample.ImageUploader
Bitmap bmp = currentPhoto.Image;
frm.backgroundImage = bmp;
frm.Width= bmp.Width;
frm.Height = bmp.Height + 120;
frm.WindowState = FormWindowState.Maximized;
//frm.Width= bmp.Width;
//frm.Height = bmp.Height + 120;
frm.Owner = this;
frm.ShowDialog();
......@@ -947,5 +957,20 @@ namespace Kivii.Sample.ImageUploader
addSnapshot(editedPhoto, index);
showSnapshot(editedPhoto);
}
private void btnEnabled_EnabledChanged(object sender, EventArgs e)
{
if(btnShot.Enabled) btnShot.BackColor = Color.White;
else btnShot.BackColor = SystemColors.ButtonFace;
if(btnEditor.Enabled) btnEditor.BackColor = Color.White;
else btnEditor.BackColor = SystemColors.ButtonFace;
if(btnDelete.Enabled) btnDelete.BackColor = Color.White;
else btnDelete.BackColor = SystemColors.ButtonFace;
if (btnUpload.Enabled) btnUpload.BackColor = Color.White;
else btnUpload.BackColor = SystemColors.ButtonFace;
if (btnCamearTurn.Enabled) btnCamearTurn.BackColor = Color.White;
else btnCamearTurn.BackColor = SystemColors.ButtonFace;
}
}
}
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2024.5300")]
[assembly: AssemblyFileVersion("5.4.2024.5300")]
[assembly: AssemblyVersion("5.4.2024.6040")]
[assembly: AssemblyFileVersion("5.4.2024.6040")]
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