Beispiel #1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var saveFileDialog = new SaveFileDialog();

            saveFileDialog.ShowDialog();
            saveFileDialog.InitialDirectory = Utility.getSteamPath();

            //to-do clean that up + move messageboxes to encrypt/decrypt functions -.-
            if (saveFile != null && !saveFile.validChecksum)
            {
                if (MessageBox.Show("The checksum is invalid. Should it be fixed?", "Checksum", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (MessageBox.Show("Encrypt the file?", "Save", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        saveFile.Encrypt();
                    }
                    saveFile.Save(saveFileDialog.FileName, true);
                }
                else
                {
                    if (MessageBox.Show("Encrypt the file?", "Save", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        saveFile.Encrypt();
                    }
                    saveFile.Save(saveFileDialog.FileName, false);
                }
            }
            else if (saveFile != null)
            {
                if (MessageBox.Show("Encrypt the file?", "Save", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    saveFile.Encrypt();
                }
                saveFile.Save(saveFileDialog.FileName, false);
            }
            else
            {
                genericFile.Encrypt();
                genericFile.Save(saveFileDialog.FileName);
            }

            MessageBox.Show("File saved.", "Save", MessageBoxButton.OK);
        }