Esempio n. 1
0
        private void onSettingsSave(object sender, EventArgs e)
        {
            if (SettingsCombo.Text.Length > 0 && SettingsCombo.Text != "<Current>")
            {
                updateSettings();

                CheckInSettingsEntry settings = new CheckInSettingsEntry();
                settings.name     = SettingsCombo.Text.Trim();
                settings.settings = JsonConvert.SerializeObject(Program.settings);

                try
                {
                    var wc   = Util.CreateWebClient();
                    var post = new NameValueCollection();
                    var msg  = new BaseMessage();

                    msg.data = JsonConvert.SerializeObject(settings);

                    post.Add("data", JsonConvert.SerializeObject(msg));

                    var save        = Program.settings.createURI("CheckInAPI/SaveSettings");
                    var saveResults = wc.UploadValues(save, post);

                    BaseMessage bm = JsonConvert.DeserializeObject <BaseMessage>(Encoding.ASCII.GetString(saveResults));

                    if (bm.error == 0)
                    {
                        MessageBox.Show("Your settings have been saved!", "Save Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Program.updateSettingsList(settings.name, settings.settings);
                        rebindSettingsList();
                    }
                    else
                    {
                        MessageBox.Show("The server you enter is not valid, please try again.\n\n" + Program.settings.createURL(), "Communication Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (WebException)
                {
                    MessageBox.Show("Could not connect to: " + Program.settings.createURL(), "Communication Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                if (SettingsCombo.Text.Length == 0)
                {
                    MessageBox.Show("The settings name cannot be blank, please save as a different name.", "Invalid Settings Name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("The settings name cannot be \"<Current>\", please save as a different name.", "Invalid Settings Name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 2
0
        private void onSettingsNameChanged(object sender, EventArgs e)
        {
            string name = SettingsCombo.Text;

            if (name != "<Current>")
            {
                CheckInSettingsEntry entry = Program.getSettingsFromList(name);

                if (entry != null)
                {
                    Program.settings.copy(JsonConvert.DeserializeObject <Settings>(entry.settings));
                    updateDisplay();
                }
            }
        }
Esempio n. 3
0
		private void onSettingsSave(object sender, EventArgs e)
		{
			if (SettingsCombo.Text.Length > 0 && SettingsCombo.Text != "<Current>") {
				updateSettings();

				CheckInSettingsEntry settings = new CheckInSettingsEntry();
				settings.name = SettingsCombo.Text.Trim();
				settings.settings = JsonConvert.SerializeObject(Program.settings);

				try {
					var wc = Util.CreateWebClient();
					var post = new NameValueCollection();
					var msg = new BaseMessage();

					msg.data = JsonConvert.SerializeObject(settings);

					post.Add("data", JsonConvert.SerializeObject(msg));

					var save = Program.settings.createURI("CheckInAPI/SaveSettings");
					var saveResults = wc.UploadValues(save, post);

					BaseMessage bm = JsonConvert.DeserializeObject<BaseMessage>(Encoding.ASCII.GetString(saveResults));

					if (bm.error == 0) {
						MessageBox.Show("Your settings have been saved!", "Save Complete");
						Program.updateSettingsList(settings.name, settings.settings);
						rebindSettingsList();
					} else {
						MessageBox.Show("The server you enter is not valid, please try again.\n\n" + Program.settings.createURL(), "Communication Error");
					}
				} catch (WebException) {
					MessageBox.Show("Could not connect to: " + Program.settings.createURL(), "Communication Error");
				}
			} else {
				if (SettingsCombo.Text.Length == 0) {
					MessageBox.Show("The settings name cannot be blank, please save as a different name.", "Invalid Settings Name");
				} else {
					MessageBox.Show("The settings name cannot be \"<Current>\", please save as a different name.", "Invalid Settings Name");
				}
			}
		}