private void loadWeightsBtn_Click(object sender, RoutedEventArgs e) { if (network == null) { weightsStatus.Content = "Stwórz najpierw sieć"; return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.CurrentDirectory; openFileDialog.Filter = "txt files (*.txt)|*.txt"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != true) { weightsStatus.Content = "Wystąpił problem z wybranym plikiem"; return; } string path = openFileDialog.FileName; string[] weightsString = File.ReadAllLines(path); if (!FormValidation.areWeightsValid(configuration.networkStructure, weightsString, out string message)) { weightsStatus.Content = message; return; } weights = WeightsHandler.loadWeights(path); network.setWeights(weights); weightsStatus.Content = "Załadowano wagi"; weightsLoaded = true; }
private void saveWeightsBtn_Click(object sender, RoutedEventArgs e) { if (!weightsLoaded) { savingStatus.Content = "Brak wag do zapisania"; return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.CurrentDirectory; saveFileDialog.Filter = "txt files (*.txt)|*.txt"; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() != true) { return; } if (saveFileDialog.FileName == "") { savingStatus.Content = "Wagi nie zapisane, plik musi mieć nazwę"; return; } var path = saveFileDialog.FileName; WeightsHandler.saveWeights(weights, path); savingStatus.Content = "Wagi zapisane"; }