Esempio n. 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();
            }
        }
Esempio n. 2
0
        private void OnAddNewFile(IMemory obj)
        {
            var hfvm = new HexFileViewModel(obj, this);

            _files.Add(hfvm);
            ActiveDocument = hfvm;
            RaiseCanExecuteChanged();
        }
Esempio n. 3
0
        internal void Save(HexFileViewModel fileToSave)
        {
            var dlg = new SaveFileDialog();

            dlg.Filter   = "Hex files (*.hex) | *.hex";
            dlg.FileName = fileToSave.FileName;
            if (dlg.ShowDialog().GetValueOrDefault())
            {
                fileToSave.Path     = dlg.FileName;
                fileToSave.IsDirty  = false;
                fileToSave.FileName = System.IO.Path.GetFileName(dlg.FileName);

                hexFileManager.SaveFile(dlg.FileName, fileToSave.memory);
                RaiseCanExecuteChanged();
            }
        }
Esempio n. 4
0
        internal void Close(HexFileViewModel fileToClose)
        {
            if (fileToClose.IsDirty)
            {
                ConfirmationSaveViewModel vm = new ConfirmationSaveViewModel(fileToClose.FileName);
                ConfirmationView          v  = new ConfirmationView(vm);
                v.Owner = Application.Current.MainWindow;
                if ((bool)v.ShowDialog())
                {
                    Save(fileToClose);
                }
            }

            _files.Remove(fileToClose);
            GC.Collect();
            RaiseCanExecuteChanged();
        }
        internal void Close(HexFileViewModel fileToClose)
        {
            if (fileToClose.IsDirty)
            {
                ConfirmationSaveViewModel vm = new ConfirmationSaveViewModel(fileToClose.FileName);
                ConfirmationView v = new ConfirmationView(vm);
                v.Owner = Application.Current.MainWindow;
                if((bool)v.ShowDialog())
                {
                    Save(fileToClose);
                }
            }

            _files.Remove(fileToClose);
            GC.Collect();
            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();
     }
 }
 private void OnAddNewFile(IMemory obj)
 {
     var hfvm = new HexFileViewModel(obj, this);
     _files.Add(hfvm);
     ActiveDocument = hfvm;
     RaiseCanExecuteChanged();
 }
        internal void Save(HexFileViewModel fileToSave)
        {
            var dlg = new SaveFileDialog();
            dlg.Filter = "Hex files (*.hex) | *.hex";
            dlg.FileName = fileToSave.FileName;
            if (dlg.ShowDialog().GetValueOrDefault())
            {
                fileToSave.Path = dlg.FileName;
                fileToSave.IsDirty = false;
                fileToSave.FileName = System.IO.Path.GetFileName(dlg.FileName);

                hexFileManager.SaveFile(dlg.FileName, fileToSave.memory);
                RaiseCanExecuteChanged();
            }
        }