You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
274 lines
11 KiB
274 lines
11 KiB
using ESRI.ArcGIS.Geodatabase; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Views; |
|
using Kingo.ImageViewForWebSocket; |
|
using Kingo.PluginServiceInterface; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.Linq; |
|
using System.Windows.Controls; |
|
using UIShell.OSGi; |
|
|
|
namespace Kingo.Plugin.ProofManager.View |
|
{ |
|
/// <summary> |
|
/// UCImgView.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class UCImgView : UserControl, IElementInfo |
|
{ |
|
ICameraPoint CameraHelper = null; |
|
private Dictionary<string, IRDBHelper> DICIRDBHelper = null; |
|
private string pPath = string.Empty; |
|
private List<string> DelFJList = new List<string>(); |
|
IProofManager ProofMgr = null; |
|
private List<AttachEntity> ImgList = null; |
|
private ProjectInfo PrjInfo |
|
{ |
|
get |
|
{ |
|
return MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; |
|
} |
|
} |
|
public UCImgView() |
|
{ |
|
InitializeComponent(); |
|
Title = "外业照片"; |
|
DockHeight = 240; |
|
this.Loaded += (s1, e1) => |
|
{ |
|
MapsManager.Instance.MapService.getAxMapControl().OnMouseDown += (s, e) => |
|
{ |
|
try |
|
{ |
|
if (e.button != 1) |
|
{ |
|
return; |
|
} |
|
//System.Drawing.Point point = new System.Drawing.Point() { X = e.x, Y = e.y }; |
|
if (!(ImgList != null && ImgList.Count > 0)) |
|
{ |
|
return; |
|
} |
|
int x = 0, y = 0; |
|
foreach (var item in ImgList) |
|
{ |
|
ESRI.ArcGIS.Geometry.IPoint mP = new ESRI.ArcGIS.Geometry.PointClass() { X = item.X, Y = item.Y }; |
|
MapsManager.Instance.MapService.getAxMapControl().FromMapPoint(mP, ref x, ref y); |
|
double d = Math.Pow(x - e.x, 2) + Math.Pow(y - e.y, 2); |
|
double l = Math.Sqrt(d); |
|
//AttachEntity photoInfo = ImgList.FirstOrDefault(Z => Z.FJMC.Equals(item.FJMC)); |
|
if (l < 21) |
|
{ |
|
ucImgXZZP.SetImage(item.FJMC); |
|
//for (int i = 0; i < fj1.ImgListSource.Count; i++) |
|
//{ |
|
// if (fj1.ImgListSource[i].FJMC.Equals(item.Key, StringComparison.CurrentCultureIgnoreCase)) |
|
// { |
|
// fj1.Index = i; |
|
// fj1.BindImage(); |
|
// break; |
|
// } |
|
//} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("方位角选择同步照片异常:" + ex.Message); |
|
} |
|
}; |
|
}; |
|
|
|
ucImgXZZP.ChangedPointSymbol = ChangedPointSymbol; |
|
ucImgXZZP.ShowImgHandel = (path) => |
|
{ |
|
WebsocketHelper.Instance.Send("src:" + path); |
|
}; |
|
ucImgXZZP.RotateImgHandel = (angle) => |
|
{ |
|
WebsocketHelper.Instance.Send("angle:" + angle); |
|
}; |
|
ucImgXZZP.FullImgHandel = () => |
|
{ |
|
WebsocketHelper.Instance.Send("full:"); |
|
}; |
|
Platform.Instance.NotifyMsgEven2 += (o) => |
|
{ |
|
try |
|
{ |
|
switch (o.MsgType) |
|
{ |
|
case "BindProofImg": |
|
ucImgXZZP.InitData(o.Content as List<AttachEntity>); |
|
break; |
|
case "FullShowPic": |
|
ucImgXZZP.Img_Full_MouseLeftButtonDown(null, null); |
|
break; |
|
case "Select": |
|
ucImgXZZP.CbIsCheck_Checked(null, null); |
|
break; |
|
case "Next": |
|
ucImgXZZP.nextImg_MouseLeftButtonDown(null, null); |
|
break; |
|
case "Prev": |
|
ucImgXZZP.prevImg_MouseLeftButtonDown(null, null); |
|
break; |
|
default: |
|
break; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("绑定外业照片时异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("绑定外业照片时异常 异常信息结束"); |
|
} |
|
}; |
|
} |
|
private void ChangedPointSymbol(string fjmc) |
|
{ |
|
//更新地图显示方位角样式 |
|
//EnvironmentVariables.Instance.cameraPoint.ChangedPointSymbol(fjmc); |
|
if (CameraHelper == null) |
|
CameraHelper = MapsManager.Instance.MapService as ICameraPoint; |
|
if (CameraHelper != null) |
|
CameraHelper.ChangedPointSymbol(fjmc); |
|
} |
|
|
|
public int ShowIndex { get; set; } |
|
public bool ResetSize { get; set; } |
|
public bool AllowEdit { get; set; } |
|
public Guid ID { get; set; } |
|
public DockStyle DockAreas { get; set; } |
|
public System.Drawing.Size FloatSize { get; set; } |
|
public int DockWidth { get; set; } |
|
public int DockHeight { get; set; } |
|
public DockStyle DefaultArea { get; set; } |
|
public bool ShowCloseButton { get; set; } |
|
public bool ShowAutoHideButton { get; set; } |
|
public string Title { get; set; } |
|
public bool IsShow { get; set; } |
|
|
|
public void BindData(object obj) |
|
{ |
|
try |
|
{ |
|
DelFJList.Clear(); |
|
if (obj == null) |
|
ucImgXZZP.InitData(null, false); |
|
|
|
if (ProofMgr == null) |
|
ProofMgr = BundleRuntime.Instance.GetFirstOrDefaultService<IProofManager>(); |
|
if (obj is List<AttachEntity>) |
|
{ |
|
if (CameraHelper == null) |
|
CameraHelper = MapsManager.Instance.MapService as ICameraPoint; |
|
if (CameraHelper != null) |
|
CameraHelper.AddCameraPoint(obj as List<AttachEntity>); |
|
ucImgXZZP.InitData(obj as List<AttachEntity>, true); |
|
ImgList = obj as List<AttachEntity>; |
|
} |
|
else if (obj is List<ProofInfo>) |
|
{ |
|
List<ProofInfo> _ProofList = obj as List<ProofInfo>; |
|
if (_ProofList != null && _ProofList.Count > 0) |
|
{ |
|
if (CameraHelper == null) |
|
CameraHelper = MapsManager.Instance.MapService as ICameraPoint; |
|
if (CameraHelper != null) |
|
CameraHelper.AddCameraPoint(_ProofList[0].ImgList); |
|
} |
|
var tempData = obj as List<ProofInfo>; |
|
if (tempData != null && tempData.Count > 0) |
|
{ |
|
ucImgXZZP.InitData(tempData[0].ImgList as List<AttachEntity>, true); |
|
ImgList = tempData[0].ImgList as List<AttachEntity>; |
|
} |
|
else |
|
{ |
|
ucImgXZZP.InitData(null); |
|
ImgList = null; |
|
} |
|
} |
|
//var list = ucImgXZZP.GetAttachEntityList(); |
|
//if (list != null && list.Count > 0) |
|
//{ |
|
// List<AttachEntity> attachEntities_checkfalse = list.FindAll(x => x.isCheck == false); |
|
// foreach (var item in attachEntities_checkfalse) |
|
// { |
|
// DelFJList.Add(item.FJMC); |
|
// } |
|
//} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("绑定外业照片时异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("绑定外业照片时异常 异常信息结束"); |
|
} |
|
} |
|
private List<ProofInfo> GetProofData(IFeature pFeature) |
|
{ |
|
List<ProofInfo> result = new List<ProofInfo>(); |
|
int fieldIndex = pFeature.Fields.FindField("TBYBH"); |
|
if (fieldIndex > 0) |
|
{ |
|
result = ProofMgr.GetProofInfoList<ProofInfo>(pFeature.Value[fieldIndex].ToString()); |
|
} |
|
|
|
return result; |
|
} |
|
public void SaveEdit() |
|
{ |
|
List<AttachEntity> attachEntities = ucImgXZZP.GetAttachEntityList(); |
|
if (attachEntities != null && attachEntities.Count > 0) |
|
{ |
|
try |
|
{ |
|
if (DICIRDBHelper == null) |
|
DICIRDBHelper = new Dictionary<string, IRDBHelper>(); |
|
string dbPath = $"{(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir}\\BGTJ.sqlite"; |
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); |
|
var tempPrj = new ProjectInfo(); |
|
DataTable tab = rdbHelper.ExecuteDatatable("dbpath", $"select TBBH,DbPath from hcdb_relation where TBBH='{attachEntities[0].JCBH}' ", true); |
|
if (tab != null && tab.Rows.Count > 0) |
|
{ |
|
List<AttachEntity> attachEntities_checkfalse = null; |
|
string fjmcs = string.Empty; |
|
string DBPath = tab.Rows[0]["DbPath"].ToString(); |
|
if (!DICIRDBHelper.ContainsKey(DBPath)) |
|
DICIRDBHelper.Add(DBPath, RDBFactory.CreateDbHelper("Data Source=" + DBPath, DatabaseType.SQLite)); |
|
rdbHelper = DICIRDBHelper[DBPath]; |
|
var v = rdbHelper.ExecuteSQL($" update FJ set isSelected=0 where TBBSM = '{attachEntities[0].JCBH}' "); |
|
attachEntities_checkfalse = attachEntities.FindAll(x => x.isCheck == true); |
|
fjmcs = string.Join(",", attachEntities_checkfalse.Select(x => $"'{x.FJMC}'")); |
|
v = rdbHelper.ExecuteSQL($" update FJ set isSelected=1 where TBBSM = '{attachEntities[0].JCBH}' and FJMC in ({fjmcs}) "); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("保存照片状态时异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("保存照片状态时异常 异常信息结束"); |
|
} |
|
} |
|
} |
|
|
|
public void Clear() |
|
{ |
|
if (DICIRDBHelper != null) |
|
{ |
|
foreach (var item in DICIRDBHelper) |
|
{ |
|
if (item.Value == null) continue; |
|
item.Value.DisConnect(); |
|
} |
|
DICIRDBHelper = null; |
|
} |
|
} |
|
} |
|
}
|
|
|