资源简介
里面包含了十几种动态二值化阈值的算法,能够采集和保存智能车图像信息,也能在上面编写程序实现图像处理算法。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class AutoSizeFormClass
{
//(1).声明结构只记录窗体和其控件的初始位置和大小。
public struct controlRect
{
public int Left;
public int Top;
public int Width;
public int Height;
public float FontSize;
public string FontName;
public Fontstyle Fontstyle;
}
//存储控件名和他的位置
public Dictionary oldCtrl = new Dictionary();
int ctrlNo = 0;//1;
//(3). 创建两个函数
//(3.1)记录窗体和其控件的初始位置和大小
public void controllInitializeSize(Control mForm)
{
controlRect cR;
cR.Left = mForm.Left;
cR.Top = mForm.Top;
cR.Width = mForm.Width;
cR.Height = mForm.Height;
cR.FontSize = mForm.Font.Size;
cR.FontName = mForm.Font.Name;
cR.Fontstyle = mForm.Font.style;
insertDictionary(mForm.Name cR);
AddControl(mForm);//窗体内其余控件还可能嵌套控件(比如panel)要单独抽出因为要递归调用
}
private void AddControl(Control ctl)
{
foreach (Control c in ctl.Controls)
{
controlRect objCtrl;
objCtrl.Left = c.Left;
objCtrl.Top = c.Top;
objCtrl.Width = c.Width;
objCtrl.Height = c.Height;
objCtrl.FontSize = c.Font.Size;
objCtrl.FontName = c.Font.Name;
objCtrl.Fontstyle = c.Font.style;
insertDictionary(c.Name objCtrl);
if (c.Controls.Count > 0)
AddControl(c);
}
}
//(3.2)控件自适应大小
public void controlAutoSize(Control mForm)
{
if (ctrlNo == 0)
{
AddControl(mForm); //窗体内其余控件可能嵌套其它控件(比如panel)故单独抽出以便递归调用
}
float wScale = (float)mForm.Width / oldCtrl[mForm.Name].Width; ;//新旧窗体之间的比例,与最早的旧窗体
float hScale = (float)mForm.Height / oldCtrl[mForm.Name].Height; ;//.Height;
ctrlNo = 1; //进入=1,第0个为窗体本身窗体内的控件从序号1开始
AutoScaleControl(mForm wScale hScale); //窗体内其余控件还可能嵌套控件(比如panel)要单独抽出因为要递归调用
}
private void insertDictionary(String name controlRect cr) //添加控件名和位置,如果名称重复则更新
{
Dictionary temp = new Dictionary();
bool flag = false;
foreach (var pair in oldCtrl)
{
if (pair.Key.ToString() == name)
{
temp.Ad
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1041 2018-02-11 21:40 WindowsFormsApplication1.sln
文件 51200 2018-03-07 14:35 WindowsFormsApplication1.v12.suo
目录 0 2018-03-07 12:38 WindowsFormsApplication1\
文件 187 2018-02-11 21:40 WindowsFormsApplication1\App.config
文件 7025 2018-02-11 21:40 WindowsFormsApplication1\AutoSizeFormClass.cs
目录 0 2018-02-11 21:41 WindowsFormsApplication1\bin\
目录 0 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\
目录 0 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\AutoPicture\
目录 0 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\
文件 91041 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\1.png
文件 111570 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\2.png
文件 86634 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\3.png
文件 95974 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\5.png
文件 215321 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\56d94cfa0e328.png
文件 101232 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\6.png
文件 261360 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\Blue.png
文件 36474 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\Close.png
文件 40106 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\huanyuan.png
文件 586808 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\MIn.bmp
文件 35408 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\MIn.png
文件 230846 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\ButtonPicture\Red.png
目录 0 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\icon\
文件 115535 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\icon\m4.ico
目录 0 2018-03-07 13:14 WindowsFormsApplication1\bin\Debug\Picture\
文件 23638 2018-03-06 22:11 WindowsFormsApplication1\bin\Debug\Picture\Image0.bmp
文件 640054 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\Picture\Image1.bmp
文件 4750 2018-03-06 21:03 WindowsFormsApplication1\bin\Debug\Picture\Imaged1.bmp
文件 640054 2018-02-11 21:41 WindowsFormsApplication1\bin\Debug\Picture\Imageing0.bmp
文件 23638 2018-03-07 13:14 WindowsFormsApplication1\bin\Debug\Picture\Imaging0.bmp
文件 23638 2018-03-06 22:19 WindowsFormsApplication1\bin\Debug\Picture\imaging1.bmp
文件 23638 2018-03-06 22:09 WindowsFormsApplication1\bin\Debug\Picture\Imaging2.bmp
............此处省略65个文件信息
评论
共有 条评论