Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Options form buttons #418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions src/ServiceBusExplorer/Forms/OptionForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 65 additions & 59 deletions src/ServiceBusExplorer/Forms/OptionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,51 @@ public OptionForm(MainSettings mainSettings, ConfigFileUse configFileUse)
public ConfigFileUse ConfigFileUse { get; private set; }
#endregion

#region Event Handlers
#region Command button event Handlers
void btnOpenConfig_Click(object sender, EventArgs e)
{
var selected = GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex);

if (selected == ConfigFileUse.None)
{
MessageBox.Show("No file was selected in the list.", "No file opened",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

// Open the file(s) depending on what's selected. Create an instance of the
// TwoFilesConfiguration just to get the paths
var configuration = TwoFilesConfiguration.Create(selected);

if (cboConfigFile.SelectedIndex == ApplicationConfigFileIndex ||
cboConfigFile.SelectedIndex == BothConfigFileIndex)
{
// Open the application config file
Process.Start(configuration.ApplicationFilePath);
}

if (cboConfigFile.SelectedIndex == UserConfigFileIndex ||
cboConfigFile.SelectedIndex == BothConfigFileIndex)
{
// Open the user config file. It might not exist though
if (File.Exists(configuration.UserConfigFilePath))
{
Process.Start(configuration.UserConfigFilePath);
}
else
{
MessageBox.Show($"The file {configuration.UserConfigFilePath} does not exist. Click the Save"
+ " button to create it.",
"File does exist", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

private void btnOk_Click(object sender, EventArgs e)
{
MainSettings.SelectedEntities = GetSelectedEntities();

SaveSettings(GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex));

DialogResult = DialogResult.OK;
Close();
Expand All @@ -109,6 +150,28 @@ private void btnCancel_Click(object sender, EventArgs e)
Close();
}

void btnSave_Click(object sender, EventArgs e)
{
// Get selected items
MainSettings.SelectedEntities = GetSelectedEntities();

SaveSettings(GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex));
}

void btnOpen_Click(object sender, EventArgs e)
{
using (var form = new TextForm(MessageTextTitle, txtMessageText.Text))
{
if (form.ShowDialog() == DialogResult.OK)
{
txtMessageText.Text = form.Content;
}
}
}
#endregion

#region Event Handlers

private void logNumericUpDown_ValueChanged(object sender, EventArgs e)
{
MainSettings.LogFontSize = logNumericUpDown.Value;
Expand All @@ -128,7 +191,7 @@ private void OptionForm_KeyPress(object sender, KeyPressEventArgs e)
}
}

private void btnDefault_Click(object sender, EventArgs e)
private void btnReset_Click(object sender, EventArgs e)
{
MainSettings.SetDefault();

Expand Down Expand Up @@ -316,70 +379,13 @@ void cboDefaultMessageBodyType_SelectedIndexChanged(object sender, EventArgs e)
MainSettings.MessageBodyType = cboDefaultMessageBodyType.Text;
}

void btnSave_Click(object sender, EventArgs e)
{
// Get selected items
MainSettings.SelectedEntities = GetSelectedEntities();

SaveSettings(GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex));
}

void btnOpen_Click(object sender, EventArgs e)
{
using (var form = new TextForm(MessageTextTitle, txtMessageText.Text))
{
if (form.ShowDialog() == DialogResult.OK)
{
txtMessageText.Text = form.Content;
}
}
}

void cboEncoding_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboEncodingType.SelectedItem is EncodingType)
{
MainSettings.EncodingType = (EncodingType)cboEncodingType.SelectedItem;
}
}
void btnOpenConfig_Click(object sender, EventArgs e)
{
var selected = GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex);

if (selected == ConfigFileUse.None)
{
MessageBox.Show("No file was selected in the list.", "No file opened",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

// Open the file(s) depending on what's selected. Create an instance of the
// TwoFilesConfiguration just to get the paths
var configuration = TwoFilesConfiguration.Create(selected);

if (cboConfigFile.SelectedIndex == ApplicationConfigFileIndex ||
cboConfigFile.SelectedIndex == BothConfigFileIndex)
{
// Open the application config file
Process.Start(configuration.ApplicationFilePath);
}

if (cboConfigFile.SelectedIndex == UserConfigFileIndex ||
cboConfigFile.SelectedIndex == BothConfigFileIndex)
{
// Open the user config file. It might not exist though
if (File.Exists(configuration.UserConfigFilePath))
{
Process.Start(configuration.UserConfigFilePath);
}
else
{
MessageBox.Show($"The file {configuration.UserConfigFilePath} does not exist. Click the Save"
+ " button to create it.",
"File does exist", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

void cboConfigFile_SelectionChangeCommitted(object sender, EventArgs e)
{
Expand Down