using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Text;
using System.Windows.Forms;
using static System.Net.WebRequestMethods;
namespace MOTINOVA_MC_Test
{
public partial class topFormCapture : Form
{
Point point; //鼠标按下时的点
bool isMoving = false;//标识是否拖动
public topFormCapture()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;//无边框
this.StartPosition = FormStartPosition.Manual;//手工指定位置
this.ShowInTaskbar = false;//在任务栏不显示图标
this.TopMost = true;//置顶显示
this.BackColor = Color.White;//背景色
this.StartPosition = FormStartPosition.Manual;
int xWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
int yHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
this.Location= new Point(xWidth / 2 - this.Width / 2, 10);
}
private void topFormCapture_Load(object sender, EventArgs e)
{
}
private void topFormCapture_MouseDown(object sender, MouseEventArgs e)
{
point = e.Location;//按下的点
isMoving = true;//启动拖动
}
private void topFormCapture_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && isMoving)
{
Point pNew = new Point(e.Location.X - point.X, e.Location.Y - point.Y);
//Location = new Point(Location.X + pNew.X, Location.Y + pNew.Y);
Location += new Size(pNew);
}
}
private void topFormCapture_MouseUp(object sender, MouseEventArgs e)
{
isMoving = false;//停止
}
///
/// 双击截图
///
///
///
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
string PdName = Class_Motor_Ver.Mode + "_" + Class_Motor_Ver.SN;
if (Form1.myFtp.IsNetConnected == true)
{
string DataNow = DateTime.Now.ToString("yyyy-MM-dd");
//检查路径
if (Form1.myFtp.DirectoryExist("\\", Form1.ServerPath) == false)
{
Form1.myFtp.MakeDir(Form1.ServerPath);
}
if (Form1.myFtp.DirectoryExist(Form1.ServerPath, DataNow) == false)
{
Form1.myFtp.MakeDir(Form1.ServerPath + "\\" + DataNow);
}
if (Form1.myFtp.DirectoryExist(Form1.ServerPath + "\\" + DataNow, PdName) == false)
{
Form1.myFtp.MakeDir(Form1.ServerPath + "\\" + DataNow + "\\" + PdName);
}
//截图
string PIC_SaveFileName = "";
int ScreenWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
int ScreenHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
Bitmap bit = new Bitmap(ScreenWidth, ScreenHeight);//实例化一个和窗体一样大的bitmap
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(0, 0, 0, 0, new Size(ScreenWidth, ScreenHeight));//保存整个窗体为图片
PIC_SaveFileName = Form1.LocalPath + "\\" + "MotorRunTest" + "\\" + PdName + "_测功记录_" + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png";
bit.Save(PIC_SaveFileName);
//上传图片
bool result1 = Form1.myFtp.UploadFile(PIC_SaveFileName, Form1.ServerPath + "\\" + DataNow + "\\" + PdName);
if (result1 == true)
{
MessageBox.Show("数据已上传!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("数据上传失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
MessageBox.Show("服务器断开!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
///
///
///
///
///
private void label_ServerStatus_MouseHover(object sender, EventArgs e)
{
// 创建the ToolTip
ToolTip toolTip1 = new ToolTip();
// 设置显示样式
toolTip1.AutoPopDelay = 5000;//提示信息的可见时间
toolTip1.InitialDelay = 50;//事件触发多久后出现提示
toolTip1.ReshowDelay = 50;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框
toolTip1.ShowAlways = true;//是否显示提示框
// 设置伴随的对象
string info = "";
if (Form1.myFtp.IsNetConnected == true)
info = "网络已连接";
else
info = "网络断开";
toolTip1.SetToolTip(this.label_ServerStatus, info);//设置提示内容
}
}
}