| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Base; |
| | | using Bro.Common.Helper; |
| | | using Bro.UI.Model.Winform; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | plImage.Controls.Add(cvImage); |
| | | |
| | | tscEditLocation.Visible = tsmiShowEditor.Checked = false; |
| | | |
| | | this.Load += async (s, e) => |
| | | { |
| | | await Task.Delay(300); |
| | | |
| | | cvImage.SetScreenSize(); |
| | | cvImage.OnElementChangedHandle -= CvImage_OnElementChangedHandle; |
| | | cvImage.OnElementChangedHandle += CvImage_OnElementChangedHandle; |
| | | }; |
| | | } |
| | | |
| | | public override void OnProcessUpdated() |
| | |
| | | if (string.IsNullOrWhiteSpace(Config.BackgroundImagePath)) |
| | | return; |
| | | |
| | | try |
| | | this.Invoke(new Action(() => |
| | | { |
| | | Bitmap image = (Bitmap)Image.FromFile(Config.BackgroundImagePath); |
| | | cvImage.LoadImage(image); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(new LogMsg(DateTime.Now, "载入背景图异常", ex.Message)); |
| | | return; |
| | | } |
| | | |
| | | cvImage.Elements.Clear(); |
| | | lvMeasures.Items.Clear(); |
| | | Config.MeasurementUnitCollection.ForEach(u => |
| | | { |
| | | if (!u.IsEnabled) |
| | | try |
| | | { |
| | | Bitmap image = (Bitmap)Image.FromFile(Config.BackgroundImagePath); |
| | | cvImage.LoadImage(image); |
| | | cvImage.SetScreenSize(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(new LogMsg(DateTime.Now, "载入背景图异常", ex.Message)); |
| | | return; |
| | | } |
| | | |
| | | var ele = new KeyIndicator(u.Id, u.DisplayLocation); |
| | | cvImage.Elements.Add(ele); |
| | | cvImage.Elements.Clear(); |
| | | lvMeasures.Items.Clear(); |
| | | |
| | | ListViewItem item = new ListViewItem(u.GetDisplayText()); |
| | | item.Tag = u.Id; |
| | | lvMeasures.Items.Add(item); |
| | | }); |
| | | txtBarcode.Enabled = !Config.IsBarcodeManualInputBlocked; |
| | | |
| | | txtBarcode.ReadOnly = Config.IsBarcodeManulInputBlocked; |
| | | Config.MeasurementUnitCollection.ForEach(u => |
| | | { |
| | | if (!u.IsEnabled) |
| | | return; |
| | | |
| | | var ele = new KeyIndicator(u.Id, u.DisplayLocation); |
| | | cvImage.Elements.Add(ele); |
| | | |
| | | ListViewItem item = new ListViewItem(u.GetDisplayText()); |
| | | item.Tag = u.Id; |
| | | lvMeasures.Items.Add(item); |
| | | }); |
| | | })); |
| | | |
| | | Process_M071.OnClearBarcode -= M071_MainForm_OnClearBarcode; |
| | | Process_M071.OnClearBarcode += M071_MainForm_OnClearBarcode; |
| | |
| | | |
| | | Process_M071.OnFullResetDone -= Process_M071_FullResetDone; |
| | | Process_M071.OnFullResetDone += Process_M071_FullResetDone; |
| | | |
| | | Config.PropertyChanged -= Config_PropertyChanged; |
| | | Config.PropertyChanged += Config_PropertyChanged; |
| | | } |
| | | |
| | | private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e) |
| | | { |
| | | txtBarcode.Enabled = !Config.IsBarcodeManualInputBlocked; |
| | | } |
| | | |
| | | #region 图片区右键菜单 |
| | |
| | | #endregion |
| | | |
| | | #region 标签编辑区 |
| | | private async void CvImage_OnElementChangedHandle(Common.Interface.IShapeElement ele) |
| | | { |
| | | this.Invoke(new Action(() => |
| | | { |
| | | if (ele is KeyIndicator indicator) |
| | | { |
| | | if (indicator.State == ElementState.Selected) |
| | | { |
| | | foreach (ListViewItem item in lvMeasures.Items) |
| | | { |
| | | if (item.Tag.ToString() == indicator.ID) |
| | | { |
| | | item.Selected = true; |
| | | |
| | | lvMeasures.EnsureVisible(item.Index); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | |
| | | await Task.Delay(100); |
| | | } |
| | | |
| | | private void lvMeasures_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | if (lvMeasures.SelectedItems.Count <= 0) |
| | | return; |
| | | |
| | | foreach (ListViewItem item in lvMeasures.Items) |
| | | { |
| | | item.BackColor = SystemColors.Control; |
| | | } |
| | | |
| | | foreach (ListViewItem item in lvMeasures.SelectedItems) |
| | | { |
| | | item.BackColor = Color.Orange; |
| | | } |
| | | |
| | | var ele = cvImage.Elements.FirstOrDefault(u => u.ID == lvMeasures.SelectedItems[0].Tag.ToString()); |
| | | propGridKeyIndicator.SelectedObject = ele; |
| | |
| | | |
| | | MessageBox.Show("标签修改完成"); |
| | | } |
| | | |
| | | private void lvMeasures_DoubleClick(object sender, EventArgs e) |
| | | { |
| | | if (lvMeasures.SelectedItems.Count <= 0) |
| | | return; |
| | | |
| | | cvImage.Elements.ToList().ForEach(u => u.State = ElementState.Normal); |
| | | var ele = cvImage.Elements.FirstOrDefault(u => u.ID == lvMeasures.SelectedItems[0].Tag.ToString()); |
| | | if (ele != null) |
| | | { |
| | | ele.State = ElementState.Selected; |
| | | //cvImage.Invalidate(); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 上方状态区 |
| | |
| | | { |
| | | txtBarcode.Text = _barcode; |
| | | _barcode = ""; |
| | | } |
| | | |
| | | if (e.KeyValue == 27) |
| | | { |
| | | cvImage.Elements.ToList().ForEach(ele => ele.State = ElementState.Normal); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | else if (btnStartMeasure.Text == "继续测量") |
| | | { |
| | | Process_M071.ResumeJob(null, null, null); |
| | | Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 0 } }, null, null); |
| | | btnStartMeasure.Text = "暂停测量"; |
| | | } |
| | | else |
| | | { |
| | | Process_M071.PauseJob(null, null, null); |
| | | Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 1 } }, null, null); |
| | | btnStartMeasure.Text = "继续测量"; |
| | | } |
| | | |