├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── VisionMix.sln
├── Yoga.Camera
├── BaslerCamera.cs
├── CameraBase.cs
├── CameraManger.cs
├── CameraOperator.cs
├── CameraPram.cs
├── DHCamera.cs
├── DirectShowCamera.cs
├── EnumInfo.cs
├── Fps.cs
├── GigeCamera.cs
├── HikvisionCamera.cs
├── ICImagingCamera.cs
├── IOSerial.cs
├── ImageEventArgs.cs
├── MVGigE.cs
├── MVSDK.cs
├── MicrovisionCamera.cs
├── MindCamera.cs
├── Properties
│ └── AssemblyInfo.cs
├── Yoga.Camera.csproj
├── frmCameraSetting.Designer.cs
├── frmCameraSetting.cs
└── frmCameraSetting.resx
├── Yoga.Common
├── Basic
│ ├── CommonJsonModel.cs
│ ├── CommunicationParam.cs
│ ├── GDI.cs
│ ├── ISerializeCheck.cs
│ ├── MessageEventArgs.cs
│ ├── MessageQueue.cs
│ ├── SoftAuthorize.cs
│ ├── SoftBasic.cs
│ ├── StringResources.cs
│ ├── frmImputText.Designer.cs
│ ├── frmImputText.cs
│ └── frmImputText.resx
├── FileAct
│ ├── CsvFiles.cs
│ ├── FileManger.cs
│ ├── INIOperation.cs
│ └── SerializationFile.cs
├── Helpers
│ ├── ApplicationHelper.cs
│ ├── EnumHelper.cs
│ ├── IPHelper.cs
│ ├── ImageWaterHelper.cs
│ ├── MessageHelper.cs
│ ├── QueueHelper.cs
│ ├── RegexHelper.cs
│ ├── RegisterHelper.cs
│ ├── RegisterTool.cs
│ ├── ScreenHelper.cs
│ ├── SerialHelper.cs
│ ├── ShareDataHelper.cs
│ ├── StartupHelper.cs
│ ├── StringHelper.cs
│ └── WindowsHelper.cs
├── ImageProcess
│ └── HImageExt.cs
├── MotionControl
│ ├── CommBase.cs
│ ├── DataAcquisition.cs
│ ├── GT400.cs
│ ├── GT400Comm.cs
│ ├── GTSMoveCard.cs
│ ├── GtsManger.cs
│ ├── MoveCard.cs
│ └── gts.cs
├── PrinterHelper
│ ├── IPrinter.cs
│ ├── PrintQueueHelper.cs
│ ├── Printer.cs
│ └── PrinterFactory.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── _return.gif
│ └── waiting.gif
├── TCPHelper
│ ├── Coder.cs
│ ├── DatagramResolver.cs
│ ├── NetEventArgs.cs
│ ├── Session.cs
│ ├── SessionId.cs
│ ├── TCPClientHelper.cs
│ └── TCPServerHelper.cs
├── UI
│ ├── AgileProgressBar.Designer.cs
│ ├── AgileProgressBar.cs
│ ├── AgileProgressBar.resx
│ ├── FrmLoad.Designer.cs
│ ├── FrmLoad.cs
│ ├── FrmLoad.resx
│ ├── IpTextBoxExt.Designer.cs
│ ├── IpTextBoxExt.cs
│ ├── IpTextBoxExt.resx
│ ├── SevenSegment.Designer.cs
│ ├── SevenSegment.cs
│ ├── SevenSegmentArray.Designer.cs
│ ├── SevenSegmentArray.cs
│ ├── frmWaitingBox.Designer.cs
│ ├── frmWaitingBox.cs
│ └── frmWaitingBox.resx
├── Util.cs
├── VBAEngine
│ ├── AutofillText.cs
│ ├── GlobalObject.cs
│ ├── HotKeyManager.cs
│ ├── SearchManager.cs
│ ├── VbaEditBox.Designer.cs
│ ├── VbaEditBox.cs
│ ├── VbaEditBox.resx
│ ├── VbaFunction.cs
│ └── XVBAEngine.cs
├── Yoga.Common.csproj
├── log4net.config
├── log4net.dll
└── packages.config
├── Yoga.ImageControl
├── EnumInfo.cs
├── FunctionPlot.cs
├── FunctionPlotUnit.Designer.cs
├── FunctionPlotUnit.cs
├── FunctionPlotUnit.resx
├── GraphicsContext.cs
├── HObjectEntry.cs
├── HWndCtrl.cs
├── HWndMessage.cs
├── HWndUnit.Designer.cs
├── HWndUnit.cs
├── HWndUnit.resx
├── Mode.cs
├── PictureUnit.Designer.cs
├── PictureUnit.cs
├── PictureUnit.resx
├── Properties
│ └── AssemblyInfo.cs
├── ROI.cs
├── ROIActUnit.Designer.cs
├── ROIActUnit.cs
├── ROIActUnit.resx
├── ROICircle.cs
├── ROICircularArc.cs
├── ROIController.cs
├── ROIEventArgs.cs
├── ROILine.cs
├── ROIRectangle1.cs
├── ROIRectangle2.cs
├── ShowMessageEventArgs.cs
└── Yoga.ImageControl.csproj
├── Yoga.Native
├── DynThresholdParamN.h
├── GraphicsContext.cpp
├── GraphicsContext.h
├── HObjectEntry.cpp
├── HObjectEntry.h
├── HWndMessage.cpp
├── HWndMessage.h
├── MyMD5.cpp
├── MyMD5.h
├── NativeFitPlane.cpp
├── NativeFitPlane.h
├── NativeFun.cpp
├── NativeFun.h
├── NativeShowUnit.cpp
├── NativeShowUnit.h
├── OcrParamN.h
├── ReadMe.txt
├── Util.cpp
├── Util.h
├── Yoga.Native.cpp
├── Yoga.Native.h
├── Yoga.Native.vcxproj
├── Yoga.Native.vcxproj.filters
├── dllmain.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── Yoga.Test
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── Yoga.Test.csproj
├── Yoga.Tools.Matching
├── Matching
│ ├── MatchingOpt.cs
│ ├── MatchingOptSpeed.cs
│ ├── MatchingOptStatistics.cs
│ ├── MatchingParam.cs
│ ├── MatchingResult.cs
│ ├── MatchingStatus.cs
│ ├── MatchingTool.cs
│ ├── MatchingToolUnit.Designer.cs
│ ├── MatchingToolUnit.cs
│ └── MatchingToolUnit.resx
├── NccMatching
│ ├── NccMatchingTool.cs
│ ├── NccMatchingToolUnit.Designer.cs
│ ├── NccMatchingToolUnit.cs
│ └── NccMatchingToolUnit.resx
├── Properties
│ └── AssemblyInfo.cs
└── Yoga.Tools.Matching.csproj
├── Yoga.Tools.ReadCode
├── BarCode
│ ├── BarCodeTool.cs
│ ├── BarCodeToolUnit.Designer.cs
│ ├── BarCodeToolUnit.cs
│ └── BarCodeToolUnit.resx
├── Code2D
│ ├── Code2DTool.cs
│ ├── Code2DToolUnit.Designer.cs
│ ├── Code2DToolUnit.cs
│ └── Code2DToolUnit.resx
├── Properties
│ └── AssemblyInfo.cs
├── Yoga.Tools.ReadCode.csproj
└── packages.config
├── Yoga.Tools.Util
├── AngleFind
│ ├── AngleFindTool.cs
│ ├── AngleFindToolUnit.Designer.cs
│ ├── AngleFindToolUnit.cs
│ └── AngleFindToolUnit.resx
├── Calib9Point
│ ├── Calib9PointTool.cs
│ ├── Calib9PointToolUnit.Designer.cs
│ ├── Calib9PointToolUnit.cs
│ └── Calib9PointToolUnit.resx
├── DynThreshold
│ ├── DynThresholdTool.cs
│ ├── DynThresholdToolUnit.Designer.cs
│ ├── DynThresholdToolUnit.cs
│ └── DynThresholdToolUnit.resx
├── ExtractColor
│ ├── ExtractColorTool.cs
│ ├── ExtractColorToolUnit.Designer.cs
│ ├── ExtractColorToolUnit.cs
│ └── ExtractColorToolUnit.resx
├── Metrology
│ ├── FitlineTool.cs
│ ├── MetrologyMessage.cs
│ ├── MetrologyParam.cs
│ ├── MetrologyResult.cs
│ ├── MetrologyTool.cs
│ ├── MetrologyToolUnit.Designer.cs
│ ├── MetrologyToolUnit.cs
│ └── MetrologyToolUnit.resx
├── OCR
│ ├── OCRTool.cs
│ ├── OCRToolUnit.Designer.cs
│ ├── OCRToolUnit.cs
│ ├── OCRToolUnit.resx
│ └── OcrPram.cs
├── OcrHand
│ ├── OcrHandTool.cs
│ ├── OcrHandToolUnit.Designer.cs
│ ├── OcrHandToolUnit.cs
│ └── OcrHandToolUnit.resx
├── PlaneFun
│ └── PlaneFun.cs
├── PretreatImage
│ ├── PretreatImageTool.cs
│ ├── PretreatImageToolUnit.Designer.cs
│ ├── PretreatImageToolUnit.cs
│ └── PretreatImageToolUnit.resx
├── PrintCheck
│ ├── EnumInfo.cs
│ ├── PrintCheckEventArgs.cs
│ ├── PrintCheckTool.cs
│ ├── PrintCheckToolUnit.Designer.cs
│ ├── PrintCheckToolUnit.cs
│ └── PrintCheckToolUnit.resx
├── Properties
│ └── AssemblyInfo.cs
├── TextureInspection
│ ├── TextureInspectionTool.cs
│ ├── TextureInspectionToolUnit.Designer.cs
│ ├── TextureInspectionToolUnit.cs
│ └── TextureInspectionToolUnit.resx
├── VBA
│ ├── VabToolUnit.Designer.cs
│ ├── VabToolUnit.cs
│ ├── VabToolUnit.resx
│ └── VbaTool.cs
└── Yoga.Tools.Util.csproj
├── Yoga.Tools
├── CreateImage
│ ├── CreateImageTool.cs
│ ├── CreateImageUnit.Designer.cs
│ ├── CreateImageUnit.cs
│ └── CreateImageUnit.resx
├── Factory
│ ├── AllInterface.cs
│ ├── Mat2DManger.cs
│ ├── Mat2DMangerUnit.Designer.cs
│ ├── Mat2DMangerUnit.cs
│ ├── Mat2DMangerUnit.resx
│ ├── PointD.cs
│ ├── RunStatus.cs
│ ├── SacleImagePretreatment.cs
│ ├── SacleImagePretreatmentUnit.Designer.cs
│ ├── SacleImagePretreatmentUnit.cs
│ ├── SacleImagePretreatmentUnit.resx
│ ├── SettingThread.cs
│ ├── ToolBase.cs
│ ├── ToolReflection.cs
│ ├── ToolShowUnit.Designer.cs
│ ├── ToolShowUnit.cs
│ ├── ToolShowUnit.resx
│ ├── ToolVbaFun.cs
│ ├── ToolsFactory.cs
│ ├── ToolsSettingUnit.Designer.cs
│ ├── ToolsSettingUnit.cs
│ ├── ToolsSettingUnit.resx
│ ├── frmSelectCameraIndex.Designer.cs
│ ├── frmSelectCameraIndex.cs
│ ├── frmSelectCameraIndex.resx
│ ├── frmToolSelect.Designer.cs
│ ├── frmToolSelect.cs
│ ├── frmToolSelect.resx
│ ├── frmToolSetting.Designer.cs
│ ├── frmToolSetting.cs
│ └── frmToolSetting.resx
├── Properties
│ └── AssemblyInfo.cs
└── Yoga.Tools.csproj
├── Yoga.VisionMix
├── App.config
├── AppManger
│ ├── AppInterlockHelper.cs
│ ├── IniStatus.cs
│ ├── ProjectData.cs
│ ├── StatusManger.cs
│ └── UserSetting.cs
├── Frame
│ ├── FrmMain.cs
│ ├── FrmMain.resx
│ ├── frmAbout.Designer.cs
│ ├── frmAbout.cs
│ ├── frmAbout.resx
│ ├── frmCommSetting.Designer.cs
│ ├── frmCommSetting.cs
│ ├── frmCommSetting.resx
│ ├── frmLogin.Designer.cs
│ ├── frmLogin.cs
│ ├── frmLogin.resx
│ ├── frmMain.Designer.cs
│ ├── frmProjectManger.Designer.cs
│ ├── frmProjectManger.cs
│ ├── frmProjectManger.resx
│ ├── frmRegistered.Designer.cs
│ ├── frmRegistered.cs
│ └── frmRegistered.resx
├── PLC
│ ├── PanasonicPLCComm.cs
│ └── PanasonicSerial.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── Setting.png
│ ├── logo.png
│ ├── openImg.png
│ ├── openPrj.png
│ ├── saveAs.png
│ ├── saveProject.png
│ ├── saveprj.png
│ ├── test.png
│ ├── user.png
│ └── video.png
├── Scheduling
│ ├── RunTheadData.cs
│ └── UpdateUI.cs
├── Units
│ ├── AutoUnit.Designer.cs
│ ├── AutoUnit.cs
│ ├── AutoUnit.resx
│ ├── CameraShow.cs
│ ├── DockUnit.Designer.cs
│ ├── DockUnit.cs
│ ├── DockUnit.resx
│ ├── IOUnit.Designer.cs
│ ├── IOUnit.cs
│ ├── IOUnit.resx
│ ├── SysConfigUnit.Designer.cs
│ ├── SysConfigUnit.cs
│ ├── SysConfigUnit.resx
│ ├── ToolDgv.Designer.cs
│ ├── ToolDgv.cs
│ ├── ToolDgv.resx
│ ├── TopInfoUnit.Designer.cs
│ ├── TopInfoUnit.cs
│ └── TopInfoUnit.resx
├── Yoga.VisionMix.csproj
└── bitbug_favicon.ico
└── Yoga.Wrapper
├── AssemblyInfo.cpp
├── Conversion.cpp
├── Conversion.h
├── DynThresholdParam.h
├── Fun.cpp
├── Fun.h
├── NativeTest.cpp
├── NativeTest.h
├── OcrParam.h
├── ReadMe.txt
├── ShowUnit.cpp
├── ShowUnit.h
├── Stdafx.cpp
├── Stdafx.h
├── UtilManaged.cpp
├── UtilManaged.h
├── Wrapper.vcxproj
├── Wrapper.vcxproj.filters
├── app.ico
├── app.rc
└── resource.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2020, yoga
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VisionMix
2 | 视觉混合编程项目,使用cli代理加密部分算法,框架仅提供学习使用,商业用途请自行测试!!!
3 | 包含功能:
4 | 1. 多品牌相机驱动
5 | 2. 模板匹配工具
6 | 3. 灰度匹配工具
7 | 4. 二维测量
8 | 5. 二维码扫描
9 | 6. 印刷缺陷检测
10 | 7. 其他功能
11 | 代理部分项目仅在老版本中存在,此版本需要删除各个模块的代理算子方可使用!
12 | 本软件共享仅为学习使用,谢绝索取直接编译运行版本
13 |
14 | qq交流群:592170250,已经修改为付费群,象征性的5块钱给作者一个赞赏吧
15 |
16 | 
17 |
18 |
19 | 
20 |
21 | 软件主界面
22 |
23 | 
--------------------------------------------------------------------------------
/Yoga.Camera/CameraPram.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Camera
8 | {
9 |
10 | public enum ImageAngle
11 | {
12 | 角度0,
13 | 角度90,
14 | 角度180,
15 | 角度270
16 | }
17 |
18 | [Serializable]
19 | public class CameraPram
20 | {
21 | ///
22 | /// 曝光时间
23 | ///
24 | private long shutter = 3500;
25 | ///
26 | /// 增益
27 | ///
28 | private double gain = 0;
29 | ///
30 | /// 外触发延时
31 | ///
32 | private double triggerDelayAbs = 10;
33 | ///
34 | /// 外触发防抖动
35 | ///
36 | private double lineDebouncerTimeAbs = 10;
37 | ///
38 | /// 输出信号输出时间
39 | ///
40 | private double outLineTime = 1000;
41 |
42 | private ImageAngle imageAngle = ImageAngle.角度0;
43 |
44 | public ImageAngle ImageAngle
45 | {
46 | get
47 | {
48 | return imageAngle;
49 | }
50 | set
51 | {
52 | imageAngle = value;
53 | }
54 | }
55 | public long Shutter
56 | {
57 | get
58 | {
59 | return shutter;
60 | }
61 |
62 | set
63 | {
64 | shutter = value;
65 | }
66 | }
67 |
68 | public double Gain
69 | {
70 | get
71 | {
72 | return gain;
73 | }
74 |
75 | set
76 | {
77 | gain = value;
78 | }
79 | }
80 |
81 | public double TriggerDelayAbs
82 | {
83 | get
84 | {
85 | return triggerDelayAbs;
86 | }
87 |
88 | set
89 | {
90 | triggerDelayAbs = value;
91 | }
92 | }
93 |
94 | public double LineDebouncerTimeAbs
95 | {
96 | get
97 | {
98 | return lineDebouncerTimeAbs;
99 | }
100 |
101 | set
102 | {
103 | lineDebouncerTimeAbs = value;
104 | }
105 | }
106 |
107 | public double OutLineTime
108 | {
109 | get
110 | {
111 | return outLineTime;
112 | }
113 |
114 | set
115 | {
116 | outLineTime = value;
117 | }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Yoga.Camera/EnumInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Camera
2 | {
3 | ///
4 | /// 命令枚举
5 | ///
6 | public enum Command
7 | {
8 | None,
9 | ExtTrigger,
10 | Video,
11 | Grab
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Yoga.Camera/IOSerial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO.Ports;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Yoga.Common.Basic;
8 |
9 | namespace Yoga.Camera
10 | {
11 | public class IOSerial
12 | {
13 | private static IOSerial instance;
14 |
15 | private SerialPort com = new SerialPort();
16 |
17 |
18 | private CommunicationParam rs232Param;
19 | public CommunicationParam Rs232Param
20 | {
21 | get
22 | {
23 | if (rs232Param == null)
24 | {
25 | rs232Param = new CommunicationParam();
26 | }
27 | return rs232Param;
28 | }
29 |
30 | set
31 | {
32 | rs232Param = value;
33 | }
34 | }
35 | public static IOSerial Instance
36 | {
37 | get
38 | {
39 | if (instance == null)
40 | {
41 | instance = new IOSerial();
42 | }
43 | return instance;
44 | }
45 | }
46 |
47 | ///
48 | /// 串口初始化
49 | ///
50 | public void InitSerial()
51 | {
52 | try
53 | {
54 | if (com.IsOpen)
55 | {
56 | Close();
57 | }
58 |
59 | com.PortName = Rs232Param.ComName;
60 | com.BaudRate = Convert.ToInt32(Rs232Param.BaudRate);
61 | com.Parity = (Parity)Convert.ToInt32(Rs232Param.Parity);
62 | com.DataBits = Convert.ToInt32(Rs232Param.DataBits);
63 | com.StopBits = (StopBits)Convert.ToInt32(Rs232Param.StopBits);
64 | //com.NewLine = "\r\n";
65 | //com.NewLine = "\r";
66 | //com.DataReceived += new SerialDataReceivedEventHandler(this.OnDataReceived);
67 |
68 | com.Open();
69 | }
70 | catch (Exception ex)
71 | {
72 | throw new ApplicationException("串口打开失败," + ex.Message);
73 | }
74 | }
75 |
76 | public void Close()
77 | {
78 | if (com.IsOpen)
79 | com.Close();
80 | }
81 |
82 | ///
83 | /// 写入数据到串口
84 | ///
85 | /// 待写入字符串-无校验
86 | ///
87 | public bool WriteDataToSerial(string str)
88 | {
89 | bool writeFlag = false;
90 | try
91 | {
92 | if (!com.IsOpen)
93 | {
94 | InitSerial();
95 | //com.Open();
96 | }
97 | com.Write(str);
98 | writeFlag = true;
99 | }
100 | catch
101 | {
102 | throw new ApplicationException("串口设置异常");
103 | }
104 | return writeFlag;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/Yoga.Camera/ImageEventArgs.cs:
--------------------------------------------------------------------------------
1 | using HalconDotNet;
2 | using System;
3 | using System.IO;
4 | using System.Runtime.Serialization;
5 | using System.Runtime.Serialization.Formatters.Binary;
6 |
7 | namespace Yoga.Camera
8 | {
9 | [Serializable]
10 | public class ImageEventArgs : EventArgs, IDisposable
11 | {
12 | public readonly Command Command;
13 | public readonly HImage CameraImage;
14 | public readonly HTuple StartTime;
15 |
16 | int? cameraIndex;
17 | int? settingIndex;
18 | bool _disposed;
19 | public void Dispose()
20 | {
21 | this.Dispose(true);
22 | GC.SuppressFinalize(this);
23 | }
24 |
25 | protected virtual void Dispose(bool disposing)
26 | {
27 | if (_disposed) return;
28 | if (disposing)
29 | {
30 | if (CameraImage != null && CameraImage.IsInitialized())
31 | {
32 | CameraImage.Dispose();
33 | }
34 | _disposed = true;
35 | }
36 | cameraIndex = null;
37 | settingIndex = null;
38 |
39 | }
40 |
41 | ~ImageEventArgs()
42 | {
43 | this.Dispose(false);
44 | }
45 | ///
46 | /// 工具编号,默认为1,只能设置一次
47 | ///
48 | public int SettingIndex
49 | {
50 | get
51 | {
52 | if (settingIndex == null)
53 | {
54 | return 1;
55 | }
56 | return settingIndex.Value;
57 | }
58 |
59 | set
60 | {
61 | if (settingIndex == null)
62 | {
63 | settingIndex = value;
64 | }
65 | }
66 | }
67 | ///
68 | /// 相机编号,默认为1,只能设置一次
69 | ///
70 | public int CameraIndex
71 | {
72 | get
73 | {
74 | if (cameraIndex == null)
75 | {
76 | return 1;
77 | }
78 | return cameraIndex.Value;
79 | }
80 |
81 | set
82 | {
83 | if (cameraIndex == null)
84 | {
85 | cameraIndex = value;
86 | }
87 | }
88 | }
89 | public ImageEventArgs Clone()
90 | {
91 | using (Stream objectStream = new MemoryStream())
92 | {
93 | IFormatter formatter = new BinaryFormatter();
94 | formatter.Serialize(objectStream, this);
95 |
96 | BinaryFormatter b = new BinaryFormatter();
97 | object obj = b.Deserialize(objectStream);
98 | return obj as ImageEventArgs;
99 | }
100 | }
101 | public ImageEventArgs(Command command, HImage cameraImage, int cameraIndex, HTuple startTime)
102 | {
103 | Command = command;
104 | CameraImage = cameraImage;
105 | CameraIndex = cameraIndex;
106 | StartTime = startTime;
107 | }
108 | public ImageEventArgs(Command command, HImage cameraImage, int cameraIndex, int settingIndex, HTuple startTime)
109 | {
110 | Command = command;
111 | CameraImage = cameraImage;
112 | CameraIndex = cameraIndex;
113 | SettingIndex = SettingIndex;
114 | StartTime = startTime;
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/Yoga.Camera/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Camera")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HYCONN")]
12 | [assembly: AssemblyProduct("Camera")]
13 | [assembly: AssemblyCopyright("Copyright © HYCONN 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("306083da-d250-4b6d-a487-f684f4330c0d")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | [assembly: AssemblyVersion("1.1.*")]
35 | //[assembly: AssemblyVersion("1.0.0.0")]
36 | //[assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.Common/Basic/CommunicationParam.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Yoga.Common.Helpers;
8 |
9 | namespace Yoga.Common.Basic
10 | {
11 | ///
12 | /// 通信模式
13 | ///
14 | public enum InterlockMode
15 | {
16 | [EnumDescription("串口")]
17 | 串口,
18 | [EnumDescription("TCP服务器")]
19 | TCP服务器,
20 | [EnumDescription("TCP客户端")]
21 | TCP客户端,
22 | [EnumDescription("UDP")]
23 | UDP,
24 | [EnumDescription("相机IO")]
25 | 相机IO
26 | }
27 |
28 | [Serializable]
29 | public class CommunicationParam
30 | {
31 | public string ComName = "COM1";
32 | public string BaudRate = "9600";
33 | public string Parity = "0";
34 | public string DataBits = "8";
35 | public string StopBits = "1";
36 |
37 | public int[] PlcData = new int[5];
38 |
39 | public bool Use = false;
40 |
41 | public string TcpIP = IPAddress.Any.ToString();
42 | public string TcpPort = "5000";
43 | public InterlockMode InterlockMode = InterlockMode.串口;
44 |
45 | public bool IsExtTrigger = false;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Yoga.Common/Basic/ISerializeCheck.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Common.Basic
8 | {
9 | public interface ISerializeCheck
10 | {
11 |
12 | void SerializeCheck();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Yoga.Common/Basic/MessageEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Yoga.Common.Basic
4 | {
5 | public enum Level
6 | {
7 | Normal,
8 | Err
9 | }
10 | public class MessageEventArgs : EventArgs
11 | {
12 | public readonly string Message;
13 | public readonly Level level;
14 | public MessageEventArgs(Level level, string message)
15 | {
16 | this.Message = message;
17 | this.level = level;
18 | }
19 | public MessageEventArgs( string message)
20 | {
21 | this.Message = message;
22 | this.level = Level.Normal;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Yoga.Common/Basic/MessageQueue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Concurrent;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Yoga.Common.Basic
12 | {
13 | public class MessageQueue
14 | {
15 | private ConcurrentQueue ListQueue = new ConcurrentQueue();
16 |
17 | TextBox txtShow;
18 | object objLock = new object();
19 |
20 | int messageCount = 0;
21 | private int InShowMessage = 0;
22 |
23 | public MessageQueue(TextBox txtShow)
24 | {
25 | this.txtShow = txtShow;
26 | }
27 | //int x;
28 | async void UIDoWork()
29 | {
30 | ShowMessage();
31 | await Task.Delay(10);
32 |
33 | Interlocked.Exchange(ref InShowMessage, 0);
34 | if ((ListQueue.IsEmpty == false))
35 | {
36 | TriggerShow();
37 | }
38 | }
39 |
40 | private void ShowMessage()
41 | {
42 | StringBuilder str = new StringBuilder();
43 |
44 | while (ListQueue.IsEmpty == false)
45 | {
46 | try
47 | {
48 | string message = string.Empty;
49 |
50 | //从队列中取出
51 | if (ListQueue.TryDequeue(out message) == false)
52 | {
53 | continue;
54 | }
55 |
56 | if (message == string.Empty)
57 | {
58 | continue;
59 | }
60 | messageCount++;
61 | str.Append(message);
62 | str.Append(Environment.NewLine);
63 | }
64 | catch (Exception /*ex*/)
65 | {
66 | }
67 |
68 | }
69 | txtShow.AppendText(str.ToString());
70 | //超过1000行就删除500行
71 | if (messageCount > 1000)
72 | {
73 | string[] lines = txtShow.Lines;
74 | List a = lines.ToList();
75 | a.RemoveRange(0, 500);
76 | txtShow.Lines = a.ToArray();
77 | messageCount = 500;
78 | }
79 | txtShow.ScrollToCaret();
80 | }
81 |
82 |
83 | private void TriggerShow()
84 | {
85 | if (Interlocked.CompareExchange(ref InShowMessage, 1, 0) == 0)
86 | {
87 | //启动显示
88 | if (txtShow.InvokeRequired)
89 | {
90 | txtShow.BeginInvoke(new Action(UIDoWork));
91 | }
92 | else
93 | {
94 | UIDoWork();
95 | }
96 |
97 | }
98 | }
99 | public void ShowMessage(string message)
100 | {
101 | //AddCount();
102 | ListQueue.Enqueue($"{DateTime.Now.ToString("HH:mm:ss")} {message}");
103 | TriggerShow();
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Yoga.Common/Basic/frmImputText.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Common.Basic
2 | {
3 | partial class frmImputText
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.txtData = new System.Windows.Forms.TextBox();
32 | this.btnOk = new System.Windows.Forms.Button();
33 | this.SuspendLayout();
34 | //
35 | // txtData
36 | //
37 | this.txtData.Location = new System.Drawing.Point(12, 22);
38 | this.txtData.Name = "txtData";
39 | this.txtData.Size = new System.Drawing.Size(341, 21);
40 | this.txtData.TabIndex = 0;
41 | //
42 | // btnOk
43 | //
44 | this.btnOk.Location = new System.Drawing.Point(359, 22);
45 | this.btnOk.Name = "btnOk";
46 | this.btnOk.Size = new System.Drawing.Size(75, 23);
47 | this.btnOk.TabIndex = 1;
48 | this.btnOk.Text = "确定";
49 | this.btnOk.UseVisualStyleBackColor = true;
50 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
51 | //
52 | // frmImputText
53 | //
54 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
55 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
56 | this.ClientSize = new System.Drawing.Size(446, 69);
57 | this.Controls.Add(this.btnOk);
58 | this.Controls.Add(this.txtData);
59 | this.Name = "frmImputText";
60 | this.Text = "请输入:";
61 | this.ResumeLayout(false);
62 | this.PerformLayout();
63 |
64 | }
65 |
66 | #endregion
67 |
68 | private System.Windows.Forms.TextBox txtData;
69 | private System.Windows.Forms.Button btnOk;
70 | }
71 | }
--------------------------------------------------------------------------------
/Yoga.Common/Basic/frmImputText.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Yoga.Common.Basic
12 | {
13 | public partial class frmImputText : Form
14 | {
15 | public string ImputText { get; set; }
16 | public frmImputText(string description)
17 | {
18 | InitializeComponent();
19 | this.Text =string.Format("请输入{0}:", description);
20 | }
21 |
22 | private void btnOk_Click(object sender, EventArgs e)
23 | {
24 | ImputText = txtData.Text;
25 | this.DialogResult = DialogResult.OK;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Yoga.Common/FileAct/FileManger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Threading;
6 |
7 | namespace Yoga.Common.FileAct
8 | {
9 | class FileComparer : IComparer
10 | {
11 | int IComparer.Compare(Object o1, Object o2)
12 | {
13 | FileInfo fi1 = o1 as FileInfo;
14 | FileInfo fi2 = o2 as FileInfo;
15 | return fi1.CreationTime.CompareTo(fi2.CreationTime);
16 | }
17 | }
18 |
19 | public class FileManger
20 | {
21 | //文件操作必须是原子的如果正在操作就直接放弃
22 | private static int InOverflow=0;
23 | public static void DeleteOverflowFile(string path,int maxFileNumber)
24 | {
25 | if (Interlocked.CompareExchange(ref InOverflow, 1, 0) == 0)
26 | {
27 | try
28 | {
29 | DirectoryInfo di = new DirectoryInfo(path);
30 | FileInfo[] files = di.GetFiles();
31 | if (files.Length < maxFileNumber)
32 | {
33 | return;
34 | }
35 | FileComparer fc = new FileComparer();
36 | Array.Sort(files, fc);
37 | int number = files.Length / 2;
38 | for (int i = 0; i < number; i++)
39 | {
40 | File.Delete(files[i].FullName);
41 | }
42 | File.Delete(files[0].FullName);
43 | Util.Notify("多余图像被删除");
44 |
45 |
46 | }
47 | catch (Exception ex)
48 | {
49 | Util.WriteLog(typeof(FileManger), ex);
50 | Util.Notify("图像文件删除失败");
51 | }
52 | finally
53 | {
54 | Interlocked.Exchange(ref InOverflow, 0);
55 | }
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/ApplicationHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Yoga.Common.Helpers
9 | {
10 | public static class ApplicationHelper
11 | {
12 | ///
13 | /// 启动一个应用程序/进程
14 | ///
15 | public static void StartApplication(string appFilePath)
16 | {
17 | Process downprocess = new Process();
18 | downprocess.StartInfo.FileName = appFilePath;
19 | downprocess.Start();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/EnumHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Common.Helpers
8 | {
9 | ///
10 | /// 枚举名称
11 | ///
12 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
13 | public sealed class EnumDescriptionAttribute : Attribute
14 | {
15 | private string description;
16 | public string Description { get { return description; } }
17 |
18 | public EnumDescriptionAttribute(string description)
19 | : base()
20 | {
21 | this.description = description;
22 | }
23 | }
24 |
25 | ///
26 | /// 获取枚举字符串
27 | ///
28 | public static class EnumHelper
29 | {
30 | public static string GetDescription(Enum value)
31 | {
32 | if (value == null)
33 | {
34 | throw new ArgumentException("value");
35 | }
36 | string description = value.ToString();
37 | var fieldInfo = value.GetType().GetField(description);
38 | var attributes =
39 | (EnumDescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);
40 | if (attributes != null && attributes.Length > 0)
41 | {
42 | description = attributes[0].Description;
43 | }
44 | return description;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/IPHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.RegularExpressions;
3 |
4 | namespace Yoga.Common.Helpers
5 | {
6 | ///
7 | /// IP帮助类
8 | ///
9 | public class IPHelper
10 | {
11 | private static bool IsIPAddress(string str)
12 | {
13 | try
14 | {
15 | if (string.IsNullOrWhiteSpace(str) || str.Length < 7 || str.Length > 15)
16 | return false;
17 | const string regformat = @"^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}{1}";
18 | var regex = new Regex(regformat, RegexOptions.IgnoreCase);
19 | return regex.IsMatch(str);
20 | }
21 | catch (Exception)
22 | {
23 | return false;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/MessageHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace Yoga.Common.Helpers
9 | {
10 | ///
11 | /// Message封装
12 | ///
13 | public static class MessageHelper
14 | {
15 | ///
16 | /// 显示一般的提示信息
17 | ///
18 | /// 提示信息
19 | public static DialogResult ShowTips(string message)
20 | {
21 | return MessageBox.Show(message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
22 | }
23 | ///
24 | /// 显示警告信息
25 | ///
26 | /// 警告信息
27 | public static DialogResult ShowWarning(string message)
28 | {
29 | return MessageBox.Show(message, "警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
30 | }
31 | ///
32 | /// 显示错误信息
33 | ///
34 | /// 错误信息
35 | public static DialogResult ShowError(string message)
36 | {
37 | return MessageBox.Show(message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
38 | }
39 | ///
40 | /// 显示询问用户信息,并显示错误标志
41 | ///
42 | /// 错误信息
43 | public static DialogResult ShowYesNoAndError(string message)
44 | {
45 | return MessageBox.Show(message, "错误信息", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
46 | }
47 | ///
48 | /// 显示询问用户信息,并显示提示标志
49 | ///
50 | /// 错误信息
51 | public static DialogResult ShowYesNoAndTips(string message)
52 | {
53 | return MessageBox.Show(message, "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
54 | }
55 | ///
56 | /// 显示询问用户信息,并显示警告标志
57 | ///
58 | /// 警告信息
59 | public static DialogResult ShowYesNoAndWarning(string message)
60 | {
61 | return MessageBox.Show(message, "警告信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
62 | }
63 | ///
64 | /// 显示询问用户信息,并显示提示标志
65 | ///
66 | /// 错误信息
67 | public static DialogResult ShowYesNoCancelAndTips(string message)
68 | {
69 | return MessageBox.Show(message, "提示信息", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/ShareDataHelper.cs:
--------------------------------------------------------------------------------
1 | using System.IO.MemoryMappedFiles;
2 | using System.Runtime.InteropServices;
3 | using System.Threading;
4 |
5 | namespace Yoga.Common.Helpers
6 | {
7 | ///
8 | /// 对结构体数据映射到内存并做线程安全访问
9 | ///
10 | ///
11 | public class ShareDataHelper where T : struct
12 | {
13 | private MemoryMappedFile file = null;
14 | private MemoryMappedViewAccessor accessor = null;
15 | private Mutex mutexShMem = null;
16 |
17 | private T data;
18 | ///
19 | /// 跨exe的线程安全结构体
20 | ///
21 | public T Data
22 | {
23 | get
24 | {
25 | mutexShMem.WaitOne();
26 |
27 | accessor.Read(0, out data);
28 | // 解除
29 | mutexShMem.ReleaseMutex();
30 |
31 | return data;
32 | }
33 |
34 | set
35 | {
36 |
37 | mutexShMem.WaitOne();
38 | data = value;
39 | accessor.Write(0, ref data);
40 | // 解除
41 | mutexShMem.ReleaseMutex();
42 | }
43 | }
44 | ///
45 | /// 创建连接
46 | ///
47 | ///
48 | public void CreateLink(string key)
49 | {
50 |
51 | int size = Marshal.SizeOf(typeof(T));
52 | file = MemoryMappedFile.CreateOrOpen(key, size);
53 |
54 | mutexShMem = new Mutex(false, key + "Lock");
55 | accessor = file.CreateViewAccessor();
56 | }
57 |
58 | public void Close()
59 | {
60 | if (accessor != null)
61 | {
62 | accessor.Dispose();
63 | accessor = null;
64 | }
65 |
66 | if (file != null)
67 | {
68 | file.Dispose();
69 | file = null;
70 | }
71 |
72 | if (mutexShMem != null)
73 | {
74 | mutexShMem.Close();
75 | mutexShMem = null;
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Yoga.Common/Helpers/StartupHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Common.Helpers
8 | {
9 | public class StartupHelper
10 | {
11 |
12 | private static string regAll = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
13 | private static string regCurrent = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run";
14 | private static string commonStartup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);
15 | private static string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
16 | public static bool Register(string name, string file, bool start = true, bool allUser = true)
17 | {
18 | if (start)
19 | {
20 | //注册开机启动注册表项
21 | if (allUser)
22 | {
23 | if (RegisterTool.SetValue(regAll, name, file)) return true;
24 | }
25 | else
26 | {
27 | if (RegisterTool.SetValue(regCurrent, name, file)) return true;
28 | }
29 | }
30 | else
31 | {
32 | //移除开机启动注册表项
33 | if (allUser)
34 | {
35 | if (RegisterTool.DeleteValue(regAll, name)) return true;
36 | }
37 | else
38 | {
39 | if (RegisterTool.DeleteValue(regCurrent, name)) return true;
40 | }
41 | }
42 | return false;
43 | }
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Yoga.Common/MotionControl/DataAcquisition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Common.MotionControl
8 | {
9 | ///
10 | /// 数据采集基类
11 | ///
12 | public abstract class DataAcquisition : IDisposable
13 | {
14 | bool _disposed;
15 | public string ReceiveData { get; set; }
16 | protected string receiveDataTmp;
17 | public void Dispose()
18 | {
19 | if (_disposed) return;
20 | Close();
21 | _disposed = true;
22 | }
23 |
24 | ///
25 | /// 接口打开
26 | ///
27 | /// 是否打开成功
28 | public abstract bool Open();
29 | ///
30 | /// 写入数据到通信口
31 | ///
32 | /// 数据
33 | /// 是否写入成功
34 | public abstract bool Write(string data);
35 | public abstract void Close();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Yoga.Common/PrinterHelper/IPrinter.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 |
3 | namespace Yoga.Common.PrinterHelper
4 | {
5 | public interface IPrinter
6 | {
7 | void PrintText(
8 | string content,
9 | FontSize fontSize = FontSize.Normal,
10 | StringAlignment stringAlignment = StringAlignment.Near,
11 | float width = 1,
12 | float offset = 0
13 | );
14 |
15 | void PrintImage(
16 | Image image,
17 | StringAlignment stringAlignment = StringAlignment.Near);
18 |
19 | void PrintLine(FontSize fontSize = FontSize.Normal);
20 |
21 | void NewRow();
22 |
23 | ///
24 | /// invoke this method when you ready to print document
25 | ///
26 | void Finish();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Yoga.Common/PrinterHelper/PrintQueueHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Printing;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Yoga.Common.PrinterHelper
9 | {
10 | public static class PrintQueueHelper
11 | {
12 | public static IEnumerable GetPrintQueue()
13 | {
14 | var localPrintServer = new LocalPrintServer();
15 | var printQueues = localPrintServer.GetPrintQueues().GetEnumerator();
16 | while (printQueues.MoveNext())
17 | {
18 | yield return printQueues.Current;
19 | }
20 |
21 | }
22 |
23 | public static IEnumerable GetPrintQueueName()
24 | {
25 | return GetPrintQueue().Select(s => s.Name);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Yoga.Common/PrinterHelper/PrinterFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Yoga.Common.PrinterHelper
9 | {
10 | public static class PrinterFactory
11 | {
12 | ///
13 | /// 打印实例 此处需要添加纸张长度计算
14 | ///
15 | public static void test()
16 | {
17 | var printer = PrinterFactory.GetPrinter("Adobe PDF", PaperWidth.Paper80mm);
18 | printer.NewRow();
19 | printer.NewRow();
20 | printer.PrintText("永辉超市", FontSize.Huge, StringAlignment.Center);
21 | printer.NewRow();
22 | printer.NewRow();
23 | printer.NewRow();
24 | printer.PrintText("操作员:张三");
25 | printer.PrintText(DateTime.Now.ToString("HH:mm:ss"), stringAlignment: StringAlignment.Far);
26 | printer.NewRow();
27 | printer.PrintLine();
28 | printer.NewRow();
29 | printer.PrintText("商品");
30 | printer.PrintText("单价", offset: 0.35f);
31 | printer.PrintText("数量", offset: 0.65f);
32 | printer.PrintText("总价", stringAlignment: StringAlignment.Far);
33 | printer.NewRow();
34 | printer.PrintLine();
35 | printer.NewRow();
36 | printer.PrintText("**长白山大萝卜,跳楼吐血大甩卖,不甜不要钱**", width: 0.35f);
37 | printer.PrintText("6.00", width: 0.2f, offset: 0.35f);
38 | printer.PrintText("2.00", width: 0.2f, offset: 0.65F);
39 | printer.PrintText("12.00", stringAlignment: StringAlignment.Far);
40 | printer.NewRow();
41 | printer.NewRow();
42 | printer.PrintText("大螃蟹", width: 0.35f);
43 | printer.PrintText("6.000000000001", width: 0.2f, offset: 0.35f);
44 | printer.PrintText("1", width: 0.2f, offset: 0.65F);
45 | printer.PrintText("6.000000000001", offset: 0.8f, width: 0.2f);
46 | printer.NewRow();
47 | printer.PrintLine();
48 | printer.NewRow();
49 | //var bitmap = new Bitmap("qr.png");
50 | //printer.PrintImage(bitmap, StringAlignment.Center);
51 | printer.NewRow();
52 | printer.PrintLine();
53 | printer.NewRow();
54 | printer.PrintText("感谢光临,欢迎下次再来!", stringAlignment: StringAlignment.Center);
55 | printer.NewRow();
56 | printer.Finish();
57 | }
58 | public static Printer GetPrinter(string printerName, double paperWidth, int? pagerHeight = null)
59 | {
60 | if (string.IsNullOrEmpty(printerName)) throw new ArgumentException(nameof(printerName));
61 | return new Printer(printerName, paperWidth, pagerHeight ?? 10000);
62 | }
63 |
64 | public static Printer GetPrinter(string printerName, PaperWidth paperWidth, int? pagerHeight = null)
65 | {
66 | switch (paperWidth)
67 | {
68 | case PaperWidth.Paper80mm:
69 | //80打印纸扣去两边内距实际可打的宽度为72.1
70 | return GetPrinter(printerName, 72.1, pagerHeight);
71 | case PaperWidth.Paper76mm:
72 | //76打印纸扣去两边内距实际可打的宽度为63.5
73 | return GetPrinter(printerName, 63.5, pagerHeight);
74 | case PaperWidth.Paper58mm:
75 | //58打印纸扣去两边内距实际可打的宽度为48
76 | return GetPrinter(printerName, 48, pagerHeight);
77 | default:
78 | throw new ArgumentException(nameof(paperWidth));
79 | }
80 |
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Yoga.Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Common")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HYCONN")]
12 | [assembly: AssemblyProduct("Common")]
13 | [assembly: AssemblyCopyright("Copyright © HYCONN 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("c42f352e-f4f1-43b8-aeda-812a1ca2cf8a")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | [assembly: AssemblyVersion("1.1.*")]
35 | //[assembly: AssemblyVersion("1.0.0.0")]
36 | //[assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
38 |
--------------------------------------------------------------------------------
/Yoga.Common/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Yoga.Common.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Yoga.Common.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Bitmap _return {
67 | get {
68 | object obj = ResourceManager.GetObject("_return", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
75 | ///
76 | internal static System.Drawing.Bitmap waiting {
77 | get {
78 | object obj = ResourceManager.GetObject("waiting", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Yoga.Common/Resources/_return.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Common/Resources/_return.gif
--------------------------------------------------------------------------------
/Yoga.Common/Resources/waiting.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Common/Resources/waiting.gif
--------------------------------------------------------------------------------
/Yoga.Common/TCPHelper/Coder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Yoga.Common.TCPHelper
5 | {
6 | ///
7 | /// 通讯编码格式提供者,为通讯服务提供编码和解码服务
8 | /// 可以在继承类中定制自己的编码方式如:数据加密传输等
9 | ///
10 | public class Coder
11 | {
12 | public enum EncodingMothord
13 | {
14 | Default = 0,
15 | Unicode,
16 | UTF8,
17 | ASCII,
18 | }
19 | ///
20 | /// 编码方式
21 | ///
22 | private EncodingMothord _encodingMothord;
23 |
24 | protected Coder()
25 | {
26 |
27 | }
28 |
29 | public Coder(EncodingMothord encodingMothord)
30 | {
31 | _encodingMothord = encodingMothord;
32 | }
33 |
34 |
35 |
36 | ///
37 | /// 通讯数据解码
38 | ///
39 | /// 需要解码的数据
40 | /// 编码后的数据
41 | public virtual string GetEncodingString(byte[] dataBytes, int start, int size)
42 | {
43 | switch (_encodingMothord)
44 | {
45 | case EncodingMothord.Default:
46 | {
47 | return Encoding.Default.GetString(dataBytes, start, size);
48 | //return Encoding.Unicode.GetString(dataBytes, start, size);
49 | }
50 | case EncodingMothord.Unicode:
51 | {
52 | return Encoding.Unicode.GetString(dataBytes, start, size);
53 | }
54 | case EncodingMothord.UTF8:
55 | {
56 | return Encoding.UTF8.GetString(dataBytes, start, size);
57 | }
58 | case EncodingMothord.ASCII:
59 | {
60 | return Encoding.ASCII.GetString(dataBytes, start, size);
61 | }
62 | default:
63 | {
64 | Util.WriteLog(this.GetType(), "未定义的编码格式");
65 | throw (new Exception("未定义的编码格式"));
66 | }
67 | }
68 |
69 | }
70 | ///
71 | /// 数据编码
72 | ///
73 | /// 需要编码的报文
74 | /// 编码后的数据
75 | public virtual byte[] GetTextBytes(string datagram)
76 | {
77 | byte[] rbyte = new byte[Encoding.UTF8.GetBytes(datagram).Length];
78 | switch (_encodingMothord)
79 | {
80 | case EncodingMothord.Default:
81 | {
82 | Encoding.Default.GetBytes(datagram, 0, datagram.Length, rbyte, 0);
83 | return rbyte;
84 | }
85 | case EncodingMothord.Unicode:
86 | {
87 | Encoding.Unicode.GetBytes(datagram, 0, datagram.Length, rbyte, 0);
88 | return rbyte;
89 | }
90 | case EncodingMothord.UTF8:
91 | {
92 | Encoding.UTF8.GetBytes(datagram, 0, datagram.Length, rbyte, 0);
93 | return rbyte;
94 | }
95 | case EncodingMothord.ASCII:
96 | {
97 | Encoding.ASCII.GetBytes(datagram, 0, datagram.Length, rbyte, 0);
98 | return rbyte;
99 | }
100 | default:
101 | {
102 | Util.WriteLog(this.GetType(), "未定义的编码格式");
103 | throw (new Exception("未定义的编码格式"));
104 |
105 | }
106 | }
107 |
108 | }
109 | }
110 | }
111 |
112 |
--------------------------------------------------------------------------------
/Yoga.Common/TCPHelper/DatagramResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Yoga.Common.TCPHelper
5 | {
6 | ///
7 | /// 数据报文分析器,通过分析接收到的原始数据,得到完整的数据报文.
8 | /// 继承该类可以实现自己的报文解析方法.
9 | /// 当前没有设定报文的解析方法
10 | ///
11 | public class DatagramResolver
12 | {
13 | ///
14 | /// 报文结束标记
15 | ///
16 | private string endTag;
17 |
18 | ///
19 | /// 返回结束标记
20 | ///
21 | public string EndTag
22 | {
23 | get
24 | {
25 | return endTag;
26 | }
27 | }
28 |
29 | ///
30 | /// 受保护的默认构造函数,提供给继承类使用
31 | ///
32 | protected DatagramResolver()
33 | {
34 |
35 | }
36 |
37 | ///
38 | /// 构造函数
39 | ///
40 | /// 报文结束标记
41 | public DatagramResolver(string endTag)
42 | {
43 | if (endTag == null)
44 | {
45 | throw (new ArgumentNullException("结束标记不能为null"));
46 | }
47 |
48 | if (endTag == "")
49 | {
50 | throw (new ArgumentException("结束标记符号不能为空字符串"));
51 | }
52 |
53 | this.endTag = endTag;
54 | }
55 |
56 | ///
57 | /// 解析报文
58 | ///
59 | /// 原始数据,返回未使用的报文片断,
60 | /// 该片断会保存在Session的Datagram对象中
61 | /// 报文数组,原始数据可能包含多个报文
62 | public virtual string[] Resolve(ref string rawDatagram)
63 | {
64 | ArrayList datagrams = new ArrayList();
65 |
66 | //末尾标记位置索引
67 | int tagIndex = -1;
68 |
69 | while (true)
70 | {
71 | tagIndex = rawDatagram.IndexOf(endTag, tagIndex + 1);
72 |
73 | if (tagIndex == -1)
74 | {
75 | break;
76 | }
77 | else
78 | {
79 | //按照末尾标记把字符串分为左右两个部分
80 | string newDatagram = rawDatagram.Substring(
81 | 0, tagIndex + endTag.Length);
82 |
83 | datagrams.Add(newDatagram);
84 |
85 | if (tagIndex + endTag.Length >= rawDatagram.Length)
86 | {
87 | rawDatagram = "";
88 |
89 | break;
90 | }
91 |
92 | rawDatagram = rawDatagram.Substring(tagIndex + endTag.Length,
93 | rawDatagram.Length - newDatagram.Length);
94 |
95 | //从开始位置开始查找
96 | tagIndex = 0;
97 | }
98 | }
99 |
100 | string[] results = new string[datagrams.Count];
101 |
102 | datagrams.CopyTo(results);
103 |
104 | return results;
105 | }
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/Yoga.Common/TCPHelper/NetEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Yoga.Common.TCPHelper
4 | {
5 | ///
6 | /// 网络通讯事件模型委托
7 | ///
8 | public delegate void NetEvent(object sender, NetEventArgs e);
9 |
10 | ///
11 | /// 服务器程序的事件参数,包含了激发该事件的会话对象
12 | ///
13 | public class NetEventArgs : EventArgs
14 | {
15 |
16 | #region 字段
17 |
18 | ///
19 | /// 客户端与服务器之间的会话
20 | ///
21 | private Session _client;
22 |
23 | #endregion
24 |
25 | #region 构造函数
26 | ///
27 | /// 构造函数
28 | ///
29 | /// 客户端会话
30 | public NetEventArgs(Session client)
31 | {
32 | if (null == client)
33 | {
34 | throw (new ArgumentNullException());
35 | }
36 |
37 | _client = client;
38 | }
39 | #endregion
40 |
41 | #region 属性
42 |
43 | ///
44 | /// 获得激发该事件的会话对象
45 | ///
46 | public Session Client
47 | {
48 | get
49 | {
50 | return _client;
51 | }
52 |
53 | }
54 |
55 | #endregion
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Yoga.Common/TCPHelper/SessionId.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Common.TCPHelper
2 | {
3 | ///
4 | /// 唯一的标志一个Session,辅助Session对象在Hash表中完成特定功能
5 | ///
6 | public class SessionId
7 | {
8 | ///
9 | /// 与Session对象的Socket对象的Handle值相同,必须用这个值来初始化它
10 | ///
11 | private int _id;
12 |
13 | ///
14 | /// 返回ID值
15 | ///
16 | public int ID
17 | {
18 | get
19 | {
20 | return _id;
21 | }
22 | }
23 |
24 | ///
25 | /// 构造函数
26 | ///
27 | /// Socket的Handle值
28 | public SessionId(int id)
29 | {
30 | _id = id;
31 | }
32 |
33 | ///
34 | /// 重载.为了符合Hashtable键值特征
35 | ///
36 | ///
37 | ///
38 | public override bool Equals(object obj)
39 | {
40 | if (obj != null)
41 | {
42 | SessionId right = (SessionId)obj;
43 |
44 | return _id == right._id;
45 | }
46 | else if (this == null)
47 | {
48 | return true;
49 | }
50 | else
51 | {
52 | return false;
53 | }
54 |
55 | }
56 |
57 | ///
58 | /// 重载.为了符合Hashtable键值特征
59 | ///
60 | ///
61 | public override int GetHashCode()
62 | {
63 | return _id;
64 | }
65 |
66 | ///
67 | /// 重载,为了方便显示输出
68 | ///
69 | ///
70 | public override string ToString()
71 | {
72 | return _id.ToString();
73 | }
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Yoga.Common/UI/AgileProgressBar.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Common.UI
2 | {
3 | partial class AgileProgressBar
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.progressBar1 = new System.Windows.Forms.ProgressBar();
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.SuspendLayout();
34 | //
35 | // progressBar1
36 | //
37 | this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
38 | | System.Windows.Forms.AnchorStyles.Left)
39 | | System.Windows.Forms.AnchorStyles.Right)));
40 | this.progressBar1.BackColor = System.Drawing.SystemColors.Window;
41 | this.progressBar1.ForeColor = System.Drawing.Color.Green;
42 | this.progressBar1.Location = new System.Drawing.Point(3, 3);
43 | this.progressBar1.Name = "progressBar1";
44 | this.progressBar1.Size = new System.Drawing.Size(122, 22);
45 | this.progressBar1.TabIndex = 0;
46 | //
47 | // label1
48 | //
49 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
50 | this.label1.Location = new System.Drawing.Point(131, 3);
51 | this.label1.Name = "label1";
52 | this.label1.Size = new System.Drawing.Size(36, 22);
53 | this.label1.TabIndex = 1;
54 | this.label1.Text = "0%";
55 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
56 | //
57 | // AgileProgressBar
58 | //
59 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
60 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
61 | this.Controls.Add(this.label1);
62 | this.Controls.Add(this.progressBar1);
63 | this.Name = "AgileProgressBar";
64 | this.Size = new System.Drawing.Size(170, 29);
65 | this.ResumeLayout(false);
66 |
67 | }
68 |
69 | #endregion
70 |
71 | private System.Windows.Forms.ProgressBar progressBar1;
72 | private System.Windows.Forms.Label label1;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Yoga.Common/UI/AgileProgressBar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace Yoga.Common.UI
10 | {
11 | public partial class AgileProgressBar : UserControl
12 | {
13 | public AgileProgressBar()
14 | {
15 | InitializeComponent();
16 | }
17 |
18 | #region Total
19 | private int total = 10;
20 | public int Total
21 | {
22 | get { return total; }
23 | set { total = value; }
24 | }
25 | #endregion
26 |
27 | public void SetProgress(int val)
28 | {
29 | if (this.InvokeRequired)
30 | {
31 | this.Invoke(new Action (this.SetProgress), val);
32 | }
33 | else
34 | {
35 | this.progressBar1.Maximum = this.total;
36 | this.progressBar1.Value = val;
37 |
38 | int percent = val *1000 /this.total ;
39 | this.label1.Text = (percent / 10.0).ToString() + "%";
40 | }
41 | }
42 |
43 | public void MessageBoxShow(string msg)
44 | {
45 | if (this.InvokeRequired)
46 | {
47 | this.Invoke(new Action(this.MessageBoxShow), msg);
48 | }
49 | else
50 | {
51 | MessageBox.Show(msg);
52 | }
53 |
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Yoga.Common/UI/FrmLoad.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | namespace Yoga.Common.UI
5 | {
6 | partial class FrmLoad
7 | {
8 | ///
9 | /// Required designer variable.
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// Clean up any resources being used.
15 | ///
16 | /// true if managed resources should be disposed; otherwise, false.
17 | protected override void Dispose(bool disposing)
18 | {
19 | try
20 | {
21 | if (disposing && background != null)
22 | {
23 | background.Dispose();
24 | background = null;
25 | }
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | }
31 | finally
32 | {
33 | base.Dispose(disposing);
34 | }
35 | }
36 |
37 | #region Windows Form Designer generated code
38 |
39 | ///
40 | /// Required method for Designer support - do not modify
41 | /// the contents of this method with the code editor.
42 | ///
43 | private void InitializeComponent()
44 | {
45 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLoad));
46 | this.SuspendLayout();
47 | //
48 | // FrmLoad
49 | //
50 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
51 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
52 | this.ClientSize = new System.Drawing.Size(927, 485);
53 | //this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
54 | this.Name = "FrmLoad";
55 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
56 | this.Text = "Loading";
57 | this.Load += new System.EventHandler(this.FrmLoad_Load);
58 | this.ResumeLayout(false);
59 |
60 | }
61 |
62 | #endregion
63 |
64 |
65 | }
66 | }
--------------------------------------------------------------------------------
/Yoga.Common/UI/SevenSegment.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Common.UI
2 | {
3 | partial class SevenSegment
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Yoga.Common/UI/SevenSegmentArray.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Common.UI
2 | {
3 | partial class SevenSegmentArray
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Yoga.Common/VBAEngine/AutofillText.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Common.VBAEngine
8 | {
9 | public class AutofillText
10 | {
11 |
12 | public List MethodNameList { get; private set; }
13 | public AutofillText( List methodNameList)
14 | {
15 | this.MethodNameList = methodNameList;
16 | }
17 | public override string ToString()
18 | {
19 | if (MethodNameList==null|| MethodNameList.Count<1)
20 | {
21 | return string.Empty;
22 | }
23 | StringBuilder str = new StringBuilder();
24 | MethodNameList.Sort();
25 | foreach (var item in MethodNameList)
26 | {
27 | str.Append(item);
28 | str.Append(" ");
29 | }
30 | return str.ToString().Trim();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Yoga.Common/VBAEngine/GlobalObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Yoga.Common.VBAEngine
5 | {
6 | ///
7 | /// vba引擎共用方法
8 | ///
9 | [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute()]
10 | public class GlobalObject
11 | {
12 | static VbaFunction h = null;
13 | ///
14 | /// 全局的 HMeasureSYS 对象
15 | ///
16 | public static VbaFunction H
17 | {
18 | get
19 | {
20 | return h;
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Yoga.Common/VBAEngine/HotKeyManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | namespace Yoga.Common.VBAEngine
7 | {
8 | internal class HotKeyManager {
9 |
10 | public static bool Enable = true;
11 |
12 | public static void AddHotKey(Form form, Action function, Keys key, bool ctrl = false, bool shift = false, bool alt = false) {
13 | form.KeyPreview = true;
14 |
15 | form.KeyDown += delegate(object sender, KeyEventArgs e) {
16 | if (IsHotkey(e, key, ctrl, shift, alt)) {
17 | function();
18 | }
19 | };
20 | }
21 |
22 | public static bool IsHotkey(KeyEventArgs eventData, Keys key, bool ctrl = false, bool shift = false, bool alt = false) {
23 | return eventData.KeyCode == key && eventData.Control == ctrl && eventData.Shift == shift && eventData.Alt == alt;
24 | }
25 |
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Yoga.Common/VBAEngine/SearchManager.cs:
--------------------------------------------------------------------------------
1 | using ScintillaNET;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | namespace Yoga.Common.VBAEngine
9 | {
10 | internal class SearchManager {
11 |
12 | public static ScintillaNET.Scintilla TextArea;
13 | public static TextBox SearchBox;
14 |
15 | public static string LastSearch = "";
16 |
17 | public static int LastSearchIndex;
18 |
19 | public static void Find(bool next, bool incremental) {
20 | bool first = LastSearch != SearchBox.Text;
21 |
22 | LastSearch = SearchBox.Text;
23 | if (LastSearch.Length > 0) {
24 |
25 | if (next) {
26 |
27 | // SEARCH FOR THE NEXT OCCURANCE
28 |
29 | // Search the document at the last search index
30 | TextArea.TargetStart = LastSearchIndex - 1;
31 | TextArea.TargetEnd = LastSearchIndex + (LastSearch.Length + 1);
32 | TextArea.SearchFlags = SearchFlags.None;
33 |
34 | // Search, and if not found..
35 | if (!incremental || TextArea.SearchInTarget(LastSearch) == -1) {
36 |
37 | // Search the document from the caret onwards
38 | TextArea.TargetStart = TextArea.CurrentPosition;
39 | TextArea.TargetEnd = TextArea.TextLength;
40 | TextArea.SearchFlags = SearchFlags.None;
41 |
42 | // Search, and if not found..
43 | if (TextArea.SearchInTarget(LastSearch) == -1) {
44 |
45 | // Search again from top
46 | TextArea.TargetStart = 0;
47 | TextArea.TargetEnd = TextArea.TextLength;
48 |
49 | // Search, and if not found..
50 | if (TextArea.SearchInTarget(LastSearch) == -1) {
51 |
52 | // clear selection and exit
53 | TextArea.ClearSelections();
54 | return;
55 | }
56 | }
57 |
58 | }
59 |
60 | } else {
61 |
62 | // SEARCH FOR THE PREVIOUS OCCURANCE
63 |
64 | // Search the document from the beginning to the caret
65 | TextArea.TargetStart = 0;
66 | TextArea.TargetEnd = TextArea.CurrentPosition;
67 | TextArea.SearchFlags = SearchFlags.None;
68 |
69 | // Search, and if not found..
70 | if (TextArea.SearchInTarget(LastSearch) == -1) {
71 |
72 | // Search again from the caret onwards
73 | TextArea.TargetStart = TextArea.CurrentPosition;
74 | TextArea.TargetEnd = TextArea.TextLength;
75 |
76 | // Search, and if not found..
77 | if (TextArea.SearchInTarget(LastSearch) == -1) {
78 |
79 | // clear selection and exit
80 | TextArea.ClearSelections();
81 | return;
82 | }
83 | }
84 |
85 | }
86 |
87 | // Select the occurance
88 | LastSearchIndex = TextArea.TargetStart;
89 | TextArea.SetSelection(TextArea.TargetEnd, TextArea.TargetStart);
90 | TextArea.ScrollCaret();
91 |
92 | }
93 |
94 | SearchBox.Focus();
95 | }
96 |
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Yoga.Common/VBAEngine/VbaFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace Yoga.Common.VBAEngine
9 | {
10 | public class VbaFunction
11 | {
12 | ///
13 | /// 信息提示框
14 | ///
15 | /// 提示信息
16 | public static void Show(string s)
17 | {
18 | MessageBox.Show(s);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Yoga.Common/log4net.config:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Yoga.Common/log4net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Common/log4net.dll
--------------------------------------------------------------------------------
/Yoga.Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/EnumInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Yoga.ImageControl
4 | {
5 | [Serializable]
6 | public enum ROIType
7 | {
8 | ///
9 | /// 直线
10 | ///
11 | Line = 10,
12 | ///
13 | /// 圆
14 | ///
15 | Circle,
16 | ///
17 | /// 圆弧
18 | ///
19 | CircleArc,
20 | ///
21 | /// 矩形
22 | ///
23 | Rectangle1,
24 | ///
25 | /// 带角度矩形
26 | ///
27 | Rectangle2
28 | }
29 | ///
30 | /// ROI运算
31 | ///
32 | public enum ROIOperation
33 | {
34 | ///
35 | /// ROI求和模式
36 | ///
37 | Positive = 21,
38 | ///
39 | /// ROI求差模式
40 | ///
41 | Negative,
42 | ///
43 | /// ROI模式为无
44 | ///
45 | None,
46 | }
47 | public enum ViewMessage
48 | {
49 | /// Constant describing an update of the model region
50 | UpdateROI = 50,
51 |
52 | ChangedROISign,
53 |
54 | /// Constant describing an update of the model region
55 | MovingROI,
56 | DeletedActROI,
57 | DelectedAllROIs,
58 |
59 | ActivatedROI,
60 |
61 | MouseMove,
62 | CreatedROI,
63 | ///
64 | /// Constant describes delegate message to signal new image
65 | ///
66 | UpdateImage,
67 | ///
68 | /// Constant describes delegate message to signal error
69 | /// when reading an image from file
70 | ///
71 | ErrReadingImage,
72 | ///
73 | /// Constant describes delegate message to signal error
74 | /// when defining a graphical context
75 | ///
76 | ErrDefiningGC
77 | }
78 | public enum ShowMode
79 | {
80 | ///
81 | /// 包含ROI显示
82 | ///
83 | IncludeROI = 1,
84 | ///
85 | /// 不包含ROI显示
86 | ///
87 | ExcludeROI
88 | }
89 | public enum ResultShow
90 | {
91 | 原图,
92 | 处理后
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/FunctionPlot.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/FunctionPlot.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/GraphicsContext.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/GraphicsContext.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/HObjectEntry.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/HObjectEntry.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/HWndUnit.cs:
--------------------------------------------------------------------------------
1 | using HalconDotNet;
2 | using System;
3 | using System.Drawing;
4 | using System.Windows.Forms;
5 |
6 | namespace Yoga.ImageControl
7 | {
8 | public partial class HWndUnit : UserControl
9 | {
10 | private HWndCtrl hWndCtrl;
11 | private string cameraName;
12 | public HWndUnit()
13 | {
14 | InitializeComponent();
15 | hWindowControl1.Size = this.Size;
16 | this.Disposed += HWndUnit_Disposed;
17 | }
18 |
19 | private void HWndUnit_Disposed(object sender, EventArgs e)
20 | {
21 | if (hWndCtrl==null)
22 | {
23 | return;
24 | }
25 | hWndCtrl.ClearWindowData();
26 | }
27 |
28 | public HWndCtrl HWndCtrl
29 | {
30 | get
31 | {
32 | if (hWndCtrl == null)
33 | {
34 | hWindowControl1.Size = this.Size;
35 | hWndCtrl = new HWndCtrl(hWindowControl1);
36 | hWndCtrl.ShowMessageEvent += HWndCtrl_ShowMessageEvent;
37 | }
38 | return hWndCtrl;
39 | }
40 | }
41 |
42 | private void HWndCtrl_ShowMessageEvent(object sender, ShowMessageEventArgs e)
43 | {
44 | switch (e.MessageType)
45 | {
46 | case MessageType.MouseMessage:
47 | if (lblMouseMessage.Visible == false)
48 | {
49 | lblMouseMessage.Visible = true;
50 | }
51 | lblMouseMessage.Text = e.message;
52 | break;
53 | case MessageType.ShowOk:
54 | if (labelResult.Visible==false)
55 | {
56 | labelResult.Visible = true;
57 | }
58 | labelResult.BackColor = Color.Green;
59 | labelResult.Text = "OK";
60 | break;
61 | case MessageType.ShowNg:
62 | if (labelResult.Visible == false)
63 | {
64 | labelResult.Visible = true;
65 | }
66 | labelResult.BackColor = Color.Red;
67 | labelResult.Text = "NG";
68 | break;
69 | default:
70 | break;
71 | }
72 | }
73 |
74 | public string CameraMessage
75 | {
76 | get
77 | {
78 | return cameraName;
79 | }
80 | set
81 | {
82 | this.lblName.Text = value;
83 | this.lblName.Visible = true;
84 | cameraName = value;
85 | }
86 | }
87 |
88 | private string ToHexColor(Color color)
89 | {
90 | if (color.IsEmpty)
91 | return "#000000";
92 | string R = Convert.ToString(color.R, 16);
93 | if (R == "0")
94 | R = "00";
95 | string G = Convert.ToString(color.G, 16);
96 | if (G == "0")
97 | G = "00";
98 | string B = Convert.ToString(color.B, 16);
99 | if (B == "0")
100 | B = "00";
101 | string HexColor = "#" + R + G + B;
102 | return HexColor.ToUpper();
103 | }
104 | private void HWndUnit_SizeChanged(object sender, EventArgs e)
105 | {
106 | if (this.DesignMode)
107 | {
108 | return;
109 | }
110 | HWndCtrl.ResetWindow();
111 | hWndCtrl.Repaint();
112 | }
113 |
114 | private void HWndUnit_Load(object sender, EventArgs e)
115 | {
116 | //Wrapper.ShowUnit.ShowHat(hWindowControl1.HalconWindow, true);
117 | }
118 |
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/Mode.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/Mode.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/PictureUnit.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.ImageControl
2 | {
3 | partial class PictureUnit
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.pictureBox1 = new System.Windows.Forms.PictureBox();
32 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
33 | this.SuspendLayout();
34 | //
35 | // pictureBox1
36 | //
37 | this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
38 | this.pictureBox1.Location = new System.Drawing.Point(0, 0);
39 | this.pictureBox1.Name = "pictureBox1";
40 | this.pictureBox1.Size = new System.Drawing.Size(391, 263);
41 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
42 | this.pictureBox1.TabIndex = 0;
43 | this.pictureBox1.TabStop = false;
44 | //
45 | // PictureUnit
46 | //
47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
49 | this.Controls.Add(this.pictureBox1);
50 | this.Name = "PictureUnit";
51 | this.Size = new System.Drawing.Size(391, 263);
52 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.PictureBox pictureBox1;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/PictureUnit.cs:
--------------------------------------------------------------------------------
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 |
11 | namespace Yoga.ImageControl
12 | {
13 | public partial class PictureUnit : UserControl
14 | {
15 | Bitmap curBitmap;
16 | public PictureUnit()
17 | {
18 | InitializeComponent();
19 | }
20 | public void ShowImage(Image image)
21 | {
22 | pictureBox1.Image = image;
23 | }
24 | public void ShowScreenshots(string savePath)
25 | {
26 | if (curBitmap != null)
27 | {
28 | curBitmap.Dispose();
29 | }
30 | int width = Screen.PrimaryScreen.Bounds.Width;
31 | int height = Screen.PrimaryScreen.Bounds.Height;
32 | curBitmap = new Bitmap(width, height);
33 | using (Graphics g = Graphics.FromImage(curBitmap))
34 | {
35 | g.CopyFromScreen(0, 0, 0, 0, new Size(width, height));
36 | }
37 | pictureBox1.Image = curBitmap;
38 | if (savePath!=string.Empty)
39 | {
40 | System.IO.FileInfo fi = new System.IO.FileInfo(savePath);
41 | if (!fi.Directory.Exists)
42 | {
43 | fi.Directory.Create();
44 | }
45 | curBitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
46 | }
47 | }
48 | public void ShowScreenshots()
49 | {
50 | ShowScreenshots(string.Empty);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ImageControl")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HYCONN")]
12 | [assembly: AssemblyProduct("ImageControl")]
13 | [assembly: AssemblyCopyright("Copyright © HYCONN 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("34ddafed-be60-4a7d-b438-c8eb74a3d1f7")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | [assembly: AssemblyVersion("1.1.*")]
35 | //[assembly: AssemblyVersion("1.0.0.0")]
36 | //[assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROI.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROI.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROIActUnit.cs:
--------------------------------------------------------------------------------
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 |
11 | namespace Yoga.ImageControl
12 | {
13 | public partial class ROIActUnit : UserControl
14 | {
15 | private ROIController roiController;
16 | private bool useSearchRoi=true;
17 | public ROIActUnit()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | public ROIController RoiController
23 | {
24 | get
25 | {
26 | return roiController;
27 | }
28 |
29 | set
30 | {
31 | roiController = value;
32 | }
33 | }
34 |
35 | public bool UseSearchRoi
36 | {
37 | get
38 | {
39 | return useSearchRoi;
40 | }
41 |
42 | set
43 | {
44 | useSearchRoi = value;
45 | reduceRect1Button.Visible = useSearchRoi;
46 | }
47 | }
48 |
49 | private void addToROIButton_CheckedChanged(object sender, EventArgs e)
50 | {
51 | if (addToROIButton.Checked)
52 | RoiController.SetROISign(ROIOperation.Positive);
53 | }
54 |
55 | private void subFromROIButton_CheckedChanged(object sender, EventArgs e)
56 | {
57 | if (subFromROIButton.Checked)
58 | RoiController.SetROISign(ROIOperation.Negative);
59 | }
60 |
61 | private void rect1Button_Click(object sender, EventArgs e)
62 | {
63 | RoiController.SetROIShape(new ROIRectangle1());
64 | }
65 |
66 | private void rect2Button_Click(object sender, EventArgs e)
67 | {
68 | RoiController.SetROIShape(new ROIRectangle2());
69 | }
70 |
71 | private void circleButton_Click(object sender, EventArgs e)
72 | {
73 | RoiController.SetROIShape(new ROICircle());
74 | }
75 |
76 | private void reduceRect1Button_Click(object sender, EventArgs e)
77 | {
78 | RoiController.SetROIShapeNoOperator(new ROIRectangle2("搜索区域"));
79 | }
80 |
81 | private void delROIButton_Click(object sender, EventArgs e)
82 | {
83 | RoiController.RemoveActive();
84 | }
85 |
86 | private void delAllROIButton_Click(object sender, EventArgs e)
87 | {
88 | RoiController.Reset();
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROICircle.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROICircle.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROICircularArc.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROICircularArc.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROIController.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROIController.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROIEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Yoga.ImageControl
4 | {
5 | ///
6 | /// 显示引发事件
7 | ///
8 | public class ViewEventArgs : EventArgs
9 | {
10 | public readonly ViewMessage ViewMessage;
11 | public ViewEventArgs(ViewMessage viewMessage)
12 | {
13 | this.ViewMessage = viewMessage;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROILine.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROILine.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROIRectangle1.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROIRectangle1.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ROIRectangle2.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.ImageControl/ROIRectangle2.cs
--------------------------------------------------------------------------------
/Yoga.ImageControl/ShowMessageEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.ImageControl
8 | {
9 | public enum MessageType
10 | {
11 | MouseMessage,
12 | ShowOk,
13 | ShowNg
14 | }
15 | public class ShowMessageEventArgs
16 | {
17 | public readonly MessageType MessageType;
18 | public readonly string message;
19 | public ShowMessageEventArgs(MessageType messageType)
20 | {
21 | this.MessageType = messageType;
22 | }
23 | public ShowMessageEventArgs(string message)
24 | {
25 | this.MessageType = MessageType.MouseMessage;
26 | this.message = message;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Yoga.Native/DynThresholdParamN.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | using namespace std;
3 | #include
4 | typedef struct _DynThresholdParamN
5 | {
6 | std::string lightDark;
7 | double offset;
8 | int maskWidth;
9 | int maskHeight;
10 | double closingRadius;
11 | double openingRadius;
12 | double leastArea;
13 | }DynThresholdParamN;
14 |
--------------------------------------------------------------------------------
/Yoga.Native/GraphicsContext.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/GraphicsContext.cpp
--------------------------------------------------------------------------------
/Yoga.Native/GraphicsContext.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "HalconCpp.h"
3 | #include
4 | #include
5 | #include
6 | class GraphicsContext
7 | {
8 | public:
9 | static QString GC_COLOR;
10 | static QString GC_COLORED;
11 | static QString GC_LINEWIDTH;
12 | static QString GC_DRAWMODE;
13 | static QString GC_SHAPE;
14 | static QString GC_LUT;
15 | static QString GC_PAINT;
16 | static QString GC_LINESTYLE;
17 | QHash graphicalSettings;
18 | QHash stateOfSettings;
19 |
20 | GraphicsContext();
21 | void applyContext(const HalconCpp::HTuple &winID, const QHash &cContext);
22 | void setAttribute(const QString &key, const HalconCpp::HTuple &val);
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/Yoga.Native/HObjectEntry.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "HObjectEntry.h"
3 |
4 | HObjectEntry::HObjectEntry(const HalconCpp::HObject & obj, const QHash& gc)
5 | {
6 | this->gc = gc;
7 | this->hobj = obj;
8 | }
9 |
10 | HObjectEntry::HObjectEntry(const HWndMessage & message)
11 | {
12 | this->message = message;
13 | }
14 |
15 | HObjectEntry::~HObjectEntry()
16 | {
17 | }
18 |
19 | QHash HObjectEntry::getGC() const
20 | {
21 | return gc;
22 | }
23 |
24 |
25 | HalconCpp::HObject HObjectEntry::getHobj() const
26 | {
27 | return hobj;
28 | }
29 |
30 | HWndMessage HObjectEntry::getMessage() const
31 | {
32 | return message;
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/Yoga.Native/HObjectEntry.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "qstring.h"
3 | #include "HalconCpp.h"
4 | #include "HWndMessage.h"
5 | #include
6 | #include
7 | using namespace std;
8 | class HObjectEntry
9 | {
10 | public:
11 | HObjectEntry(const HalconCpp::HObject &obj, const QHash &gc);
12 | HObjectEntry(const HWndMessage &message);
13 | ~HObjectEntry();
14 | QHash getGC() const;
15 | HalconCpp::HObject getHobj() const;
16 |
17 | HWndMessage getMessage() const;
18 |
19 | private:
20 | QHash gc;
21 | HalconCpp::HObject hobj;
22 | HWndMessage message;
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/Yoga.Native/HWndMessage.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/HWndMessage.cpp
--------------------------------------------------------------------------------
/Yoga.Native/HWndMessage.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | # include "HalconCpp.h"
3 | #include
4 | class HWndMessage
5 | {
6 | public:
7 | HWndMessage();
8 | HWndMessage(HalconCpp::HTuple message, int row, int colunm, int size, HalconCpp::HTuple color);
9 | HWndMessage(HalconCpp::HTuple message, int row, int colunm);
10 | ~HWndMessage();
11 | double dispMessage(HalconCpp::HTuple winID, QString coordSystem, double zoom,double currentSize);
12 | void dispMessage(HalconCpp::HTuple winID, QString coordSystem, double zoom);
13 | bool IsInitialized() const;
14 | HWndMessage clone() const;
15 | private:
16 | HalconCpp::HTuple message;
17 | int size = 16;
18 | int row;
19 | int colunm;
20 | HalconCpp::HTuple color = "green";
21 | bool isInitialized;
22 | void dispMessage(HalconCpp::HTuple hv_WindowHandle, HalconCpp::HTuple hv_String, HalconCpp::HTuple hv_CoordSystem,
23 | HalconCpp::HTuple hv_Row, HalconCpp::HTuple hv_Column, HalconCpp::HTuple hv_Color, HalconCpp::HTuple hv_Box);
24 | void setDisplayFont(HalconCpp::HTuple hv_WindowHandle, HalconCpp::HTuple hv_Size, HalconCpp::HTuple hv_Font, HalconCpp::HTuple hv_Bold,
25 | HalconCpp::HTuple hv_Slant);
26 |
27 | };
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Yoga.Native/MyMD5.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | /* Parameters of MD5. */
4 | #define s11 7
5 | #define s12 12
6 | #define s13 17
7 | #define s14 22
8 | #define s21 5
9 | #define s22 9
10 | #define s23 14
11 | #define s24 20
12 | #define s31 4
13 | #define s32 11
14 | #define s33 16
15 | #define s34 23
16 | #define s41 6
17 | #define s42 10
18 | #define s43 15
19 | #define s44 21
20 |
21 | /**
22 | * @Basic MD5 functions.
23 | *
24 | * @param there bit32.
25 | *
26 | * @return one bit32.
27 | */
28 | #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
29 | #define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
30 | #define H(x, y, z) ((x) ^ (y) ^ (z))
31 | #define I(x, y, z) ((y) ^ ((x) | (~z)))
32 |
33 | /**
34 | * @Rotate Left.
35 | *
36 | * @param {num} the raw number.
37 | *
38 | * @param {n} rotate left n.
39 | *
40 | * @return the number after rotated left.
41 | */
42 | #define ROTATELEFT(num, n) (((num) << (n)) | ((num) >> (32-(n))))
43 |
44 | /**
45 | * @Transformations for rounds 1, 2, 3, and 4.
46 | */
47 | #define FF(a, b, c, d, x, s, ac) { \
48 | (a) += F ((b), (c), (d)) + (x) + ac; \
49 | (a) = ROTATELEFT ((a), (s)); \
50 | (a) += (b); \
51 | }
52 | #define GG(a, b, c, d, x, s, ac) { \
53 | (a) += G ((b), (c), (d)) + (x) + ac; \
54 | (a) = ROTATELEFT ((a), (s)); \
55 | (a) += (b); \
56 | }
57 | #define HH(a, b, c, d, x, s, ac) { \
58 | (a) += H ((b), (c), (d)) + (x) + ac; \
59 | (a) = ROTATELEFT ((a), (s)); \
60 | (a) += (b); \
61 | }
62 | #define II(a, b, c, d, x, s, ac) { \
63 | (a) += I ((b), (c), (d)) + (x) + ac; \
64 | (a) = ROTATELEFT ((a), (s)); \
65 | (a) += (b); \
66 | }
67 |
68 | #include
69 | #include
70 |
71 | using std::string;
72 |
73 | /* Define of btye.*/
74 | typedef unsigned char byte;
75 | /* Define of byte. */
76 | typedef unsigned int bit32;
77 | class MyMD5
78 | {
79 | public:
80 | MyMD5(const string& message);
81 | /* Generate md5 digest. */
82 | const byte* getDigest();
83 |
84 | /* Convert digest to string value */
85 | string toStr();
86 |
87 | private:
88 | /* Initialization the md5 object, processing another message block,
89 | * and updating the context.*/
90 | void init(const byte* input, size_t len);
91 |
92 | /* MD5 basic transformation. Transforms state based on block. */
93 | void transform(const byte block[64]);
94 |
95 | /* Encodes input (usigned long) into output (byte). */
96 | void encode(const bit32* input, byte* output, size_t length);
97 |
98 | /* Decodes input (byte) into output (usigned long). */
99 | void decode(const byte* input, bit32* output, size_t length);
100 |
101 | private:
102 | /* Flag for mark whether calculate finished. */
103 | bool finished;
104 |
105 | /* state (ABCD). */
106 | bit32 state[4];
107 |
108 | /* number of bits, low-order word first. */
109 | bit32 count[2];
110 |
111 | /* input buffer. */
112 | byte buffer[64];
113 |
114 | /* message digest. */
115 | byte digest[16];
116 |
117 | /* padding for calculate. */
118 | static const byte PADDING[64];
119 |
120 | /* Hex numbers. */
121 | static const char HEX_NUMBERS[16];
122 | };
123 |
124 |
--------------------------------------------------------------------------------
/Yoga.Native/NativeFitPlane.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/NativeFitPlane.cpp
--------------------------------------------------------------------------------
/Yoga.Native/NativeFitPlane.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Yoga.Native.h"
3 | typedef struct _PlaneInfo
4 | {
5 | double A;
6 | double B;
7 | double C;
8 | double D;
9 | } nPlaneInfo;
10 | extern "C" __declspec(dllexport) bool FitPlane(int nPntSum, const double px[], const double py[], const double pz[], nPlaneInfo *planeInfo);
11 |
12 | extern "C" __declspec(dllexport) double DisPntToPlane(double dx, double dy, double dz, const nPlaneInfo& plane);
13 |
14 | extern "C" __declspec(dllexport) double Flatness(int nPntSum, const double px[], const double py[], const double pz[], const nPlaneInfo& plane);
15 |
16 |
--------------------------------------------------------------------------------
/Yoga.Native/NativeFun.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/NativeFun.cpp
--------------------------------------------------------------------------------
/Yoga.Native/NativeFun.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/NativeFun.h
--------------------------------------------------------------------------------
/Yoga.Native/NativeShowUnit.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/NativeShowUnit.cpp
--------------------------------------------------------------------------------
/Yoga.Native/NativeShowUnit.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "HalconCpp.h"
4 | #include"HObjectEntry.h"
5 | class __declspec(dllexport) NativeShowUnit
6 | {
7 | public:
8 | static void AddIconicVar(const HalconCpp::HTuple& winID, const HalconCpp::HImage& img);
9 | static void AddIconicVar(const HalconCpp::HTuple& winID, const HalconCpp::HObject& obj);
10 |
11 | static void ShowText(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& message, int row, int colunm, int size, const HalconCpp::HTuple& color, const HalconCpp::HTuple & coordSystem);
12 | static void AddText(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& message, int row, int colunm, int size, const HalconCpp::HTuple& color);
13 | static void AddText(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& message, int row, int colunm);
14 |
15 |
16 | static void ClearWindowData(const HalconCpp::HTuple& winID);
17 | static void ClearEntryList(const HalconCpp::HTuple& winID);
18 | static void Refresh(const HalconCpp::HTuple& winID, bool showImageOnly, bool isShowText, double scale);
19 | static void SaveImage(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& path);
20 | static bool IsEmpty(const HalconCpp::HTuple& winID);
21 | static void ChangeGraphicSettings(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& mode, const HalconCpp::HTuple& val);
22 |
23 | static void SetImageSize(const HalconCpp::HTuple & winID, double imageWidth, double imageHeight);
24 | static void SetBackgroundColor(const HalconCpp::HTuple & winID, const HalconCpp::HTuple & color);
25 | static void ShowHat(const HalconCpp::HTuple& winID, bool isShowCross);
26 | static std::string GetPixMessage(const HalconCpp::HTuple& winID, HalconCpp::HTuple *currX, HalconCpp::HTuple*currY);
27 | static HalconCpp::HTuple GetGrayHisto(const HalconCpp::HTuple& winID, const HalconCpp::HTuple& rectangle1);
28 | private:
29 | static void addEntry(const HalconCpp::HTuple & winID, const HObjectEntry & entry);
30 | };
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Yoga.Native/OcrParamN.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | using namespace std;
3 | #include
4 | typedef struct _OcrParamN
5 | {
6 | std::string polarity;
7 | std::string ocrType;
8 | std::string expression;
9 | int thresholdValue;
10 | double closeCircleRadius;
11 | double openCircleRadius;
12 | int minCharArea;
13 | int maxCharArea;
14 | int minCharWidth;
15 | int maxCharWidth;
16 | int minCharHeight;
17 | int maxCharHeight;
18 | int partitionCharWidth;
19 |
20 | }OcrParamN;
--------------------------------------------------------------------------------
/Yoga.Native/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 动态链接库:Yoga.Native 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 Yoga.Native DLL。
6 |
7 | 本文件概要介绍组成 Yoga.Native 应用程序的每个文件的内容。
8 |
9 |
10 | Yoga.Native.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | Yoga.Native.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | Yoga.Native.cpp
17 | 这是主 DLL 源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 Yoga.Native.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/Yoga.Native/Util.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "Util.h"
3 | EventCallback Util::ms_callback = 0;
4 | Util::Util()
5 | {
6 | }
7 |
8 |
9 | Util::~Util()
10 | {
11 | }
12 | void Util::RegisterCallback(EventCallback callback)
13 | {
14 | //assert(0 != callback);
15 | ms_callback = callback;
16 | }
17 |
18 | void Util::Invoke(char* msg)
19 | {
20 | //assert(0 != ms_callback);
21 | if (0 != ms_callback)
22 | {
23 | ms_callback(msg);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Yoga.Native/Util.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/Util.h
--------------------------------------------------------------------------------
/Yoga.Native/Yoga.Native.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/Yoga.Native.cpp
--------------------------------------------------------------------------------
/Yoga.Native/Yoga.Native.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/Yoga.Native.h
--------------------------------------------------------------------------------
/Yoga.Native/Yoga.Native.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件
50 |
51 |
52 | 头文件
53 |
54 |
55 | 头文件
56 |
57 |
58 | 头文件
59 |
60 |
61 |
62 |
63 | 源文件
64 |
65 |
66 | 源文件
67 |
68 |
69 | 源文件
70 |
71 |
72 | 源文件
73 |
74 |
75 | 源文件
76 |
77 |
78 | 源文件
79 |
80 |
81 | 源文件
82 |
83 |
84 | 源文件
85 |
86 |
87 | 源文件
88 |
89 |
90 | 源文件
91 |
92 |
93 | 源文件
94 |
95 |
96 |
--------------------------------------------------------------------------------
/Yoga.Native/dllmain.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/dllmain.cpp
--------------------------------------------------------------------------------
/Yoga.Native/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/stdafx.cpp
--------------------------------------------------------------------------------
/Yoga.Native/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/stdafx.h
--------------------------------------------------------------------------------
/Yoga.Native/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Native/targetver.h
--------------------------------------------------------------------------------
/Yoga.Test/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Yoga.Test/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Yoga.Test
12 | {
13 | public partial class Form1 : Form
14 | {
15 | public Form1()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void button1_Click(object sender, EventArgs e)
21 | {
22 | Yoga.Common.PrinterHelper.PrinterFactory.test();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Yoga.Test/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace Yoga.Test
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Yoga.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Yoga.Test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Yoga.Test")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("1355b3e1-5b2d-4804-9cc4-ca2a7b2887c1")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.Test/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Yoga.Test.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Yoga.Test.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 覆盖当前线程的 CurrentUICulture 属性
56 | /// 使用此强类型的资源类的资源查找。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Yoga.Test/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Yoga.Test.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Yoga.Test/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Yoga.Tools.Matching/Matching/MatchingOpt.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Tools.Matching/Matching/MatchingOpt.cs
--------------------------------------------------------------------------------
/Yoga.Tools.Matching/Matching/MatchingParam.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Tools.Matching/Matching/MatchingParam.cs
--------------------------------------------------------------------------------
/Yoga.Tools.Matching/Matching/MatchingResult.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Tools.Matching/Matching/MatchingResult.cs
--------------------------------------------------------------------------------
/Yoga.Tools.Matching/Matching/MatchingStatus.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Tools.Matching
2 | {
3 | public enum MatchingStatus
4 | {
5 | ///
6 | /// 更新图形常量
7 | ///
8 | UpdateXLD = 0,
9 | ///
10 | ///更新金字塔。
11 | ///
12 | UpdatePyramid,
13 | ///
14 | ///检测结果应该更新。
15 | ///
16 | UpdateDetectiongResult,
17 | ///
18 | /// 应该更新测试图像
19 | ///
20 | UpdateTestView,
21 |
22 | ///
23 | /// 文件扩展名错误
24 | ///
25 | ErrNoValidFile,
26 | ///
27 | /// 模板写入错误
28 | ///
29 | ErrWriteShapeModel,
30 | ///
31 | /// 模板读取错误
32 | ///
33 | ErrReadShapeModel,
34 | ///
35 | ///模板未定义异常
36 | ///
37 | ErrNoModelDefined,
38 | ///
39 | /// 无模板图像异常
40 | ///
41 | ErrNoImage,
42 | ///
43 | /// 无测试图像异常
44 | ///
45 | ErrNoTestImage,
46 | ///
47 | /// 无搜索框
48 | ///
49 | ErrNoSearchRegion,
50 | ///
51 | /// 读取图像异常
52 | ///
53 | ErrReadingImage,
54 | ///
55 | ///更新优化状态
56 | ///
57 | UpdateRecogSattisticStatus,
58 | ///
59 | /// 更新上次优化结果数据
60 | ///
61 | UpdateRecogVals,
62 | ///
63 | /// 更新优化后的结果数据
64 | ///
65 | UpdateRecogOptimumVals,
66 | ///
67 | /// 更新错误信息,包含图像错误及模板错误等
68 | ///
69 | UpdateTestErr,
70 | ///
71 | /// Constant describing an error, which says that there is
72 | /// no possible combination of matching parameters to obtain
73 | /// a detection result
74 | ///
75 | UpdateRecogErr,
76 |
77 | ///
78 | /// Constant describing a change in the statistics of
79 | /// the recognition rate
80 | ///
81 | UpdateInspRecograte,
82 | ///
83 | /// Constant describing a change in the statics of
84 | /// the average recognition results
85 | ///
86 | UpdateInspStatistics,
87 | /// Constant describing the success of the optimization
88 | /// process and triggering the adjustment of the GUI
89 | /// components to the optimal parameter setting
90 | ///
91 | RunSucccessful,
92 | ///
93 | /// Constant describing the failure of the optimization
94 | /// process and reseting the matching parameters to the
95 | /// initial setup
96 | ///
97 | RunFailed
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Yoga.Tools.Matching/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Yoga.Tools.Matching")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Yoga.Tools.Matching")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("4480158a-e61e-4371-8809-8d585b93a341")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.Tools.ReadCode/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Yoga.Tools.ReadCode")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Yoga.Tools.ReadCode")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("c3a5dae7-82bd-4b59-aec2-97c66cb579b4")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.Tools.ReadCode/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/Metrology/FitlineTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Tools.Metrology
8 | {
9 | public class FitLineTool :MetrologyTool
10 | {
11 | public FitLineTool(int settingIndex):base(settingIndex)
12 | {
13 |
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/Metrology/MetrologyMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Tools.Metrology
2 | {
3 | ///
4 | /// 二维测量与ui交互用枚举
5 | ///
6 | public enum MetrologyMessage
7 | {
8 | ///
9 | /// 更新测量实例常量.
10 | ///
11 | EventUpdateMetrology,
12 | ///
13 | /// 从测量实例数组中移除实例常量
14 | ///
15 | EventUpdateRemoveObject,
16 | ///
17 | /// 更新测量结果常量.
18 | ///
19 | EventUpdateResultXLD,
20 | ///
21 | /// 读取文件错误异常的常量标识.
22 | ///
23 | ErrReadingFile,
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/Metrology/MetrologyResult.cs:
--------------------------------------------------------------------------------
1 | using HalconDotNet;
2 |
3 | namespace Yoga.Tools.Metrology
4 | {
5 | public abstract class MetrologyResult
6 | {
7 | public abstract HXLDCont GetXLD();
8 | public abstract HTuple GetData();
9 | }
10 | public class MetrologyResultLine:MetrologyResult
11 | {
12 | public HTuple row1, col1; // 直线起始点
13 | public HTuple row2, col2; // 直线终点
14 |
15 | public MetrologyResultLine(double r1,double c1,double r2,double c2)
16 | {
17 | row1 = r1;
18 | col1 = c1;
19 | row2 = r2;
20 | col2 = c2;
21 | }
22 | ///
23 | /// 深度复制的构造函数
24 | ///
25 | ///
26 | public MetrologyResultLine(MetrologyResultLine result)
27 | : this(result.row1, result.col1,
28 | result.row2, result.col2)
29 | {
30 | }
31 | public MetrologyResultLine()
32 | {
33 |
34 | }
35 | public override HXLDCont GetXLD()
36 | {
37 | if (row1 == null || row2 == null || col1 == null || col2 == null)
38 | {
39 | return null;
40 | }
41 | HXLDCont edge = new HXLDCont();
42 | HTuple rows, cols;
43 | //行数组
44 | rows = new HTuple(new double[] { row1, row2 });
45 | //列数组
46 | cols = new HTuple(new double[] { col1, col2 });
47 | //生成直线图形
48 | edge.GenContourPolygonXld(rows, cols);
49 | //返回数据
50 | return edge;
51 | }
52 | public override HTuple GetData()
53 | {
54 | if (row1 == null || col1 == null || row2 == null || col2 == null)
55 | {
56 | return null;
57 | }
58 | return new HTuple(new double[] { row1, col1, row2, col2 });
59 | }
60 | }
61 | public class MetrologyResultCircularArc : MetrologyResult
62 | {
63 | public HTuple midR, midC;
64 | public HTuple radius;
65 | public HTuple startPhi, extentPhi; // -2*PI <= x <= 2*PI
66 | public MetrologyResultCircularArc(double _midR, double _midC, double _randius, double _startPhi,double _extentPhi)
67 | {
68 | midR = _midR;
69 | midC = _midC;
70 | radius = _randius;
71 | startPhi = _startPhi;
72 | extentPhi = _extentPhi;
73 | }
74 | ///
75 | /// 深度复制的构造函数
76 | ///
77 | ///
78 | public MetrologyResultCircularArc(MetrologyResultCircularArc result)
79 | : this(result.midR, result.midC,
80 | result.radius, result.startPhi,result.extentPhi)
81 | {
82 | }
83 | public MetrologyResultCircularArc()
84 | {
85 |
86 | }
87 | public override HXLDCont GetXLD()
88 | {
89 | if (midR == null || midC == null || radius == null || startPhi == null || extentPhi==null)
90 | {
91 | return null;
92 | }
93 | HXLDCont edge = new HXLDCont();
94 | //生成圆弧图形
95 | edge.GenCircleContourXld(midR.D, midC.D, radius.D, 0.0,
96 | 6.28318, "positive", 1.0);
97 | //返回数据
98 | return edge;
99 | }
100 | public override HTuple GetData()
101 | {
102 | if(midR==null)
103 | {
104 | return null;
105 | }
106 | return new HTuple(new double[] { midR, midC, radius, startPhi,
107 | (startPhi + extentPhi) });
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/OCR/OcrPram.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Tools.OCR
8 | {
9 | ///
10 | /// ocr文字识别自动模式下参数
11 | ///
12 | public enum OCRAutoParam
13 | {
14 | ///
15 | /// 字符最小对比度默认值 15
16 | ///
17 | min_contrast,
18 | ///
19 | /// 极性 默认值:both 值列表: 'dark_on_light','light_on_dark', 'both'
20 | ///
21 | polarity,
22 | ///
23 | /// 像素中字符的最小高度。如果要分割任意高度的文本,则可以传递“auto”。
24 | /// “min_char_height”仅指字符。标点符号或分隔符的高度不受“min_char_height”的限制 。
25 | ///
26 | min_char_height,
27 | ///
28 | /// 像素中字符的最大高度。如果要分割任意高度的文本,则可以传递“auto”。
29 | /// “max_char_height”仅指字符。标点符号或分隔符的高度不受“max_char_height”的限制
30 | ///
31 | max_char_height,
32 | ///
33 | /// 像素中字符的最小宽度。如果要分割任意宽度的文本,可以传递“auto”。
34 | /// “min_char_width”仅指字符。标点符号或分隔符的宽度不受'min_char_width'限制 。
35 | ///
36 | min_char_width,
37 | ///
38 | /// 像素中字符的最大宽度。如果要分割任意宽度的文本, 可以传递“auto”。
39 | /// “max_char_width”仅指字符。标点符号或分隔符的宽度不受'max_char_width'限制 。
40 | ///
41 | max_char_width,
42 | ///
43 | /// 像素中字符的最小行程宽度。如果要在文本分割过程中自动估计最小行程宽度,可以传递“自动”。
44 | /// “min_stroke_width”仅指字符。标点符号或分隔符的笔触宽度不受'min_stroke_width'限制。
45 | ///
46 | min_stroke_width,
47 | ///
48 | /// 像素中字符的最大行程宽度。如果自动在文本分割过程中估计最大行程宽度,则可以传递“自动”。
49 | /// “max_stroke_width”仅指字符。标点符号或分隔符的笔画宽度不受'max_stroke_width'限制。
50 | ///
51 | max_stroke_width,
52 | ///
53 | /// “true”=所选区域的边界地区应被丢弃,否则 =“false”。
54 | ///
55 | eliminate_border_blobs,
56 | ///
57 | /// 如果还应该返回标点符号(例如,点或逗号),则为 “true”。如果不返回标点符号,则为 “false”。
58 | ///
59 | return_punctuation,
60 | ///
61 | /// 如果还应该返回分隔符如减号或等号,则为 “true”。 如果没有分离器应该被返回,则为 'false'。
62 | ///
63 | return_separators,
64 | ///
65 | /// “true”,如果片段,诸如在“I”,应该被添加到分割的字符,否则“false”的点。请注意,这可能会导致噪音添加到分段字符。
66 | ///
67 | add_fragments,
68 |
69 | text_line_structure,
70 | text_line_separators,
71 | return_whole_line,
72 | mlp_classifier,
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/PlaneFun/PlaneFun.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Yoga.Tools.PlaneFun
4 | {
5 | public class PlaneFun
6 | {
7 |
8 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
9 | public struct PlaneInfo
10 | {
11 | public double A;
12 | public double B;
13 | public double C;
14 | public double D;
15 | };
16 |
17 | /***************************************************************************************
18 | ///// // Ax + By + Cz + D=0
19 | ////A 1
20 | ////B 2
21 | ////C - 1
22 | ////D -4
23 |
24 | ////平面拟合测试结果正确
25 | //FitPlaneFun.PlaneInfo p1 = new FitPlaneFun.PlaneInfo();
26 | //double[] x = new double[4];
27 | //double[] y = new double[4];
28 | //double[] z = new double[4];
29 |
30 | //x[0] = 1;
31 | // x[1] = 2;
32 | // x[2] = 3;
33 | // x[3] = 4;
34 |
35 | // y[0] = 2;
36 | // y[1] = 3;
37 | // y[2] = 4;
38 | // y[3] = 6;
39 |
40 | // z[0] = 1;
41 | // z[1] = 4;
42 | // z[2] = 7;
43 | // z[3] = 12;
44 | // bool f = FitPlaneFun.FitPlane(4, x, y, z, ref p1);
45 | ***********************************************************************************************/
46 |
47 |
48 | ///
49 | /// 平面拟合
50 | ///
51 | /// 点位个数
52 | /// x坐标
53 | /// y坐标
54 | /// z坐标
55 | /// 拟合结果
56 | ///
57 |
58 | [DllImport("Yoga.Native.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
59 | public static extern bool FitPlane(int nPntSum, double[] px, double[] py, double[] pz, ref PlaneInfo planeInfo);
60 | [DllImport("Yoga.Native.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
61 | public static extern double DisPntToPlane(double dx, double dy, double dz, ref PlaneInfo planeInfo);
62 | ///
63 | /// 平面度计算 既是求所有点到平面的最大距离
64 | ///
65 | /// 点个数
66 | /// x坐标数组
67 | /// y坐标数组
68 | /// z坐标数组
69 | /// 已知的平面结构体
70 | /// 点到平面的最大距离
71 | [DllImport("Yoga.Native.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
72 | public static extern double Flatness(int nPntSum, double[] px, double[] py, double[] pz, ref PlaneInfo planeInfo);
73 |
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/PrintCheck/EnumInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Tools.PrintCheck
2 | {
3 | public enum PrintCheckMessage
4 | {
5 | ErrNoMatchingTool,
6 | ErrTrainImage,
7 | ErrFindModel,
8 | ErrTestImage,
9 | ErrNoTestImage,
10 | ErrNoModelRegion,
11 | ErrReadingImage,
12 | ErrTrain,
13 | UpdateTrainView,
14 | UpdateTestView,
15 | UpdateTrainResult
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/PrintCheck/PrintCheckEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Yoga.Tools.PrintCheck
4 | {
5 | public class PrintCheckEventArgs: EventArgs
6 | {
7 | public readonly PrintCheckMessage PrintCheckMessage;
8 | public PrintCheckEventArgs(PrintCheckMessage printCheckMessage)
9 | {
10 | this.PrintCheckMessage = printCheckMessage;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Yoga.Tools.Util/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Yoga.Tools.Util")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Yoga.Tools.Util")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("bb30c904-3ce7-4704-ab3f-7eb602c6ed29")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.Tools/CreateImage/CreateImageUnit.cs:
--------------------------------------------------------------------------------
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 |
11 | namespace Yoga.Tools.CreateImage
12 | {
13 | public partial class CreateImageUnit : ToolsSettingUnit
14 | {
15 | CreateImageTool tool;
16 | public CreateImageUnit(CreateImageTool tool)
17 | {
18 | InitializeComponent();
19 | this.tool = tool;
20 | locked = true;
21 | Init();
22 | HideMax();
23 | HideMin();
24 | base.Init(tool.Name, tool);
25 | locked = false;
26 | }
27 |
28 | private void Init()
29 | {
30 | UpDownCameraIndex.Value = tool.CameraIndex;
31 | chkOffLine.Checked = tool.OffLineMode;
32 | txtOffLinePath.Text = tool.OffLineImagePath;
33 | }
34 | public override void ShowResult()
35 | {
36 | }
37 | private void UpDownCameraIndex_ValueChanged(object sender, EventArgs e)
38 | {
39 | if (locked)
40 | {
41 | return;
42 | }
43 | tool.CameraIndex = (int)UpDownCameraIndex.Value;
44 | }
45 |
46 | private void btnGetImagePath_Click(object sender, EventArgs e)
47 | {
48 | FolderBrowserDialog folder = new FolderBrowserDialog();
49 | folder.Description = "选择图片文件存放目录";
50 | if (tool.OffLineImagePath != "")
51 | {
52 | folder.SelectedPath = tool.OffLineImagePath;
53 | }
54 |
55 | if (folder.ShowDialog() == DialogResult.OK)
56 | {
57 |
58 | string sPath = folder.SelectedPath;
59 | tool.OffLineImagePath = sPath;
60 | txtOffLinePath.Text = sPath;
61 | }
62 | }
63 |
64 | private void chkOffLine_CheckedChanged(object sender, EventArgs e)
65 | {
66 | if (locked)
67 | {
68 | return;
69 | }
70 | tool.OffLineMode = chkOffLine.Checked;
71 | }
72 |
73 | private void btnGetImage_Click(object sender, EventArgs e)
74 | {
75 | tool.SetExtTriggerDataOff();
76 | tool.Run();
77 | tool.ShowImage(hWndUnit1.HWndCtrl);
78 | hWndUnit1.HWndCtrl.Repaint();
79 | }
80 |
81 | private void btnSetRefImage_Click(object sender, EventArgs e)
82 | {
83 | if (tool.ImageTestOut == null|| tool.ImageTestOut.IsInitialized()==false)
84 | {
85 | MessageBox.Show("未采集到图像数据,请先采集图像", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
86 | return;
87 | }
88 | tool.RefImage = tool.ImageTestOut.CopyImage();
89 | MessageBox.Show("模板图像设置完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
90 | ShowRefImage();
91 | }
92 |
93 | private void btnShowRefImage_Click(object sender, EventArgs e)
94 | {
95 | ShowRefImage();
96 | }
97 |
98 | private void ShowRefImage()
99 | {
100 | if (tool.RefImage != null && tool.RefImage.IsInitialized())
101 | {
102 | hWndUnit1.HWndCtrl.AddIconicVar(tool.RefImage);
103 | hWndUnit1.HWndCtrl.AddText("模板图像", 20, 20, 20, "blue");
104 | hWndUnit1.HWndCtrl.Repaint();
105 | }
106 | }
107 | private void CreateImageUnit_Load(object sender, EventArgs e)
108 | {
109 | ShowRefImage();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/AllInterface.cs:
--------------------------------------------------------------------------------
1 | using HalconDotNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Yoga.Tools
9 | {
10 | public interface ICalibration
11 | {
12 | void ImagePointsToWorldPlane(HTuple px, HTuple py, out HTuple rx, out HTuple ry);
13 | }
14 | public interface IOCRTool
15 | {
16 | string GetOCRResultText();
17 | }
18 | public interface IToolEnable
19 | {
20 | }
21 | public interface IToolRun
22 | {
23 | }
24 | public interface ICreateImage
25 | {
26 | }
27 | public interface IMatching
28 | {
29 | ///
30 | /// 测试图像2d映射到模板图像,此处需要查找模板成功
31 | ///
32 | ///
33 | HHomMat2D TestimageToRefImage(bool useAngle);
34 | HTuple TestToRefMat2D(bool useAngle);
35 | ///
36 | /// 生成原始图像到测试图像的变换矩阵,此处需要查找模板成功
37 | ///
38 | ///
39 | HHomMat2D RefImageToTestImage(bool useAngle);
40 | HTuple GetRefPoint();
41 | HTuple GetMatchingPoint();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/Mat2DManger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Yoga.Tools
6 | {
7 | public delegate void SelectMatchingToolDelegate(IMatching matchingTool);
8 | [Serializable]
9 | public class Mat2DManger
10 | {
11 | private string mat2DToolName;
12 | private bool useMat2D = false;
13 | [NonSerialized]
14 | IMatching matchingTool;
15 | [NonSerialized]
16 | private ToolBase tool;
17 | [NonSerialized]
18 | private List mat2dTools;
19 | private bool useMat2DAlways = false;
20 |
21 | private int settingIndex;
22 | private string toolName;
23 | [NonSerialized]
24 | public SelectMatchingToolDelegate SelectMatchingToolObserver;
25 | #region 属性
26 |
27 | private bool canSelectTool = true;
28 | public string Mat2DToolName
29 | {
30 | get
31 | {
32 | return mat2DToolName;
33 | }
34 |
35 | set
36 | {
37 | mat2DToolName = value;
38 | }
39 | }
40 |
41 | public bool UseMat2D
42 | {
43 | get
44 | {
45 | return useMat2D;
46 | }
47 |
48 | set
49 | {
50 | useMat2D = value;
51 | }
52 | }
53 | ///
54 | /// 当前工具所使用的定位工具
55 | ///
56 | public IMatching MatchingTool
57 | {
58 | get
59 | {
60 | if (matchingTool == null)
61 | {
62 | matchingTool = ToolsFactory.GetToolList(settingIndex).Find(
63 | x => x.Name == mat2DToolName) as IMatching;
64 | }
65 | return matchingTool;
66 | }
67 |
68 | set
69 | {
70 | matchingTool = value;
71 | Mat2DToolName = ((ToolBase)matchingTool).Name;
72 | CanSelectTool = false;
73 | }
74 | }
75 |
76 | public List Mat2dTools
77 | {
78 | get
79 | {
80 | if (mat2dTools == null)
81 | {
82 | mat2dTools = ToolsFactory.GetAllMatchingTools(settingIndex);
83 | }
84 | return mat2dTools;
85 | }
86 |
87 | }
88 | ///
89 | /// 一直使用匹配定位
90 | ///
91 | public bool UseMat2DAlways
92 | {
93 | get
94 | {
95 | return useMat2DAlways;
96 | }
97 |
98 | set
99 | {
100 | if (value == true)
101 | {
102 | useMat2D = true;
103 | }
104 | useMat2DAlways = value;
105 | }
106 | }
107 |
108 | public int SettingIndex
109 | {
110 | get
111 | {
112 | return settingIndex;
113 | }
114 | }
115 |
116 | public bool CanSelectTool
117 | {
118 | get
119 | {
120 | return canSelectTool;
121 | }
122 |
123 | set
124 | {
125 | canSelectTool = value;
126 | }
127 | }
128 | #endregion
129 | public Mat2DManger(ToolBase tool)
130 | {
131 | this.tool = tool;
132 | this.settingIndex = tool.SettingIndex;
133 | this.toolName = tool.Name;
134 | }
135 | }
136 |
137 | }
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/Mat2DMangerUnit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace Yoga.Tools
7 | {
8 | public partial class Mat2DMangerUnit : UserControl
9 | {
10 | private List mat2dTools;
11 | private Mat2DManger mat2dManger;
12 |
13 |
14 |
15 | public Mat2DMangerUnit()
16 | {
17 | InitializeComponent();
18 | }
19 | public void Init(Mat2DManger mat2dManger )
20 | {
21 | this.mat2dManger = mat2dManger;
22 | mat2dTools = mat2dManger.Mat2dTools;
23 | chkUseMat2D.Checked = mat2dManger.UseMat2D;
24 | if (mat2dManger.UseMat2DAlways)
25 | {
26 | chkUseMat2D.Enabled = false;
27 | }
28 | if (mat2dManger.CanSelectTool==false)
29 | {
30 | groupBoxSelectMat2DTool.Enabled = false;
31 | }
32 | foreach (var item in mat2dTools)
33 | {
34 | cmbMatchingToolSelect.Items.Add(item);
35 | }
36 | if (mat2dTools != null && mat2dTools.Count > 0)
37 | {
38 | int index = mat2dTools.FindIndex(x => x == mat2dManger.Mat2DToolName);
39 | if (index != -1)
40 | {
41 | cmbMatchingToolSelect.SelectedIndex = index;
42 | }
43 | }
44 | }
45 | private void cmbMatchingToolSelect_SelectedIndexChanged(object sender, EventArgs e)
46 | {
47 | if (mat2dManger==null)
48 | {
49 | return;
50 | }
51 | int index = cmbMatchingToolSelect.SelectedIndex;
52 |
53 | if (index > -1)
54 | {
55 | mat2dManger.Mat2DToolName = mat2dTools[index];
56 | IMatching matchingTool = ToolsFactory.GetToolList(mat2dManger.SettingIndex).Find(
57 | x => x.Name == mat2dTools[index]) as IMatching;
58 | if (matchingTool != null)
59 | {
60 | mat2dManger.Mat2DToolName = ((ToolBase)matchingTool).Name;
61 | if (mat2dManger.SelectMatchingToolObserver!=null)
62 | {
63 | mat2dManger.SelectMatchingToolObserver(matchingTool);
64 | }
65 | }
66 | }
67 | }
68 |
69 | private void chkUseMat2D_CheckedChanged(object sender, EventArgs e)
70 | {
71 | if (mat2dManger == null)
72 | {
73 | return;
74 | }
75 | cmbMatchingToolSelect.Enabled = chkUseMat2D.Checked;
76 | mat2dManger.UseMat2D = chkUseMat2D.Checked;
77 | }
78 |
79 | private void Mat2DMangerUnit_Load(object sender, EventArgs e)
80 | {
81 |
82 |
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/PointD.cs:
--------------------------------------------------------------------------------
1 | using HalconDotNet;
2 | using System;
3 |
4 | namespace Yoga.Tools
5 | {
6 | ///
7 | /// 坐标点数据
8 | ///
9 | [Serializable]
10 | public struct PointD
11 | {
12 | public double X;
13 | public double Y;
14 | public PointD(double x, double y)
15 | {
16 | X = x;
17 | Y = y;
18 | }
19 | }
20 | [Serializable]
21 | public struct PointT
22 | {
23 | public HTuple X;
24 | public HTuple Y;
25 | public PointT(HTuple x, HTuple y)
26 | {
27 | X = x;
28 | Y = y;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/RunStatus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Tools.Factory
8 | {
9 | [Serializable]
10 | public class RunStatus
11 | {
12 | public int SettingIndex { get; private set; } = 1;
13 | public int CameraIndex { get; private set; } = 1;
14 | public int OKCount { get; set; } = 0;
15 | public int NgCount { get; set; } = 0;
16 | public double CylceTime { get; set; } = 0;
17 |
18 | public string FpsStr { get; set; } = string.Empty;
19 | public List RunStatusList = new List();
20 |
21 | public string ResultMessage { get; set; } = "";
22 | public RunStatus(int settingIndex,int cameraIndex)
23 | {
24 | SettingIndex = settingIndex;
25 | CameraIndex = cameraIndex;
26 | }
27 | public RunStatus DeepClone()
28 | {
29 | if (this==null)
30 | {
31 | return null;
32 | }
33 | return Common.FileAct.SerializationFile.Clone(this) as RunStatus;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/SacleImagePretreatment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using HalconDotNet;
7 | namespace Yoga.Tools
8 | {
9 | [Serializable]
10 | public class SacleImagePretreatment
11 | {
12 | int offset = 0;
13 | double scale = 1;
14 | public int Offset
15 | {
16 | get
17 | {
18 | return offset;
19 | }
20 | set
21 | {
22 | offset = value;
23 | }
24 | }
25 | public double Scale
26 | {
27 | get
28 | {
29 | return scale;
30 | }
31 | set
32 | {
33 | scale = value;
34 | }
35 |
36 | }
37 |
38 | public HImage Run(HImage img)
39 | {
40 | double offsetTmp = Scale * Offset;
41 | return img.ScaleImage(Scale, offsetTmp);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/SacleImagePretreatmentUnit.cs:
--------------------------------------------------------------------------------
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 |
11 | namespace Yoga.Tools.Factory
12 | {
13 | public partial class SacleImagePretreatmentUnit : UserControl
14 | {
15 |
16 | bool locked = false;
17 |
18 | public SacleImagePretreatmentUnit()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void ScaleUpDown_ValueChanged(object sender, EventArgs e)
24 | {
25 | if (locked)
26 | {
27 | return;
28 | }
29 | }
30 |
31 | private void OffsetUpDown_ValueChanged(object sender, EventArgs e)
32 | {
33 | if (locked)
34 | {
35 | return;
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/SettingThread.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Yoga.Tools
8 | {
9 | ///
10 | /// 设置处理线程
11 | ///
12 | public class SettingThread
13 | {
14 | ToolBase tool;
15 | int runCount;
16 | bool isRunning = false;
17 | public event EventHandler RunFinishEvent;
18 |
19 | private object lockObj = new object();
20 |
21 | public int RunCount
22 | {
23 | get
24 | {
25 | lock (lockObj)
26 | {
27 | return runCount;
28 | }
29 | }
30 |
31 | set
32 | {
33 | lock (lockObj)
34 | {
35 | runCount = value;
36 | }
37 | }
38 | }
39 |
40 | public bool IsRunning
41 | {
42 | get
43 | {
44 | lock (lockObj)
45 | {
46 | return isRunning;
47 | }
48 | }
49 |
50 | set
51 | {
52 | lock (lockObj)
53 | {
54 | isRunning = value;
55 | }
56 | }
57 | }
58 |
59 | public SettingThread(ToolBase tool)
60 | {
61 | this.tool = tool;
62 | }
63 | private void Run()
64 | {
65 | Task.Run(new Action(() =>
66 | {
67 | IsRunning = true;
68 | try
69 | {
70 | while (RunCount > 0)
71 | {
72 | RunCount = 0;
73 |
74 | tool.RunRef();
75 | if (RunFinishEvent != null)
76 | {
77 | RunFinishEvent(this, null);
78 | }
79 |
80 | }
81 |
82 | }
83 | catch (Exception /*ex*/)
84 | {
85 | Common.Util.Notify("发生异常,请检查参数" );
86 | }
87 | finally
88 | {
89 | IsRunning = false;
90 | }
91 |
92 | }));
93 |
94 | }
95 | public void AddTask()
96 | {
97 | RunCount++;
98 | if (IsRunning == false)
99 | {
100 | Run();
101 | }
102 | }
103 |
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/ToolReflection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Yoga.Tools
9 | {
10 | public struct ToolReflection
11 | {
12 | public Assembly Assembly;
13 | public Type Type;
14 | public ToolReflection(Assembly assembly, Type type)
15 | {
16 | this.Assembly = assembly;
17 | this.Type = type;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/ToolVbaFun.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace Yoga.Tools.Factory
9 | {
10 |
11 | ///
12 | /// vba引擎共用方法
13 | ///
14 | [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute()]
15 | public class ToolObject
16 | {
17 | static ToolVbaFun f = null;
18 | ///
19 | /// 全局的 HMeasureSYS 对象
20 | ///
21 | public static ToolVbaFun F
22 | {
23 | get
24 | {
25 | return f;
26 | }
27 | }
28 | }
29 | public class ToolVbaFun
30 | {
31 | public static void Show(string s)
32 | {
33 | MessageBox.Show(s);
34 | }
35 |
36 | public static bool GetToolStatus(string toolName)
37 | {
38 | ToolBase tool = ToolsFactory.GetTool(toolName);
39 | if (tool != null)
40 | {
41 | return tool.IsOk;
42 | }
43 | return false;
44 | }
45 | public static void SetValue(string toolName, string key, object value)
46 | {
47 | ToolBase tool = ToolsFactory.GetTool(toolName);
48 | if (tool != null)
49 | {
50 | return;
51 | }
52 | tool.SetValue(key, value);
53 | }
54 |
55 | public static object GetValue(string toolName, string key)
56 | {
57 | ToolBase tool = ToolsFactory.GetTool(toolName);
58 | if (tool != null)
59 | {
60 | return null;
61 | }
62 | return tool.getValue(key);
63 | }
64 | public static void MarkTool(string toolName, bool flag)
65 | {
66 | ToolBase tool = ToolsFactory.GetTool(toolName);
67 | if (tool != null)
68 | {
69 | tool.MarkTool(flag);
70 | }
71 | }
72 | public static void SetToolResult(string toolName, string dat)
73 | {
74 | ToolBase tool = ToolsFactory.GetTool(toolName);
75 | if (tool != null)
76 | {
77 | tool.Result = dat;
78 | }
79 | }
80 |
81 | public static string GetToolResult(string toolName)
82 | {
83 | ToolBase tool = ToolsFactory.GetTool(toolName);
84 | if (tool != null)
85 | {
86 | return tool.Result;
87 | }
88 | return "";
89 | }
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/frmSelectCameraIndex.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Tools.Factory
2 | {
3 | partial class frmSelectCameraIndex
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.cmbCameraSelect = new System.Windows.Forms.ComboBox();
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.btnOK = new System.Windows.Forms.Button();
34 | this.SuspendLayout();
35 | //
36 | // cmbCameraSelect
37 | //
38 | this.cmbCameraSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
39 | this.cmbCameraSelect.FormattingEnabled = true;
40 | this.cmbCameraSelect.Location = new System.Drawing.Point(111, 29);
41 | this.cmbCameraSelect.Name = "cmbCameraSelect";
42 | this.cmbCameraSelect.Size = new System.Drawing.Size(121, 20);
43 | this.cmbCameraSelect.TabIndex = 0;
44 | this.cmbCameraSelect.SelectedIndexChanged += new System.EventHandler(this.cmbCameraSelect_SelectedIndexChanged);
45 | //
46 | // label1
47 | //
48 | this.label1.AutoSize = true;
49 | this.label1.Location = new System.Drawing.Point(40, 32);
50 | this.label1.Name = "label1";
51 | this.label1.Size = new System.Drawing.Size(53, 12);
52 | this.label1.TabIndex = 1;
53 | this.label1.Text = "相机编号";
54 | //
55 | // btnOK
56 | //
57 | this.btnOK.Location = new System.Drawing.Point(84, 123);
58 | this.btnOK.Name = "btnOK";
59 | this.btnOK.Size = new System.Drawing.Size(75, 23);
60 | this.btnOK.TabIndex = 2;
61 | this.btnOK.Text = "确定";
62 | this.btnOK.UseVisualStyleBackColor = true;
63 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
64 | //
65 | // frmSelectCameraIndex
66 | //
67 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
68 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
69 | this.ClientSize = new System.Drawing.Size(297, 173);
70 | this.Controls.Add(this.btnOK);
71 | this.Controls.Add(this.label1);
72 | this.Controls.Add(this.cmbCameraSelect);
73 | this.Name = "frmSelectCameraIndex";
74 | this.Text = "相机选择";
75 | this.ResumeLayout(false);
76 | this.PerformLayout();
77 |
78 | }
79 |
80 | #endregion
81 |
82 | private System.Windows.Forms.ComboBox cmbCameraSelect;
83 | private System.Windows.Forms.Label label1;
84 | private System.Windows.Forms.Button btnOK;
85 | }
86 | }
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/frmSelectCameraIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Yoga.Tools.Factory
12 | {
13 | public partial class frmSelectCameraIndex : Form
14 | {
15 | int cameraIndex = 1;
16 |
17 | public int CameraIndex
18 | {
19 | get
20 | {
21 | return cameraIndex;
22 | }
23 | private set
24 | {
25 | cameraIndex = value;
26 | }
27 | }
28 |
29 | public frmSelectCameraIndex(int cameraWant)
30 | {
31 | InitializeComponent();
32 |
33 | cmbCameraSelect.Items.Clear();
34 | int count = Camera.CameraManger.CameraDic.Count;
35 | for (int i = 1; i < count + 1; i++)
36 | {
37 | cmbCameraSelect.Items.Add(string.Format("相机{0}", i));
38 | }
39 | if (cameraWant< count + 1)
40 | {
41 | cmbCameraSelect.SelectedIndex = cameraWant-1;
42 | }
43 |
44 | }
45 |
46 | private void cmbCameraSelect_SelectedIndexChanged(object sender, EventArgs e)
47 | {
48 | CameraIndex = cmbCameraSelect.SelectedIndex+1;
49 | }
50 |
51 | private void btnOK_Click(object sender, EventArgs e)
52 | {
53 | this.DialogResult = DialogResult.OK;
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/frmToolSelect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 |
5 | namespace Yoga.Tools
6 | {
7 | public partial class frmToolSelect : Form
8 | {
9 | List toolsTypeList = ToolsFactory.AllToolsType;
10 | int settingIndex;
11 | public frmToolSelect(int settingIndex)
12 | {
13 | InitializeComponent();
14 | this.settingIndex = settingIndex;
15 | }
16 |
17 | private void btnSelect_Click(object sender, EventArgs e)
18 | {
19 | int index = lsbxTools.SelectedIndex;
20 | if (index > -1)
21 | {
22 | try
23 | {
24 | ToolsFactory.CreateTool(settingIndex, toolsTypeList[index]);
25 |
26 | this.DialogResult = DialogResult.OK;
27 | }
28 | catch(Exception ex)
29 | {
30 | MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
31 | }
32 | }
33 | }
34 |
35 | private void frmToolSelect_Load(object sender, EventArgs e)
36 | {
37 | lsbxTools.Items.Clear();
38 | foreach (var item in toolsTypeList)
39 | {
40 | ////= item.GetField("toolName", BindingFlags.Static).GetValue(null).ToString();
41 |
42 | string tooltype = item.Type.GetProperty("ToolType").GetValue(null, null).ToString();
43 | lsbxTools.Items.Add(tooltype);
44 | }
45 | }
46 |
47 |
48 | private void lsbxTools_SelectedIndexChanged(object sender, EventArgs e)
49 | {
50 | int index = lsbxTools.SelectedIndex;
51 | if (index > -1)
52 | {
53 | txtToolExplanation.Text = toolsTypeList[index].Type.GetProperty("ToolExplanation").GetValue(null, null).ToString();
54 | //txtToolName.Text=ToolsFactory.getf
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/frmToolSetting.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.Tools
2 | {
3 | partial class frmToolSetting
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.panel1 = new System.Windows.Forms.Panel();
32 | this.SuspendLayout();
33 | //
34 | // panel1
35 | //
36 | this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
37 | this.panel1.Location = new System.Drawing.Point(0, 0);
38 | this.panel1.Name = "panel1";
39 | this.panel1.Size = new System.Drawing.Size(796, 573);
40 | this.panel1.TabIndex = 0;
41 | //
42 | // frmToolSetting
43 | //
44 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
45 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
46 | this.ClientSize = new System.Drawing.Size(796, 573);
47 | this.Controls.Add(this.panel1);
48 | this.Name = "frmToolSetting";
49 | this.Text = "工具设置";
50 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmToolSetting_FormClosing);
51 | this.Load += new System.EventHandler(this.frmToolSetting_Load);
52 | this.ResumeLayout(false);
53 |
54 | }
55 |
56 | #endregion
57 |
58 | private System.Windows.Forms.Panel panel1;
59 | }
60 | }
--------------------------------------------------------------------------------
/Yoga.Tools/Factory/frmToolSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 |
5 | namespace Yoga.Tools
6 | {
7 | public partial class frmToolSetting : Form
8 | {
9 | private ToolsSettingUnit settingUnit;
10 |
11 |
12 | public frmToolSetting(ToolsSettingUnit settingUnit)
13 | {
14 | InitializeComponent();
15 | this.settingUnit = settingUnit;
16 | Size size = settingUnit.Size;
17 | this.Size = new Size(size.Width + 10, size.Height + 10);
18 | this.panel1.Dock = DockStyle.Fill;
19 | settingUnit.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
20 | this.panel1.Controls.Clear();
21 | this.panel1.Controls.Add(settingUnit);
22 | }
23 |
24 | private void frmToolSetting_Load(object sender, EventArgs e)
25 | {
26 | settingUnit.ShowTranResult();
27 | }
28 |
29 | private void frmToolSetting_FormClosing(object sender, FormClosingEventArgs e)
30 | {
31 | try
32 | {
33 | settingUnit.Tool.SerializeCheck();
34 | }
35 | catch(Exception ex)
36 | {
37 | DialogResult result = MessageBox.Show("数据异常:" +ex.Message+ " 是否继续退出?",
38 | "异常", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
39 | if (result != DialogResult.Yes)
40 | {
41 | e.Cancel = true;
42 | return;
43 | }
44 | }
45 | settingUnit.Clear();
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/Yoga.Tools/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Tools")]
9 | [assembly: AssemblyDescription("图像处理工具集")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HYCONN")]
12 | [assembly: AssemblyProduct("Tools")]
13 | [assembly: AssemblyCopyright("Copyright © HYCONN 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("205d289c-64f9-4b9c-bf5f-0327152ea14a")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | [assembly: AssemblyVersion("1.2.*")]
35 | //[assembly: AssemblyVersion("1.0.0.0")]
36 | //[assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/AppManger/UserSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Yoga.Common;
4 | using Yoga.Common.Basic;
5 | using Yoga.Common.FileAct;
6 |
7 | namespace Yoga.VisionMix
8 | {
9 | [Serializable]
10 | ///
11 | /// 用户自定义数据类
12 | ///
13 | class UserSetting
14 | {
15 | public static UserSetting Instance = new UserSetting();
16 |
17 | private static readonly string userDataPath = Environment.CurrentDirectory + "\\user.dat";
18 | private string projectPath = Environment.CurrentDirectory + "\\project\\产品1.prj";
19 | private readonly string projectPathInit = Environment.CurrentDirectory + "\\project\\产品1.prj";
20 |
21 | private string softKey;
22 | // private Dictionary cameraPramDic;
23 |
24 | private CommunicationParam ioRs232Param;
25 | public CommunicationParam IoRs232Param
26 | {
27 | get
28 | {
29 | if (ioRs232Param == null)
30 | {
31 | ioRs232Param = new CommunicationParam();
32 | }
33 | return ioRs232Param;
34 | }
35 |
36 | set
37 | {
38 | ioRs232Param = value;
39 | }
40 | }
41 |
42 |
43 | public string ProjectPath
44 | {
45 | get
46 | {
47 | if (projectPath == null)
48 | {
49 | projectPath = projectPathInit;
50 | }
51 | return projectPath;
52 | }
53 |
54 | set
55 | {
56 | projectPath = value;
57 | }
58 | }
59 |
60 | public static string UserDataPath
61 | {
62 | get
63 | {
64 | return userDataPath;
65 | }
66 | }
67 |
68 | public string SoftKey
69 | {
70 | get
71 | {
72 | return softKey;
73 | }
74 |
75 | set
76 | {
77 | softKey = value;
78 | }
79 | }
80 |
81 |
82 |
83 | public void ReadSetting()
84 | {
85 |
86 | UserSetting setting = SerializationFile.DeserializeObject(
87 | UserDataPath) as UserSetting;
88 | if (setting == null)
89 | {
90 | setting = new UserSetting();
91 | }
92 | Instance = setting;
93 | }
94 | public void SaveSetting()
95 | {
96 | if (projectPath == projectPathInit)
97 | {
98 | projectPath = null;
99 | }
100 | if (SerializationFile.TrySerialize(Instance))
101 | {
102 | try
103 | {
104 | SerializationFile.SerializeObject(userDataPath, Instance);
105 | }
106 | catch(Exception ex)
107 | {
108 | Util.WriteLog(this.GetType(), ex);
109 | Util.Notify(Level.Err,"用户设置保存失败");
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Frame/frmAbout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Windows.Forms;
4 |
5 | namespace Yoga.VisionMix.Frame
6 | {
7 | partial class frmAbout : Form
8 | {
9 | public frmAbout()
10 | {
11 | InitializeComponent();
12 | this.Text = String.Format("关于 {0}", AssemblyTitle);
13 | this.labelProductName.Text = AssemblyProduct;
14 | this.labelVersion.Text = String.Format("版本 {0}", AssemblyVersion);
15 | this.labelCopyright.Text = AssemblyCopyright;
16 | this.labelCompanyName.Text = AssemblyCompany;
17 | this.textBoxDescription.Text = AssemblyDescription;
18 | }
19 |
20 | #region 程序集特性访问器
21 |
22 | public static string AssemblyTitle
23 | {
24 | get
25 | {
26 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
27 | if (attributes.Length > 0)
28 | {
29 | AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
30 | if (titleAttribute.Title != "")
31 | {
32 | return titleAttribute.Title;
33 | }
34 | }
35 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
36 | }
37 | }
38 |
39 | public static string AssemblyVersion
40 | {
41 | get
42 | {
43 | return Assembly.GetExecutingAssembly().GetName().Version.ToString();
44 | }
45 | }
46 |
47 | public static string AssemblyDescription
48 | {
49 | get
50 | {
51 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
52 | if (attributes.Length == 0)
53 | {
54 | return "";
55 | }
56 | return ((AssemblyDescriptionAttribute)attributes[0]).Description;
57 | }
58 | }
59 |
60 | public static string AssemblyProduct
61 | {
62 | get
63 | {
64 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
65 | if (attributes.Length == 0)
66 | {
67 | return "";
68 | }
69 | return ((AssemblyProductAttribute)attributes[0]).Product;
70 | }
71 | }
72 |
73 | public static string AssemblyCopyright
74 | {
75 | get
76 | {
77 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
78 | if (attributes.Length == 0)
79 | {
80 | return "";
81 | }
82 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
83 | }
84 | }
85 |
86 | public static string AssemblyCompany
87 | {
88 | get
89 | {
90 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
91 | if (attributes.Length == 0)
92 | {
93 | return "";
94 | }
95 | return ((AssemblyCompanyAttribute)attributes[0]).Company;
96 | }
97 | }
98 | #endregion
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Frame/frmLogin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace Yoga.VisionMix.Frame
5 | {
6 | public partial class frmLogin : Form
7 | {
8 | private string password = "";
9 | private string checkerPassword = "";
10 | public frmLogin()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | private void Btn_Ok_Click(object sender, EventArgs e)
16 | {
17 | string passwordInput = Text_PassWord.Text.Trim();
18 | if (drpOperator.SelectedIndex == 1
19 | && (passwordInput == password.Trim()|| passwordInput==checkerPassword.Trim()))
20 | {
21 | if (passwordInput == checkerPassword.Trim())
22 | {
23 | StatusManger.Instance.IsChecker = true;
24 | Common.Util.Notify("可以开始点检");
25 | }
26 | this.DialogResult = DialogResult.OK;
27 | }
28 | else if (drpOperator.SelectedIndex == 0)
29 | {
30 | this.DialogResult = DialogResult.Cancel;
31 | }
32 | else
33 | {
34 | MessageBox.Show("账户或密码错误!");
35 | }
36 | }
37 |
38 | private void Btn_Cancel_Click(object sender, EventArgs e)
39 | {
40 | this.DialogResult = DialogResult.Cancel;
41 | }
42 |
43 | private void frmLogin_Load(object sender, EventArgs e)
44 | {
45 | drpOperator.SelectedIndex = 1;
46 | password = IniStatus.Instance.Password;
47 | checkerPassword = IniStatus.Instance.CheckPassword;
48 | }
49 |
50 | private void Text_PassWord_KeyDown(object sender, KeyEventArgs e)
51 | {
52 | if (e.KeyCode == Keys.Enter)
53 | {
54 | Btn_Ok_Click(null, null);
55 | }
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/Yoga.VisionMix/Frame/frmProjectManger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using Yoga.Common.Basic;
12 |
13 | namespace Yoga.VisionMix.Frame
14 | {
15 | public partial class frmProjectManger : Form
16 | {
17 | string path = Environment.CurrentDirectory + "\\project";
18 | public frmProjectManger()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void btnAddNewProject_Click(object sender, EventArgs e)
24 | {
25 | frmImputText frm = new frmImputText("项目名称");
26 | DialogResult result = frm.ShowDialog();
27 | if (result != DialogResult.OK)
28 | {
29 | return;
30 | }
31 | if (lsbAllProject.Items.Contains(frm.ImputText)!=false)
32 | {
33 | MessageBox.Show("名称");
34 | }
35 | }
36 |
37 | private void frmProjectManger_Load(object sender, EventArgs e)
38 | {
39 | if (!Directory.Exists(path))//若文件夹不存在则新建文件夹
40 | {
41 | Directory.CreateDirectory(path); //新建文件夹
42 | }
43 | List picPathList = new List();
44 | lsbAllProject.Items.Clear();
45 | //获取指定文件夹的所有文件
46 | string[] paths = Directory.GetFiles(path);
47 | foreach (var item in paths)
48 | {
49 | //获取文件后缀名
50 | string extension = Path.GetExtension(item).ToLower();
51 | if (extension == ".prj")
52 | {
53 | string prj = Path.GetFileNameWithoutExtension(item);
54 | lsbAllProject.Items.Add(prj);
55 | }
56 | }
57 | txtCurrentProject.Text = Path.GetFileNameWithoutExtension(UserSetting.Instance.ProjectPath);
58 |
59 | }
60 |
61 | private void btnSetCurrentProject_Click(object sender, EventArgs e)
62 | {
63 | string name = lsbAllProject.SelectedItem.ToString();
64 | if (txtCurrentProject.Text== name)
65 | {
66 | return;
67 | }
68 | UserSetting.Instance.ProjectPath = name;
69 | txtCurrentProject.Text = name;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Frame/frmRegistered.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.VisionMix.Frame
2 | {
3 | partial class frmRegistered
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.tbSoftKey = new System.Windows.Forms.TextBox();
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.btnOk = new System.Windows.Forms.Button();
34 | this.SuspendLayout();
35 | //
36 | // tbSoftKey
37 | //
38 | this.tbSoftKey.Location = new System.Drawing.Point(104, 26);
39 | this.tbSoftKey.Name = "tbSoftKey";
40 | this.tbSoftKey.Size = new System.Drawing.Size(407, 21);
41 | this.tbSoftKey.TabIndex = 0;
42 | //
43 | // label1
44 | //
45 | this.label1.AutoSize = true;
46 | this.label1.Location = new System.Drawing.Point(44, 29);
47 | this.label1.Name = "label1";
48 | this.label1.Size = new System.Drawing.Size(41, 12);
49 | this.label1.TabIndex = 1;
50 | this.label1.Text = "注册码";
51 | //
52 | // btnOk
53 | //
54 | this.btnOk.Location = new System.Drawing.Point(217, 67);
55 | this.btnOk.Name = "btnOk";
56 | this.btnOk.Size = new System.Drawing.Size(75, 23);
57 | this.btnOk.TabIndex = 2;
58 | this.btnOk.Text = "确定";
59 | this.btnOk.UseVisualStyleBackColor = true;
60 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
61 | //
62 | // frmRegistered
63 | //
64 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
65 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
66 | this.ClientSize = new System.Drawing.Size(544, 102);
67 | this.Controls.Add(this.btnOk);
68 | this.Controls.Add(this.label1);
69 | this.Controls.Add(this.tbSoftKey);
70 | this.Name = "frmRegistered";
71 | this.Text = "软件注册";
72 | this.ResumeLayout(false);
73 | this.PerformLayout();
74 |
75 | }
76 |
77 | #endregion
78 |
79 | private System.Windows.Forms.TextBox tbSoftKey;
80 | private System.Windows.Forms.Label label1;
81 | private System.Windows.Forms.Button btnOk;
82 | }
83 | }
--------------------------------------------------------------------------------
/Yoga.VisionMix/Frame/frmRegistered.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using Yoga.Common.Helpers;
11 |
12 | namespace Yoga.VisionMix.Frame
13 | {
14 | public partial class frmRegistered : Form
15 | {
16 | public frmRegistered()
17 | {
18 | InitializeComponent();
19 | this.ControlBox = false; // 设置不出现关闭按钮
20 | }
21 |
22 | private void btnOk_Click(object sender, EventArgs e)
23 | {
24 | string str = RegisterHelper.getMNum();
25 | if (tbSoftKey.Text==str)
26 | {
27 | MessageBox.Show("注册成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
28 |
29 | UserSetting.Instance.SoftKey = str;
30 | UserSetting.Instance.SaveSetting();
31 | this.DialogResult = DialogResult.OK;
32 | }
33 | else
34 | {
35 | MessageBox.Show("注册失败,机器码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
36 | // 终止此进程并为基础操作系统提供指定的退出代码。
37 | System.Environment.Exit(1);
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("VisionMix")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("M")]
12 | [assembly: AssemblyProduct("VisionMix")]
13 | [assembly: AssemblyCopyright("Copyright © M 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("bae8be40-ac76-43c4-898a-e4c1d2fa6c36")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | [assembly: AssemblyVersion("1.3.*")]
35 | //[assembly: AssemblyVersion("1.0.0.0")]
36 | //[assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Yoga.VisionMix.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/Setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/Setting.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/logo.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/openImg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/openImg.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/openPrj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/openPrj.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/saveAs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/saveAs.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/saveProject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/saveProject.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/saveprj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/saveprj.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/test.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/user.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Resources/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/Resources/video.png
--------------------------------------------------------------------------------
/Yoga.VisionMix/Units/DockUnit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Windows.Forms;
4 | using Yoga.VisionMix.Frame;
5 | using System.Diagnostics;
6 |
7 | namespace Yoga.VisionMix.Units
8 | {
9 | public partial class DockUnit : UserControl
10 | {
11 | FrmMain _pMainFrame;
12 | Process kbpr;
13 | public DockUnit(FrmMain mainframe)
14 | {
15 | _pMainFrame = mainframe;
16 | InitializeComponent();
17 | }
18 | private void Btn_Quit_Click(object sender, EventArgs e)
19 | {
20 | _pMainFrame.Close();
21 |
22 | }
23 |
24 |
25 | private void Btn_IO_Click(object sender, EventArgs e)
26 | {
27 | //_pMainFrame.Frame_Show.ShowControls(_pMainFrame.Frame_Show.FrameIO);
28 | }
29 |
30 |
31 | private void Btn_Automation_Click(object sender, EventArgs e)
32 | {
33 | //_pMainFrame.Frame_Show.ShowControls(_pMainFrame.Frame_Show.FrameAuto);
34 | }
35 |
36 |
37 | private void Btn_About_Click(object sender, EventArgs e)
38 | {
39 | frmAbout about = new frmAbout();
40 | about.ShowDialog();
41 | }
42 |
43 | private void Clock_Tick(object sender, EventArgs e)
44 | {
45 | Label_Date.Text = DateTime.Now.Date.ToString("yyyy/MM/dd");
46 | Label_Time.Text = DateTime.Now.ToLongTimeString().ToString();
47 | }
48 |
49 | private void DockFrame_Load(object sender, EventArgs e)
50 | {
51 | string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
52 | string time = System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).
53 | ToString("yy_MM_dd");
54 | Label_Version.Text = "V"+ version+"\r\n"+time;
55 | }
56 | private void btnLogin_Click(object sender, EventArgs e)
57 | {
58 | frmLogin Frame_Login = new frmLogin();
59 | bool isLogin = false;
60 | if (Frame_Login.ShowDialog() != DialogResult.OK)
61 | {
62 | isLogin = false;
63 | //_pMainFrame.Frame_Show.FrameAuto.LoginSetting(false);
64 | //btnSetting.Enabled = false;
65 | //return;
66 | }
67 | else
68 | {
69 | isLogin = true;
70 | timerLogin.Interval = 1000 * 60* IniStatus.Instance.LogionDelay;
71 | timerLogin.Enabled = true;
72 | }
73 |
74 | LoginSetting(isLogin);
75 | }
76 |
77 | public void LoginSetting(bool isLogin)
78 | {
79 | //_pMainFrame.Frame_Show.FrameAuto.LoginSetting(isLogin);
80 | btnSetting.Enabled = isLogin;
81 | // Btn_Quit.Enabled = isLogin;
82 | }
83 | private void btnSetting_Click(object sender, EventArgs e)
84 | {
85 | //_pMainFrame.Frame_Show.ShowControls(_pMainFrame.Frame_Show.FrameConfig);
86 | }
87 |
88 | private void btnSoftKeyBoard_Click(object sender, EventArgs e)
89 | {
90 | try
91 | {
92 | if (kbpr != null && !kbpr.HasExited)
93 | {
94 | kbpr.Kill();
95 | }
96 | else
97 | {
98 | kbpr = System.Diagnostics.Process.Start("osk.exe"); // 打开系统键盘
99 | }
100 | }
101 | catch(Exception ex)
102 | {
103 | MessageBox.Show("软键盘操作异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
104 | }
105 | }
106 |
107 | private void timerLogin_Tick(object sender, EventArgs e)
108 | {
109 | LoginSetting(false);
110 | timerLogin.Enabled = false;
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Units/ToolDgv.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Yoga.VisionMix.Units
2 | {
3 | partial class ToolDgv
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.dgvTools = new System.Windows.Forms.DataGridView();
32 | this.groupBox1 = new System.Windows.Forms.GroupBox();
33 | ((System.ComponentModel.ISupportInitialize)(this.dgvTools)).BeginInit();
34 | this.groupBox1.SuspendLayout();
35 | this.SuspendLayout();
36 | //
37 | // dgvTools
38 | //
39 | this.dgvTools.AllowUserToAddRows = false;
40 | this.dgvTools.AllowUserToResizeColumns = false;
41 | this.dgvTools.AllowUserToResizeRows = false;
42 | this.dgvTools.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
43 | this.dgvTools.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
44 | this.dgvTools.Dock = System.Windows.Forms.DockStyle.Fill;
45 | this.dgvTools.Location = new System.Drawing.Point(3, 17);
46 | this.dgvTools.MultiSelect = false;
47 | this.dgvTools.Name = "dgvTools";
48 | this.dgvTools.RowTemplate.Height = 23;
49 | this.dgvTools.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
50 | this.dgvTools.Size = new System.Drawing.Size(374, 429);
51 | this.dgvTools.TabIndex = 82;
52 | //
53 | // groupBox1
54 | //
55 | this.groupBox1.Controls.Add(this.dgvTools);
56 | this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
57 | this.groupBox1.Location = new System.Drawing.Point(0, 0);
58 | this.groupBox1.Name = "groupBox1";
59 | this.groupBox1.Size = new System.Drawing.Size(380, 449);
60 | this.groupBox1.TabIndex = 83;
61 | this.groupBox1.TabStop = false;
62 | this.groupBox1.Text = "groupBox1";
63 | //
64 | // ToolDgv
65 | //
66 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
68 | this.Controls.Add(this.groupBox1);
69 | this.Name = "ToolDgv";
70 | this.Size = new System.Drawing.Size(380, 449);
71 | ((System.ComponentModel.ISupportInitialize)(this.dgvTools)).EndInit();
72 | this.groupBox1.ResumeLayout(false);
73 | this.ResumeLayout(false);
74 |
75 | }
76 |
77 | #endregion
78 |
79 | private System.Windows.Forms.DataGridView dgvTools;
80 | private System.Windows.Forms.GroupBox groupBox1;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/Units/ToolDgv.cs:
--------------------------------------------------------------------------------
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 |
11 | namespace Yoga.VisionMix.Units
12 | {
13 | public partial class ToolDgv : UserControl
14 | {
15 | public ToolDgv()
16 | {
17 | InitializeComponent();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Yoga.VisionMix/bitbug_favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.VisionMix/bitbug_favicon.ico
--------------------------------------------------------------------------------
/Yoga.Wrapper/AssemblyInfo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/AssemblyInfo.cpp
--------------------------------------------------------------------------------
/Yoga.Wrapper/Conversion.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/Conversion.cpp
--------------------------------------------------------------------------------
/Yoga.Wrapper/Conversion.h:
--------------------------------------------------------------------------------
1 | // Data conversion between HALCON/C++ and HALCON/.NET objects
2 | //
3 | // This class can be reused as is for your own interoperating project
4 |
5 | #pragma once
6 |
7 | #include "HalconCpp.h"
8 | #include"DynThresholdParamN.h"
9 | #include"DynThresholdParam.h"
10 | #include"OcrParam.h"
11 | #include"OcrParamN.h"
12 | // Due to identical class names in C++ and .NET, we only
13 | // declare the namespace for HALCON/.NET and use all C++
14 | // classes with the fully qualified name (HalconCpp::X)
15 | using namespace HalconDotNet;
16 |
17 | class Conversion
18 | {
19 | public:
20 |
21 | // Conversions from HALCON/.NET to HALCON/C++
22 | static HalconCpp::HObject ObjectToNative(HObject^ object);
23 | static HalconCpp::HImage ImageToNative(HImage^ image);
24 | static HalconCpp::HRegion RegionToNative(HRegion^ region);
25 | static HalconCpp::HXLD XLDToNative(HXLD^ xld);
26 | static HalconCpp::HTuple TupleToNative(HTuple^ tuple);
27 |
28 | static DynThresholdParamN DynThresholdParamToNative(Yoga::Wrapper::DynThresholdParam ^ param);
29 | static OcrParamN OcrPramToNative(Yoga::Wrapper::OcrParam^ param);
30 | // Conversions from HALCON/C++ to HALCON/.NET
31 | static HObject^ ObjectToManaged(const HalconCpp::HObject& object);
32 | static HImage^ ImageToManaged(const HalconCpp::HImage& image);
33 | static HRegion^ RegionToManaged(const HalconCpp::HRegion& region);
34 | static HXLD^ XLDToManaged(const HalconCpp::HXLD& xld);
35 | static HXLDCont^ HXLDContToManaged(const HalconCpp::HXLDCont& xld);
36 | static HTuple^ TupleToManaged(const HalconCpp::HTuple& tuple);
37 | static System::String^ StringToManged(const std::string& string);
38 | private:
39 |
40 | // Support functionality for implementing the conversions
41 | static System::IntPtr KeyToManaged(Hkey key);
42 | static Hkey KeyToNative(System::IntPtr handle);
43 | };
44 |
--------------------------------------------------------------------------------
/Yoga.Wrapper/DynThresholdParam.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | using namespace System::Runtime::InteropServices;
4 | using namespace System::Runtime::Serialization;
5 | using namespace System;
6 | namespace Yoga
7 | {
8 | namespace Wrapper
9 | {
10 | [Serializable]
11 | public ref struct DynThresholdParam
12 | {
13 | String^ lightDark;
14 | Double offset;
15 | Int32 maskWidth;
16 | Int32 maskHeight;
17 | Double closingRadius;
18 | Double openingRadius;
19 | Double leastArea;
20 | };
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/Yoga.Wrapper/Fun.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/Fun.cpp
--------------------------------------------------------------------------------
/Yoga.Wrapper/Fun.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/Fun.h
--------------------------------------------------------------------------------
/Yoga.Wrapper/NativeTest.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "NativeTest.h"
3 |
4 | using namespace HalconCpp;
5 | NativeTest::NativeTest()
6 | {
7 | }
8 |
9 |
10 | NativeTest::~NativeTest()
11 | {
12 | }
13 |
--------------------------------------------------------------------------------
/Yoga.Wrapper/NativeTest.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "HalconCpp.h"
3 |
4 | class NativeTest
5 | {
6 | public:
7 | NativeTest();
8 | ~NativeTest();
9 |
10 | };
11 |
12 |
--------------------------------------------------------------------------------
/Yoga.Wrapper/OcrParam.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/OcrParam.h
--------------------------------------------------------------------------------
/Yoga.Wrapper/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | DYNAMIC LINK LIBRARY : Wrapper Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this Wrapper DLL for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your Wrapper application.
9 |
10 | Wrapper.vcxproj
11 | This is the main project file for VC++ projects generated using an Application Wizard.
12 | It contains information about the version of Visual C++ that generated the file, and
13 | information about the platforms, configurations, and project features selected with the
14 | Application Wizard.
15 |
16 | Wrapper.vcxproj.filters
17 | This is the filters file for VC++ projects generated using an Application Wizard.
18 | It contains information about the association between the files in your project
19 | and the filters. This association is used in the IDE to show grouping of files with
20 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
21 | "Source Files" filter).
22 |
23 | Wrapper.cpp
24 | This is the main DLL source file.
25 |
26 | Wrapper.h
27 | This file contains a class declaration.
28 |
29 | AssemblyInfo.cpp
30 | Contains custom attributes for modifying assembly metadata.
31 |
32 | /////////////////////////////////////////////////////////////////////////////
33 | Other notes:
34 |
35 | AppWizard uses "TODO:" to indicate parts of the source code you
36 | should add to or customize.
37 |
38 | /////////////////////////////////////////////////////////////////////////////
39 |
--------------------------------------------------------------------------------
/Yoga.Wrapper/ShowUnit.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/ShowUnit.h
--------------------------------------------------------------------------------
/Yoga.Wrapper/Stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/Stdafx.cpp
--------------------------------------------------------------------------------
/Yoga.Wrapper/Stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/Stdafx.h
--------------------------------------------------------------------------------
/Yoga.Wrapper/UtilManaged.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/UtilManaged.cpp
--------------------------------------------------------------------------------
/Yoga.Wrapper/UtilManaged.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Util.h"
3 |
4 | using namespace System;
5 | using namespace System::Runtime::InteropServices;
6 |
7 | class Util;
8 | namespace Yoga
9 | {
10 | namespace Wrapper {
11 |
12 | public delegate void EventDelegate(String^ msg);
13 |
14 | public ref class UtilManaged
15 | {
16 | public:
17 | UtilManaged();
18 | ~UtilManaged();
19 | EventDelegate^ NetCallback;
20 | private:
21 | void Callback(String^ msg);
22 | GCHandle delegateHandle;
23 | EventDelegate^ nativeCallback;
24 | };
25 | }
26 | }
--------------------------------------------------------------------------------
/Yoga.Wrapper/Wrapper.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {12d8a31c-4ebe-4c5a-ab05-595255cb954c}
18 |
19 |
20 | {da3166ff-0374-440a-8cde-11b143a08f82}
21 |
22 |
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件\Native
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件
50 |
51 |
52 |
53 |
54 | 源文件
55 |
56 |
57 | 源文件
58 |
59 |
60 | 源文件
61 |
62 |
63 | 源文件
64 |
65 |
66 | 源文件
67 |
68 |
69 | 源文件
70 |
71 |
72 | 源文件\Native
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | 资源文件
81 |
82 |
83 |
84 |
85 | 资源文件
86 |
87 |
88 |
--------------------------------------------------------------------------------
/Yoga.Wrapper/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/app.ico
--------------------------------------------------------------------------------
/Yoga.Wrapper/app.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LoveSharp2019/VisionMix/5d3be4371b9950f4990bd365aa06529b04ed0748/Yoga.Wrapper/app.rc
--------------------------------------------------------------------------------
/Yoga.Wrapper/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by app.rc
4 |
--------------------------------------------------------------------------------