Exemple #1
0
        public static bool validate(List <string> requiredControlList, Window userControl)
        {
            bool isValid = true;

            try
            {
                foreach (var control in requiredControlList)
                {
                    TextBox textBox = FindControls.FindVisualChildren <TextBox>(userControl).Where(x => x.Name == "tb_" + control)
                                      .FirstOrDefault();
                    Path path = FindControls.FindVisualChildren <Path>(userControl).Where(x => x.Name == "p_error_" + control)
                                .FirstOrDefault();
                    if (textBox != null && path != null)
                    {
                        if (!HelpClass.validateEmpty(textBox.Text, path))
                        {
                            isValid = false;
                        }
                    }
                }
                foreach (var control in requiredControlList)
                {
                    ComboBox comboBox = FindControls.FindVisualChildren <ComboBox>(userControl).Where(x => x.Name == "cb_" + control)
                                        .FirstOrDefault();
                    Path path = FindControls.FindVisualChildren <Path>(userControl).Where(x => x.Name == "p_error_" + control)
                                .FirstOrDefault();
                    if (comboBox != null && path != null)
                    {
                        if (!HelpClass.validateEmpty(comboBox.Text, path))
                        {
                            isValid = false;
                        }
                    }
                }
                foreach (var control in requiredControlList)
                {
                    PasswordBox passwordBox = FindControls.FindVisualChildren <PasswordBox>(userControl).Where(x => x.Name == "pb_" + control)
                                              .FirstOrDefault();
                    Path path = FindControls.FindVisualChildren <Path>(userControl).Where(x => x.Name == "p_error_" + control)
                                .FirstOrDefault();
                    if (passwordBox != null && path != null)
                    {
                        if (!HelpClass.validateEmpty(passwordBox.Password, path))
                        {
                            isValid = false;
                        }
                    }
                }
                #region Email
                IsValidEmail(userControl);
                #endregion
            }
            catch { }
            return(isValid);
        }
Exemple #2
0
        static public void EndAwait(Grid grid)
        {
            MahApps.Metro.Controls.ProgressRing progressRing = FindControls.FindVisualChildren <MahApps.Metro.Controls.ProgressRing>(grid)
                                                               .Where(x => x.Name == "prg_awaitRing").FirstOrDefault();
            grid.Children.Remove(progressRing);

            var progressRingList = FindControls.FindVisualChildren <MahApps.Metro.Controls.ProgressRing>(grid)
                                   .Where(x => x.Name == "prg_awaitRing");

            if (progressRingList.Count() == 0)
            {
                grid.IsEnabled = true;
                grid.Opacity   = 1;
            }
        }
Exemple #3
0
 public static void clearValidateWindow(List <string> requiredControlList, Window window)
 {
     try
     {
         foreach (var control in requiredControlList)
         {
             Path path = FindControls.FindVisualChildren <Path>(window).Where(x => x.Name == "p_error_" + control)
                         .FirstOrDefault();
             if (path != null)
             {
                 HelpClass.clearValidate(path);
             }
         }
     }
     catch { }
 }
Exemple #4
0
        public static bool IsValidEmailWindow(Window window)
        {//for email
            bool    isValidEmail = true;
            TextBox textBoxEmail = FindControls.FindVisualChildren <TextBox>(window).Where(x => x.Name == "tb_email")
                                   .FirstOrDefault();
            Path pathEmail = FindControls.FindVisualChildren <Path>(window).Where(x => x.Name == "p_error_email")
                             .FirstOrDefault();

            if (textBoxEmail != null && pathEmail != null)
            {
                if (textBoxEmail.Text.Equals(""))
                {
                    return(isValidEmail);
                }
                else
                {
                    Regex regex = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
                                            RegexOptions.CultureInvariant | RegexOptions.Singleline);
                    isValidEmail = regex.IsMatch(textBoxEmail.Text);

                    if (!isValidEmail)
                    {
                        pathEmail.Visibility = Visibility.Visible;
                        #region Tooltip
                        ToolTip toolTip = new ToolTip();
                        toolTip.Content   = MainWindow.resourcemanager.GetString("trErrorEmailToolTip");
                        toolTip.Style     = Application.Current.Resources["ToolTipError"] as Style;
                        pathEmail.ToolTip = toolTip;
                        #endregion
                        isValidEmail = false;
                    }
                    else
                    {
                        pathEmail.Visibility = Visibility.Collapsed;
                    }
                }
            }
            return(isValidEmail);
        }