首页 > 其他分享 >Random 项目总结 -06 定时器、 随机数,截图,生成WORD报告 (result完整)

Random 项目总结 -06 定时器、 随机数,截图,生成WORD报告 (result完整)

时间:2024-04-20 22:01:04浏览次数:18  
标签:06 string Missing int Random Value Range ToString result

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

using Msword = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{

public partial class result : Form
{
Msword.Application wordapp = null;
Msword.Document worddoc = null;
public Msword.Application Application
{
get { return wordapp; }
set { wordapp = value; }
}

public Msword.Document Document
{
get { return worddoc; }
set { worddoc = value; }
}

public result()
{
InitializeComponent();
this.ControlBox = false;

qr.Visible = false;

}
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
System.Windows.Forms.Timer timer2 = new System.Windows.Forms.Timer();
string xmlpath = System.AppDomain.CurrentDomain.BaseDirectory + "setting.xml";
public string filepath = "";// 图片地址
XmlDocument xmldoc = new XmlDocument();

string dwinfo = "";
string xminfo = "";
string phinfo = "";
string idinfo = "";
string proinfo = "";
string strdata = "";
string strsa = "";
string strpwd = "";
string typeinfo = "其他(20%)";
string type = "7";

private void result_Load(object sender, EventArgs e)
{

 

string uppath = System.AppDomain.CurrentDomain.BaseDirectory;


uppath = uppath.Substring(0, uppath.Length - 1);
int clen = uppath.LastIndexOf("\\");

uppath = uppath.Substring(0, clen);
//MessageBox.Show(uppath);

uppath = uppath + "\\setting.xml";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(uppath);
XmlElement xroot = xdoc.DocumentElement;
XmlElement cname = (XmlElement)xroot.GetElementsByTagName("cname")[0]; // 单位信息
XmlElement pname = (XmlElement)xroot.GetElementsByTagName("pname")[0];// 姓名
XmlElement phnum = (XmlElement)xroot.GetElementsByTagName("phnum")[0]; // 电话
XmlElement xidnum = (XmlElement)xroot.GetElementsByTagName("idnum")[0]; // 身份证号
XmlElement proname = (XmlElement)xroot.GetElementsByTagName("proname")[0]; // 项目名称
//XmlElement strdata = (XmlElement)xroot.GetElementsByTagName("datasource")[0];
//XmlElement strsa = (XmlElement)xroot.GetElementsByTagName("sa")[0];
//XmlElement strpwd = (XmlElement)xroot.GetElementsByTagName("sapwd")[0];
dw.Text = cname.InnerText;
// 随机数
label4.Text = proname.InnerText;
label5.Text = pname.InnerText;
label6.Text = phnum.InnerText;
label7.Text = xidnum.InnerText;
label8.Text = typeinfo;
dwinfo = cname.InnerText; //单位信息
xminfo = pname.InnerText; // 姓名
phinfo = phnum.InnerText;// 电话
idinfo = xidnum.InnerText; // 身份证号
proinfo = proname.InnerText; //项目名称
label16.Visible = true;
label15.Text = DateTime.Now.ToString();
dy.Visible = false;
XmlNodeList nlist = xdoc.SelectNodes("Mjdesign/serverset");
if (nlist != null)
{

foreach (XmlNode msnode in nlist)
{
XmlNodeList mlist = msnode.ChildNodes;
foreach (XmlNode nsnode in mlist)
{
if (nsnode.Name == "datasource")
{
strdata = nsnode.InnerText;

//label6.Text = t_data;

}
if (nsnode.Name == "sa")
{

strsa = nsnode.InnerText;
//MessageBox.Show(dwmc.Text);
}
if (nsnode.Name == "sapwd")
{
strpwd = nsnode.InnerText;

}
}
}
}

// MessageBox.Show(ui.ToString());

 

SqlConnectionStringBuilder sqlb01 = new SqlConnectionStringBuilder();

sqlb01.DataSource = strdata;

sqlb01.InitialCatalog = "random";
sqlb01.UserID = strsa;
sqlb01.Password = strpwd;
sqlb01.IntegratedSecurity = false;
sqlb01.Pooling = true;
SqlConnection conn01 = new SqlConnection();
conn01.ConnectionString = sqlb01.ConnectionString;

// MessageBox.Show(strdata + "11" + strsa + "12" + strpwd);

try
{
conn01.Open();
if (conn01.State.ToString() == "Open")
{
label3.Text = "数据库链接成功";

timer2.Start();
timer2.Interval = 100;
timer2.Tick += new EventHandler(callback2);
tz.Visible = true;

conn01.Close();
}

}

catch (SqlException sqlex)
{
MessageBox.Show("数据库配置错误,请重新填写/n");
label3.Text = "数据库链接失败";
tz.Visible = false;
conn01.Close();
}


}

 

public void callback2(object sender, EventArgs e)
{


Random ran = new Random();
int rt = ran.Next(1, 101); // 含下线不含上线
label1.Text = rt.ToString();


//List<string> ucheck = new List<string>();
//xmldoc.Load(xmlpath);
//XmlElement root = xmldoc.DocumentElement;
//XmlElement checkcount = (XmlElement)root.GetElementsByTagName("checkcount")[0];
//XmlElement ncount = (XmlElement)root.GetElementsByTagName("numcount")[0];
//int c1 = int.Parse(checkcount.InnerText);
//int c2 = int.Parse(ncount.InnerText);

//if (c1 < c2)
//{


// XmlNodeList xlist = xmldoc.SelectNodes("Mjdesign/unchecked/id");
// if (xlist != null)
// {

// foreach (XmlNode msnode in xlist)
// {
// XmlElement xe = (XmlElement)msnode;
// string orderstr = xe.InnerText;

// string contentstr = xe.InnerText;

 


// ucheck.Add(contentstr);
// }
// }

// int xui = ucheck.Count;
// Random ran = new Random();
// int rt = ran.Next(xui);
// label1.Text = ucheck[rt].ToString();
// // 待修改
// // MessageBox.Show(i.ToString());

//}
//else
//{
// MessageBox.Show(null, "数已用完,请重新设定", "MJSJ");
// return;

//}

////if (i < 0)
////{
//// timer2.Stop();
//// timer2.Enabled = false;
//// // MessageBox.Show("时间到");


////}


}

 

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
//if (keyData == Keys.Left)
//{
// this.button1.PerformClick();
// //this.btnTempTest.PerformClick();
//}
if (keyData == Keys.Space)
{
this.tz.PerformClick();//定义快捷键
}
return base.ProcessCmdKey(ref msg, keyData);
}

 

private void tz_Click_1(object sender, EventArgs e)
{
dy.Visible = true;
//string xmlpath = System.AppDomain.CurrentDomain.BaseDirectory + "setting.xml";
//XmlDocument xmldoc = new XmlDocument();

//List<string> uncheck = new List<string>();

//xmldoc.Load(xmlpath);
//XmlNodeList nlist = xmldoc.SelectNodes("Mjdesign/unchecked/id");
//if (nlist != null)
//{

// foreach (XmlNode msnode in nlist)
// {
// XmlElement xe = (XmlElement)msnode;
// string contentstr = "";

// if (xe.IsEmpty == false)
// {
// //MessageBox.Show(xe.InnerText);
// contentstr = xe.InnerText;
// }

 

// uncheck.Add(contentstr);
// }
//}
string reva = "2";

timer2.Stop();
timer2.Enabled = false;
//int ui = uncheck.Count;
//// MessageBox.Show(ui.ToString());
//string[] mstext = new string[ui];
//for (int i = 0; i < ui; i++)
//{

// mstext[i] = uncheck[i];
//}

//Random ran = new Random();
//int wn = ran.Next(ui);


//label1.Text = mstext[wn];

int msnum = int.Parse(label1.Text);
// MessageBox.Show(msnum.ToString());
if (msnum %5==0)
{
label2.Text = "您已选中";
reva = "1";
}
else
{
label2.Text = "您没选中";
reva = "0";
}
kg.Text = "1";
tz.Visible = false;

string chnum = label1.Text;
qr.Visible = false;
// string time = DateTime.Now.ToLongDateString();
//string time2 = DateTime.Now.ToLongTimeString();
DateTime timeo = DateTime.Now;
// string timestr = time + time2;
// 存入数据库
// MessageBox.Show(strdata + "11" + strsa + "12" + strpwd);
SqlConnectionStringBuilder sqlb02 = new SqlConnectionStringBuilder();

sqlb02.DataSource = strdata;

sqlb02.InitialCatalog = "random";
sqlb02.UserID = strsa;
sqlb02.Password = strpwd;
sqlb02.IntegratedSecurity = false;
sqlb02.Pooling = true;
SqlConnection conn02 = new SqlConnection();
conn02.ConnectionString = sqlb02.ConnectionString;
try
{
conn02.Open();
if (conn02.State.ToString() == "Open")
{
// string sqlstr = "insert into result(d_content,cs_num,cpname,timekey,xmmc,pcname,oid,locationx,locationy,major) values (" + "'" + vd_content + "'," + "'" + vd_csnum + "'," + "'" + vd_cpname + "','" + vd_timekey + "','" + xmmc + "','" + pcname + "','" + oidstr + "','" + locationxstr + "','" + locationystr + "','" + major + "')";
string sqlstr = @"insert into result(dwxx,xmxx,name,lx,xm,dh,sfzh,cqsz,cqjg,type,cqsj)values(" + "'" + dwinfo + "','" + proinfo + "','" + label16.Text + "','" + typeinfo + "','" + xminfo + "','" + phinfo + "','" + idinfo + "','" + chnum + "','" + label2.Text + "','" + type + "','" + timeo + "')";

//MessageBox.Show(sqlstr);
SqlCommand sqlcmd = new SqlCommand(sqlstr, conn02);
int n = sqlcmd.ExecuteNonQuery();
if (n > 0)
{
MessageBox.Show("保存成功");

conn02.Close();

}
else
{

MessageBox.Show("保存失败");
conn02.Close();
}

}

}


catch (SqlException sqlex)
{
MessageBox.Show("数据库配置错误,请重新填写/n" + sqlex);

 

}


// 完成

//xmldoc.Load(xmlpath);
//XmlElement root = xmldoc.DocumentElement;
//XmlElement cnum = (XmlElement)root.GetElementsByTagName("checkcount")[0];
//string strcnum = cnum.InnerText;
//int checkedcon = int.Parse(strcnum);
//cnum.InnerText = (checkedcon + 1).ToString();

//xmldoc.Save(xmlpath);
//XmlNodeList nlist = xmldoc.SelectNodes("Mjdesign/unchecked/id");
//XmlNode xn = xmldoc.SelectSingleNode("Mjdesign/unchecked");
//if (nlist != null)
//{
// foreach (XmlNode msnode in nlist)
// {
// XmlElement xe = (XmlElement)msnode;
// string orderstr = xe.InnerText;

// string contentstr = xe.InnerText;

// if (xe.InnerText == chnum)
// {
// xn.RemoveChild(xe);

// }


// }

//}
//XmlNodeList Mlist = xmldoc.SelectNodes("Mjdesign/checked");
//if (Mlist != null)
//{
// foreach (XmlNode msnode in Mlist)
// {
// XmlElement xe = (XmlElement)msnode;
// XmlNode xnode = xmldoc.CreateElement("id");
// xnode.InnerText = label1.Text;
// xe.AppendChild(xnode);


// }


//}
//xmldoc.Save(xmlpath);

//*** 存入EXCEL

 

//EXCELAPPLICATION.Application EXCELA = new EXCELAPPLICATION.Application();

//if (EXCELA == null)
//{
// MessageBox.Show("无法创建EXCEL对象,您的电脑可能未安装excel");
//}

//string tname = System.AppDomain.CurrentDomain.BaseDirectory + "抽取记录.xlsx";

//EXCELAPPLICATION.Workbook xbook = EXCELA.Workbooks.Open(tname, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
// Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
//EXCELAPPLICATION.Worksheet xsheet = xbook.Sheets[1];
//int p = 1;
//string wz = "A1";
//string dwwz = "B1";
//EXCELAPPLICATION.Range rng = xsheet.get_Range(wz, Missing.Value);

////MessageBox.Show(rng.Value2.ToString());
//while (rng.Value2 != null)
//{
// p++;
// wz = "A" + p.ToString();
// rng = xsheet.get_Range(wz, Missing.Value);

// // MessageBox.Show(i.ToString());
// // MessageBox.Show(rng.Value.ToString());
// //MessageBox.Show(rng.Value2.ToString());
//}
//int j = p - 2;
//rng.Value2 = j.ToString();
//string time = DateTime.Now.ToLongDateString();
//string time2 = DateTime.Now.ToLongTimeString();
//string timestr = time + time2;
//dwwz = "B" + p.ToString();
//string prwz = "C" + p.ToString();
//string xmwz = "D" + p.ToString();
//string dhwz = "E" + p.ToString();
//string idwz = "F" + p.ToString();
//string szwz = "G" + p.ToString();
//string jgwz = "H" + p.ToString();
//string sjwz = "I" + p.ToString();

//EXCELAPPLICATION.Range dwrng = xsheet.get_Range(dwwz, Missing.Value);
//dwrng.Value2 = dwinfo;
//EXCELAPPLICATION.Range prwzg = xsheet.get_Range(prwz, Missing.Value);
//prwzg.Value2 = proinfo;
//EXCELAPPLICATION.Range xmrng = xsheet.get_Range(xmwz, Missing.Value);
//xmrng.Value2 = xminfo;
//EXCELAPPLICATION.Range dhrng = xsheet.get_Range(dhwz, Missing.Value);
//dhrng.Value2 = phinfo;
//EXCELAPPLICATION.Range idrng = xsheet.get_Range(idwz, Missing.Value);
//idrng.Value2 = idinfo;
//EXCELAPPLICATION.Range szrng = xsheet.get_Range(szwz, Missing.Value);
//szrng.Value2 = label1.Text;
//EXCELAPPLICATION.Range jgrng = xsheet.get_Range(jgwz, Missing.Value);
//jgrng.Value2 = label2.Text;
//EXCELAPPLICATION.Range sjrng = xsheet.get_Range(sjwz, Missing.Value);
//sjrng.Value2 = timestr;

 

 

 


//xbook.Save();
//xbook.Close();
//System.Windows.Forms.Application.DoEvents();

//EXCELA.Quit();

//GC.Collect();

////****结束

//qr.Visible = true;

 

 

 

}

 

private void qr_Click_1(object sender, EventArgs e)
{
//string chnum = label1.Text;
//qr.Visible = false;
////xmldoc.Load(xmlpath);
////XmlElement root = xmldoc.DocumentElement;
////XmlElement cnum = (XmlElement)root.GetElementsByTagName("checkcount")[0];
////string strcnum = cnum.InnerText;
////int checkedcon = int.Parse(strcnum);
////cnum.InnerText = (checkedcon + 1).ToString();

////xmldoc.Save(xmlpath);
////XmlNodeList nlist = xmldoc.SelectNodes("Mjdesign/unchecked/id");
////XmlNode xn = xmldoc.SelectSingleNode("Mjdesign/unchecked");
////if (nlist != null)
////{
//// foreach (XmlNode msnode in nlist)
//// {
//// XmlElement xe = (XmlElement)msnode;
//// string orderstr = xe.InnerText;

//// string contentstr = xe.InnerText;

//// if (xe.InnerText == chnum)
//// {
//// xn.RemoveChild(xe);

//// }


//// }

////}
////XmlNodeList Mlist = xmldoc.SelectNodes("Mjdesign/checked");
////if (Mlist != null)
////{
//// foreach (XmlNode msnode in Mlist)
//// {
//// XmlElement xe = (XmlElement)msnode;
//// XmlNode xnode = xmldoc.CreateElement("id");
//// xnode.InnerText = label1.Text;
//// xe.AppendChild(xnode);


//// }


////}
////xmldoc.Save(xmlpath);

////*** 存入EXCEL

 

//EXCELAPPLICATION.Application EXCELA = new EXCELAPPLICATION.Application();

//if (EXCELA == null)
//{
// MessageBox.Show("无法创建EXCEL对象,您的电脑可能未安装excel");
//}

//string tname = System.AppDomain.CurrentDomain.BaseDirectory + "抽取记录.xlsx";

// EXCELAPPLICATION.Workbook xbook= EXCELA.Workbooks.Open(tname,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
// Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
// EXCELAPPLICATION.Worksheet xsheet = xbook.Sheets[1];
// int i = 1;
// string wz = "A1";
// string dwwz = "B1";
// EXCELAPPLICATION.Range rng = xsheet.get_Range(wz, Missing.Value);

// //MessageBox.Show(rng.Value2.ToString());
// while(rng.Value2 != null)
// {
// i++;
// wz = "A" + i.ToString();
// rng = xsheet.get_Range(wz, Missing.Value);

// // MessageBox.Show(i.ToString());
// // MessageBox.Show(rng.Value.ToString());
// //MessageBox.Show(rng.Value2.ToString());
// }
// int j = i - 2;
// rng.Value2 = j.ToString();
// string time = DateTime.Now.ToLongDateString();
// string time2 = DateTime.Now.ToLongTimeString();
// string timestr = time + time2;
// dwwz = "B" + i.ToString();
// string prwz = "C" + i.ToString();
// string xmwz = "D" + i.ToString();
// string dhwz = "E" + i.ToString();
// string idwz = "F" + i.ToString();
// string szwz = "G" + i.ToString();
// string jgwz = "H" + i.ToString();
// string sjwz = "I" + i.ToString();

// EXCELAPPLICATION.Range dwrng = xsheet.get_Range(dwwz, Missing.Value);
// dwrng.Value2 = dwinfo;
// EXCELAPPLICATION.Range prwzg = xsheet.get_Range(prwz, Missing.Value);
// prwzg.Value2 = proinfo;
// EXCELAPPLICATION.Range xmrng = xsheet.get_Range(xmwz, Missing.Value);
// xmrng.Value2 = xminfo;
// EXCELAPPLICATION.Range dhrng = xsheet.get_Range(dhwz, Missing.Value);
// dhrng.Value2 = phinfo;
// EXCELAPPLICATION.Range idrng = xsheet.get_Range(idwz, Missing.Value);
// idrng.Value2 = idinfo;
// EXCELAPPLICATION.Range szrng = xsheet.get_Range(szwz, Missing.Value);
// szrng.Value2 = label1.Text;
// EXCELAPPLICATION.Range jgrng = xsheet.get_Range(jgwz, Missing.Value);
// jgrng.Value2 = label2.Text;
// EXCELAPPLICATION.Range sjrng = xsheet.get_Range(sjwz, Missing.Value);
// sjrng.Value2 = timestr ;

 

 

 


// xbook.Save();
// xbook.Close();
// System.Windows.Forms.Application.DoEvents();

// EXCELA.Quit();
// GC.Collect();

////****结束

 

 

//main nm = new main();


//nm.REload();
//nm.Show();


this.FindForm().Close();

main nm = new main();
project pro = new project();


pro.Show();

//this.FindForm().Hide();
}

private void dy_Click(object sender, EventArgs e)

{
Form f1 = dy.FindForm();

int gx = f1.Location.X;
int gy = f1.Location.Y;
int gw = f1.Width;
int gh = f1.Height;
int gleft = f1.Location.X;

// MessageBox.Show(gx.ToString() + ";" + gy.ToString() + ";" + gw.ToString() + ";" + gh.ToString() + ";" + gleft.ToString() + ";");

screenshut(0, 0, gw, gh, 0, 0);
string pname = "项目名称:" + label4.Text;
string cname = "单位名称:"+dw.Text;
string lx = "抽取类型:" + label8.Text;
string xm = "抽取人姓名:"+label5.Text;
string dh = "联系电话:"+label6.Text;
string pid ="身份证号:" +label7.Text;
string time1 = "抽取时间:"+label15.Text;
string jg = "抽取结果:"+label2.Text;

wordapp = new Msword.Application();
wordapp.DisplayAlerts = Msword.WdAlertLevel.wdAlertsNone;

wordapp.Visible = true;
object missing = System.Reflection.Missing.Value;
string path = System.AppDomain.CurrentDomain.BaseDirectory + "2020.doc"; ///???
object templatename = path;
// MessageBox.Show(path);
object dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\"+dw.Text+".doc";

object format = Msword.WdSaveFormat.wdFormatDocument;


worddoc = wordapp.Documents.Add(ref templatename, ref missing, ref missing, ref missing);

 

// PromptSelectionOptions pso = new PromptSelectionOptions();
string strcon = "建筑消防抽取结果确认表\n";
worddoc.Paragraphs.Last.Range.Font.Name = "黑体";
worddoc.Paragraphs.Last.Range.Font.Bold = 1;
worddoc.Paragraphs.Last.Range.Font.Size = 18;
wordapp.Selection.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceDouble;
worddoc.Paragraphs.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphLeft;
worddoc.Paragraphs.Last.Range.Text = strcon;

object unit = Msword.WdUnits.wdStory;
object count = 2;
wordapp.Selection.ParagraphFormat.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphCenter;

wordapp.Selection.EndKey(ref unit, ref missing);
wordapp.Selection.MoveEnd(unit, missing);
wordapp.Selection.Font.Size = 11;
wordapp.Selection.Font.Bold = 0;
wordapp.Selection.Font.Name = "宋体";
wordapp.Selection.TypeText(lx);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(pname);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(cname);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(xm);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(pid);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(dh);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(time1);
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText(jg);
wordapp.Selection.TypeText("\n");
wordapp.Selection.ParagraphFormat.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphRight;
wordapp.Selection.TypeText("抽取人签字:____________________");
wordapp.Selection.TypeText("\n");
wordapp.Selection.TypeText("日期:____________________");
wordapp.Selection.TypeText("\n");
wordapp.Selection.ParagraphFormat.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphLeft;
wordapp.Selection.TypeText("抽取结果截图:");
wordapp.Selection.TypeText("\n");

object rang2 = worddoc.Paragraphs.Last.Range;

object linktofile = false;

object savewdoc = true;

worddoc.InlineShapes.AddPicture(filepath, ref linktofile, ref savewdoc, ref rang2);

 

worddoc.SaveAs(ref dir, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

 

qr.Visible = true;
}

private void result_FormClosing_1(object sender, FormClosingEventArgs e)
{
System.Environment.Exit(0);
}

private void dwxx_Click(object sender, EventArgs e)
{

}

[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight, HandleRef hSrcDC, int xSrc, int ySrc, int dwRop);

private void screenshut(int intx,int inty,int intwidth,int inthigh,int intleft,int intright)
{

DateTime ndate = new DateTime();
ndate = DateTime.Now;
string filename = ndate.ToFileTime().ToString();
filepath = @"c:\myresult\" + filename + ".bmp";

Rectangle rect = new Rectangle();

rect = this.Bounds;
Graphics g1 = this.CreateGraphics();
Bitmap mybmp = new Bitmap(intwidth, inthigh, g1);

Graphics g2 = Graphics.FromImage(mybmp);
IntPtr dc1 = g1.GetHdc();
HandleRef hdcsrc = new HandleRef(null, dc1);
IntPtr dc2 = g2.GetHdc();
HandleRef hdcsave = new HandleRef(null, dc2);

const int scrcop = 0xcc0020;
BitBlt(hdcsave, intx, inty, intwidth, inthigh, hdcsrc, intleft, intright, scrcop);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);

mybmp.Save(filepath, ImageFormat.Bmp);

}

 


}
}

标签:06,string,Missing,int,Random,Value,Range,ToString,result
From: https://www.cnblogs.com/lionmxs/p/18148257

相关文章

  • Random 项目总结 -04设置项目项目写入XML,,调用exe
     Processpro=newProcess();stringpropath=System.AppDomain.CurrentDomain.BaseDirectory;stringt_data="";stringt_sa="";stringt_pwd="";privatevoidbutton1_Click(objectsender,Eve......
  • Random 项目总结 -03测试链接按钮 测试数据链接
    注意:如果填写地址是指定端口IP地址与端口之间需要用逗号隔开。 privatevoidbutton2_Click(objectsender,EventArgse){stringstrdata=textBox1.Text;stringstrsa=textBox2.Text;stringstrpwd=textBox3.Text;......
  • Random 项目总结 -登录按钮 读取XML文件判断用户、密码是否正确
      一、登录按钮privatevoidbutton1_Click(objectsender,EventArgse){stringxmlpath=System.AppDomain.CurrentDomain.BaseDirectory+"setting.xml";XmlDocumentdocx=newXmlDocument();docx.Load(xmlpath);......
  • Random 项目总结 -设置按钮 设置数据库地址, 用户密码写入XML
    privatevoidbutton1_Click(objectsender,EventArgse){stringxmlpath=System.AppDomain.CurrentDomain.BaseDirectory+"setting.xml";XmlDocumentxmldoc=newXmlDocument();xmldoc.Load(xmlpath);......
  • P9745 「KDOI-06-S」树上异或
    P9745「KDOI-06-S」树上异或位运算trick+树形dp看到题目中贡献的计算,可以想到乘法分配律,也就是一个连通块的乘积可以直接乘在当前所有方案的权值之和上。可以考虑特殊性质:链。那么树的问题就变成了序列问题。容易设\(f_i\)表示\(i\)以前的节点的所有断边方案权值和。转移......
  • 106.React SSR(服务器端渲染)实践指南
    106.ReactSSR(服务器端渲染)实践指南极客前端探索者前沿技术的探索者,编码艺术的实践者​关注他 1人赞同了该文章随着前端技术的发展,单页应用(SPA)已经成为了前端开发的主流形式。然而,在某些场景下,如首屏加载速度、SEO优化等方面,SPA仍然存在着一些......
  • 【爆款推荐】初中中考阅读理解难题一网打尽!句子结构深度解析+答案揭秘,助你轻松冲刺高
    PDF格式公众号回复关键字:ZKYDT006原文1Whatdidmanypeopledowhentheyvisitedthemuseum?解析1What什么manypeople很多人do做whentheyvisitedthemuseum当他们参观博物馆时当人们参考博物馆时,他们做什么?2Manypeoplefromallovertheworldvi......
  • [题解]CF33C Wonderful Randomized Sum
    CF33CWonderfulRandomizedSum我们可以发现,如果两区间不交叉也不会影响到结果,所以我们只需要考虑不交叉的情况即可。我们所选择的前缀\(1\simi\)应满足区间和最小,后缀也一样。所以用两个数组\(lr,rl\)分别记录下\(1\simi\)(前缀)最小和、\(i\simn\)(后缀)最小和。然后枚举分割......
  • random
    使用importrandom   大于0且小于1之间的小数print(random.random())#(0,1)----float 大于等于1且小于等于3之间的整数print(random.randint(1,3))#[1,3] 大于等于1且小于3之间的整数#print(random.randrange(1,3))#[1,3) 1或者23或者[4,5......
  • 30天【代码随想录算法训练营34期】第七章 回溯算法part06 (● 332.重新安排行程 ● 51
    332.重新安排行程木有看懂,没视频所以也没看懂51.N皇后自己写出来还是有难度的classSolution:defsolveNQueens(self,n:int)->List[List[str]]:result=[]#存储最终结果的二维字符串数组chessboard=['.'*nfor_inrange(n)]#初始化......