/// <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); }
// 创建同步设置面板 private void CreateSyncSettingPanel() { // 创建同步目录文本框 CharmTextBox txtSyncDir = new CharmTextBox { Location = new Point(127 + MENU_WIDTH, 20 + TITLE_HEIGHT), Width = 260 }; // 创建浏览路径按钮 CharmButton btnViewPath = new CharmButton { ButtonType = ButtonType.Classic_Size_08223, Text = "浏览路径", ForeColor = Color.DarkGreen, Location = new Point(399 + MENU_WIDTH, 22 + TITLE_HEIGHT) }; // 创建同步周期文本框 CharmTextBox txtSyncCycle = new CharmTextBox { Location = new Point(127 + MENU_WIDTH, 55 + TITLE_HEIGHT), Width = 50, TextInputMode = InputMode.Integer, MaxLength = 5, TextAlign = HorizontalAlignment.Center }; // 创建空间名称文本框 CharmTextBox txtBucket = new CharmTextBox { Location = new Point(290 + MENU_WIDTH, 55 + TITLE_HEIGHT), Width = 95, }; // 创建私有空间检查框 CharmCheckBox chkPrivateBucket = new CharmCheckBox { Location = new Point(400 + MENU_WIDTH, 57 + TITLE_HEIGHT), Text = "私有空间" }; // 创建同步前缀文本框 CharmTextBox txtPrefix = new CharmTextBox { Location = new Point(150 + MENU_WIDTH, 90 + TITLE_HEIGHT), Width = 95, }; // 创建监控变动检查框 CharmCheckBox chkCaptureChange = new CharmCheckBox { Location = new Point(260 + MENU_WIDTH, 92 + TITLE_HEIGHT), Text = "监控目录文件变化" }; // 创建立即同步按钮 CharmButton btnSyncNow = new CharmButton { ButtonType = ButtonType.Classic_Size_08223, Text = "立即同步", ForeColor = Color.Purple, Location = new Point(399 + MENU_WIDTH, 92 + TITLE_HEIGHT) }; // 创建 AccessKey 文本框 CharmTextBox txtAccessKey = new CharmTextBox { Location = new Point(127 + MENU_WIDTH, 160 + TITLE_HEIGHT), Width = 260, TextInputMode = InputMode.Password }; // 创建查看 AccessKey 按钮 CharmButton btnViewAccessKey = new CharmButton { ButtonType = ButtonType.Classic_Size_08223, Text = "查看密钥", ForeColor = Color.Red, Location = new Point(399 + MENU_WIDTH, 162 + TITLE_HEIGHT) }; // 创建 SecretKey 文本框 CharmTextBox txtSecretKey = new CharmTextBox { Location = new Point(127 + MENU_WIDTH, 195 + TITLE_HEIGHT), Width = 260, TextInputMode = InputMode.Password }; // 创建查看 SecretKey 按钮 CharmButton btnViewSecretKey = new CharmButton { ButtonType = ButtonType.Classic_Size_08223, Text = "查看密钥", ForeColor = Color.Red, Location = new Point(399 + MENU_WIDTH, 197 + TITLE_HEIGHT) }; // 创建七牛开发平台链接标签 CharmLinkLabel lblQiniuOpen = new CharmLinkLabel { Location = new Point(280, 265), ForeColor = Color.Blue, Text = "七牛云存储开发者平台" }; // 关联控件事件 txtSyncDir.TextChanged += txtSyncDir_TextChanged; btnViewPath.MouseClick += btnViewPath_MouseClick; txtSyncCycle.TextChanged += txtSyncDir_TextChanged; txtBucket.TextChanged += txtSyncDir_TextChanged; chkPrivateBucket.MouseClick += chkPrivateBucket_MouseClick; lblQiniuOpen.MouseClick += lblQiniuOpen_MouseClick; txtAccessKey.TextChanged += txtSyncDir_TextChanged; btnViewAccessKey.MouseClick += btnViewAccessKey_MouseClick; txtSecretKey.TextChanged += txtSyncDir_TextChanged; btnViewSecretKey.MouseClick += btnViewSecretKey_MouseClick; txtPrefix.TextChanged += txtSyncDir_TextChanged; chkCaptureChange.MouseClick += chkPrivateBucket_MouseClick; btnSyncNow.MouseClick += btnSyncNow_MouseClick; // 将控件添加到集合中 this.Controls.Add(txtSyncDir); this.Controls.Add(txtSyncCycle); this.Controls.Add(txtAccessKey); this.Controls.Add(txtSecretKey); this.Controls.Add(txtBucket); this.Controls.Add(txtPrefix); // 创建同步设置面板控件集合 mSyncSettingControls = new List<Control> { txtSyncDir, txtSyncCycle, txtAccessKey, txtSecretKey, txtBucket, txtPrefix }; mSyncSettingCharmControls = new List<CharmControl> { btnViewPath, lblQiniuOpen, btnViewAccessKey, btnViewSecretKey, chkPrivateBucket, chkCaptureChange, btnSyncNow }; }
/// <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); }