private void OpenFile_OnClick(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".ady";
            dlg.Filter     = "Audyssey files (*.ady)|*.ady";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                filename            = dlg.FileName;
                currentFile.Content = filename;
                // Load document
                String audysseyFile = File.ReadAllText(filename);
                // Parse JSON data
                parsedAudyssey = JsonConvert.DeserializeObject <Audyssey>(audysseyFile,
                                                                          new JsonSerializerSettings {
                    FloatParseHandling = FloatParseHandling.Decimal
                });
                // Data Binding
                if (parsedAudyssey != null)
                {
                    this.DataContext = parsedAudyssey;
                }
            }
        }
Esempio n. 2
0
        private void ReloadFile_OnClick(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("This will reload the .ady file and discard all changes since last save", "Are you sure?", MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                String audysseyFile = File.ReadAllText(filename);
                parsedAudyssey = JsonConvert.DeserializeObject <Audyssey>(audysseyFile, new JsonSerializerSettings
                {
                    FloatParseHandling = FloatParseHandling.Decimal
                });
                if (parsedAudyssey != null)
                {
                    this.DataContext = parsedAudyssey;
                }
            }
        }