Skip to content

Commit

Permalink
Setup script changes. Settings bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaatworld committed Nov 18, 2020
1 parent ce30d51 commit 8f22d4d
Show file tree
Hide file tree
Showing 17 changed files with 344 additions and 295 deletions.
10 changes: 3 additions & 7 deletions HyperionScreenCap/Config/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,10 @@ public static void MigrateLegacySettings()
configurations.Add(HyperionTaskConfiguration.BuildUsingLegacySettings());
Settings.Default.hyperionTaskConfigurations = JsonConvert.SerializeObject(configurations);
Settings.Default.migrateLegacyHyperionConfiguration = false;
Settings.Default.migrateFromBefore2_7 = false;
Settings.Default.Save();
LOG.Info("[Settings Migration] Saved legacy hyperion configuration as JSON string");
}
}

public static void MigrateFromBefore2_7()
{
if (Settings.Default.migrateFromBefore2_7)
} else if ( Settings.Default.migrateFromBefore2_7 )
{
LOG.Info("[Settings Migration] Migrating settings from before version 2.7");
var configurations = JsonConvert.DeserializeObject<List<HyperionTaskConfiguration>>(Settings.Default.hyperionTaskConfigurations);
Expand All @@ -159,7 +155,7 @@ public static void MigrateFromBefore2_7()
Settings.Default.hyperionTaskConfigurations = JsonConvert.SerializeObject(configurations);
Settings.Default.migrateFromBefore2_7 = false;
Settings.Default.Save();
LOG.Info("[Settings Migration] Migrated settings were saved successfully");
LOG.Info("[Settings Migration] Settings from befor version 2.7 were migrated successfully");
}
}
}
Expand Down
177 changes: 88 additions & 89 deletions HyperionScreenCap/Form/ServerPropertiesForm.Designer.cs

Large diffs are not rendered by default.

47 changes: 41 additions & 6 deletions HyperionScreenCap/Form/ServerPropertiesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class ServerPropertiesForm : Form

public ServerPropertiesForm(HyperionTaskConfiguration taskConfiguration)
{
this._defaultServerConfiguration = HyperionServer.BuildUsingDefaultProtoSettings();
this._defaultServerConfiguration = HyperionServer.BuildUsingDefaultFbsSettings();
this.TaskConfiguration = taskConfiguration;
InitializeComponent();
this.Text = $"{this.Text} - {taskConfiguration.Id}";
Expand All @@ -28,7 +28,6 @@ public ServerPropertiesForm(HyperionTaskConfiguration taskConfiguration)

private void InitFormFields()
{
chkConfigurationEnabled.Checked = TaskConfiguration.Enabled;
EnableRelevantDxFields(TaskConfiguration.CaptureMethod);

SelectValueFromComboBox(cbDx11AdapterIndex, TaskConfiguration.Dx11AdapterIndex); // TODO check item list for each combo box
Expand All @@ -48,7 +47,6 @@ private void InitFormFields()

private void SaveFormFields()
{
TaskConfiguration.Enabled = chkConfigurationEnabled.Checked;
TaskConfiguration.CaptureMethod = rbcmDx11.Checked ? CaptureMethod.DX11 : CaptureMethod.DX9;
TaskConfiguration.Dx11AdapterIndex = int.Parse(cbDx11AdapterIndex.SelectedItem.ToString());
TaskConfiguration.Dx11MonitorIndex = int.Parse(cbDx11MonitorIndex.SelectedItem.ToString());
Expand Down Expand Up @@ -120,10 +118,15 @@ private void btnCancel_Click(object sender, EventArgs e)
private void btnSave_Click(object sender, EventArgs e)
{
bool validServerFound = false;
bool invalidPriority = false;
// Validate server rows using IP address default value
for ( int i = 0; i < TaskConfiguration.HyperionServers.Count; i++ )
{
HyperionServer server = TaskConfiguration.HyperionServers[i];
if (server.Priority < 100 || server.Priority > 199)
{
invalidPriority = true;
}
if ( !_defaultServerConfiguration.Host.Equals(server.Host) )
{
validServerFound = true;
Expand All @@ -136,6 +139,11 @@ private void btnSave_Click(object sender, EventArgs e)
MessageBox.Show("All Hyperion server host names are invalid. Please sepcify a valid Hyperion server configuraion.");
return;
}
if (invalidPriority)
{
MessageBox.Show("Invalid priority value found. Priority should be set within the range 100-199.");
return;
}

TaskConfiguration.HyperionServers.RemoveAll(server => _defaultServerConfiguration.Host.Equals(server.Host));
SaveRequested = true;
Expand All @@ -156,13 +164,41 @@ private void ServerPropertiesForm_Shown(object sender, EventArgs e)
private void dgHyperionAddress_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress -= new KeyPressEventHandler(PreventNonNumeric_KeyPressEventHandler);
// Only columnIndex 0 is allowed to have non-numeric characters
if ( dgHyperionAddress.CurrentCell.ColumnIndex > 1 )
if ( dgHyperionAddress.CurrentCell.ColumnIndex == dgHyperionAddress.Columns["clmnPort"].Index
|| dgHyperionAddress.CurrentCell.ColumnIndex == dgHyperionAddress.Columns["clmnPriority"].Index
|| dgHyperionAddress.CurrentCell.ColumnIndex == dgHyperionAddress.Columns["clmnMessageDuration"].Index)
{
e.Control.KeyPress += new KeyPressEventHandler(PreventNonNumeric_KeyPressEventHandler);
}
}

private void dgHyperionAddress_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == dgHyperionAddress.Columns["clmnProtocol"].Index)
{
var columnValue = dgHyperionAddress.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (columnValue != null)
{
var serverProtocol = (HyperionServerProtocol) columnValue;
int newPortValue = -1;
switch (serverProtocol)
{
case HyperionServerProtocol.FLAT_BUFFERS:
newPortValue = HyperionServer.BuildUsingDefaultFbsSettings().Port;
break;

case HyperionServerProtocol.PROTOCOL_BUFFERS:
newPortValue = HyperionServer.BuildUsingDefaultProtoSettings().Port;
break;

default:
throw new NotImplementedException($"Hyperion server protocol {serverProtocol} is not supported yet");
}
dgHyperionAddress.Rows[e.RowIndex].Cells["clmnPort"].Value = newPortValue; // Change port according to protocol
}
}
}

private void PreventNonNumeric_KeyPressEventHandler(object sender, KeyPressEventArgs e)
{
if ( !char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) )
Expand All @@ -187,6 +223,5 @@ private void rbcmDx11_CheckedChanged(object sender, EventArgs e)
else
EnableRelevantDxFields(CaptureMethod.DX9);
}

}
}
2 changes: 1 addition & 1 deletion HyperionScreenCap/Form/ServerPropertiesForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="Protocol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="clmnProtocol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clmnHost.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand Down
Loading

0 comments on commit 8f22d4d

Please sign in to comment.