Exemplo n.º 1
0
        bool IsValid(EditorPositionState state)
        {
            var textView = documentViewerControl.TextView;

            if (state.CaretAffinity != PositionAffinity.Successor && state.CaretAffinity != PositionAffinity.Predecessor)
            {
                return(false);
            }
            if (state.CaretVirtualSpaces < 0)
            {
                return(false);
            }
            if (state.CaretPosition < 0 || state.CaretPosition > textView.TextSnapshot.Length)
            {
                return(false);
            }
            if (double.IsNaN(state.ViewportLeft) || state.ViewportLeft < 0)
            {
                return(false);
            }
            if (state.TopLinePosition < 0 || state.TopLinePosition > textView.TextSnapshot.Length)
            {
                return(false);
            }
            if (double.IsNaN(state.TopLineVerticalDistance))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 void VisualElement_Loaded(object sender, RoutedEventArgs e)
 {
     documentViewerControl.TextView.VisualElement.Loaded -= VisualElement_Loaded;
     if (cachedEditorPositionState == null)
     {
         return;
     }
     InitializeState(cachedEditorPositionState);
     cachedEditorPositionState = null;
 }
Exemplo n.º 3
0
        void InitializeState(EditorPositionState state)
        {
            var textView = documentViewerControl.TextView;

            if (IsValid(state))
            {
                textView.ViewportLeft = state.ViewportLeft;
                textView.DisplayTextLineContainingBufferPosition(new SnapshotPoint(textView.TextSnapshot, state.TopLinePosition), state.TopLineVerticalDistance, ViewRelativePosition.Top);
                var newPos = new VirtualSnapshotPoint(new SnapshotPoint(textView.TextSnapshot, state.CaretPosition), state.CaretVirtualSpaces);
                textView.Caret.MoveTo(newPos, state.CaretAffinity, true);
            }
            else
            {
                textView.Caret.MoveTo(new VirtualSnapshotPoint(textView.TextSnapshot, 0));
            }
            textView.Selection.Clear();
        }
Exemplo n.º 4
0
        bool IsValid(DecompilerTextView decompilerTextView, EditorPositionState state)
        {
            if (state.VerticalOffset < 0 || state.HorizontalOffset < 0)
                return false;
            if (state.DesiredXPos < 0)
                return false;
            if (state.TextViewPosition.Line < 1 || state.TextViewPosition.Column < 1)
                return false;
            if (state.TextViewPosition.VisualColumn < -1)
                return false;

            if (state.TextViewPosition.Line > decompilerTextView.TextEditor.LineCount)
                return false;

            return true;
        }
Exemplo n.º 5
0
		void TextEditor_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
			textEditorControl.TextEditor.IsVisibleChanged -= TextEditor_IsVisibleChanged;
			if (cachedEditorPositionState == null)
				return;
			InitializeState(cachedEditorPositionState);
			cachedEditorPositionState = null;
		}
Exemplo n.º 6
0
		void InitializeState(EditorPositionState state) {
			textEditorControl.TextEditor.ScrollToVerticalOffset(state.VerticalOffset);
			textEditorControl.TextEditor.ScrollToHorizontalOffset(state.HorizontalOffset);
			textEditorControl.TextEditor.TextArea.Caret.Position = state.TextViewPosition;
			textEditorControl.TextEditor.TextArea.Caret.DesiredXPos = state.DesiredXPos;
		}