Beispiel #1
0
        /// <summary>
        /// 测试连接中心
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TestConn_Click(object parameter)
        {
            PasswordBox passwordBox = parameter as PasswordBox;

            //PasswordBox的Password属性因为安全原因不支持直接绑定
            this.CenterDbPwd = PasswordBoxHelper.GetPassword(passwordBox);
            DbConnectString  = $"Data Source={CenterIp};port={CenterDbPort};User ID={CenterDbUser};Password={CenterDbPwd};Initial Catalog={CenterDb};";

            try
            {
                MySqlHelper.ExecuteDataset(DbConnectString, "select * from sys_user limit 1");
                ShowMessage("中心数据库连接成功!");
                //存储中心连接字符串
                SaveCenterDbConfig();
                CheckBoxConnStr();
                if (dictBoxConnStr.Count > 0)
                {
                    IsEnable0 = false;
                    IsEnable1 = true;
                }
                else
                {
                    ShowMessage("没有获取到任何盒子的连接信息!");
                }
            }
            catch (Exception ex)
            {
                string str = ex.ToString();
                MessageBox.Show("数据库连接失败!");
            }
        }
        private void UpdateTemplate()
        {
            var color = Helper.GetColorByOffset(_linearGradientBrush.GradientStops, SldTheme.Value / 7);

            PasswordBoxHelper.SetCornerRadius(PbCustom, new CornerRadius(SldCornerRadius.Value));

            PasswordBoxHelper.SetFocusedBorderBrush(PbCustom, color.ToBrush());
            PasswordBoxHelper.SetFocusedShadowColor(PbCustom, color);
        }
Beispiel #3
0
    private static void OnPasswordChanged(object sender, RoutedEventArgs e)
    {
        var passwordBox = sender as PasswordBox;

        var password = PasswordBoxHelper.GetPassword(passwordBox);

        if (passwordBox != null && passwordBox.Password != password)
        {
            PasswordBoxHelper.SetPassword(passwordBox, passwordBox.Password);
        }
    }
        private void ChbShowWatermark_CheckChanged(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            PasswordBoxHelper.SetWatermark(PbCustom, ChbShowWatermark.IsChecked == true ? "Watermark" : null);

            UpdateCode();
        }
Beispiel #5
0
        private void ChbShowPwdButton_CheckChanged(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            PasswordBoxHelper.SetIsShowPwdButtonVisible(PbCustom, ChbShowPwdButton.IsChecked == true);

            UpdateCode();
        }
Beispiel #6
0
        private void ChbShowIcon_CheckChanged(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            PasswordBoxHelper.SetIcon(PbCustom, ChbShowIcon.IsChecked == true ? "\uf11c" : null);

            UpdateCode();
        }
Beispiel #7
0
 private void B21_Click(object sender, RoutedEventArgs e)
 {
     if (PassWord.Visibility == Visibility.Visible)
     {
         if (!String.IsNullOrWhiteSpace(Password.Password))
         {
             if (Password.Password == "NULL" || Password.Password == "null")
             {
                 Password.Password = "";
                 PasswordBoxHelper.SetWatermark(Password, " ( 这不是个合法的密码! ) ");
                 return;
             }
             Main.Settings["Features"]["Privacy"]["Password"] = Password.Password;
             SaveSet();
             Password.Password = "";
         }
         this.PassWord.Visibility = Visibility.Collapsed;
     }
     else
     {
         if (Main.Settings["Features"]["Privacy"]["Password"].ToString() != "NULL")
         {
             PassWordEnterF7 EP = new PassWordEnterF7();
             this.IsMaskVisible       = true;
             EP.Owner                 = this;
             EP.WindowStartupLocation = WindowStartupLocation.CenterOwner;
             EP.ShowDialog();
             this.IsMaskVisible = false;
         }
         else
         {
             LoadingSetter.PasswordPass = true;
         }
         if (!LoadingSetter.PasswordPass)
         {
             return;
         }
         LoadingSetter.PasswordPass = false;
         this.PassWord.Visibility   = Visibility.Visible;
         PasswordBoxHelper.SetWatermark(Password, " ( 再次点击设置按钮确定 ) ");
         if (Main.Settings["Features"]["Privacy"]["Password"].ToString() != "NULL")
         {
             PasswordBoxHelper.SetWatermark(Password, " ( 空白将保持已设置的密码 ) ");
         }
         else
         {
             MessageBoxX.Show("私隐密码为弱密码,以 <明文> 记录在设置文件中,这意味着这个密码仅用于警告,没有任何安全性,请不要把重要信息存储在 SSTB 内。", "提示");
         }
     }
 }
        private void UpdateCode()
        {
            var icon         = PasswordBoxHelper.GetIcon(PbCustom);
            var watermark    = PasswordBoxHelper.GetWatermark(PbCustom);
            var cornerRadius = SldCornerRadius.Value;

            TbCode.Text = "<PasswordBox  Height=\"30\"" +
                          $"\nWidth=\"{PbCustom.Width}\"" +
                          (watermark == null ? "" : $"\npu:PasswordBoxHelper.Watermark=\"{watermark}\"") +
                          (icon == null ? "" : $"\npu:PasswordBoxHelper.Icon=\"{icon}\"") +
                          $"\npu:PasswordBoxHelper.FocusedBorderBrush=\"{PasswordBoxHelper.GetFocusedBorderBrush(PbCustom).ToColor().ToHexString(false)}\"" +
                          $"\npu:PasswordBoxHelper.FocusedShadowColor=\"{PasswordBoxHelper.GetFocusedShadowColor(PbCustom).ToHexString(false)}\"" +
                          (cornerRadius == 0 ? "" : $"\npu:ButtonHelper.CornerRadius=\"{cornerRadius}\"") +
                          " />";
        }
        private void TestMySqlConn(object parameter)
        {
            PasswordBox passwordBox = parameter as PasswordBox;

            //PasswordBox的Password属性因为安全原因不支持直接绑定
            this.CenterDbPwd = PasswordBoxHelper.GetPassword(passwordBox);
            string mySqlConnStr = GetConnStr();

            if (string.IsNullOrEmpty(mySqlConnStr))
            {
                MessageBoxHelper.MessageBoxShowWarning("请输入完整的数据库连接信息");
                return;
            }
            TestMySql(mySqlConnStr);
        }