Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
 internal virtual void InitialiseDocument(TextDocument textDocument)
 {
     SegmentedDocument          = new SegmentedDocument(textDocument);
     SegmentedDocument.Changed += (sender, e) =>
     {
         OnPropertyChanged("CaretIndex");
         OnPropertyChanged("CaretInExpression");
         OnPropertyChanged("TemplateAtCaret");
     };
 }
Пример #4
0
        internal void InsertTemplate(Template template)
        {
            if (!CanInsert(template))
            {
                return;
            }
            int newCaretIndex = 0;

            SegmentedDocument.InsertTemplate(caretIndex, template, out newCaretIndex);
            caretIndex = newCaretIndex;
        }
Пример #5
0
        internal override void InitialiseDocument(TextDocument textDocument)
        {
            base.InitialiseDocument(textDocument);

            if (String.IsNullOrEmpty(propertyValue))
            {
                SegmentedDocument.Load(serialiser.Deserialise(defaultText));
            }
            else
            {
                SegmentedDocument.Load(propertyValue);
            }
        }
Пример #6
0
 private void OnClose()
 {
     SegmentedDocument.StripEditingSections();
     DialogResult = true;
 }