private void logIn(object sender, RoutedEventArgs e)
        {
            string nameRecord = "";
            string passRecord = "";

            if (UsernameField.Text == "" || UserPassField.Password == "")
            {
                if (activeErrorFlag == -1)
                {
                    activeErrorFlag = 1;
                    Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                    errorMarqueeScroll("Username and password required");
                }
                else
                {
                    activeErrorFlag++;
                    Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                    errorMarqueeScroll("Username and password required");
                }
            }
            else
            {
                var userNullCheck = new user();
                using (otongadgethubEntities logCheck = new otongadgethubEntities())
                {
                    userNullCheck = logCheck.users.FirstOrDefault(a => a.username == UsernameField.Text);
                }

                if (userNullCheck == null)
                {
                    if (activeErrorFlag == -1)
                    {
                        activeErrorFlag = 1;
                        Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                        errorMarqueeScroll("Username does not exist");
                    }
                    else
                    {
                        activeErrorFlag++;
                        Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                        errorMarqueeScroll("Username does not exist");
                    }
                }

                if (userNullCheck != null)
                {
                    nameRecord = userNullCheck.username;
                }

                if (nameRecord == UsernameField.Text)
                {
                    passRecord = Encrypt.MD5(UserPassField.Password).ToLower();
                    if (passRecord == userNullCheck.password)
                    {
                        //var chatClientWPFWindowSet = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is ChatWPFClient) as ChatWPFClient;

                        //var set = Application.Current.Windows.OfType<ChatWPFClient>().FirstOrDefault(window => window is ChatWPFClient) as ChatWPFClient;

                        WPFUserSession.sessionUser = userNullCheck;

                        UserMenu menu = new UserMenu();
                        menu.Show();
                        this.Close();
                    }
                    else
                    {
                        if (activeErrorFlag == -1)
                        {
                            activeErrorFlag = 1;
                            Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                            errorMarqueeScroll("Password invalid");
                        }
                        else
                        {
                            activeErrorFlag++;
                            Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                            errorMarqueeScroll("Password invalid");
                        }
                    }
                }
            }
        }
        private void logIn(object sender, RoutedEventArgs e)
        {
            string nameRecord = "";
            string passRecord = "";

            if (UsernameField.Text == "" || UserPassField.Password == "")
            {
                if (activeErrorFlag == -1)
                {
                    activeErrorFlag = 1;
                    Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                    errorMarqueeScroll("Username and password required");
                }
                else
                {
                    activeErrorFlag++;
                    Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                    errorMarqueeScroll("Username and password required");
                }
            }
            else
            {
                var userNullCheck = new user();
                using (otongadgethubEntities logCheck = new otongadgethubEntities())
                {
                    userNullCheck = logCheck.users.FirstOrDefault(a => a.username == UsernameField.Text);

                }

                if (userNullCheck == null)
                {
                    if (activeErrorFlag == -1)
                    {
                        activeErrorFlag = 1;
                        Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                        errorMarqueeScroll("Username does not exist");
                    }
                    else
                    {
                        activeErrorFlag++;
                        Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                        errorMarqueeScroll("Username does not exist");
                    }
                }

                if (userNullCheck != null)
                {
                    nameRecord = userNullCheck.username;
                }

                if (nameRecord == UsernameField.Text)
                {
                    passRecord = Encrypt.MD5(UserPassField.Password).ToLower();
                    if (passRecord == userNullCheck.password)
                    {
                        //var chatClientWPFWindowSet = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is ChatWPFClient) as ChatWPFClient;

                        //var set = Application.Current.Windows.OfType<ChatWPFClient>().FirstOrDefault(window => window is ChatWPFClient) as ChatWPFClient;

                        WPFUserSession.sessionUser = userNullCheck;

                        UserMenu menu = new UserMenu();
                        menu.Show();
                        this.Close();
                    }
                    else
                    {
                        if (activeErrorFlag == -1)
                        {
                            activeErrorFlag = 1;
                            Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                            errorMarqueeScroll("Password invalid");
                        }
                        else
                        {
                            activeErrorFlag++;
                            Debug.WriteLine("Animations ongoing: " + activeErrorFlag);
                            errorMarqueeScroll("Password invalid");
                        }
                    }
                }
            }
        }