public MainWindow()
        {
            XmlConfigurator.Configure();
            InitializeComponent();
            AppearanceManager.Current.AccentColor = Colors.Red;
            CopyDatabase();
            UploadAccount objUploadAccount = new UploadAccount();
            objUploadAccount.AccounLoad();
            mainFormReference = this;
           
            Thread Obj_CheckVersion = new Thread(CheckVersion);
            Obj_CheckVersion.SetApartmentState(ApartmentState.STA);
            Obj_CheckVersion.Start();

            string GetFolderPath=(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\PinDominator3.0" + "\\favicon(1).ico").Replace("\\","/");

            this.objNotifyIcon.Icon = new Icon(@GetFolderPath);

            objNotifyIcon.Click +=
            delegate(object o, EventArgs e)
            {
                this.Show();
                this.WindowState = WindowState.Normal;
            };

            InitializeAllDelegates();//objRepin_Comments_UserPins_Repin
                   
        }
        public void AddSingleAccountUploadAcc()
        {
            try
            {
                QueryManager QM = new QueryManager();
                string accountUser = string.Empty;
                string accountPass = string.Empty;
                string niches = string.Empty;
                string proxyAddress = string.Empty;
                string proxyPort = string.Empty;
                string proxyUserName = string.Empty;
                string proxyPassword = string.Empty;
                //string Useragent = string.Empty;
                string BoardsName = string.Empty;
                string ScreenName = string.Empty;
                string LoginStatus = string.Empty;

                if (string.IsNullOrEmpty(obj_AddSingleAccount_UploadAccount.txtEmail_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountUser = (obj_AddSingleAccount_UploadAccount.txtEmail_AddSingleAcc.Text).ToString();
                }

                if (string.IsNullOrEmpty(obj_AddSingleAccount_UploadAccount.txtPassword_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountPass = (obj_AddSingleAccount_UploadAccount.txtPassword_AddSingleAcc.Text).ToString();
                }

                try
                {
                    niches = (obj_AddSingleAccount_UploadAccount.txtNiche_AddSinleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyAddress = (obj_AddSingleAccount_UploadAccount.txtProxyAddress_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPort = (obj_AddSingleAccount_UploadAccount.txtProxyPort_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyUserName = (obj_AddSingleAccount_UploadAccount.txtProxyUsername_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPassword = (obj_AddSingleAccount_UploadAccount.txtProxyPassword_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                if (Globals.IsBasicVersion)
                {
                    try
                    {
                        string selectQuery = "select count(UserName) from tb_emails";
                        DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_emails");
                        int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                        if (countLoadedAccounts >= 5)
                        {
                            AccounLoad();
                            MessageBox.Show("You Are Using PD Basic Version 5 Accounts allready loaded..");
                            return;
                        }
                        else
                        {
                           // int RemainingAccount = 5 - countLoadedAccounts;

                            //templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount);

                        }
                    }
                    catch { }
                }
                if (Globals.IsProVersion)
                {
                    try
                    {
                        string selectQuery = "select count(UserName) from tb_emails";
                        DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_emails");
                        int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                        if (countLoadedAccounts >= 15)
                        {
                            AccounLoad();
                            MessageBox.Show("You Are Using PD Pro Version 15 Accounts allready loaded..");
                            return;
                        }
                        else
                        {
                           // int RemainingAccount = 15 - countLoadedAccounts;

                           // templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount);

                        }
                    }
                    catch { }
                }

                LoginStatus = "NotChecked";
                QM.AddAccountInDataBase(accountUser, accountPass, niches, proxyAddress, proxyPort, proxyUserName, proxyPassword, ScreenName, LoginStatus);
                UploadAccount objUploadAccount = new UploadAccount();
                objUploadAccount.AccounLoad();

                //Window parentWindow = (Window)this.Parent;
                //parentWindow.Close();

            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }       
        }
        private void btnSave_AddSingleAcc_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                QueryManager QM = new QueryManager();
                string accountUser = string.Empty;
                string accountPass = string.Empty;
                string niches = string.Empty;
                string proxyAddress = string.Empty;
                string proxyPort = string.Empty;
                string proxyUserName = string.Empty;
                string proxyPassword = string.Empty;
                //string Useragent = string.Empty;
                string BoardsName = string.Empty;
                string ScreenName = string.Empty;
                string LoginStatus = string.Empty;

                if (string.IsNullOrEmpty(txtEmail_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountUser = (txtEmail_AddSingleAcc.Text).ToString();
                }

                if (string.IsNullOrEmpty(txtPassword_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountPass = (txtPassword_AddSingleAcc.Text).ToString();
                }

                try
                {
                    niches = (txtNiche_AddSinleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyAddress = (txtProxyAddress_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPort = (txtProxyPort_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyUserName = (txtProxyUsername_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPassword = (txtProxyPassword_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }
                LoginStatus = "NotChecked";

                QM.AddAccountInDataBase(accountUser, accountPass, niches, proxyAddress, proxyPort, proxyUserName, proxyPassword, ScreenName,LoginStatus);
                UploadAccount objUploadAccount = new UploadAccount();
                objUploadAccount.AccounLoad();

                Window parentWindow = (Window)this.Parent;
                parentWindow.Close();

            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }       
        }
        public void AddSingleAccountUploadAcc()
        {
            try
            {
                QueryManager QM            = new QueryManager();
                string       accountUser   = string.Empty;
                string       accountPass   = string.Empty;
                string       niches        = string.Empty;
                string       proxyAddress  = string.Empty;
                string       proxyPort     = string.Empty;
                string       proxyUserName = string.Empty;
                string       proxyPassword = string.Empty;
                //string Useragent = string.Empty;
                string BoardsName  = string.Empty;
                string ScreenName  = string.Empty;
                string LoginStatus = string.Empty;

                if (string.IsNullOrEmpty(obj_AddSingleAccount_UploadAccount.txtEmail_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountUser = (obj_AddSingleAccount_UploadAccount.txtEmail_AddSingleAcc.Text).ToString();
                }

                if (string.IsNullOrEmpty(obj_AddSingleAccount_UploadAccount.txtPassword_AddSingleAcc.Text))
                {
                    try
                    {
                        GlobusLogHelper.log.Info("Please Enter Account");
                        ModernDialog.ShowMessage("Please Enter Account", "Enter Account", MessageBoxButton.OK);
                        return;
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
                else
                {
                    accountPass = (obj_AddSingleAccount_UploadAccount.txtPassword_AddSingleAcc.Text).ToString();
                }

                try
                {
                    niches = (obj_AddSingleAccount_UploadAccount.txtNiche_AddSinleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyAddress = (obj_AddSingleAccount_UploadAccount.txtProxyAddress_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPort = (obj_AddSingleAccount_UploadAccount.txtProxyPort_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyUserName = (obj_AddSingleAccount_UploadAccount.txtProxyUsername_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                try
                {
                    proxyPassword = (obj_AddSingleAccount_UploadAccount.txtProxyPassword_AddSingleAcc.Text).ToString();
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }

                if (Globals.IsBasicVersion)
                {
                    try
                    {
                        string  selectQuery         = "select count(UserName) from tb_emails";
                        DataSet DS                  = DataBaseHandler.SelectQuery(selectQuery, "tb_emails");
                        int     countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                        if (countLoadedAccounts >= 5)
                        {
                            AccounLoad();
                            MessageBox.Show("You Are Using PD Basic Version 5 Accounts allready loaded..");
                            return;
                        }
                        else
                        {
                            // int RemainingAccount = 5 - countLoadedAccounts;

                            //templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount);
                        }
                    }
                    catch { }
                }
                if (Globals.IsProVersion)
                {
                    try
                    {
                        string  selectQuery         = "select count(UserName) from tb_emails";
                        DataSet DS                  = DataBaseHandler.SelectQuery(selectQuery, "tb_emails");
                        int     countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                        if (countLoadedAccounts >= 15)
                        {
                            AccounLoad();
                            MessageBox.Show("You Are Using PD Pro Version 15 Accounts allready loaded..");
                            return;
                        }
                        else
                        {
                            // int RemainingAccount = 15 - countLoadedAccounts;

                            // templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount);
                        }
                    }
                    catch { }
                }

                LoginStatus = "NotChecked";
                QM.AddAccountInDataBase(accountUser, accountPass, niches, proxyAddress, proxyPort, proxyUserName, proxyPassword, ScreenName, LoginStatus);
                UploadAccount objUploadAccount = new UploadAccount();
                objUploadAccount.AccounLoad();

                //Window parentWindow = (Window)this.Parent;
                //parentWindow.Close();
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }