C#软件开发实例.私人订制自己的屏幕截图工具(六)添加配置管理功能

上一篇:C#软件开发实例.私人订制自己的屏幕截图工具(五)针对拖拽时闪烁卡顿现象的优化

添加设置窗口

在解决方案资源管理器窗口中,右键单击项目名称,在弹出的菜单中选择:添加》Windows窗体:

输入窗体名称“frmSetup”:

设置窗体的Text属性为“设置”,设置窗体的Size为“472, 276”,StartPosition属性为“CenterScreen”。

添加设置标签页:

左侧工具箱》窗器:双击“TabControl”

设置的Dock属性为“Top”,Size属性为“456, 200”;

添加标签页:

添加三个标签页,Text分别设置为“基本设置,自动上传,自动保存”

添加确定和取消按钮;

基本设置标签页:

从工具箱中添加两个GroupBox,分别为“热键、截图选项”;

添加两个RadioButton,用于热键选择;

添加四个CheckBox用于截图选项;

添加两个TextBox用于设置放大镜的尺寸;

添加两个PictureBox用于显示X和锁的图片;

添加图片资源:

双击Properties中的“Resources.resx”

切换到图像视图:

将图片复制,粘贴到这里,分别命名为“Lock,X”;

设置PictureBox的Image属性为对应的资源:

自动上传标签页:

自动保存标签页:

其中文件名称需要使用两个ComboBox,Items集合分别设置为:

编写代码:

双击设置窗体,切换到代码视图,添加私有变量:

        /// <summary>
        /// 保存Form1的句柄
        /// </summary>
        private IntPtr frm1Handle = IntPtr.Zero;

修改构造函数:

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="frm1_Handle"></param>
        public frmSetup(IntPtr frm1_Handle)
        {
            InitializeComponent();
            this.frm1Handle = frm1_Handle;
        }

为托盘菜单中的设置添加事件处理

打开主窗体Form1的设计视图,选中“contextMenuStrip1”

修改设置菜单的Name为“tsmi_Set”,双击设置菜单,添加代码:

        /// <summary>
        /// 托盘菜单设置事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmi_Set_Click(object sender, EventArgs e)
        {
            frmSetup frm = new frmSetup(this.Handle);
            frm.ShowDialog();
        }

编译,调试一下,通过托盘图标的右键菜单》设置 可以打开刚刚添加的设置窗口了。

添加项目引用:

主窗体添加相关配置项变量:

        #region 基本设置参数
        /// <summary>
        /// 截图时是否显示截图信息栏
        /// </summary>
        public bool InfoBoxVisible = true;
        /// <summary>
        /// 截图时是否显示编辑工具栏
        /// </summary>
        public bool ToolBoxVisible = true;
        /// <summary>
        /// 截图中是否包含鼠标指针形状
        /// </summary>
        public bool IsCutCursor = true;
        /// <summary>
        /// 截图时是否显示放大镜
        /// </summary>
        public bool ZoomBoxVisible = true;
        /// <summary>
        /// 放大镜的尺寸——宽度
        /// </summary>
        public int ZoomBoxWidth = 120;
        /// <summary>
        /// 放大镜的尺寸——高度
        /// </summary>
        public int ZoomBoxHeight = 100;
        #endregion

        #region 图片上传参数
        public string PicDescFieldName = "pictitle";
        public string ImageFieldName = "upfile";
        public string PicDesc = "cutImage";
        public string UploadUrl = "http://";
        public bool DoUpload = false;
        #endregion

        #region 自动保存参数
        /// <summary>
        /// 是否自动保存到硬盘
        /// </summary>
        public bool AutoSaveToDisk = false;
        /// <summary>
        /// 自动保存目录
        /// </summary>
        public string AutoSaveDirectory = string.Empty;
        /// <summary>
        /// 是否启用日期格式“2013_02_22”的子目录
        /// </summary>
        public bool AutoSaveSubDir = false;
        /// <summary>
        /// 自动保存文件名前缀
        /// </summary>
        public string AutoSaveFileName1 = "屏幕截图";
        /// <summary>
        /// 自动文件名规则:日期时间,日期_序号,序号
        /// </summary>
        public string AutoSaveFileName2 = "日期时间";
        /// <summary>
        /// 自动保存文件格式:.png, .jpg, .jpeg, .gif, .bmp
        /// </summary>
        public string AutoSaveFileName3 = ".png";
        /// <summary>
        /// 自动保存文件名序号
        /// </summary>
        public int autoSaveFileIndex = 0;
        #endregion 自动保存参数

添加“AppSettingKeys”类:

    /// <summary>
    /// 提供配置文件中AppSettings节中对应的Key名称
    /// </summary>
    public static class AppSettingKeys
    {
        //基本设置
        public static string HotKeyMode = "HotKeyMode";
        public static string InfoBoxVisible = "InfoBoxVisible";
        public static string ToolBoxVisible = "ToolBoxVisible";
        public static string ZoomBoxVisible = "ZoomBoxVisible";
        public static string ZoomBoxWidth = "ZoomBoxWidth";
        public static string ZoomBoxHeight = "ZoomBoxHeight";
        public static string IsCutCursor = "IsCutCursor";
        //图片上传
        public static string PicDescFieldName = "PicDescFieldName";
        public static string ImageFieldName = "ImageFieldName";
        public static string PicDesc = "PicDesc";
        public static string UploadUrl = "UploadUrl";
        public static string DoUpload = "DoUpload";
        //自动保存
        public static string AutoSaveToDisk = "AutoSaveToDisk";
        public static string AutoSaveSubDir = "AutoSaveSubDir";
        public static string AutoSaveDirectory = "AutoSaveDirectory";
        public static string AutoSaveFileName1 = "AutoSaveFileName1";
        public static string AutoSaveFileName2 = "AutoSaveFileName2";
        public static string AutoSaveFileName3 = "AutoSaveFileName3";

    }

Program.cs文件添加枚举类型:

    /// <summary>
    /// 控制键的类型
    /// </summary>
    public enum KeyModifiers : uint
    {
        None = 0,
        Alt = 1,
        Control = 2,
        Shift = 4,
        Windows = 8
    }

警告:由于xxx是引用封送类的字段,访问上面的成员可能导致运行时异常

设置窗口完整代码:

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

namespace Screenshot
{
    public partial class frmSetup : Form
    {
        /// <summary>
        /// 保存Form1的句柄
        /// </summary>
        private IntPtr frm1Handle = IntPtr.Zero;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="frm1_Handle"></param>
        public frmSetup(IntPtr frm1_Handle)
        {
            InitializeComponent();
            this.frm1Handle = frm1_Handle;
        }

        /// <summary>
        /// 确定按钮单击事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_ok_Click(object sender, EventArgs e)
        {
            if (checkBox_autoSave.Checked && textBox_saveDir.Text.Trim().Length == 0)
            {
                MessageBox.Show("您选择了“自动保存屏幕截图到磁盘”\n但还没有设置存储目录!");
                return;
            }
            if (checkBox_autoSave.Checked && textBox_saveDir.Text.Trim().Length > 0)
            {
                if (!System.Text.RegularExpressions.Regex.IsMatch(textBox_saveDir.Text.Trim(), "^[a-zA-Z]:\\\\[^/:\\*\\?\"<>\\|]*$", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    MessageBox.Show("您选择了“自动保存屏幕截图到磁盘”\n但设置的存储目录不是有效的目录!");
                    return;
                }
                if (!System.IO.Directory.Exists(textBox_saveDir.Text.Trim()))
                {
                    MessageBox.Show("您选择了“自动保存屏幕截图到磁盘”\n但设置的存储目录不存在!");
                    return;
                }
            }
            Form1 frm = (Form1)Form.FromHandle(frm1Handle);
            if (frm != null)
            {
                //基本设置
                if (radioButton1.Checked) // && frm.HotKeyMode != 0 无论是否改变都重新注册热键,解决有时热键失效的问题
                {
                    Form1.UnregisterHotKey(frm1Handle, frm.hotKeyId);
                    Form1.RegisterHotKey(frm1Handle, frm.hotKeyId, (uint)KeyModifiers.Control | (uint)KeyModifiers.Alt, Keys.A);
                    frm.HotKeyMode = 0;
                }

                if (radioButton2.Checked) // && frm.HotKeyMode != 1 无论是否改变都重新注册热键,解决有时热键失效的问题
                {
                    Form1.UnregisterHotKey(frm1Handle, frm.hotKeyId);
                    Form1.RegisterHotKey(frm1Handle, frm.hotKeyId, (uint)KeyModifiers.Control | (uint)KeyModifiers.Shift, Keys.A);
                    frm.HotKeyMode = 1;
                }

                frm.InfoBoxVisible = ckb_InfoBox.Checked;
                frm.ToolBoxVisible = ckb_ToolBox.Checked;
                frm.IsCutCursor = ckb_CutCursor.Checked;
                frm.ZoomBoxVisible = ckb_ZoomBox.Checked;

                frm.ZoomBoxWidth1 = Convert.ToInt32(tb_zoomBoxWidth.Text);
                frm.ZoomBoxHeight1 = Convert.ToInt32(tb_zoomBoxHeight.Text);

                if (frm.ZoomBoxWidth1 < 120)
                {
                    frm.ZoomBoxWidth1 = 120;
                    tb_zoomBoxWidth.Text = frm.ZoomBoxWidth1.ToString();
                }
                if (frm.ZoomBoxHeight1 < 100)
                {
                    frm.ZoomBoxHeight1 = 100;
                    tb_zoomBoxHeight.Text = frm.ZoomBoxHeight1.ToString();
                }

                //图片上传
                frm.PicDescFieldName = textBox_fieldDesc.Text;
                frm.ImageFieldName = textBox_fieldFile.Text;
                frm.PicDesc = textBox_desc.Text;
                frm.UploadUrl = textBox_uploadUrl.Text;
                frm.DoUpload = checkBox_upload.Checked;

                //自动保存
                frm.AutoSaveToDisk = checkBox_autoSave.Checked;
                frm.AutoSaveSubDir = chb_subDir.Checked;
                frm.AutoSaveDirectory = textBox_saveDir.Text;

                frm.AutoSaveFileName1 = textBox_fileName1.Text;
                if (comboBox_fileName2.SelectedItem != null)
                {
                    frm.AutoSaveFileName2 = comboBox_fileName2.Text;
                }
                else
                {
                    frm.AutoSaveFileName2 = "日期时间";
                }
                if (comboBox_Extn.SelectedItem != null)
                {
                    frm.AutoSaveFileName3 = comboBox_Extn.Text;
                }
                else
                {
                    frm.AutoSaveFileName3 = ".png";
                }
            }

            SaveConfiguration();

            this.Close();
        }

        /// <summary>
        /// 保存配置信息到配置文件
        /// </summary>
        private void SaveConfiguration()
        {
            System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(null);

            //基本设置
            SetConfigAppSetting(ref config, AppSettingKeys.HotKeyMode, radioButton1.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.InfoBoxVisible, ckb_InfoBox.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.ToolBoxVisible, ckb_ToolBox.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.IsCutCursor, ckb_CutCursor.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.ZoomBoxVisible, ckb_ZoomBox.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.ZoomBoxWidth, tb_zoomBoxWidth.Text);
            SetConfigAppSetting(ref config, AppSettingKeys.ZoomBoxHeight, tb_zoomBoxHeight.Text);

            //图片上传
            SetConfigAppSetting(ref config, AppSettingKeys.PicDescFieldName, textBox_fieldDesc.Text.Trim());
            SetConfigAppSetting(ref config, AppSettingKeys.ImageFieldName, textBox_fieldFile.Text.Trim());
            SetConfigAppSetting(ref config, AppSettingKeys.PicDesc, textBox_desc.Text.Trim());
            SetConfigAppSetting(ref config, AppSettingKeys.UploadUrl, textBox_uploadUrl.Text.Trim());
            SetConfigAppSetting(ref config, AppSettingKeys.DoUpload, checkBox_upload.Checked ? "1" : "0");

            //自动保存
            SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveToDisk, checkBox_autoSave.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveSubDir, chb_subDir.Checked ? "1" : "0");
            SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveDirectory, textBox_saveDir.Text.Trim());
            SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveFileName1, textBox_fileName1.Text.Trim());
            if (comboBox_fileName2.SelectedItem != null)
            {
                SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveFileName2, comboBox_fileName2.Text);
            }
            else
            {
                SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveFileName2, "日期时间");
            }
            if (comboBox_Extn.SelectedItem != null)
            {
                SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveFileName3, comboBox_Extn.Text);
            }
            else
            {
                SetConfigAppSetting(ref config, AppSettingKeys.AutoSaveFileName3, ".png");
            }

            config.Save(System.Configuration.ConfigurationSaveMode.Modified);
        }

        /// <summary>
        /// 设置配置信息
        /// </summary>
        /// <param name="config"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private bool SetConfigAppSetting(ref System.Configuration.Configuration config, string key, string value)
        {
            try
            {
                if (config.AppSettings.Settings[key] != null)
                {
                    config.AppSettings.Settings[key].Value = value;
                }
                else
                {
                    config.AppSettings.Settings.Add(key, value);
                }
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);
                return false;
            }
        }

        /// <summary>
        /// 获取配置信息
        /// </summary>
        /// <param name="config"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        private string GetConfigAppSetting(ref System.Configuration.Configuration config, string key)
        {
            try
            {
                if (config.AppSettings.Settings[key] != null)
                {
                    return config.AppSettings.Settings[key].Value;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);
            }
            return string.Empty;
        }

        /// <summary>
        /// 取消按钮单击事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 窗口加载事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmSetup_Load(object sender, EventArgs e)
        {
            chb_subDir.Text = "启用(按日期命名,格式:" + DateTime.Now.Date.ToString("yyyy_MM_dd") + ")";

            Form1 frm = (Form1)Form.FromHandle(frm1Handle);
            if (frm != null)
            {
                //基本设置
                if (frm.HotKeyMode == 0)
                {
                    radioButton1.Checked = true;
                    radioButton2.Checked = false;
                }
                else
                {
                    radioButton1.Checked = false;
                    radioButton2.Checked = true;
                }

                ckb_InfoBox.Checked = frm.InfoBoxVisible;
                ckb_ToolBox.Checked = frm.ToolBoxVisible;
                ckb_CutCursor.Checked = frm.IsCutCursor;
                ckb_ZoomBox.Checked = frm.ZoomBoxVisible;

                //图片上传
                textBox_fieldDesc.Text = frm.PicDescFieldName;
                textBox_fieldFile.Text = frm.ImageFieldName;
                textBox_desc.Text = frm.PicDesc;
                textBox_uploadUrl.Text = frm.UploadUrl;
                checkBox_upload.Checked = frm.DoUpload;

                //自动保存
                checkBox_autoSave.Checked = frm.AutoSaveToDisk;
                chb_subDir.Checked = frm.AutoSaveSubDir;
                textBox_saveDir.Text = frm.AutoSaveDirectory;
                textBox_fileName1.Text = frm.AutoSaveFileName1;
                comboBox_fileName2.SelectedItem = frm.AutoSaveFileName2;
                comboBox_Extn.SelectedItem = frm.AutoSaveFileName3;

            }
        }
        /// <summary>
        /// 浏览按钮事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_browse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "请选择屏幕截图的保存目录:";
            fbd.ShowNewFolderButton = true;
            fbd.RootFolder = Environment.SpecialFolder.MyComputer;
            fbd.SelectedPath = textBox_saveDir.Text;
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox_saveDir.Text = fbd.SelectedPath;
            }
        }
        /// <summary>
        /// 更新自动保存文件名称示例
        /// </summary>
        private void UpdateFileNameExmple()
        {
            string AutoSaveFileName2 = string.Empty;
            if (comboBox_fileName2.SelectedItem != null)
            {
                AutoSaveFileName2 = comboBox_fileName2.Text;
            }
            string AutoSaveFileName3 = ".png";
            if (comboBox_Extn.SelectedItem != null)
            {
                AutoSaveFileName3 = comboBox_Extn.Text;
            }

            switch (AutoSaveFileName2)
            {
                case "日期_序号":
                    textBox_exmple.Text = textBox_fileName1.Text + DateTime.Now.ToString("yyyy-MM-dd_") + "0001" + AutoSaveFileName3;
                    break;
                case "序号":
                    textBox_exmple.Text = textBox_fileName1.Text + "0001" + AutoSaveFileName3;
                    break;
                default:
                    textBox_exmple.Text = textBox_fileName1.Text + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + AutoSaveFileName3;
                    break;
            }
        }

        private void comboBox_fileName2_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateFileNameExmple();
        }

        private void comboBox_Extn_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateFileNameExmple();
        }

        private void textBox_fileName1_TextChanged(object sender, EventArgs e)
        {
            UpdateFileNameExmple();
        }

        // Boolean flag used to determine when a character other than a number is entered.
        private bool nonNumberEntered = false;

        private void tb_zoomBoxWidth_KeyDown(object sender, KeyEventArgs e)
        {
            // Initialize the flag to false.
            nonNumberEntered = false;

            // Determine whether the keystroke is a number from the top of the keyboard.
            if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
            {
                // Determine whether the keystroke is a number from the keypad.
                if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
                {
                    // Determine whether the keystroke is a backspace.
                    if (e.KeyCode != Keys.Back)
                    {
                        // A non-numerical keystroke was pressed.
                        // Set the flag to true and evaluate in KeyPress event.
                        nonNumberEntered = true;
                    }
                }
            }
            //If shift key was pressed, it's not a number.
            if (Control.ModifierKeys == Keys.Shift)
            {
                nonNumberEntered = true;
            }
        }

        private void tb_zoomBoxHeight_KeyDown(object sender, KeyEventArgs e)
        {
            // Initialize the flag to false.
            nonNumberEntered = false;

            // Determine whether the keystroke is a number from the top of the keyboard.
            if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
            {
                // Determine whether the keystroke is a number from the keypad.
                if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
                {
                    // Determine whether the keystroke is a backspace.
                    if (e.KeyCode != Keys.Back)
                    {
                        // A non-numerical keystroke was pressed.
                        // Set the flag to true and evaluate in KeyPress event.
                        nonNumberEntered = true;
                    }
                }
            }
            //If shift key was pressed, it's not a number.
            if (Control.ModifierKeys == Keys.Shift)
            {
                nonNumberEntered = true;
            }
        }

        private void tb_zoomBoxWidth_KeyPress(object sender, KeyPressEventArgs e)
        {

            // Check for the flag being set in the KeyDown event.
            if (nonNumberEntered == true)
            {
                // Stop the character from being entered into the control since it is non-numerical.
                e.Handled = true;
            }
        }

        private void tb_zoomBoxHeight_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Check for the flag being set in the KeyDown event.
            if (nonNumberEntered == true)
            {
                // Stop the character from being entered into the control since it is non-numerical.
                e.Handled = true;
            }
        }

        /// <summary>
        /// 放大镜宽度改变事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tb_zoomBoxWidth_TextChanged(object sender, EventArgs e)
        {
            int zoomWidth = Convert.ToInt32(tb_zoomBoxWidth.Text);
            if (zoomWidth < 120) { zoomWidth = 120; }

            tb_zoomBoxHeight.Text = ((int)(zoomWidth * 100 / 120)).ToString();
        }

        /// <summary>
        /// 放大镜高度改变事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tb_zoomBoxHeight_TextChanged(object sender, EventArgs e)
        {
            int zoomHeight = Convert.ToInt32(tb_zoomBoxHeight.Text);
            if (zoomHeight < 100) { zoomHeight = 100; }

            tb_zoomBoxWidth.Text = ((int)(zoomHeight * 120 / 100)).ToString();
        }
    }
}

源码下载:http://download.csdn.net/detail/testcs_dn/7263143

下一篇:C#软件开发实例.私人订制自己的屏幕截图工具(七)添加放大镜的功能

时间: 2024-08-01 17:31:56

C#软件开发实例.私人订制自己的屏幕截图工具(六)添加配置管理功能的相关文章

C#软件开发实例.私人订制自己的屏幕截图工具(一)功能概览

概述 开发该软件的原因主要是想订制实现自己想要的功能,比如:自动保存,气泡提示框类型的标注功(主要用于功能说明文档的写作)能. 托盘图标及菜单 添加托盘图标,是因为有些功能还是需要使用菜单呼出,不能什么都用快捷键. 有些东西(菜单.提示框)可能通过快捷键截图的时候截取不到,所以设置了"延时5秒截图"功能. 基本设置 QQ的截图热键是"Ctrl + Alt + A",为了不和它冲突,这里默认使用"Ctrl + Shift + A"作为快捷键. 有些

C#软件开发实例.私人订制自己的屏幕截图工具(九)使用自定义光标,QQ截图时的光标

在使用QQ的截图功能的时候,是不是觉得它的光标很酷呢?今天就说一下怎么应用自定义光标,在我们的截图工具中使用QQ截图的光标. 打开资源: 切换到文件资源视图: 打开资源文件目录,将光标文件复制到此目录下: 所需光标文件下载:C#软件开发实例.私人订制自己的屏幕截图工具中使用的光标文件 选中Resources目录,刷新,显示出刚刚复制进来的光标文件: 选中光标文件,拖动到资源的文件视图中: 资源资源名称中的单词第一个字母改为大写. 光标预览: 在Form1类中添加私有变量: #region 自定义

C#软件开发实例.私人订制自己的屏幕截图工具(七)添加放大镜的功能

上一篇:C#软件开发实例.私人订制自己的屏幕截图工具(六)添加配置管理功能 由于截图时可能需要精确截取某一部分,所以需要放大镜的功能,这样截取的时候才更容易定位截图的位置. 添加PictureBox,name属性设置为"pictureBox_zoom": 在"Form1_Load"事件处理函数中添加以下代码: //设置放大镜的大小 this.pictureBox_zoom.Width = this.ZoomBoxWidth; this.pictureBox_zoom

C#软件开发实例.私人订制自己的屏幕截图工具(十)在截图中包含鼠标指针形状

在写一此帮助说明类的文档时,截取的图片如果还有鼠标的指针形状,看起来就更直观更友好一些.接下来就讲一下如何在截图中包含鼠标指针形状. 上一篇:C#软件开发实例.私人订制自己的屏幕截图工具(九)使用自定义光标,QQ截图时的光标 添加结构CURSORINFO: [StructLayout(LayoutKind.Sequential)] struct CURSORINFO { public int cbSize; public int flags; public IntPtr hCursor; pub

C#软件开发实例.私人订制自己的屏幕截图工具(三)托盘图标及菜单的实现

概述 添加托盘图标功能主要是为了添加菜单功能,可以通过托盘图标来管理程序:托盘菜单包括"打开保存目录.录制Flash动画.录制GIF动画.延时5秒截图.截图.设置.退出"等功能. 系统托盘 系统托盘是个特殊区域,通常在桌面的底部,在那里,用户可以随时访问正在运行中的那些程序.在微软的Windows里,系统托盘常指任务栏的状态区域:在Gnome的桌面时,常指布告栏区域:在KDE桌面时,指系统托盘.在每个系统里,托盘是所有正运行在桌面环境里的应用程序共享的区域. 添加托盘图标 在Form1

C#软件开发实例.私人订制自己的屏幕截图工具(二)创建项目、注册热键、显示截图主窗口

开发环境 操作系统:Windows Server 2008 R2 集成开发环境(IDE):Microsoft Visual Studio 2010 开发语言:c# 创建项目 文件>新建>项目 .NET Framework可以选择2.0版本,也可以选择4.0版本: 项目类型选择:Windows窗体应用程序 输入项目名称,确定 项目创建成功,如下图: 修改主窗体属性 修改窗体的"FormBorderStyle"属性为"none",实现一个没有边框的窗体 修改

C#软件开发实例.私人订制自己的屏幕截图工具(四)基本截图功能实现

实现原理 基本截图的功能主要靠响应主窗体的鼠标按下.鼠标移动.鼠标抬起几个事件的功能来实现的.截取的图片区域使用"Label"组件来显示,需要重新实现"Label"组件的"Paint"方法. 左键单击开始截图,右键单击取消截图,双击鼠标左键完成截图,将截取的图片保存到Windows剪贴板中. 添加"Label"组件 工具箱>公共组件>双击"Label"组件,修改组件属性: Name=lbl_Cu

iPhone拍照/摄像软件开发实例

  这个App基于lolfriend的源码改写,完全使用官方API.目前还没实现的功能有:替换 UIImagePickerController的cameraOverlayView;滤镜.其他效果如图,我的测试环境是3.1.2的虚拟机和 3.1.2的iPhone 3GS. 开发实例-iphone7双摄像头拍照"> 附件: CameraDemo.zips 帖子如下: 为什么我联机开发如此简单呢?? 其实今天有点激动的,因为可以通过XCode连接自己的iPod Touch进行程序的运行了. 一般

个人考勤软件开发实例(Update)

更新说明:自拙作 attendance( 2.0 版 ) 个人考勤软件登出后,不时有网友来信交流,最近有网友指出程序中的一个缺陷:在打印预览窗口中工具条按钮的命令状态不能改变.现在这个问题已基本解决.现将改好的源代码(可以算作2.1版)发布出来,同时对说明文档进行了增补(第10点说明). 这个程序是一个个人考勤软件,它从系统时钟获取时间信息,只要上下班时按时在当日考勤栏内点击相应的栏目标题即可逐日记录下个人每天的工作时间,按月统计汇总,按年形成文件.可以随意查看过去的记录,也可把记录按月打印出来