Exemple #1
0
        private void OnOpenFile()
        {
            var dlg = new OpenFileDialog();

            dlg.Filter = "Hex files (*.hex) | *.hex";
            if (dlg.ShowDialog().GetValueOrDefault())
            {
                try
                {
                    long size = (settings.MemoryType == MemoryType.FLASH)
                        ? settings.SettingsInfo.Processor.FlashSize
                        : settings.SettingsInfo.Processor.EepromSize;
                    IMemory memory = new Memory(size);
                    hexFileManager.OpenFile(dlg.FileName, memory);
                    var hfvm = new HexFileViewModel(memory, dlg.FileName, this);
                    _files.Add(hfvm);
                    ActiveDocument = hfvm;
                }
                catch (Exception ex)
                {
                    NotificationOpenViewModel vm = new NotificationOpenViewModel(ex.Message);
                    NotificationView          v  = new NotificationView(vm);
                    v.Owner = Application.Current.MainWindow;
                    v.ShowDialog();
                }
                RaiseCanExecuteChanged();
            }
        }
 private void OnOpenFile()
 {
     var dlg = new OpenFileDialog();
     dlg.Filter = "Hex files (*.hex) | *.hex";
     if (dlg.ShowDialog().GetValueOrDefault())
     {
         try
         {
             long size = (settings.MemoryType == MemoryType.FLASH)
                 ? settings.SettingsInfo.Processor.FlashSize
                 : settings.SettingsInfo.Processor.EepromSize;
             IMemory memory = new Memory(size);
             hexFileManager.OpenFile(dlg.FileName, memory);
             var hfvm = new HexFileViewModel(memory, dlg.FileName, this);
             _files.Add(hfvm);
             ActiveDocument = hfvm;
         }
         catch (Exception ex)
         {
             NotificationOpenViewModel vm = new NotificationOpenViewModel(ex.Message);
             NotificationView v = new NotificationView(vm);
             v.Owner = Application.Current.MainWindow;
             v.ShowDialog();
         }
         RaiseCanExecuteChanged();
     }
 }