BJdmt.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using WWPipeLine.MapBasic.Conditions;
  11. using SuperMap.Data;
  12. using Sunny.UI;
  13. using WWPipeLine.MapBasic;
  14. using WeifenLuo.WinFormsUI.Docking;
  15. using SuperMap.UI;
  16. using SuperMap.Mapping;
  17. using System.IO;
  18. namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
  19. {
  20. public partial class BJdmt : ConditionPanel
  21. {
  22. public BJdmt()
  23. {
  24. this.ConditionPanelName = "节点图片信息管理";
  25. InitializeComponent();
  26. this.SetSize(800, 635);
  27. this.IsShowPanelFooter = false;
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. foreach (Layer lyr in ComsStatic.MapLayers)
  32. {
  33. if (lyr.Dataset.Type != DatasetType.Point) continue;
  34. uicbx.Items.Add(new DoListItem(lyr.Dataset.Name, lyr.Caption));
  35. }
  36. uicbx.SelectedIndex = 0;
  37. }
  38. private void uiButton1_Click(object sender, EventArgs e)
  39. {
  40. DatasetVector dv = ComsStatic.Datasource.Datasets[(uicbx.SelectedItem as DoListItem).Key] as DatasetVector;
  41. string sql = "";
  42. if (!string.IsNullOrEmpty(uitbkey.Text)) //sql = string.Format(" dmt like '%{0}%' ", uitbkey.Text);
  43. sql = string.Format("tz like '%{0}%' OR fsw like '%{0}%' OR xh like '%{0}%' OR dzms like '%{0}%'", uitbkey.Text);
  44. Recordset rd = dv.Query(sql, CursorType.Static);
  45. rd.MoveFirst();
  46. uilb.Items.Clear();
  47. while (!rd.IsEOF)
  48. {
  49. string mpValue = string.Format("{0} {1} {2} {3}", rd.GetFieldValue("tz"), rd.GetFieldValue("fsw"), rd.GetFieldValue("xh"), rd.GetFieldValue("dzms"));
  50. uilb.Items.Add(new DoListItem(rd.GetFieldValue("bsm").ToString(), mpValue));
  51. rd.MoveNext();
  52. }
  53. }
  54. private void uiButton3_Click(object sender, EventArgs e)
  55. {
  56. //if (uilb.SelectedItem == null) { UIMessageTip.ShowError("请选择图片对应的管点信息"); return; }
  57. //OpenFileDialog ofd = new OpenFileDialog
  58. //{
  59. // Filter = "Jpg 图片|*.jpg|Bmp 图片|*.bmp|Png 图片|*.png",
  60. // RestoreDirectory = true,
  61. // Title = "请选择需要上传的图片"
  62. //};
  63. //if (ofd.ShowDialog() != DialogResult.OK) return;
  64. //string imgFileName = ofd.FileName;
  65. //if (new FileInfo(imgFileName).Length > (1024 * 1000))
  66. //{
  67. // UIMessageTip.ShowError("请将图片缩放至1MB以内"); return;
  68. //}
  69. //try
  70. //{
  71. // File.Copy(imgFileName, Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + ".jpg", true);
  72. //}
  73. //catch (Exception ex)
  74. //{
  75. // ComsStatic.ShowErrorLog("图片上传失败", ex.Message); return;
  76. //}
  77. //UIMessageTip.ShowOk("图片上传成功");
  78. //using (FileStream lStream = new FileStream(imgFileName, FileMode.Open, FileAccess.Read))
  79. // picbox1.Image = Image.FromStream(lStream);
  80. }
  81. private void uilb_SelectedIndexChanged(object sender, EventArgs e)
  82. {
  83. string imgPath = Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + "-01.jpg";
  84. if (!File.Exists(imgPath))
  85. imgPath = Commons.Paths.ApplicationPictureDir + "\\no.png";
  86. using (FileStream lStream = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
  87. {
  88. picbox1.Image = Image.FromStream(lStream);
  89. picbox1.ImageLocation = imgPath;
  90. }
  91. imgPath = Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + "-02.jpg";
  92. if (!File.Exists(imgPath))
  93. imgPath = Commons.Paths.ApplicationPictureDir + "\\no.png";
  94. using (FileStream lStream = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
  95. {
  96. picbox2.Image = Image.FromStream(lStream);
  97. picbox2.ImageLocation = imgPath;
  98. }
  99. imgPath = Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + "-03.jpg";
  100. if (!File.Exists(imgPath))
  101. imgPath = Commons.Paths.ApplicationPictureDir + "\\no.png";
  102. using (FileStream lStream = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
  103. {
  104. picbox3.Image = Image.FromStream(lStream);
  105. picbox3.ImageLocation = imgPath;
  106. }
  107. imgPath = Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + "-04.jpg";
  108. if (!File.Exists(imgPath))
  109. imgPath = Commons.Paths.ApplicationPictureDir + "\\no.png";
  110. using (FileStream lStream = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
  111. {
  112. picbox4.Image = Image.FromStream(lStream);
  113. picbox4.ImageLocation = imgPath;
  114. }
  115. }
  116. private void pictureBox_DoubleClick(object sender, EventArgs e)
  117. {
  118. PictureBox pb = sender as PictureBox;
  119. if (File.Exists(pb.ImageLocation) && !pb.ImageLocation.Contains("no.png"))
  120. System.Diagnostics.Process.Start(pb.ImageLocation);
  121. }
  122. private void PicUpload_Click(object sender, EventArgs e)
  123. {
  124. if (uilb.SelectedItem == null) { UIMessageTip.ShowError("请选择图片对应的管点信息"); return; }
  125. OpenFileDialog ofd = new OpenFileDialog
  126. {
  127. Filter = "Jpg 图片|*.jpg|Bmp 图片|*.bmp|Png 图片|*.png",
  128. RestoreDirectory = true,
  129. Title = "请选择需要上传的图片"
  130. };
  131. if (ofd.ShowDialog() != DialogResult.OK) return;
  132. string imgFileName = ofd.FileName;
  133. if (new FileInfo(imgFileName).Length > (1024 * 1000))
  134. {
  135. UIMessageTip.ShowError("请将图片缩放至1MB以内"); return;
  136. }
  137. PictureBox pb = uicms.SourceControl as PictureBox;
  138. string uploadImg = Commons.Paths.ApplicationPictureDir + "\\" + (uilb.SelectedItem as DoListItem).Key + "-" + pb.Tag.ToString() + ".jpg";
  139. try
  140. {
  141. File.Copy(imgFileName, uploadImg, true);
  142. }
  143. catch (Exception ex)
  144. {
  145. ComsStatic.ShowErrorLog("图片上传失败", ex.Message); return;
  146. }
  147. ComsStatic.ShowOKLog("图片上传成功", pb.ImageLocation);
  148. using (FileStream lStream = new FileStream(uploadImg, FileMode.Open, FileAccess.Read))
  149. {
  150. pb.Image = Image.FromStream(lStream);
  151. pb.ImageLocation = uploadImg;
  152. }
  153. }
  154. private void PicDelete_Click(object sender, EventArgs e)
  155. {
  156. //if (!UIMessageDialog.ShowAskDialog(this.ParentForm, "提示", "确定删除该图片吗")) return;
  157. PictureBox pb = uicms.SourceControl as PictureBox;
  158. try
  159. {
  160. if (File.Exists(pb.ImageLocation) && !pb.ImageLocation.Contains("no.png"))
  161. new FileInfo(pb.ImageLocation).Delete();
  162. }
  163. catch (Exception ex)
  164. {
  165. ComsStatic.ShowErrorLog("图片删除失败", ex.Message); return;
  166. }
  167. ComsStatic.ShowOKLog("图片删除成功", pb.ImageLocation);
  168. pb.Image = null;
  169. pb.ImageLocation = "";
  170. }
  171. }
  172. }