private void languageDropDown_DropDownClosed(object sender, EventArgs e) { var functions = new functions(); switch (languageDropDown.SelectedItem) { case "Português": if (Thread.CurrentThread.CurrentUICulture != System.Globalization.CultureInfo.GetCultureInfo("pt-PT")) { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("pt-PT"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pt-PT"); Properties.Settings.Default.Language = "pt-PT"; Properties.Settings.Default.Save(); this.Controls.Clear(); InitializeComponent(); languageDropDown.SelectedIndex = languageDropDown.FindStringExact("Português"); versionLBL.Text = functions.GetSoftwareVersion(); } break; default: if (Thread.CurrentThread.CurrentUICulture != System.Globalization.CultureInfo.GetCultureInfo("en-US")) { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); Properties.Settings.Default.Language = "en-US"; Properties.Settings.Default.Save(); this.Controls.Clear(); InitializeComponent(); languageDropDown.SelectedIndex = languageDropDown.FindStringExact("English"); versionLBL.Text = functions.GetSoftwareVersion(); } break; } }
private void login_Load(object sender, EventArgs e) { var functions = new functions(); versionLBL.Text = functions.GetSoftwareVersion(); switch (Properties.Settings.Default.Language) { case "pt-PT": languageDropDown.SelectedIndex = languageDropDown.FindStringExact("Português"); break; default: languageDropDown.SelectedIndex = languageDropDown.FindStringExact("English"); break; } }
/// <summary> /// Upload the specified files and adopts them /// </summary> /// <see cref="https://stackoverflow.com/questions/10237983/upload-to-php-server-from-c-sharp-client-application"/> /// <param name="files">List of files to upload</param> /// <param name="summaryNumber">Current Summary ID</param> /// <returns>List of files to be adopted</returns> private List <string> UploadFiles(List <String> filesToUpload) { var functions = new functions(); List <string> filesToAdopt = new List <string>(); try { foreach (string currentFile in filesToUpload) { WebClient Client = new WebClient(); Client.Headers.Add("Content-Type", "binary/octet-stream"); Client.Headers.Add("HTTP-X-API-KEY", storage.AccessToken); byte[] result = Client.UploadFile(storage.inUseDomain + "/summaries/api/v" + functions.GetSoftwareVersion()[0] + "/user/" + storage.userID + "/uploadfile", "POST", currentFile); string response = Encoding.UTF8.GetString(result, 0, result.Length); uploadResults = JsonConvert.DeserializeObject <uploadInfo>(response); if (uploadResults.status) { filesToAdopt.Add(uploadResults.rowID); } else { MessageBox.Show(GlobalStrings.Error + ": " + uploadResults.errors, GlobalStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } } return(filesToAdopt); } catch (WebException ex) { if (functions.CheckForInternetConnection(storage.inUseDomain)) { using (var stream = ex.Response.GetResponseStream()) using (var reader = new StreamReader(stream)) { MessageBox.Show("Response: " + reader.ReadToEnd() + "\n" + "Error: " + ex.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); } }