@@ -684,68 +684,46 @@ private void ButtonAddPulses_Click(object sender, EventArgs e)
684
684
{
685
685
if ( ChannelDialog . SelectedContacts [ i ] )
686
686
{
687
- if ( textboxDelay . Tag = = null )
687
+ if ( textboxDelay . Tag ! = null )
688
688
{
689
- MessageBox . Show ( "Unable to parse delay." ) ;
690
- return ;
689
+ Sequence . Stimuli [ i ] . DelaySamples = ( uint ) textboxDelay . Tag ;
691
690
}
692
691
693
- if ( textboxAmplitudeAnodic . Tag = = null )
692
+ if ( textboxAmplitudeAnodic . Tag ! = null )
694
693
{
695
- MessageBox . Show ( "Unable to parse anodic amplitude." ) ;
696
- return ;
694
+ Sequence . Stimuli [ i ] . AnodicAmplitudeSteps = ( byte ) textboxAmplitudeAnodic . Tag ;
697
695
}
698
696
699
- if ( textboxPulseWidthAnodic . Tag = = null )
697
+ if ( textboxPulseWidthAnodic . Tag ! = null )
700
698
{
701
- MessageBox . Show ( "Unable to parse anodic pulse width." ) ;
702
- return ;
699
+ Sequence . Stimuli [ i ] . AnodicWidthSamples = ( uint ) textboxPulseWidthAnodic . Tag ;
703
700
}
704
701
705
- if ( textboxInterPulseInterval . Tag = = null )
702
+ if ( textboxInterPulseInterval . Tag ! = null )
706
703
{
707
- MessageBox . Show ( "Unable to parse inter-pulse interval." ) ;
708
- return ;
704
+ Sequence . Stimuli [ i ] . DwellSamples = ( uint ) textboxInterPulseInterval . Tag ;
709
705
}
710
706
711
- if ( textboxAmplitudeCathodic . Tag = = null )
707
+ if ( textboxAmplitudeCathodic . Tag ! = null )
712
708
{
713
- MessageBox . Show ( "Unable to parse cathodic amplitude." ) ;
714
- return ;
709
+ Sequence . Stimuli [ i ] . CathodicAmplitudeSteps = ( byte ) textboxAmplitudeCathodic . Tag ;
715
710
}
716
711
717
- if ( textboxPulseWidthCathodic . Tag = = null )
712
+ if ( textboxPulseWidthCathodic . Tag ! = null )
718
713
{
719
- MessageBox . Show ( "Unable to parse cathodic pulse width." ) ;
720
- return ;
714
+ Sequence . Stimuli [ i ] . CathodicWidthSamples = ( uint ) textboxPulseWidthCathodic . Tag ;
721
715
}
722
716
723
- if ( textboxInterStimulusInterval . Tag = = null )
717
+ if ( textboxInterStimulusInterval . Tag ! = null )
724
718
{
725
- MessageBox . Show ( "Unable to parse inter-stimulus interval." ) ;
726
- return ;
719
+ Sequence . Stimuli [ i ] . InterStimulusIntervalSamples = ( uint ) textboxInterStimulusInterval . Tag ;
727
720
}
728
721
729
- if ( ! uint . TryParse ( textboxNumberOfStimuli . Text , out uint numberOfStimuliValue ) )
722
+ if ( uint . TryParse ( textboxNumberOfStimuli . Text , out uint numberOfStimuliValue ) )
730
723
{
731
- MessageBox . Show ( "Unable to parse number of stimuli." ) ;
732
- return ;
724
+ Sequence . Stimuli [ i ] . NumberOfStimuli = numberOfStimuliValue ;
733
725
}
734
726
735
- Sequence . Stimuli [ i ] . DelaySamples = ( uint ) textboxDelay . Tag ;
736
-
737
- Sequence . Stimuli [ i ] . AnodicAmplitudeSteps = ( byte ) textboxAmplitudeAnodic . Tag ;
738
- Sequence . Stimuli [ i ] . AnodicWidthSamples = ( uint ) textboxPulseWidthAnodic . Tag ;
739
-
740
- Sequence . Stimuli [ i ] . CathodicAmplitudeSteps = ( byte ) textboxAmplitudeCathodic . Tag ;
741
- Sequence . Stimuli [ i ] . CathodicWidthSamples = ( uint ) textboxPulseWidthCathodic . Tag ;
742
-
743
- Sequence . Stimuli [ i ] . DwellSamples = ( uint ) textboxInterPulseInterval . Tag ;
744
-
745
- Sequence . Stimuli [ i ] . InterStimulusIntervalSamples = ( uint ) textboxInterStimulusInterval . Tag ;
746
-
747
- Sequence . Stimuli [ i ] . NumberOfStimuli = numberOfStimuliValue ;
748
-
749
727
Sequence . Stimuli [ i ] . AnodicFirst = checkBoxAnodicFirst . Checked ;
750
728
}
751
729
}
@@ -853,6 +831,18 @@ private void Samples_TextChanged(object sender, EventArgs e)
853
831
else if ( textBox . Text == "" )
854
832
{
855
833
textBox . Tag = null ;
834
+
835
+ if ( textBox . Name == nameof ( textboxPulseWidthAnodic ) && checkboxBiphasicSymmetrical . Checked )
836
+ {
837
+ textboxPulseWidthCathodic . Text = "" ;
838
+ textboxPulseWidthCathodic . Tag = null ;
839
+ }
840
+ else if ( textBox . Name == nameof ( textboxPulseWidthCathodic ) && checkboxBiphasicSymmetrical . Checked )
841
+ {
842
+ textboxPulseWidthAnodic . Text = "" ;
843
+ textboxPulseWidthAnodic . Tag = null ;
844
+ }
845
+
856
846
return ;
857
847
}
858
848
@@ -944,6 +934,21 @@ private void Amplitude_TextChanged(object sender, EventArgs e)
944
934
if ( textBox . Text == "" )
945
935
{
946
936
textBox . Tag = null ;
937
+
938
+ if ( checkboxBiphasicSymmetrical . Checked )
939
+ {
940
+ if ( textBox . Name == nameof ( textboxAmplitudeAnodic ) )
941
+ {
942
+ textboxAmplitudeCathodic . Text = "" ;
943
+ textboxAmplitudeCathodic . Tag = null ;
944
+ }
945
+ else if ( textBox . Name == nameof ( textboxAmplitudeCathodic ) )
946
+ {
947
+ textboxAmplitudeAnodic . Text = "" ;
948
+ textboxAmplitudeAnodic . Tag = null ;
949
+ }
950
+ }
951
+
947
952
return ;
948
953
}
949
954
@@ -981,47 +986,6 @@ private void Amplitude_TextChanged(object sender, EventArgs e)
981
986
textboxAmplitudeAnodic . Tag = textBox . Tag ;
982
987
}
983
988
}
984
- else
985
- {
986
- if ( textBox . Name == nameof ( textboxAmplitudeAnodic ) && double . TryParse ( textboxAmplitudeCathodic . Text , out var cathodicAmplitude ) )
987
- {
988
- if ( ! GetSampleFromAmplitude ( cathodicAmplitude , out var samples ) || samples == 0 )
989
- {
990
- MessageBox . Show ( "Invalid amplitude chosen for the anodic pulse. The step-size required " +
991
- "for this amplitude is incompatible with the step-size required for the cathodic pulse." , "Invalid Anodic Amplitude" ) ;
992
- textBox . Text = "" ;
993
- textBox . Tag = null ;
994
-
995
- textboxAmplitudeCathodic . Text = "" ;
996
- textboxAmplitudeCathodic . Tag = null ;
997
- return ;
998
- }
999
- else
1000
- {
1001
- textboxAmplitudeCathodic . Text = GetAmplitudeString ( samples ) ;
1002
- textboxAmplitudeCathodic . Tag = samples ;
1003
- }
1004
- }
1005
- else if ( textBox . Name == nameof ( textboxAmplitudeCathodic ) && double . TryParse ( textboxAmplitudeAnodic . Text , out var anodicAmplitude ) )
1006
- {
1007
- if ( ! GetSampleFromAmplitude ( anodicAmplitude , out var samples ) || samples == 0 )
1008
- {
1009
- MessageBox . Show ( "Invalid amplitude chosen for the cathodic pulse. The step-size required " +
1010
- "for this amplitude is incompatible with the step-size required for the anodic pulse." , "Invalid Cathodic Amplitude" ) ;
1011
- textBox . Text = "" ;
1012
- textBox . Tag = null ;
1013
-
1014
- textboxAmplitudeAnodic . Text = "" ;
1015
- textboxAmplitudeAnodic . Tag = null ;
1016
- return ;
1017
- }
1018
- else
1019
- {
1020
- textboxAmplitudeAnodic . Text = GetAmplitudeString ( samples ) ;
1021
- textboxAmplitudeAnodic . Tag = samples ;
1022
- }
1023
- }
1024
- }
1025
989
}
1026
990
1027
991
/// <summary>
@@ -1087,11 +1051,23 @@ private void Checkbox_CheckedChanged(object sender, EventArgs e)
1087
1051
{
1088
1052
groupBoxCathode . Visible = false ;
1089
1053
groupBoxAnode . Visible = true ;
1054
+
1055
+ textboxPulseWidthCathodic . Text = textboxPulseWidthAnodic . Text ;
1056
+ textboxPulseWidthCathodic . Tag = textboxPulseWidthAnodic . Tag ;
1057
+
1058
+ textboxAmplitudeCathodic . Text = textboxAmplitudeAnodic . Text ;
1059
+ textboxAmplitudeCathodic . Tag = textboxAmplitudeAnodic . Tag ;
1090
1060
}
1091
1061
else
1092
1062
{
1093
1063
groupBoxCathode . Visible = true ;
1094
1064
groupBoxAnode . Visible = false ;
1065
+
1066
+ textboxPulseWidthAnodic . Text = textboxPulseWidthCathodic . Text ;
1067
+ textboxPulseWidthAnodic . Tag = textboxPulseWidthCathodic . Tag ;
1068
+
1069
+ textboxAmplitudeAnodic . Text = textboxAmplitudeCathodic . Text ;
1070
+ textboxAmplitudeAnodic . Tag = textboxAmplitudeCathodic . Tag ;
1095
1071
}
1096
1072
}
1097
1073
else
0 commit comments