示例#1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            var recordArea = new Rectangle(PointToScreen(pnTarget.Location), pnTarget.Size);

            var img = ScreenShot.GetScreen(recordArea.X, recordArea.Y, recordArea.Width, recordArea.Height);

            var p = PointToClient(MousePosition);

            img.Save(Path.Combine(ScreenRecordOption.CachePath,
                                  string.Format("{0}#{1}#{2}#{3}", DateTime.Now.ToFileTime(), p.X, p.Y, mouseDown ? "1" : "0")));
            img.Dispose();
            GC.Collect();
        }
示例#2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var filename = ScreenShot.SaveRecord();

            if (filename == null)
            {
                return;
            }

            btnOk.Enabled      = false;
            tbQuality.Enabled  = false;
            this.UseWaitCursor = true;
            lbMsg.Text         = "正在生成GIF文件...";
            lbMsg.Visible      = true;
            new System.Threading.Thread(() =>
            {
                try
                {
                    MakeGIF(filename, (value, total) =>
                    {
                        this.InvokeMethod(() =>
                        {
                            lbMsg.Text = "正在生成GIF文件... (" + (value * 1f / total).ToString("P") + ")";
                        });
                    });

                    this.InvokeMethod(() =>
                    {
                        lbMsg.Text = "生成GIF文件完成";
                    });
                }
                catch (Exception ex)
                {
                    util.Logger.Warn(ex);
                    this.InvokeMethod(() =>
                    {
                        lbMsg.Text = "生成GIF文件出错";
                    });
                    MessageBox.Show(ex.Message, "出错了", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                this.InvokeMethod(() =>
                {
                    this.UseWaitCursor = false;
                    btnOk.Enabled      = true;
                    tbQuality.Enabled  = true;
                });
            })
            {
                IsBackground = true
            }.Start();
        }