public TextEditorViewModel(TextFileModel textFile) { _Initialize(textFile); }
private void _Initialize(TextFileModel textFile) { Name = textFile.FileInfo.FullName; _Text = textFile.Text; SaveAsCommand = new Command(arg => { if (arg as object[] == null) SaveAs(this.Name); else { string name = ""; foreach (var parts in arg as object[]) name += parts.ToString(); SaveAs(name); } }); FindTextCommand = new Command(arg => { string searchingText = (arg as object[])[0].ToString(); bool ignoreCase = (bool)(arg as object[])[1]; SelectionStart = FindNext(searchingText, ignoreCase); if (SelectionStart != -1) SelectionLength = (arg as object[])[0].ToString().Length; }); ChangeCaseCommand = new Command(arg => { if (arg.ToString().ToLower() == "down") ChangeCase(SelectionStart, SelectionLength, StringCase.Lower); if (arg.ToString().ToLower() == "up") ChangeCase(SelectionStart, SelectionLength, StringCase.Upper); }); ChangeCaseCommand.CanExecuteDelegate = arg => SelectionLength != 0; var htmlFile = textFile as HtmlFileModel; if (htmlFile != null) IsHtml = true; DisplayHtlFilesCommand = new Command(arg => { if (System.Convert.ToBoolean(arg)) FindHtmlFiles(); }); DisplayHtlFilesCommand.CanExecuteDelegate = arg => IsHtml; }