Ejemplo n.º 1
0
        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);                         // 释放注册的的热键



        public Form1()
        {
            InitializeComponent();
            if (!RegisterHotKey(this.Handle, HOT_KEY_ID, 0, Keys.F8)) // 注册热键f8
            {
                DialogResult result = MessageBox.Show("注册热键失败,是否继续运行?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.No)
                {
                    exit_Click(null, null);
                }
            }

            comboBox1_ClickMode.SelectedIndex = 0;
            comboBox2_HotKey.SelectedItem     = "F8";
            updateDele = new UpdateControlText1(updateControlText);
        }
Ejemplo n.º 2
0
 private void askTask()
 {
     Thread.Sleep(300);
     while (ask)
     {
         Thread.Sleep(200);
         UpdateControlText1 update = new UpdateControlText1(updateControlText);
         try
         {
             this.Invoke(update, udp.receiveMsg);
         }
         catch (Exception)
         {
             //还是什么都不做了,反正这里是结束
         }
     }
 }
Ejemplo n.º 3
0
        private void ScrollUp()
        {
            while (infiniteNumber == true)
            {
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0, roll, 0);
                Thread.Sleep((int)sec);//延时
            }


            for (int i = 1; i <= number; i++)
            {
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0, roll, 0);
                Thread.Sleep((int)sec);                                            //延时
            }
            UpdateControlText1 update = new UpdateControlText1(updateControlText); //定义委托

            this.Invoke(update);                                                   //调用窗体Invoke方法
        }
Ejemplo n.º 4
0
        private void RightMouseButton()
        {
            while (infiniteNumber == true)
            {
                mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
                Thread.Sleep((int)sec);//延时
            }


            for (int i = 1; i <= number; i++)
            {
                mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
                Thread.Sleep((int)sec);                                            //延时
            }
            UpdateControlText1 update = new UpdateControlText1(updateControlText); //定义委托

            this.Invoke(update);                                                   //调用窗体Invoke方法
        }
Ejemplo n.º 5
0
        private void BindPrintData()
        {
            var updateControl = new UpdateControlText1(UpdateControlText);

            Invoke(updateControl);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 生成底单
        /// </summary>
        public void BuildImage()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            UpdateControlText1 updateControl = updateControlText;

            try
            {
                if (_list == null || _list.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < _list.Count; i++)
                {
                    if (string.IsNullOrEmpty(_list[i].BillCode))
                    {
                        continue;
                    }
                    _printFileName = !string.IsNullOrEmpty(_list[i].BillCode) ? _list[i].BillCode : DateTime.Now.Ticks.ToString();
                    _tempList.Add(_list[i]);
                    ++_tempIndex;
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count));
                    }
                    //  2016-1-31下午 这一行代码一定要写,因为要导出模板的面单图片,所以一定要设置true,如果不想要就设置成false就行了,grid++的客服还是很不错的,qq:grid++ report  641243789
                    // _report.BackImagePrint = true;
                    // 直接调用ExportDirect方法执行导出任务,这里我只是导出图片哦
                    _report.ExportDirect(GRExportType.gretIMG, _printFileName, false, false);
                    _tempList.Clear();
                }
                if (_tempIndex > 0)
                {
                    if (ckAddSystemWaterMark.Checked)
                    {
                        string waterMarkFolder = BillPrintHelper.SaveFilePath + "\\水印底单";
                        if (!DirectoryUtil.IsExistDirectory(waterMarkFolder))
                        {
                            DirectoryUtil.CreateDirectory(waterMarkFolder);
                        }
                        var files = DirectoryUtil.GetFileNames(BillPrintHelper.SaveFilePath);
                        foreach (string file in files)
                        {
                            if (Utilities.FileUtil.FileIsExist(file))
                            {
                                // img对象一定要释放,不然内存上升,杨恒连,2016年7月24日15:25:35
                                using (var img = ImageHelper.WatermarkText(Image.FromFile(file), BaseSystemInfo.SoftFullName, ImageHelper.WatermarkPosition.BottomRight, new Font("Verdana", 10, FontStyle.Bold), new SolidBrush(Color.Blue)))
                                {
                                    string fileName = Utilities.FileUtil.GetFileNameNoExtension(file);
                                    img.Save(string.Format(waterMarkFolder + "\\" + fileName + ".png", fileName));
                                }
                            }
                        }
                    }
                    // alertBuildImageInfo.Show(this, "生成底单", string.Format("成功生成{0}张底单图片", _list.Count));
                    //   XtraMessageBox.Show(string.Format("成功生成{0}张底单图片,是否打开文件夹查看?", _list.Count), AppMessage.MSG0000, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //if ( == DialogResult.Yes)
                    //{
                    //    Process.Start(BillPrintHelper.SaveFilePath);
                    //}
                }
            }
            catch (Exception exception)
            {
                //   XtraMessageBox.Show(exception.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.WriteException(exception);
            }
            finally
            {
                btnBuildImage.Enabled = true;
                _tempIndex            = 0;
                if (_list != null)
                {
                    stopWatch.Stop();
                    TimeSpan ts          = stopWatch.Elapsed;
                    string   elapsedTime = string.Format("{0}分{1}秒{2}毫秒", ts.Minutes, ts.Seconds, ts.Milliseconds);
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count) + "  耗时:" + elapsedTime);
                    }
                }
            }
        }