using RichCreator.Utility;
using RichCreator.Utility.Captures;
using RichCreator.Utility.CV;
using RichCreator.Utility.InputControl;
using RichCreator.Utility.Structs;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using RichCreator.Editor.Tools;
using RichCreator.Editor.Tools.CV;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ZTImage;
using Orientation = RichCreator.Utility.Structs.Orientation;
using ZTImage.Collections;
namespace RichCreator.Editor
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
public MainWindow()
{
SelectColors = new ObservableCollection();
this.DataContext = this;
InitializeComponent();
}
private HardwareInputControl inputControl;
private Image sourceImage = null;
private Image targetImage = null;
private Image combinImage = null;
public ObservableCollection SelectColors
{
get;
private set;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
inputControl = new HardwareInputControl();
}
private void Window_Unloaded(object sender, RoutedEventArgs e)
{
this.inputControl.Close();
}
#region 文件
///
/// 加载图片
///
///
///
private void OpenFromFile(object sender, RoutedEventArgs e)
{
string imagePath = string.Empty;
Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
ofd.DefaultExt = ".jpg";
ofd.Filter = "jpg file|*.jpg";
ofd.Multiselect = false;
if (ofd.ShowDialog() == true)
{
imagePath = ofd.FileName;
}
else
{
return;
}
using (Mat source = CvInvoke.Imread(imagePath, Emgu.CV.CvEnum.ImreadModes.Color))
{
if (sourceImage != null)
{
sourceImage.Dispose();
}
sourceImage = new Image(source.Width, source.Height);
CvInvoke.CvtColor(source, sourceImage, Emgu.CV.CvEnum.ColorConversion.Rgb2Bgr);
targetImage = sourceImage;
}
SetImage(this.SourceImage, targetImage.Bitmap);
}
///
/// 截屏
///
///
///
private void OpenFromCapture(object sender, RoutedEventArgs e)
{
Application.Current.MainWindow.WindowState = WindowState.Minimized;
System.Threading.Thread.Sleep(1000);
System.Drawing.Bitmap bitmap = ScreenCapture.Instance.CaptureScreen();
if (sourceImage != null)
{
sourceImage.Dispose();
}
sourceImage = new Image(bitmap);
targetImage = sourceImage;
SetImage(this.SourceImage, bitmap);
Application.Current.MainWindow.WindowState = WindowState.Normal;
}
///
/// 粘贴
///
///
///
private void OpenFromClipboard(object sender, RoutedEventArgs e)
{
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Bitmap))
{
System.Windows.Interop.InteropBitmap content = iData.GetData(DataFormats.Bitmap) as System.Windows.Interop.InteropBitmap;
if (content == null)
{
return;
}
System.Drawing.Bitmap bitmap = ImageHelper.BitmapImageToBitmap(content);
if (sourceImage != null)
{
sourceImage.Dispose();
}
sourceImage = new Image(bitmap);
targetImage = sourceImage;
SetImage(this.SourceImage, bitmap);
}
}
///
/// 退出
///
///
///
private void Exit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
#endregion
#region 选区
///
/// 生成选区
///
///
///
private void GenericSection_Click(object sender, RoutedEventArgs e)
{
SerializeInput input = new SerializeInput();
if (input.ShowDialog() == true)
{
ColorArray colorBlock = ColorArray.FromThresholdString(input.ThresholdValue, input.ColorString);
for (int i = 0; i < colorBlock.Colors.Count; i++)
{
var item = colorBlock.Colors[i];
AddToColorList((Int32)(item.Offset.X + colorBlock.BasePosition.X),
(Int32)(item.Offset.Y + colorBlock.BasePosition.Y),
item.Color.Red,
item.Color.Green,
item.Color.Blue);
}
}
}
///
/// 复制选区
///
///
///
private void CopySelection_Click(object sender, RoutedEventArgs e)
{
string colorArray = SerialToString();
Clipboard.SetDataObject(colorArray, true);
}
///
/// 显示选区
///
///
///
private void ShowSelection_Click(object sender, RoutedEventArgs e)
{
ImageOverflowLayer.Children.Clear();
string colorArray = SerialToString();
ColorArray colorBlock = ColorArray.FromThresholdString(0, colorArray);
DrawRectangle(colorBlock.BasePosition.X, colorBlock.BasePosition.Y, colorBlock.Size.Width, colorBlock.Size.Height);
}
///
/// 计算选区hsv范围
///
///
///
private void CalcHsvRangeSelection_Click(object sender, RoutedEventArgs e)
{
ZTHsvFloatColor min = new ZTHsvFloatColor();
ZTHsvFloatColor max = new ZTHsvFloatColor();
for (int i = 0; i < ColorsListBox.SelectedItems.Count; i++)
{
SelectionColorItem sitem = ColorsListBox.SelectedItems[i] as SelectionColorItem;
if (sitem == null)
{
continue;
}
float h, s, v;
ColorUtils.RGBtoHSV(sitem.Color.R, sitem.Color.G, sitem.Color.B, out h, out s, out v);
if (i == 0)
{
min = new ZTHsvFloatColor(h, s, v);
max = new ZTHsvFloatColor(h, s, v);
}
if (h < min.H)
{
min.H = h;
}
if (s < min.S)
{
min.S = s;
}
if (v < min.V)
{
min.V = v;
}
if (h > max.H)
{
max.H = h;
}
if (s > max.S)
{
max.S = s;
}
if (v > max.V)
{
max.V = v;
}
}
string copyContent = $"min:{min.ToString()},max:{max.ToString()}";
Clipboard.SetDataObject(copyContent, true);
MessageBox.Show(copyContent, "已复制");
}
#endregion
#region 工具
///
/// 图片分割
///
///
///
private void Split_Click(object sender, RoutedEventArgs e)
{
Splitor splitor = new Splitor();
splitor.ShowDialog();
}
///
/// 样本训练
///
///
///
private void Train_Click(object sender, RoutedEventArgs e)
{
Trainor trainor = new Trainor();
trainor.ShowDialog();
}
///
/// 图像识别
///
///
///
private void ImageCheck_Click(object sender, RoutedEventArgs e)
{
MainCV mc = new MainCV();
mc.ShowDialog();
}
#endregion
#region 识别
///
/// 查找所有选区
///
///
///
private void FindSelection(object sender, RoutedEventArgs e)
{
string colorArray = SerialToString();
ColorArray colorBlock = ColorArray.FromColorString(0, 0, colorArray);
ZTRectangle rect = ZTRectangle.Empty;
ZTRectangle limit = new ZTRectangle(0, 0, this.targetImage.Width - 1, this.targetImage.Height - 1);
bool result = CVHelper.FindColorArray(out rect, this.targetImage, colorBlock, limit);
if (result)
{
DrawRectangle(rect.Start.X, rect.Start.Y, rect.End.X - rect.Start.X + 1, rect.End.Y - rect.Start.Y + 1, Colors.Green);
}
else
{
MessageBox.Show("未找到");
}
}
//Hsv查找选区
private void FindSelectionForHsv(object sender, RoutedEventArgs e)
{
Int32 thresholdValue = (Int32)this.ThresholdSlider.Value;
string colorString = SerialToString();
ColorArray colorArray = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, colorString);
ZTRectangle rect = ZTRectangle.Empty;
ZTRectangle limit = new ZTRectangle(0, 0, this.targetImage.Width - 1, this.targetImage.Height - 1);
bool result = CVHelper.FindColorArray(out rect, this.targetImage, colorArray, limit);
if (result)
{
DrawRectangle(rect.Start.X, rect.Start.Y, rect.End.X - rect.Start.X + 1, rect.End.Y - rect.Start.Y + 1, Colors.Green);
}
else
{
MessageBox.Show("未找到");
}
}
///
/// Thresold查找选取
///
///
///
private void FindSelectionForThresold(object sender, RoutedEventArgs e)
{
Int32 thresholdValue = (Int32)this.ThresholdSlider.Value;
string colorString = SerialToString();
ColorArray colorArray = ColorArray.FromThresholdString(thresholdValue, colorString);
ZTRectangle rect = ZTRectangle.Empty;
ZTRectangle limit = new ZTRectangle(0, 0, this.targetImage.Width - 1, this.targetImage.Height - 1);
bool result = CVHelper.FindColorArrayForThreshold(out rect, this.sourceImage, colorArray, limit);
if (result)
{
DrawRectangle(rect.Start.X, rect.Start.Y, rect.End.X - rect.Start.X + 1, rect.End.Y - rect.Start.Y + 1, Colors.Green);
}
else
{
MessageBox.Show("未找到");
}
}
///
/// 查找所有方块
///
///
///
private void FindBlock(object sender, RoutedEventArgs e)
{
//转为hsv
Image hsv = new Image(this.targetImage.Width, this.targetImage.Height);
CvInvoke.CvtColor(this.targetImage, hsv, ColorConversion.Rgb2Hsv);
Direction d;
//List rects = CVHelper.FindBlocks(hsv, new Hsv(165, 247, 175), new Hsv(173, 255, 230), new ZTSize(30, 30));
Hsv minHsv = new Hsv(0, 0, 178);
Hsv maxHsv = new Hsv(180, 0, 229);
ZTSize blockSize = new ZTSize(40, 20);
List rects = CVHelper.FindBlocks(hsv, minHsv, maxHsv, blockSize);
int x, y, width, height;
for (int i = 0; i < rects.Count; i++)
{
x = rects[i].Start.X;
y = rects[i].Start.Y;
width = rects[i].End.X - x + 1;
height = rects[i].End.Y - y + 1;
DrawRectangle(x, y, width, height, Colors.Green);
}
}
///
/// 查找所有方块
///
///
///
private void FindRectangle(object sender, RoutedEventArgs e)
{
ZTHsvFloatColor min = new ZTHsvFloatColor(0.050f, 0.246f, 0.549);
ZTHsvFloatColor max = new ZTHsvFloatColor(0.1f, 0.576f, 0.890f);
//转为hsv
ZTRectangle rect = ZTRectangle.Empty;
int x, y, width, height;
//ZTLine line = ZTLine.Empty;
//if (CVHelper.FindLine(out line, this.targetImage, 40, CVHelper.Orientation.Horizontal, min, max))
//{
// DrawRectangle(line.X, line.Y, line.Length, 1);
//}
if (CVHelper.FindRectangle(out rect, this.targetImage, new ZTSize(40, 10), 10, min, max))
{
x = rect.Start.X;
y = rect.Start.Y;
width = rect.End.X - x + 1;
height = rect.End.Y - y + 1;
DrawRectangle(x, y, width, height, Colors.Green);
}
}
public static ColorArray JiabailiCloseButton = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, "521,541,255,255,204$532,541,255,255,204$531,541,255,255,204$531,542,255,255,187$530,542,255,255,187$530,543,255,255,187$529,543,255,255,187$529,544,255,238,187$528,544,255,238,187$527,546,238,221,170$526,546,238,221,170$522,541,255,255,204$522,542,255,255,187$523,542,255,255,187$523,543,255,255,187$524,543,255,255,187$521,551,204,187,119$522,551,204,187,119$522,550,221,187,136$523,550,221,187,136$523,549,221,204,136$524,549,221,204,136$532,551,204,187,119$531,551,204,187,119$531,550,221,187,136$530,550,221,187,136$530,549,221,204,136$529,549,221,204,136");
public static ColorArray JiabailiSaleButton = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, "204,516,221,197,147$184,508,221,197,147$184,511,221,197,147$188,511,221,197,147$188,507,221,197,147$192,508,221,197,147$192,511,221,197,147$193,514,221,197,147$193,518,221,197,147$188,517,221,197,147$183,517,221,197,147$183,514,221,197,147$196,516,221,197,147$204,518,221,197,147$196,518,221,197,147$196,514,221,197,147$198,508,221,197,147$201,508,221,197,147$201,507,221,197,147$205,508,221,197,147$204,512,221,197,147$205,514,221,197,147");
///
/// 查找加百利
///
///
///
private void FindJiaBaili(object sender, RoutedEventArgs e)
{
Image image = this.targetImage;
ZTRectangle closeButtonPosition = ZTRectangle.Empty;
ZTRectangle limit = new ZTRectangle(0, 0, image.Width, image.Height);
ZTRectangle position = ZTRectangle.Empty;
if (CVHelper.FindColorArray(out position, image, JiabailiCloseButton, limit))
{
DrawRectangle(position.GetCenterPoint().X, position.GetCenterPoint().Y, 15, 15, Colors.Green);
}
if (CVHelper.FindColorArray(out position, image, JiabailiSaleButton, limit))
{
DrawRectangle(position.GetCenterPoint().X, position.GetCenterPoint().Y, 15, 15, Colors.Green);
}
}
///
/// 查找定位点
///
///
///
private void FindLocationPoint_Click(object sender, RoutedEventArgs e)
{
Image hsvImage = new Image(this.targetImage.Width, this.targetImage.Height);
CvInvoke.CvtColor(this.targetImage, hsvImage, Emgu.CV.CvEnum.ColorConversion.Rgb2Hsv);
MultiList list = new MultiList();
ZTRectangle limit = new ZTRectangle(0, 0, this.targetImage.Width, this.targetImage.Height);
if (DnfCVHelper.GetLocationPoint(out list,hsvImage,limit))
{
//找到位置显示出来
for (int i = 0; i < list.Count; i++)
{
ZTRectangle rect = list[i].Item1;
Int32 number = list[i].Item2;
DrawRectangle(rect.Start.X, rect.Start.Y, rect.End.X - rect.Start.X, rect.End.Y - rect.Start.Y, Colors.Green,number);
}
}
}
///
/// 找线
///
///
///
private void FindLines(object sender, RoutedEventArgs e)
{
//List list=DnfCVHelper.GetEquipmentIndexs(this.targetImage ,new ZTPoint(516, 401));
//string all = string.Empty;
//for (int i =0; i < list.Count; i++)
//{
// all += list[i].ToString() + ",";
//}
//MessageBox.Show(all);
List points = DnfCVHelper.GetThingItemPoints(this.targetImage, new ZTRectangle(0, 0, this.targetImage.Width - 1, this.targetImage.Height - 1));
for (int i = 0; i < points.Count; i++)
{
ZTPoint line = points[i];
DrawRectangle(line.X, line.Y, 5, 5, Colors.Yellow);
}
}
#endregion
///
/// 设置图像
///
///
///
private void SetImage(Image control, System.Drawing.Image image)
{
BitmapImage t = ImageHelper.BitmapToImageSource(image);
control.Source = t;
if (control == this.SourceImage)
{
mainContainer.Width = image.Width;
mainContainer.Height = image.Height;
}
}
///
/// 图形模式
///
///
///
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.targetImage == null)
{
return;
}
switch (this.ImageProccessModel.SelectedIndex)
{
case 0:
//原图
this.ThresholdSlider.IsEnabled = true;
targetImage = this.sourceImage;
break;
case 1:
//灰度
this.ThresholdSlider.IsEnabled = true;
targetImage = this.sourceImage.Convert().Convert();
break;
case 2:
//二值
this.ThresholdSlider.IsEnabled = true;
using (Image temp = this.sourceImage.Convert())
{
//temp._EqualizeHist();//均衡化
this.targetImage = temp.ThresholdBinary(new Gray(this.ThresholdSlider.Value), new Gray(255)).Convert();
}
break;
}
SetImage(this.SourceImage, targetImage.Bitmap);
}
///
/// 二值化阀值变化
///
///
///
private void ThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
if (this.targetImage == null)
{
return;
}
using (Image temp = this.sourceImage.Convert())
{
//temp._EqualizeHist();//均衡化
this.targetImage = temp.ThresholdBinary(new Gray(e.NewValue), new Gray(255)).Convert();
SetImage(this.SourceImage, this.targetImage.Bitmap);
}
}
///
/// 移动鼠标
///
///
///
private void SourceImage_MouseMove(object sender, MouseEventArgs e)
{
if (this.targetImage == null)
{
return;
}
Point point = default(Point);
Color color = default(Color);
if (!GetPosition(e, out point, out color))
{
return;
}
Canvas.SetLeft(this.SelectArea, point.X);
Canvas.SetTop(this.SelectArea, point.Y);
this.pointX.Text = point.X.ToString();
this.pointY.Text = point.Y.ToString();
this.colorShow.Fill = new SolidColorBrush(color);
this.colorHexInfo.Text = color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
this.colorOctInfo.Text = color.R.ToString() + "," + color.G.ToString() + "," + color.B.ToString();
float h, s, v;
ColorUtils.RGBtoHSV(color.R, color.G, color.B, out h, out s, out v);
this.colorHsvInfo.Text = h.ToString("0.000") + s.ToString("0.000") + v.ToString("0.000");
using (Image sub = GetPreviewImage((Int32)(point.X - 8), (Int32)(point.Y - 8), 17, 17))
{
BitmapSource bs = ImageHelper.BitmapToImageSource(sub.Bitmap);
this.PreViewImage.Source = bs;
}
}
///
/// 清空选中的颜色
///
///
///
private void ClearSelect_Click(object sender, RoutedEventArgs e)
{
this.SelectColors.Clear();
ImageOverflowLayer.Children.Clear();
}
///
/// 取色
///
///
///
private void SourceImage_MouseDown(object sender, MouseButtonEventArgs e)
{
if (this.targetImage == null)
{
return;
}
if (e.LeftButton == MouseButtonState.Released)
{
return;
}
Point point = default(Point);
Color color = default(Color);
if (!GetPosition(e, out point, out color))
{
return;
}
int width = TypeConverter.StringToInt(this.SelectAreaWidth.Text, 1);
int height = TypeConverter.StringToInt(this.SelectAreaHeight.Text, 1);
if (width == 1 && height == 1)
{
AddToColorList((Int32)(point.X), (Int32)(point.Y), color.R, color.G, color.B);
}
else
{
int maxWidth = Math.Min((Int32)point.X + width, this.targetImage.Width);
int maxHeight = Math.Min((Int32)point.Y + height, this.targetImage.Height);
byte r, g, b;
byte cr, cg, cb;
for (int fy = (Int32)point.Y; fy < maxHeight; fy++)
{
for (int fx = (Int32)point.X; fx < maxWidth; fx++)
{
r = this.targetImage.Data[fy, fx, 0];
g = this.targetImage.Data[fy, fx, 1];
b = this.targetImage.Data[fy, fx, 2];
if (combinImage != null)
{
cr = this.combinImage.Data[fy, fx, 0];
cg = this.combinImage.Data[fy, fx, 1];
cb = this.combinImage.Data[fy, fx, 2];
if (cr == r && cg == g && cb == b)
{
AddToColorList(fx, fy, r, g, b);
}
}
else
{
AddToColorList(fx, fy, r, g, b);
}
}
}
}
}
///
/// 删除列表选中项
///
///
///
private void RemvoeSelectItem_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < ColorsListBox.SelectedItems.Count; i++)
{
SelectionColorItem sitem = ColorsListBox.SelectedItems[i] as SelectionColorItem;
if (sitem == null)
{
continue;
}
this.SelectColors.Remove(sitem);
}
}
///
/// 按键快捷键
///
///
///
private void A_KeyDown(object sender, KeyEventArgs e)
{
if (inputControl == null)
{
return;
}
switch (e.Key)
{
case Key.W:
//上
inputControl.Move(0, -1, false, false, false);
e.Handled = true;
break;
case Key.S:
//下
inputControl.Move(0, 1, false, false, false);
break;
case Key.A:
//左
inputControl.Move(-1, 0, false, false, false);
break;
case Key.D:
//右
inputControl.Move(1, 0, false, false, false);
break;
}
}
///
/// 选区宽度变化时
///
///
///
private void SelectAreaWidth_TextChanged(object sender, TextChangedEventArgs e)
{
if (this.targetImage == null)
{
return;
}
Int32 width = TypeConverter.StringToInt(this.SelectAreaWidth.Text, 0);
if (width < 1)
{
MessageBox.Show("宽度不能小于1");
this.SelectAreaWidth.Text = "1";
width = 1;
}
this.SelectArea.Width = width;
Int32 height = TypeConverter.StringToInt(this.SelectAreaHeight.Text, 0);
if (height < 1)
{
MessageBox.Show("高度不能小于1");
this.SelectAreaHeight.Text = "1";
height = 1;
}
this.SelectArea.Height = height;
if (width > 1 || height > 1)
{
this.SelectArea.Visibility = Visibility.Visible;
}
else
{
this.SelectArea.Visibility = Visibility.Hidden;
}
}
///
/// 叠加层选中
///
///
///
private void HasCombinLayer_Checked(object sender, RoutedEventArgs e)
{
if (this.targetImage == null)
{
return;
}
bool has = this.HasCombinLayer.IsChecked.HasValue && this.HasCombinLayer.IsChecked.Value;
if (has)
{
this.combinImage = this.targetImage;
}
else
{
this.combinImage = null;
}
}
#region Tools
///
/// 序列化为字符串
///
///
private string SerialToString()
{
StringBuilder builder = new StringBuilder();
bool exist = false;
for (int i = 0; i < ColorsListBox.SelectedItems.Count; i++)
{
SelectionColorItem sitem = ColorsListBox.SelectedItems[i] as SelectionColorItem;
if (sitem == null)
{
return string.Empty;
}
if (exist)
{
builder.Append("$");
}
builder.Append(sitem.X).Append(",").Append(sitem.Y).Append(",").Append(sitem.Color.R).Append(",").Append(sitem.Color.G).Append(",").Append(sitem.Color.B);
exist = true;
}
return builder.ToString();
}
///
/// 在Canvas上画矩形
///
///
///
///
///
private void DrawRectangle(Int32 x, Int32 y, Int32 width, Int32 height, Color color,Int32 number=-1)
{
Rectangle rect = new Rectangle();
rect.Stroke = new SolidColorBrush(color);
rect.StrokeThickness = 1;
rect.Width = width;
rect.Height = height;
Canvas.SetLeft(rect, x);
Canvas.SetTop(rect, y);
ImageOverflowLayer.Children.Add(rect);
TextBlock tb = new TextBlock();
tb.Text = "(" + x.ToString() + "," + y.ToString() + "$" + width.ToString() + "," + height.ToString() +( number>=0?",n:"+number.ToString():string.Empty)+")";
tb.Foreground = new SolidColorBrush(color);
Canvas.SetLeft(tb, x);
Canvas.SetTop(tb, y + height + 2);
ImageOverflowLayer.Children.Add(tb);
}
private void DrawRectangle(Int32 x, Int32 y, Int32 width, Int32 height)
{
DrawRectangle(x, y, width, height, Colors.Red);
}
///
/// 计算当前鼠标位置和颜色
///
///
///
///
///
private bool GetPosition(MouseEventArgs e, out Point point, out Color color)
{
point = e.GetPosition(this.scrollViewer);
color = Colors.Transparent;
Int32 x = (Int32)Math.Round(this.scrollViewer.HorizontalOffset + point.X);
Int32 y = (Int32)Math.Round(this.scrollViewer.VerticalOffset + point.Y);
if (x >= this.sourceImage.Width || y >= this.sourceImage.Height)
{
return false;
}
point = new Point(x, y);
byte red = targetImage.Data[y, x, 0];
byte green = targetImage.Data[y, x, 1];
byte blue = targetImage.Data[y, x, 2];
color = Color.FromRgb(red, green, blue);
return true;
}
///
/// 得到子图像
///
///
///
///
///
///
public Image GetPreviewImage(Int32 x, Int32 y, Int32 width, Int32 height)
{
Int32 sourceX = 0;
Int32 sourceY = 0;
Int32 targetX = 0;
Int32 targetY = 0;
Int32 newWidth = 0;
Int32 newHeight = 0;
if (x < 0)
{
newWidth = width + x;
sourceX = 0;
targetX = width - newWidth;
}
else
{
newWidth = Math.Min(width, this.targetImage.Width - x);
sourceX = x;
targetX = 0;
}
if (y < 0)
{
newHeight = height + y;
sourceY = 0;
targetY = height - newHeight;
}
else
{
newHeight = Math.Min(height, this.targetImage.Height - y);
sourceY = y;
targetY = 0;
}
Image sub = this.targetImage.GetSubRect(new System.Drawing.Rectangle(sourceX, sourceY, newWidth, newHeight));
if (newWidth == width && newHeight == height)
{
return sub;
}
Image newsub = new Image(width, height);
for (int row = 0; row < newHeight; row++)
{
Int32 trow = row + targetY;
for (int col = 0; col < newWidth; col++)
{
Int32 tcol = col + targetX;
newsub.Data[trow, tcol, 0] = sub.Data[row, col, 0];
newsub.Data[trow, tcol, 1] = sub.Data[row, col, 1];
newsub.Data[trow, tcol, 2] = sub.Data[row, col, 2];
}
}
sub.Dispose();
return newsub;
}
private Int32 index = 0;
///
/// 添加到色彩列表
///
///
///
///
///
///
private void AddToColorList(Int32 x, Int32 y, byte r, byte g, byte b)
{
this.SelectColors.Add(new SelectionColorItem(
index,
r.ToString("X2") + g.ToString("X2") + b.ToString("X2"),
x, y,
Color.FromRgb(r, g, b)));
index++;
}
///
/// 转换为查找方块时的灰度
///
///
///
private void BlockGray(object sender, RoutedEventArgs e)
{
//转为hsv
Image hsv = new Image(this.targetImage.Width, this.targetImage.Height);
CvInvoke.CvtColor(this.targetImage, hsv, ColorConversion.Rgb2Hsv);
List rects = CVHelper.FindBlocks(hsv, new Hsv(165, 247, 175), new Hsv(173, 255, 230), new ZTSize(30, 30));
Image gray = hsv.InRange(new Hsv(165, 247, 175), new Hsv(173, 255, 230));
this.targetImage = gray.Convert();
SetImage(this.SourceImage, gray.Bitmap);
}
#endregion
///
/// 清理canvas
///
///
///
private void ClearCanvas(object sender, RoutedEventArgs e)
{
this.ImageOverflowLayer.Children.Clear();
}
///
/// 选择颜色项
///
public class SelectionColorItem
{
public SelectionColorItem(Int32 id, string colorText, Int32 x, Int32 y, Color color)
{
this.ID = id;
this.ColorText = colorText;
this.X = x;
this.Y = y;
this.Color = color;
}
public Int32 ID { get; set; }
///
/// 颜色文本
///
public string ColorText { get; set; }
public Int32 X { get; set; }
public Int32 Y { get; set; }
public Color Color { get; set; }
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
//鼠标识别
MouseTest mt = new MouseTest();
mt.ShowDialog();
}
//private void AStarTools_Click(object sender, RoutedEventArgs e)
//{
// AStarTools window = new AStarTools();
// window.ShowDialog();
//}
private void DijkstraTools_Click(object sender, RoutedEventArgs e)
{
MapEditor window = new MapEditor();
window.ShowDialog();
}
//private void test_click(object sender, RoutedEventArgs e)
//{
// string content = "%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3Cexchange%3E%3CErrCode%3E0%3C%2FErrCode%3E%3CErrMessage%3E%E6%88%90%E5%8A%9F%EF%BC%81%3C%2FErrMessage%3E%3Cbody1%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3850%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E7%99%BD%E7%BB%86%E8%83%9E%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody1%3E%3Cbody2%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3851%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E4%BA%9A%E7%A1%9D%E9%85%B8%E7%9B%90%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody2%3E%3Cbody3%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3852%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E6%AD%A3%E5%B8%B8%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E5%B0%BF%E8%83%86%E5%8E%9F%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody3%3E%3Cbody4%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3853%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E8%9B%8B%E7%99%BD%E8%B4%A8%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody4%3E%3Cbody5%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3854%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E5.0%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E4.5-8.0%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3EPH%E5%80%BC%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody5%3E%3Cbody6%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3855%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E5%B0%BF%E6%BD%9C%E8%A1%80%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody6%3E%3Cbody7%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3856%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E1.030%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E1.003-1.030%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E6%AF%94%E9%87%8D%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody7%3E%3Cbody8%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3857%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E2%2B%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E0-5.7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E6%8A%97%E5%9D%8F%E8%A1%80%E9%85%B8Vc%3C%2FItemName%3E%3CUnit%3Emmol%2FL%3C%2FUnit%3E%3C%2Fbody8%3E%3Cbody9%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3858%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E9%85%AE%E4%BD%93%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody9%3E%3Cbody10%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3859%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E8%83%86%E7%BA%A2%E7%B4%A0%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody10%3E%3Cbody11%3E%3CReportNo%3E15%3C%2FReportNo%3E%3CResultID%3E3860%3C%2FResultID%3E%3CTestNum%3E271%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170145%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A13%3A45%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A13%3A45%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FOptName%3E%3CCheckName%3E%E9%98%BF%E5%8D%9C%E6%9D%9C%E7%83%AD%E5%90%88%E6%9B%BC%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A15%3A46%3C%2FPrintTime%3E%3CLockBar%3E33700%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E-%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%E9%98%B4%E6%80%A7%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E8%91%A1%E8%90%84%E7%B3%96%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody11%3E%3Cbody12%3E%3CReportNo%3E16%3C%2FReportNo%3E%3CResultID%3E3881%3C%2FResultID%3E%3CTestNum%3E2%3C%2FTestNum%3E%3CTestDate%3E2019%2F4%2F17%3C%2FTestDate%3E%3CName%3E%E7%8E%8B%E5%88%9A%3C%2FName%3E%3CSex%3E%E5%A5%B3%3C%2FSex%3E%3CAge%3E26%E5%B2%81%3C%2FAge%3E%3CPid%3E130125199304015555%3C%2FPid%3E%3CDepartment%3E%3C%2FDepartment%3E%3CDoctor%3E%3C%2FDoctor%3E%3CPatType%3E%3C%2FPatType%3E%3CLCZD%3E%3C%2FLCZD%3E%3CBedNum%3E%3C%2FBedNum%3E%3CBarCode%3E1904170148%3C%2FBarCode%3E%3CSampleState%3E%E6%AD%A3%E5%B8%B8%3C%2FSampleState%3E%3CSample%3E%3C%2FSample%3E%3CTestTime%3E2019%2F4%2F17+23%3A23%3A21%3C%2FTestTime%3E%3CSampleDate%3E2019%2F4%2F17+23%3A23%3A21%3C%2FSampleDate%3E%3CComment%3E%3C%2FComment%3E%3COptName%3E%E5%B7%B4%E5%93%88%E5%B0%94%E5%8F%A4%E4%B8%BD%3C%2FOptName%3E%3CCheckName%3Eadmin%3C%2FCheckName%3E%3CPrintName%3E%3C%2FPrintName%3E%3CPrintTime%3E2019%2F4%2F17+23%3A24%3A43%3C%2FPrintTime%3E%3CLockBar%3E33717%3C%2FLockBar%3E%3CSCode%3E%E5%B8%B8%E8%A7%84%3C%2FSCode%3E%3CResult%3E%E5%AE%AB%E9%A2%88%E7%82%8E%3C%2FResult%3E%3CState%3E%3C%2FState%3E%3CLimit%3E%3C%2FLimit%3E%3CEName%3E%3C%2FEName%3E%3CItemName%3E%E5%AE%AB%E9%A2%88%3C%2FItemName%3E%3CUnit%3E%3C%2FUnit%3E%3C%2Fbody12%3E%3C%2Fexchange%3E";
// string fileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sys.xml");
// content = ZTImage.Text.Coding.DecodeURI(content);
// System.IO.File.WriteAllText(fileName, content);
// MessageBox.Show("test");
//}
}
}