Skip to content

Commit

Permalink
Rename Some Fields & Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yousinix committed Aug 17, 2019
1 parent 2b409dd commit a21627f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ScoutsEncoder/Cipher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public string Encode(string text, string charDelimiter, string wordDelimiter)
return encodedText;
}

public string ShowKey()
public string GetKeysMapping()
{
var outputText = "";
var numberOfAlphabetCharacters = _arabicAlphabet.Count;
Expand Down
2 changes: 1 addition & 1 deletion ScoutsEncoder/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<materialDesign:PackIcon Kind="Sync" Width="16" Height="16" />
</ToggleButton>

<ToggleButton x:Name="MirrorSelectionToggleButton"
<ToggleButton x:Name="MirrorToggleButton"
Width="32"
Height="32"
Margin="16 0 0 0"
Expand Down
39 changes: 23 additions & 16 deletions ScoutsEncoder/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public MainWindow()
// Initialize NewCipherDialog
NewCipherDialog.Context = this;

// Disable Actions
EnableActions(false);

// Clear initial block from RichTextBoxes
InputRichTextBox.Clear();
OutputRichTextBox.Clear();
Expand Down Expand Up @@ -129,35 +132,31 @@ private void CiphersComboBox_SelectionChanged(object sender, SelectionChangedEve
{
_selectedCipher = (Cipher) CiphersComboBox.SelectedItem;

KeysComboBox.IsEnabled = _selectedCipher.HasKeys || _selectedCipher.HasOverloads;
KeysComboBox.ItemsSource = _selectedCipher.KeysList;
KeysComboBox.SelectedIndex = 0;
KeysComboBox.IsEnabled = _selectedCipher.HasKeys || _selectedCipher.HasOverloads;
KeysComboBox.ItemsSource = _selectedCipher.KeysList;
KeysComboBox.SelectedIndex = 0;

EncodeButton .IsEnabled = true;
ShowKeyButton .IsEnabled = true;
RealTimeToggleButton .IsEnabled = true;
MirrorSelectionToggleButton.IsEnabled = true;
ToggleFillButton .IsEnabled = _selectedCipher.HasShapes;
ExportAudioButton .IsEnabled = _selectedCipher.IsAudible;
AudioSpeedComboBox .IsEnabled = _selectedCipher.IsAudible;
ToggleFillButton .IsEnabled = _selectedCipher.HasShapes;
ExportAudioButton .IsEnabled = _selectedCipher.IsAudible;
AudioSpeedComboBox.IsEnabled = _selectedCipher.IsAudible;

RealtimeEventHandler(sender, e); // Real-time syncing
EnableActions(true);
}

private void KeysComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Set Key to zero if KeysComboBox is empty
// or while changing the KeysComboBox's ItemsSource,
// instead of making Key = SelectedIndex = -1
// Since this event is raised while selecting first key when cipher is changed, therefore
// set Key to zero if KeysComboBox is empty instead of making Key = SelectedIndex = -1
// which will cause an error while encoding
_selectedCipher.Key = KeysComboBox.SelectedIndex == -1 ? 0 : KeysComboBox.SelectedIndex;
_selectedCipher.Key = KeysComboBox.Items.IsEmpty ? 0 : KeysComboBox.SelectedIndex;

RealtimeEventHandler(sender, e); // Real-time syncing
}

private void ShowKeyButton_Click(object sender, RoutedEventArgs e)
{
var keys = _selectedCipher.ShowKey();
var keys = _selectedCipher.GetKeysMapping();
OutputRichTextBox.SetText(keys);
_containKeys = true; // Used in mirror selection
}
Expand All @@ -175,6 +174,14 @@ private void Encode()
OutputRichTextBox.SetText(encodedText);
}

private void EnableActions(bool state)
{
ShowKeyButton .IsEnabled = state;
EncodeButton .IsEnabled = state;
RealTimeToggleButton.IsEnabled = state;
MirrorToggleButton .IsEnabled = state;
}

// Real-time Encoding & Mirror Selection Modes

private void RealtimeEventHandler(object sender, RoutedEventArgs e)
Expand All @@ -190,7 +197,7 @@ private void MirrorSelectionToggleButton_Unchecked(object sender, RoutedEventArg

private void InputRichTextBox_OnSelectionChanged(object sender, RoutedEventArgs e)
{
if (!MirrorSelectionToggleButton.IsChecked.Value) return;
if (!MirrorToggleButton.IsChecked.Value) return;

OutputRichTextBox.ClearFormatting();
if (InputRichTextBox.Selection.IsEmpty || OutputRichTextBox.IsEmpty() || _containKeys) return;
Expand Down
4 changes: 2 additions & 2 deletions ScoutsEncoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.3.0.0")]

0 comments on commit a21627f

Please sign in to comment.