public InputViewModel(IMathInputService service) { _userInput = String.Empty; _message = Messages.InputRequestedLabel; _panel = new MathInputPanelWrapper(Messages.DrawInput); _drawInput = new RelayCommand(_ => _panel.Open()); _cleanup = new RelayCommand(_ => _panel.Close()); _confirm = new RelayCommand(obj => { var window = obj as Window; _okay = true; if (window != null) { window.Close(); } }); if (_panel.IsAvailable) { _panel.OnInsertPressed += (s, e) => UserInput = service.ConvertToYamp(e); DrawInputVisibility = Visibility.Visible; } else { DrawInputVisibility = Visibility.Hidden; } }
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); } }); }