Example #1
0
        public static void Initialize()
        {
            try
            {
                SettingsManager.Init();
                if (!File.Exists(Application.StartupPath + @"\FIRSTRUN.dat"))
                {
                    File.Create(Application.StartupPath + @"\FIRSTRUN.dat");
                    GPlayer.Install();
                }

                Client = new GigClient(HOST);
                SplashScreen.frm.Refresh();
                if (!File.Exists(Application.StartupPath + @"\Data\AT.dat") || SettingsManager.GetBool("CONNECT"))
                {
                    LoginFrm frm = new LoginFrm();
                    frm.ShowDialog();
                    if (frm.close)
                    {
                        File.WriteAllText(Application.StartupPath + @"\Data\AT.dat", Client.AccessToken);
                        File.WriteAllText(Application.StartupPath + @"\Data\UN.dat", Client.Username);
                        Client.MyAccount = Client.GetUserInfo(Client.Username);
                        //AsyncExec ae = new AsyncExec(GetUI);
                        //ae.BeginInvoke(null, null);
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
                else
                {
                    SplashScreen.frm.Show();
                    Client.AccessToken = File.ReadAllText(Application.StartupPath + @"\Data\AT.dat");
                    Client.Username    = File.ReadAllText(Application.StartupPath + @"\Data\UN.dat");

                    // check AT
                    if (!Client.IsConnected())
                    {
                        LoginFrm frm = new LoginFrm();
                        frm.ShowDialog();
                        if (frm.close)
                        {
                            File.WriteAllText(Application.StartupPath + @"\Data\AT.dat", Client.AccessToken);
                            File.WriteAllText(Application.StartupPath + @"\Data\UN.dat", Client.Username);
                        }
                        else
                        {
                            Application.Exit();
                        }
                    }
                    else
                    {
                        Client.MyAccount = Client.GetUserInfo(Client.Username);
                        //AsyncExec ae = new AsyncExec(GetUI);
                        //ae.BeginInvoke(null, null);
                    }
                }

                if (!File.Exists(Application.StartupPath + @"\Data\" + Client.Username + ".dat"))
                {
                    File.WriteAllLines(Application.StartupPath + @"\Data\" + Client.Username + ".dat", new string[2] {
                        "m1", "n1"
                    });
                }



                // Initialize Controls
                ProfileControl     = new ProfileCtrl();
                CommunityControl   = new CICtrl();
                CommandControl     = new CmdCTRL();
                FriendControl      = new FriendCtrl();
                GIGPControl        = new GIGPCtrl();
                HomeControl        = new HomeCtrl();
                MessagesControl    = new MessagesCtrl();
                ShopControl        = new ShopCtrl();
                TransactionControl = new Transacfrm();
                AboutControl       = new AboutCtrl();
                AllUsersControl    = new AllUsersCtrl();

                SplashScreen.frm.Close();
            }
            catch (Exception ex)
            {
                GigSpace.LogError(ex);
            }
        }