Esempio n. 1
0
        /// <summary>
        /// 用默认设置初始化 CharmMessageBox 类的新实例
        /// </summary>
        public CharmMessageBox()
        {
            InitializeComponent();
            // 设置窗体阴影特效
            APIOperation.FormBorderShadow(Handle);
            // * 设置双缓冲模式 *
            SetStyle(ControlStyles.AllPaintingInWmPaint |  //不擦除背景 ,减少闪烁
                     ControlStyles.OptimizedDoubleBuffer | //双缓冲
                     ControlStyles.UserPaint,              //使用自定义的重绘事件,减少闪烁
                     true);
            UpdateStyles();

            // * 初始化属性 *
            TopMost         = true;
            FormBorderStyle = FormBorderStyle.None;
            StartPosition   = FormStartPosition.CenterParent;
            Width           = 350;

            mTitleColor = Color.White;
            mTextColor  = Color.Black;

            // 创建控件集合
            CharmControls = new List <CharmControl>();

            // 创建用户按钮
            mButtons = new CharmButton[3];
            for (int i = 0; i < mButtons.Length; i++)
            {
                mButtons[i]             = new CharmButton();
                mButtons[i].ButtonType  = ButtonType.Classic_Size_06922;
                mButtons[i].Visible     = false;
                mButtons[i].MouseClick += new MouseEventHandler(ButtonMouseClick);
                CharmControls.Add(mButtons[i]);
            }

            // 创建检查框
            mCheckBox         = new CharmCheckBox();
            mCheckBox.Visible = false;
            CharmControls.Add(mCheckBox);

            // 创建关闭按钮
            CharmSysButton btnClose = new CharmSysButton();

            btnClose.SysButtonType = SysButtonType.Close;
            btnClose.Location      = new Point(Width - 46, 1);
            btnClose.MouseClick   += new MouseEventHandler(btnClose_MouseClick);
            CharmControls.Add(btnClose);
        }
        /// <summary>
        /// 用默认设置初始化 CharmMessageBox 类的新实例
        /// </summary>
        public CharmMessageBox()
        {
            InitializeComponent();
            // 设置窗体阴影特效
            APIOperation.FormBorderShadow(Handle);
            // * 设置双缓冲模式 *
            SetStyle(ControlStyles.AllPaintingInWmPaint | //不擦除背景 ,减少闪烁
                               ControlStyles.OptimizedDoubleBuffer | //双缓冲
                               ControlStyles.UserPaint, //使用自定义的重绘事件,减少闪烁
                               true);
            UpdateStyles();

            // * 初始化属性 *
            TopMost = true;
            FormBorderStyle = FormBorderStyle.None;
            StartPosition = FormStartPosition.CenterParent;
            Width = 350;

            mTitleColor = Color.White;
            mTextColor = Color.Black;

            // 创建控件集合
            CharmControls = new List<CharmControl>();

            // 创建用户按钮
            mButtons = new CharmButton[3];
            for (int i = 0; i < mButtons.Length; i++)
            {
                mButtons[i] = new CharmButton();
                mButtons[i].ButtonType = ButtonType.Classic_Size_06922;
                mButtons[i].Visible = false;
                mButtons[i].MouseClick += new MouseEventHandler(ButtonMouseClick);
                CharmControls.Add(mButtons[i]);
            }

            // 创建检查框
            mCheckBox = new CharmCheckBox();
            mCheckBox.Visible = false;
            CharmControls.Add(mCheckBox);

            // 创建关闭按钮
            CharmSysButton btnClose = new CharmSysButton();
            btnClose.SysButtonType = SysButtonType.Close;
            btnClose.Location = new Point(Width - 46, 1);
            btnClose.MouseClick += new MouseEventHandler(btnClose_MouseClick);
            CharmControls.Add(btnClose);
        }
Esempio n. 3
0
        // 初始化设置
        private void InitializeSetting()
        {
            // 设置窗体属性
            this.Icon = Properties.Resources.icon;
            this.Text = APP_NAME;

            // 绘制窗体背景
            DrawFormBackground();

            // 初始化菜单栏
            mMenuNames = new[] { "同步设置", "高级设置", "网络设置", "关于" };

            #region 创建窗体组件
            // 创建最小化系统按钮
            CharmSysButton btnMin = new CharmSysButton
            {
                SysButtonType = SysButtonType.Minimum,
                ToolTipText = "最小化",
                Location = new Point(this.Width - 75, 1)
            };
            // 创建关闭系统按钮
            CharmSysButton btnClose = new CharmSysButton
            {
                SysButtonType = SysButtonType.Close,
                ToolTipText = "关闭",
                Location = new Point(this.Width - 44, 1)
            };

            // 创建确定按钮
            CharmButton btnMakeChange = new CharmButton
            {
                ButtonType = ButtonType.Classic_Size_08223,
                Text = "确 定",
                Location = new Point(300, 430)
            };
            // 创建取消按钮
            CharmButton btnCancel = new CharmButton
            {
                ButtonType = ButtonType.Classic_Size_08223,
                Text = "取 消",
                Location = new Point(390, 430)
            };
            // 创建应用按钮
            mBtnApply = new CharmButton
            {
                ButtonType = ButtonType.Classic_Size_08223,
                Text = "应 用",
                Location = new Point(480, 430),
                Enabled = false
            };

            // 创建控件集合
            mCharmControls = new List<CharmControl> { btnMin, btnClose, btnMakeChange, btnCancel, mBtnApply };

            // 关联控件事件
            btnMin.MouseClick += btnMin_MouseClick;
            btnClose.MouseClick += btnClose_MouseClick;
            btnMakeChange.MouseClick += btnMakeChange_MouseClick;
            btnCancel.MouseClick += btnCancel_MouseClick;
            mBtnApply.MouseClick += mBtnApply_MouseClick;
            #endregion

            #region 创建主体区域
            // 创建同步设置面板
            CreateSyncSettingPanel();
            // 创建高级设置面板
            CreateAdvancedSettingPanel();
            // 创建关于面板
            CreateAboutPanel();
            #endregion

            // 加载本地设置
            LoadLocalSetting();

            // 设置初始参数
            if (!mIsHasKeys)
                mStatusText = "未填写密钥";
            else if (!mIsVaildSyncDir)
                mStatusText = "无效的同步目录";
            else
                mStatusText = "正在初始化...";

            #region 创建菜单
            // 创建托盘菜单
            mTaryMenu = new CharmMenu();
            mTaryMenu.AddItem("设置中心", MenuItemType.TextItem,
                new Bitmap(Properties.Resources.logo, 16, 16));
            mTaryMenu.AddItem("打开同步目录", MenuItemType.TextItem);
            mTaryMenu.AddItem("", MenuItemType.Spliter);
            mTaryMenu.AddItem("立即同步", MenuItemType.TextItem);
            mTaryMenu.AddItem("", MenuItemType.Spliter);
            mTaryMenu.AddItem("关于", MenuItemType.TextItem);
            mTaryMenu.AddItem("退出", MenuItemType.TextItem);

            // 关联控件事件
            mTaryMenu.MenuClick += mTaryMenu_MenuClick;
            #endregion

            #region 创建托盘图标
            // 创建托盘图标
            mNotifyIcon = new NotifyIcon
            {
                Icon = Properties.Resources.icon,
                Text = APP_NAME + "\n" + mStatusText,
                Visible = true
            };

            // 关联控件事件
            mNotifyIcon.MouseClick += mNotifyIcon_MouseClick;
            #endregion

            #region 创建服务线程
            // 启动全局更新检查线程
            Thread globalUpdateCheckThread = new Thread(GlobalUpdateCheck) { IsBackground = true };
            globalUpdateCheckThread.Start();
            #endregion
        }
Esempio n. 4
0
        // 初始化设置
        private void InitializeSetting()
        {
            // 设置窗体属性
            this.Icon = Properties.Resources.icon;
            this.Text = "过滤规则测试";

            // 绘制窗体背景
            DrawFormBackground();

            #region 创建窗体组件
            // 创建关闭系统按钮
            CharmSysButton btnClose = new CharmSysButton
            {
                SysButtonType = SysButtonType.Close,
                ToolTipText = "关闭",
                Location = new Point(this.Width - 44, 1)
            };

            // 创建测试目录文本框
            CharmTextBox txtTestDir = new CharmTextBox
            {
                Location = new Point(110, 10 + TITLE_HEIGHT),
                Width = 330
            };
            // 创建浏览路径按钮
            CharmButton btnViewPath = new CharmButton
            {
                ButtonType = ButtonType.Classic_Size_08223,
                Text = "浏览路径",
                ForeColor = Color.DarkGreen,
                Location = new Point(455, 12 + TITLE_HEIGHT)
            };

            // 创建测试规则按钮
            CharmButton btnTest = new CharmButton
            {
                ButtonType = ButtonType.Classic_Size_12425,
                Text = "开始测试规则",
                ForeColor = Color.MediumSlateBlue,
                Location = new Point(420, 435),
            };

            // 将控件添加到集合中
            this.Controls.Add(txtTestDir);

            // 创建控件集合
            mControls = new List<Control> { txtTestDir };
            mCharmControls = new List<CharmControl> { btnClose, btnViewPath, btnTest };

            // 关联控件事件
            btnClose.MouseClick += btnClose_MouseClick;
            btnViewPath.MouseClick += btnViewPath_MouseClick;
            btnTest.MouseClick += btnTest_MouseClick;
            #endregion

            // 加载本地设置
            LoadLocalSetting();
        }