|
@@ -2,6 +2,7 @@
|
|
|
using MeterVision.model;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
@@ -22,8 +23,9 @@ namespace MeterVision.Dlg
|
|
|
/// </summary>
|
|
|
public partial class EditStationDlg2 : Window
|
|
|
{
|
|
|
- private bool mIsAdd;
|
|
|
public StationItem mStationItem { get; private set; }
|
|
|
+ private TStandDetail _standDetail;
|
|
|
+ private bool _can_mark;
|
|
|
|
|
|
public EditStationDlg2(StationItem stationItem)
|
|
|
{
|
|
@@ -31,22 +33,54 @@ namespace MeterVision.Dlg
|
|
|
|
|
|
cmbMeterType.ItemsSource = StationItem.MeterTypeList;
|
|
|
cmbFlowRate.ItemsSource = StationItem.FlowRateList;
|
|
|
- cmbLastUnit.ItemsSource = StationItem.UnitList;
|
|
|
- //cmbLastIndUnit.ItemsSource = StationItem.UnitList;
|
|
|
+ cmbLastUnit.ItemsSource = StationItem.UnitList;
|
|
|
|
|
|
- mIsAdd = (stationItem == null);
|
|
|
- if(stationItem != null)
|
|
|
+ mStationItem = stationItem;
|
|
|
+
|
|
|
+ txtStationId.IsEnabled = false;
|
|
|
+
|
|
|
+ Init_Load(stationItem);
|
|
|
+ Load_image();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Load_image()
|
|
|
+ {
|
|
|
+ _standDetail = DBStand.GetMinSampleTimeDetail(mStationItem.StandId, mStationItem.StationId);
|
|
|
+ if (_standDetail != null && File.Exists(_standDetail.SrcImage))
|
|
|
{
|
|
|
- mStationItem = stationItem;
|
|
|
- Init_Load(stationItem);
|
|
|
- txtStationId.IsEnabled = false;
|
|
|
+ ucMark.Visibility = Visibility.Visible;
|
|
|
+ ucMark.SetImagePath(_standDetail.SrcImage);
|
|
|
+ ucMark.MeterRegion_MarkFinished += UcMark_MeterRegion_MarkFinished;
|
|
|
+ ucMark.FeatureRegion_MarkFinished += UcMark_FeatureRegion_MarkFinished;
|
|
|
+ _can_mark = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- mStationItem = new StationItem();
|
|
|
- txtStationId.IsEnabled = true;
|
|
|
- txtBrightVal.Text = "1.2";
|
|
|
+ ucMark.Visibility = Visibility.Hidden;
|
|
|
+ _can_mark = false;
|
|
|
}
|
|
|
+
|
|
|
+ if (_can_mark)
|
|
|
+ {
|
|
|
+ ucMark.MeterType = mStationItem.MeterType;
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(mStationItem.LastTime))
|
|
|
+ {
|
|
|
+ txtLastTime.Text = _standDetail.SampleTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UcMark_FeatureRegion_MarkFinished(string regions, int meterType)
|
|
|
+ {
|
|
|
+ //throw new NotImplementedException();
|
|
|
+ this.txtFeatureRegion.Text = regions;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UcMark_MeterRegion_MarkFinished(string regions, int meterType)
|
|
|
+ {
|
|
|
+ //throw new NotImplementedException();
|
|
|
+ this.txtDialRegion.Text = regions;
|
|
|
}
|
|
|
|
|
|
//加载数据
|
|
@@ -73,7 +107,15 @@ namespace MeterVision.Dlg
|
|
|
}
|
|
|
|
|
|
txtLastValue.Text = string.IsNullOrEmpty(stationItem.LastTime) ? "" : stationItem.LastValue.ToString();
|
|
|
- txtLastTime.Text = stationItem.LastTime;
|
|
|
+
|
|
|
+ if(_standDetail != null)
|
|
|
+ {
|
|
|
+ txtLastTime.Text = _standDetail.SampleTime;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ txtLastTime.Text = stationItem.LastTime;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private bool Get_Load()
|
|
@@ -189,10 +231,7 @@ namespace MeterVision.Dlg
|
|
|
|
|
|
mStationItem.LastValue = lastValue;
|
|
|
mStationItem.LastTime = lastTime;
|
|
|
- if (mIsAdd)
|
|
|
- {
|
|
|
- mStationItem.CreateTime = ThisApp.GetNowTime_yyyyMMddHHmmss();
|
|
|
- }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -208,31 +247,15 @@ namespace MeterVision.Dlg
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- if (mIsAdd)
|
|
|
+ bool updateSuccess = DBStation.UpdateTStation(tStation);
|
|
|
+ if (updateSuccess)
|
|
|
{
|
|
|
- bool insertSuccess = DBStation.InsertTStation(tStation);
|
|
|
- if (insertSuccess)
|
|
|
- {
|
|
|
- DialogResult = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(Application.Current.MainWindow, "新增失败", "错误",
|
|
|
- MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
- }
|
|
|
+ DialogResult = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bool updateSuccess = DBStation.UpdateTStation(tStation);
|
|
|
- if (updateSuccess)
|
|
|
- {
|
|
|
- DialogResult = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(Application.Current.MainWindow, "修改失败", "错误",
|
|
|
- MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
- }
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "修改失败", "错误",
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -259,6 +282,9 @@ namespace MeterVision.Dlg
|
|
|
meterType = (int)cmbMeterType.SelectedValue;
|
|
|
}
|
|
|
this.ChangeInfoByMeterType(meterType);
|
|
|
+
|
|
|
+ //改变仪表的类型
|
|
|
+ ucMark.MeterType = meterType;
|
|
|
}
|
|
|
|
|
|
private void ChangeInfoByMeterType(int meterType)
|