private void btnImportDecoder_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog dlgOpen = new OpenFileDialog();
     dlgOpen.Filter = LanguageDictionary.Current.Translate<string>("DecoderFilesFilter", "Text", "Decoder files|*.decoder|All files|*.*");
     if (dlgOpen.ShowDialog() == true)
     {
         try
         {
             Decoder d = new Decoder();
             if (d.LoadFromFile(dlgOpen.FileName))
                 Decoder = d;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, App.Name, MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
 private void cbDecoders_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (assignDecoder)
     {
         DecoderReference dref = cbDecoders.SelectedItem as DecoderReference;
         if (dref == null)
             Decoder = null;
         else
         {
             Decoder decoder = new Decoder();
             if (decoder.LoadFromFile(dref.FileName))
                 Decoder = decoder;
         }
     }
 }
Пример #3
0
        private void OpenDecoder_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                Decoder.LoadFromFile((string)e.Parameter);
                fileName = (string)e.Parameter;
                modified = false;
                UpdateTitle();
            }
            else
            {
                if (dlgOpen.ShowDialog() == true)
                {
                    if (modified)
                    {
                        string s = LanguageDictionary.Current.Translate<string>("SaveCurrentDecoder", "Text", "Save current decoder?");
                        MessageBoxResult res = MessageBox.Show(s, App.Name, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                        if (res == MessageBoxResult.Yes)
                            RoutedCommands.SaveDecoder.Execute(null, null);
                        else if (res == MessageBoxResult.Cancel)
                            return;
                    }

                    Decoder = new Decoder();
                    Decoder.LoadFromFile(dlgOpen.FileName);
                    fileName = dlgOpen.FileName;
                    modified = false;
                    UpdateTitle();
                }
            }
        }