/// <summary> /// Initializes a new instance of the <see cref="TextEditorViewModel" /> class. /// Main TextEdtior Class is passed by reference to this Class /// </summary> /// <param name="title">The title.</param> /// <param name="messageService">The message service.</param> /// <param name="orchestraService">The orchestra service.</param> /// <param name="messageMediator">The message mediator.</param> /// <param name="contextualViewModelManager">The contextual view model manager.</param> /// <param name="textEditorModule">The Main Module Class.</param> /// <param name="processService">The process service.</param> public TextEditorViewModel(string title, TextEditorModule textEditorModule, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager, IProcessService processService) : this(textEditorModule, messageService, orchestraService, messageMediator, contextualViewModelManager, processService) { if (!string.IsNullOrWhiteSpace(title)) { Title = title; } _textEditorModule = textEditorModule; // Set Highlightning to C# this.HighlightDef = HighlightingManager.Instance.GetDefinition("C#"); //this._isDirty = false; this.IsReadOnly = false; this.ShowLineNumbers = true; this.WordWrap = false; }
/// <summary> /// Initializes a new instance of the <see cref="TextEditorViewModel" /> class. /// </summary> /// <param name="messageService">The message service.</param> /// <param name="orchestraService">The orchestra service.</param> /// <param name="messageMediator">The message mediator.</param> /// <param name="contextualViewModelManager">The contextual view model manager.</param> /// <param name="textEditorModule">The Main Module Class.</param> /// <param name="processService">The process service.</param> public TextEditorViewModel(TextEditorModule textEditorModule, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager, IProcessService processService) { Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => messageMediator); Argument.IsNotNull(() => processService); Document = new TextDocument(); _messageService = messageService; _orchestraService = orchestraService; _messageMediator = messageMediator; _contextualViewModelManager = contextualViewModelManager; _textEditorModule = textEditorModule; _processService = processService; #region TextEditor related TextOptions = new TextEditorOptions() { ShowSpaces = true }; // Set Highlightning to C# HighlightDef = HighlightingManager.Instance.GetDefinition("C#"); //SelectedLanguage = "C#"; IsDirtyDoc = false; IsReadOnly = false; ShowLineNumbers = true; WordWrap = false; // Comands ShowLineNumbersCommand = new Command(OnShowLineNumbersCommandExecute); WordWrapCommand = new Command(OnWordWrapCommandExecute); EndLineCommand = new Command(OnEndLineCommandExecute); ShowSpacesCommand = new Command(OnShowSpacesCommandExecute); SaveAsCommand = new Command(OnSaveAsCommandExecute, OnSaveAsCommandCanExecute); SaveCommand = new Command(OnSaveCommandExecute, OnSaveCommandCanExecute); CloseDocument = new Command(OnCloseDocumentExecute); UpdateCommand = new Command(OnUpdateCommandExecute, OnUpdateCommandCanExecute); DocumentMapOpenCommand = new Command(OnDocumentMapOpenExecute); ScriptCSCommand = new Command(OnScriptCSCommandExecute, OnScriptCSCommandCanExecute); #endregion #region Document related Title = FileName; #endregion string directory = Catel.IO.Path.GetApplicationDataDirectory("Orchestra.TextEditor"); // Set the path and Load the default Document Map Settings _path = Path.Combine(directory, "mapsettings.txt"); if (File.Exists(_path)) { _regextPattern = File.ReadAllText(_path); } else { // Set the default value _regextPattern = "^.*\b(private|public|sealed|protected|virtual|internal)\b.*$"; } messageMediator.Register <string>(this, OnDocMapRegexChange); // Invalidate the current viewmodel ViewModelActivated(); }