Esempio n. 1
0
 internal void NotifyCloseFile(FileAccessor file)
 {
     lock (_locker)
     {
         OpenFiles.Remove(file);
     }
 }
Esempio n. 2
0
        private void OpenFileInternal(string filename)
        {
            var exitingFile = _openFiles.FirstOrDefault(openfile => openfile.FileName == filename);

            if (exitingFile != null)
            {
                SelectedFile = exitingFile;
                return;
            }

            var file = new OpenFileViewModel(this);

            file.Ready += delegate {
                Dispatcher.CurrentDispatcher.InvokeAsync(() => {
                    try {
                        file.OpenFile(filename);
                    }
                    catch (Exception ex) {
                        OpenFiles.Remove(file);
                        MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppTitle);
                    }
                });
            };
            OpenFiles.Add(file);
            _recentFiles.Remove(filename);
            _recentFiles.Insert(0, filename);
            if (_recentFiles.Count > 10)
            {
                _recentFiles.RemoveAt(9);
            }
            SelectedFile = file;
        }
        public void CloseFile(EdataFileViewModel vm)
        {
            if (!OpenFiles.Contains(vm))
            {
                return;
            }

            OpenFiles.Remove(vm);
        }
 private async void Close_impl(TextEditorViewModel toClose)
 {
     if (!toClose.IsSaved)
     {
         Window target = Avalonia.Application.Current.Windows.Where(w => ReferenceEquals(w.DataContext, this)).Single();
         if (toClose.File is null)
         {
         }
     }
     OpenFiles.Remove(toClose);
 }