这个方法是简单的也是神奇的。

  

  有木有想过,将自己项目中的所有类型,包括自定义类型的命名空间和名称全部获取出来?

  有木有想过,有一种简便的方法可以自动化管理项目中的控件和窗体?

  有木有想过...

  首先,要敢想、要敢尝试。

通过以下方法,进行简单变换,是可以做到本程序控制本项目的窗体和控件。

以下方法简单了,就不一一说明了,如果你觉得有用,全部复制了编译一下,看看就明白是怎么反射了。

当然懂得大大们看到我有不足之处,请不要谩骂了,我脸皮薄,被你们骂骂就泄气了,技术有限,请大大们不吝赐教。


基础方法

通过反射获取项目中所有类型(重点)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace BackgroundManager.Func
{
public class GetAssemblyClass
{
static Type[] _assemblyArray;
readonly static Object lockObject = new Object(); public Type[] GetAssembly()
{
if (_assemblyArray == null)
{
lock (lockObject)
{
_assemblyArray = Assembly.GetExecutingAssembly().GetTypes();
}
}
return _assemblyArray;
} public Type[] GetFormAssembly()
{
Type[] assemblyArray = GetAssembly();
string allType = typeof(Form).FullName;
string mainType = typeof(frmMain).FullName;
return Array.FindAll(assemblyArray, delegate(Type type)
{
return (type.BaseType.FullName == allType && type.FullName != mainType);
});
} public Type[] GetUserCtlAssembly()
{
Type[] assemblyArray = GetAssembly();
string allType = typeof(UserControl).FullName;
string mainType = typeof(frmMain).FullName;
return Array.FindAll(assemblyArray, delegate(Type type)
{
return (type.BaseType.FullName == allType && type.FullName != mainType);
});
}
}
}

GetAssemblyClass

图像相关帮助类

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Win32; namespace BackgroundManager.Func
{
public class SystemIconHelper
{
[DllImport("shell32.dll")]
public static extern uint ExtractIconEx(string lpszFile, int nIconIndex, int[] phiconLarge,
int[] phiconSmall, uint nIcons); [DllImport("gdi32.dll")]
private static extern bool DeleteObject(IntPtr hObject); public static Dictionary<String, Icon> IconList = new Dictionary<String, Icon>(); /// <summary>
/// Image转换为Icon
/// </summary>
/// <param name="orgImg"></param>
/// <returns></returns>
public static Icon ImageToIcon(Image orgImg)
{
var bmp = new Bitmap(orgImg);
IntPtr h = bmp.GetHicon();
Icon icon = Icon.FromHandle(h);
// 释放IntPtr
DeleteObject(h);
return icon;
} /// <summary>
/// Image 转化为 字节流
/// </summary>
/// <param name="image"></param>
/// <param name="Format"></param>
/// <returns></returns>
public static byte[] ImageToByteArray(Image image, ImageFormat Format)
{
var ms = new MemoryStream();
image.Save(ms, ImageFormat.Png);
return ms.ToArray();
} /// <summary>
/// 字节流 转化为 Image
/// </summary>
/// <param name="btArray"></param>
/// <returns></returns>
public static Image ImageFromByteArray(byte[] btArray)
{
var ms = new MemoryStream(btArray);
Image returnImage = Image.FromStream(ms);
return returnImage;
} /// <summary>
/// 获取文件内容的类型
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string GetContentType(string fileName)
{
string contentType = "application/octetstream";
try
{
string ext = Path.GetExtension(fileName).ToLower();
RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(ext);
if (registryKey != null && registryKey.GetValue("Content Type") != null)
contentType = registryKey.GetValue("Content Type").ToString();
}
catch (Exception)
{ }
return contentType;
} /// <summary>
/// 根据文件的类型获取 Icon
/// </summary>
/// <param name="sFileExt"></param>
/// <returns></returns>
public static Icon GetIconByFileType(String sFileExt)
{
string sProg =
Registry.ClassesRoot.OpenSubKey(Registry.ClassesRoot.OpenSubKey(sFileExt).GetValue(String.Empty).ToString())
.OpenSubKey("shell")
.OpenSubKey("open")
.OpenSubKey("command")
.GetValue(String.Empty)
.ToString();
sProg = sProg.Substring(, ) == Convert.ToChar().ToString()
? sProg.Substring(, sProg.IndexOf(Convert.ToChar(), ) - )
: sProg.Substring(, sProg.IndexOf(" ", ));
sProg = sProg.Replace("%1", String.Empty);
Icon oIcon = Icon.ExtractAssociatedIcon(sProg);
return oIcon;
} /// <summary>
/// 根据文件名获得图片数组下标
/// </summary>
/// <param name="fileName"></param>
/// <param name="isLarge"></param>
/// <returns></returns>
public static Icon GetIconByFileName(String fileName, bool isLarge)
{
String GetIcon = new FileInfo(fileName).Extension;
if (IconList.ContainsKey(GetIcon))
{
return IconList[GetIcon];
} Icon mIcon = GetIconByFileType(GetIcon, isLarge);
if (mIcon != null)
{
IconList.Add("GetIcon", mIcon);
return mIcon;
} return null;
} /// <summary>
/// 给出文件扩展名(.*),返回相应图标
/// 若不以"."开头则返回文件夹的图标。
/// </summary>
/// <param name="fileType"></param>
/// <param name="isLarge"></param>
/// <returns></returns>
public static Icon GetIconByFileType(string fileType, bool isLarge)
{
if (!string.IsNullOrEmpty(fileType))
{
string regIconString = null;
//默认指定为文件夹图标
string systemDirectory = Environment.SystemDirectory + "\\shell32.dll,3"; if (fileType[] == '.')
{
//读系统注册表中文件类型信息
RegistryKey regVersion = Registry.ClassesRoot.OpenSubKey(fileType, true);
if (regVersion != null)
{
string regFileType = regVersion.GetValue(String.Empty) as String;
regVersion.Close();
regVersion = Registry.ClassesRoot.OpenSubKey(regFileType + @"\DefaultIcon", true);
if (regVersion != null)
{
regIconString = regVersion.GetValue(String.Empty) as String;
regVersion.Close();
}
}
if (regIconString == null)
{
//没有读取到文件类型注册信息,指定为未知文件类型的图标
regIconString = systemDirectory + "shell32.dll,0";
}
}
String[] fileIcon = regIconString.Split(new[] { ',' });
if (fileIcon.Length != )
{
//系统注册表中注册的标图不能直接提取,则返回可执行文件的通用图标
fileIcon = new[] { systemDirectory + "shell32.dll", "" };
}
Icon resultIcon = null;
try
{
//调用API方法读取图标
var phiconLarge = new int[];
var phiconSmall = new int[];
ExtractIconEx(fileIcon[], Int32.Parse(fileIcon[]), phiconLarge, phiconSmall, );
var IconHnd = new IntPtr(isLarge ? phiconLarge[] : phiconSmall[]);
resultIcon = Icon.FromHandle(IconHnd);
}
catch
{
try
{
//第二方案
resultIcon = GetIconByFileType(fileType);
}
catch
{
//默认方案
regIconString = systemDirectory + "shell32.dll,0";
fileIcon = regIconString.Split(new[] { ',' });
resultIcon = null;
//调用API方法读取图标
var phiconLarge = new int[];
var phiconSmall = new int[];
ExtractIconEx(fileIcon[], Int32.Parse(fileIcon[]), phiconLarge, phiconSmall, );
var IconHnd = new IntPtr(isLarge ? phiconLarge[] : phiconSmall[]);
resultIcon = Icon.FromHandle(IconHnd);
}
}
return resultIcon;
} return null;
} }
}

SystemIconHelper

自定义属性的类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace BackgroundManager
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class MyAttribute : Attribute
{
private string _name = "";
private string _display = "";
private string _value = ""; public MyAttribute(string name, string value, string display)
{
_name = name;
_value = value;
_display = display;
} public string Value
{
get { return _value; }
set { _value = value; }
}
public string Display
{
get { return _display; }
set { _display = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
}

MyAttribute


frmMain主窗体

  Application.Run(new frmMain());   为了减少篇幅,就没写这个,但它作为主窗体启动。

  mainTree 上的节点是通过反射获取到所有控件和窗体,然后将它们加入到mainTree中

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BackgroundManager.Func; namespace BackgroundManager
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
this.IsMdiContainer = true; InitTreeList();
} private void InitTreeList()
{
GetAssemblyClass getass = new GetAssemblyClass();
Type[] frmTypes = getass.GetFormAssembly();
Type[] ctlTypes = getass.GetUserCtlAssembly();
mainTree.Nodes.Clear(); var typeArray = new List<Type>();
typeArray.AddRange(frmTypes);
typeArray.AddRange(ctlTypes);
foreach (Type type in typeArray)
{
TreeNode node;
string name = type.Name;
MyAttribute[] customAttributes = type.GetCustomAttributes(typeof(MyAttribute), true) as MyAttribute[];
if (customAttributes != null && customAttributes.Length > )
{
name = customAttributes[].Display;
}
node = new TreeNode(name);
node.Tag = type;
mainTree.Nodes.Add(node);
}
} private void mainTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{ } private void mainTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node != null)
{
Type t = e.Node.Tag as Type;
if (t != null)
{
UserControl c = Activator.CreateInstance(t) as UserControl;
if (c != null)
{
this.splitContainer1.Panel2.Controls.Clear();
this.splitContainer1.Panel2.Controls.Add(c);
c.Dock = DockStyle.Fill;
} Form c2 = Activator.CreateInstance(t) as Form;
if (c2 != null)
{
c2.MdiParent = this;
this.splitContainer1.Panel2.Controls.Clear();
this.splitContainer1.Panel2.Controls.Add(c2);
c2.Dock = DockStyle.Fill;
c2.Show();
}
}
}
} /// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows 窗体设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.mainTree = new System.Windows.Forms.TreeView();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(, );
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.AutoScroll = true;
this.splitContainer1.Panel1.Controls.Add(this.mainTree);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.AutoScroll = true;
this.splitContainer1.Size = new System.Drawing.Size(, );
this.splitContainer1.SplitterDistance = ;
this.splitContainer1.TabIndex = ;
//
// mainTree
//
this.mainTree.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainTree.Location = new System.Drawing.Point(, );
this.mainTree.Name = "mainTree";
this.mainTree.Size = new System.Drawing.Size(, );
this.mainTree.TabIndex = ;
this.mainTree.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.mainTree_NodeMouseClick);
this.mainTree.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.mainTree_NodeMouseDoubleClick);
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.splitContainer1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "frmMain";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "后台管理";
this.splitContainer1.Panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false); } #endregion private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TreeView mainTree; }
}

frmMain

 请注意  this.IsMdiContainer = true;


以下四个类为测试控件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace BackgroundManager.GUI
{
[MyAttribute("","","test1")]
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
} /// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(, );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(, );
this.label1.TabIndex = ;
this.label1.Text = "label1";
//
// UserControl1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label1);
this.Name = "UserControl1";
this.ResumeLayout(false);
this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1;
}
}

UserControl1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace BackgroundManager.GUI
{
public partial class UserControl3 : UserControl
{
public UserControl3()
{
InitializeComponent();
} /// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(, );
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(, );
this.button1.TabIndex = ;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// UserControl3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.button1);
this.Name = "UserControl3";
this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button button1;
}
}

UserControl3

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace BackgroundManager.GUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} /// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form Designer generated code /// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(, );
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(, );
this.checkBox1.TabIndex = ;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(, );
this.ControlBox = false;
this.Controls.Add(this.checkBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout(); } #endregion private System.Windows.Forms.CheckBox checkBox1;
}
}

Form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace BackgroundManager.GUI
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} /// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form Designer generated code /// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(, );
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(, );
this.button1.TabIndex = ;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.button1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button button1;
}
}

Form2


生成后运行界面:

这里我们选择的是userControl1,为什么在mainTree中显示的是test1,请仔细看UserControl1中的这段:    [MyAttribute("","","test1")],这样可以灵活方便控制控件名称


做一个快乐的程序员

C#中通过反射方法获取控件类型和名称的更多相关文章

  1. asp:GridView控件使用FindControl方法获取控件的问题

    一.使用带cells的指定列 e.Item.Cells[1].Controls[1]只指定第二列的第二个控件 二.不使用带cells的指定类e.Item.FindControl("ID&qu ...

  2. android自动化测试中hierarchyviewer和uiautomatorviewer获取控件信息的方式比对

    http://blog.csdn.net/itfootball/article/details/21777835 http://blog.csdn.net/chenbang110/article/de ...

  3. Android自动化测试中AccessibilityService获取控件信息(1)

    Android自动化测试中AccessibilityService获取控件信息(1) 分类: android自动化测试2014-03-24 15:31 3455人阅读 评论(16) 收藏 举报 and ...

  4. 怎样在不对控件类型进行硬编码的情况下在 C#vs 中动态添加控件

    文章ID: 815780 最近更新: 2004-1-12 这篇文章中的信息适用于: Microsoft Visual C# .NET 2003 标准版 Microsoft Visual C# .NET ...

  5. Android在OnCreate中获取控件的宽度和高度

    在Android中,有时需要对控件进行测量,得到的控件宽度和高度可以用来做一些计算.在需要自适应屏幕的情况下,这种计算就显得特别重要.另一方便,由于需求的原因,希望一进入界面后,就能得到控件的宽度和高 ...

  6. js中使用控件名和数组下标方式获取控件的值时失败

    在做界面展示时涉及到表单行项目的增加和删除时,我们一帮都使用js的脚本实现表单行的增加和删除,那么在进行表单的提交的时我们会再页面上进行提交数据的初步校验,进行数据的初步校验时,就要动态获取控件的值. ...

  7. WPF线程中获取控件的值和给控件赋值

    WPF中使用线程操作控件,按平常的操作方法操作的话会报异常:调用线程无法访问此对象,因为另一个线程拥有该对象.所以我们要使用Dispatcher类的BeginInvoke()与Invoke()方法.B ...

  8. Android自动化测试中AccessibilityService获取控件信息(2)-三种方式对比

    Android自动化测试中AccessibilityService获取控件信息(2)-三种方式对比   上一篇文章: Android自动化测试中AccessibilityService获取控件信息(1 ...

  9. Silverlight中获取控件中子控件

    如题:,直接来看代码: /// <summary> /// 查找并返回第一个 相同 name的子元素 /// </summary> /// <typeparam name ...

随机推荐

  1. JackRabbit的前世今生

    题记 写这系列有点老调重弹的味道,比如ahuaxuan已经在他的博客里对于JackRabbit 1.0做了很详细的阐述.之所以再写,是因为JCR推出了JCR 2.0,个人觉得有必要将一些新的特性再罗列 ...

  2. jackrabbit学习笔记(1)

    http://dove19900520.iteye.com/blog/1654346 看的这个文章照着来的,遇到了一些问题,记录一下 运行报这个错:NamespaceException: wiki: ...

  3. Ue4的UE_LOG

    说明:本文为Wiki上的RAMA大神文章的大致翻译 游戏模式: 在游戏模式下,你需要在游戏的快捷方式后面加 -Log,才会在游戏中显示. 编辑器模式(Play In Editor): 你可以在Outp ...

  4. maven构建简单的web项目

    把jdk给换掉 项目修改好了以后写个页面测试一下,结果正常 下面应该添加依赖让web项目一步步丰满起来. 0-添加依赖 1-建一个servlet 2-web.xml中添加servlet声明 3-重新运 ...

  5. ECF R9(632E) & DP

    Description: 给你$n$个数可以任取$k$个(可重复取),输出所有可能的和. $n \leq 1000,a_i \leq 1000$ Solution: 好神的DP,我们排序后把每个数都减 ...

  6. XCode6.3上使用opencv教程(MacOSX 10.10)

    OpenCV 是一个基于(开源)发行的跨平台计算机视觉库,可以运行在Linux.Windows和Mac OS操作系统上.它轻量级而且高效——由一系列 C 函数和少量 C++ 类构成,同时提供了Pyth ...

  7. VS2013开启滚动条缩略图和双击选中高亮,效果杠杠滴!

    1.双击代码或选中代码高亮,用以下插件,反应很灵敏,我安装的是第三个 2.代码编辑器的滚动条缩略图是VS自带的,需要打开菜单----工具----选项,如下图设置: 3.VS默认的选中颜色,需要打开菜单 ...

  8. 浅谈MySql的存储引擎(表类型)

    来源:http://www.cnblogs.com/lina1006/archive/2011/04/29/2032894.html 什么是MySql数据库 通常意义上,数据库也就是数据的集合,具体到 ...

  9. java-String Date Calendar之间的转换

    1.Calendar 转化 String Calendar calendat = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDa ...

  10. 获取IP地址 & 伪装IP地址发送请求

    //获取请求客户端IP地址   public final static String getIpAddress(HttpServletRequest request) throws IOExcepti ...