Example #1
0
        public EditorViewModel(Kernel kernel, IConsole console, IMathInputService service)
        {
            _kernel  = kernel;
            _console = console;
            _service = service;
            _files   = new ObservableCollection <EditorFileViewModel>();
            _files.Add(new EditorFileViewModel(this, kernel));
            _create = new RelayCommand(x =>
            {
                var newfile = new EditorFileViewModel(this, _kernel);
                Files.Add(newfile);
                SelectedFile = newfile;
            });
            _open = new RelayCommand(x =>
            {
                var context = new OpenFileViewModel();
                context.AddFilter(Messages.AllFiles + " (*.*)", "*.*");
                context.AddFilter(Messages.YampScript + " (*.ys)", "*.ys");
                var dialog = new OpenFileWindow
                {
                    DataContext = context,
                    Title       = Messages.OpenFile
                };
                dialog.ShowDialog();

                if (context.Accepted)
                {
                    OpenFile(context.SelectedFile.FullName);
                }
            });
        }
Example #2
0
        /// <summary>
        /// Opens a specific file in the editor.
        /// </summary>
        /// <param name="file">The path to the file to open.</param>
        public void OpenFile(String file)
        {
            if (Files.Count == 1 && Files[0].Text.Equals(String.Empty) && !Files[0].Changed)
            {
                Remove(Files[0]);
            }

            for (var i = 0; i != Files.Count; i++)
            {
                if (Files[i].FilePath != null && Files[i].FilePath.Equals(file, StringComparison.CurrentCultureIgnoreCase))
                {
                    return;
                }
            }

            var tab = new EditorFileViewModel(this, _kernel, file);

            Files.Add(tab);
            SelectedFile = tab;
        }
Example #3
0
 /// <summary>
 /// Removes a certain tab form the editor.
 /// </summary>
 /// <param name="child">The child to remove.</param>
 public void Remove(EditorFileViewModel child)
 {
     Files.Remove(child);
 }