Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
#if (RELEASE)
            btnGenerateMetaData.Visible = false;
            btnSyncFiles.Height         = 147;
#endif


            if (!System.IO.File.Exists("data/ContentFolderLocation.txt"))
            {
                FileInfo file = new FileInfo("data/ContentFolderLocation.txt");
                file.Directory.Create();

                using (StreamWriter sw = System.IO.File.CreateText("data/ContentFolderLocation.txt"))
                {
                    string blankFile = "";
                    sw.WriteLine(blankFile);
                }
            }
            else
            {
                using (StreamReader r = new StreamReader("data/ContentFolderLocation.txt"))
                {
                    ContentFolderLocation = r.ReadLine();
                    txtProjectName.Text   = ContentFolderLocation;
                }
            }

            if (!System.IO.File.Exists("data/ProjectName.txt"))
            {
                using (StreamWriter sw = System.IO.File.CreateText("data/ProjectName.txt"))
                {
                    string blankFile = "";
                    sw.WriteLine(blankFile);
                }
            }
            else
            {
                using (StreamReader r = new StreamReader("data/ProjectName.txt"))
                {
                    ProjectName         = r.ReadLine();
                    txtProjectName.Text = ProjectName;
                }
            }

            txtMyContentFileLocation.Text = System.IO.File.ReadAllLines(@"data/ContentFolderLocation.txt")[0];

            if (!System.IO.File.Exists("data/credentials.json"))
            {
                using (StreamWriter sw = System.IO.File.CreateText("data/credentials.json"))
                {
                    string blankJSON = "{\"installed\": {\"client_id\": \"\",\"project_id\": \"\",\"auth_uri\": \"\",\"token_uri\": \"\",\"auth_provider_x509_cert_url\": \"\",\"client_secret\": \"\",\"redirect_uris\": [ \"\", \"\"]}}";
                    sw.WriteLine(blankJSON);
                }
            }
            else
            {
                using (StreamReader r = new StreamReader("data/ContentFolderLocation.txt"))
                {
                    ContentFolderLocation = r.ReadLine();
                }
            }

            using (StreamReader r = new StreamReader("data/credentials.json"))
            {
                string     json             = r.ReadToEnd();
                RootObject credentialObject = JsonConvert.DeserializeObject <RootObject>(json);

                if (credentialObject.installed.client_id == "" ||
                    credentialObject.installed.project_id == "" ||
                    credentialObject.installed.client_secret == "")
                {
                    CredentialSetupForm credentialSetupForm = new CredentialSetupForm(this);
                    r.Close();
                    credentialSetupForm.ShowDialog();
                }
                else
                {
                    txtProjectID.Text = credentialObject.installed.project_id;
                    client_id         = credentialObject.installed.client_id;
                    project_id        = credentialObject.installed.project_id;
                    client_secret     = credentialObject.installed.client_secret;
                }
            }

            backgroundWorker1.RunWorkerAsync();
        }
Пример #2
0
        private void btnReAuthenticate_Click(object sender, EventArgs e)
        {
            CredentialSetupForm credentialSetupForm = new CredentialSetupForm(this);

            credentialSetupForm.ShowDialog();
        }