private void ExecuteExpressionCommand() { LinxExpression expression; bool editExpression = InLinxExpression(out expression); string expressionText = (editExpression) ? "=" + expression.ExpressionText : string.Empty; IExpression modifiedValue; if (designerContext.EditExpression(expressionText, out modifiedValue)) { string wrappedExpression = string.Empty; if (!modifiedValue.IsEmpty) { wrappedExpression = SqlStringHandler.CreateSqlExpression(modifiedValue.GetExpression()); } if (editExpression) { SegmentedDocument.Replace(expression.StartIndex, expression.EndIndex - expression.StartIndex + 1, wrappedExpression); } else { SegmentedDocument.Replace(CaretIndex, 0, wrappedExpression); } } }
public void DragOver(IDropInfo dropInfo) { dropInfo.Effects = DragDropEffects.None; var draggedModel = dropInfo.Data as TemplateTreeItemViewModel; bool isStringDraggedModel = dropInfo.Data is string; var editor = dropInfo.VisualTarget as TextEditor; if ((draggedModel != null || isStringDraggedModel) && editor != null) { TextViewPosition?position = editor.GetPositionFromPoint(dropInfo.DropPosition); if (position.HasValue) { editor.CaretOffset = editor.Document.GetOffset(position.Value.Line, position.Value.Column); if (isStringDraggedModel) { dropInfo.Effects = dropInfo.AllowedEffects; } } else { editor.CaretOffset = editor.Document.TextLength; } if (isStringDraggedModel || SegmentedDocument.CanInsert(editor.CaretOffset, draggedModel.Template)) { dropInfo.Effects = dropInfo.AllowedEffects; } editor.Focus(); } }
internal virtual void InitialiseDocument(TextDocument textDocument) { SegmentedDocument = new SegmentedDocument(textDocument); SegmentedDocument.Changed += (sender, e) => { OnPropertyChanged("CaretIndex"); OnPropertyChanged("CaretInExpression"); OnPropertyChanged("TemplateAtCaret"); }; }
internal void InsertTemplate(Template template) { if (!CanInsert(template)) { return; } int newCaretIndex = 0; SegmentedDocument.InsertTemplate(caretIndex, template, out newCaretIndex); caretIndex = newCaretIndex; }
internal override void InitialiseDocument(TextDocument textDocument) { base.InitialiseDocument(textDocument); if (String.IsNullOrEmpty(propertyValue)) { SegmentedDocument.Load(serialiser.Deserialise(defaultText)); } else { SegmentedDocument.Load(propertyValue); } }
private void OnClose() { SegmentedDocument.StripEditingSections(); DialogResult = true; }