当前位置: 首页>>代码示例>>C#>>正文


C# VirtualSnapshotPoint.GetLineAndColumn方法代码示例

本文整理汇总了C#中VirtualSnapshotPoint.GetLineAndColumn方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualSnapshotPoint.GetLineAndColumn方法的具体用法?C# VirtualSnapshotPoint.GetLineAndColumn怎么用?C# VirtualSnapshotPoint.GetLineAndColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VirtualSnapshotPoint的用法示例。


在下文中一共展示了VirtualSnapshotPoint.GetLineAndColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReduceBoxSelectionToEditableBox

            private bool ReduceBoxSelectionToEditableBox(ref VirtualSnapshotPoint selectionTop, ref VirtualSnapshotPoint selectionBottom, bool isDelete)
            {
                int selectionTopColumn, selectionBottomColumn;
                ITextSnapshotLine selectionTopLine, selectionBottomLine;
                selectionTop.GetLineAndColumn(out selectionTopLine, out selectionTopColumn);
                selectionBottom.GetLineAndColumn(out selectionBottomLine, out selectionBottomColumn);

                int selectionLeftColumn, selectionRightColumn;
                bool horizontallyReversed = selectionTopColumn > selectionBottomColumn;

                if (horizontallyReversed)
                {
                    // bottom-left <-> top-right 
                    selectionLeftColumn = selectionBottomColumn;
                    selectionRightColumn = selectionTopColumn;
                }
                else
                {
                    // top-left <-> bottom-right
                    selectionLeftColumn = selectionTopColumn;
                    selectionRightColumn = selectionBottomColumn;
                }

                var selectionTopLeft = new VirtualSnapshotPoint(selectionTopLine, selectionLeftColumn);
                var selectionBottomRight = new VirtualSnapshotPoint(selectionBottomLine, selectionRightColumn);

                SnapshotPoint editable = GetClosestEditablePoint(selectionTopLeft.Position);
                int editableColumn;
                ITextSnapshotLine editableLine;
                editable.GetLineAndColumn(out editableLine, out editableColumn);

                Debug.Assert(selectionLeftColumn <= selectionRightColumn);
                Debug.Assert(selectionTopLine.LineNumber <= selectionBottomLine.LineNumber);

                if (editable > selectionBottomRight.Position)
                {
                    // entirely within readonly output region:
                    return false;
                }

                int minPromptLength, maxPromptLength;
                MeasurePrompts(editableLine.LineNumber, selectionBottomLine.LineNumber + 1, out minPromptLength, out maxPromptLength);

                bool result = true;
                if (isDelete)
                {
                    if (selectionLeftColumn > maxPromptLength || maxPromptLength == minPromptLength)
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = Math.Max(selectionLeftColumn, maxPromptLength); 
                    }
                }
                else
                {
                    if (selectionRightColumn < minPromptLength)
                    {
                        // entirely within readonly prompt region:
                        result = false;
                    }
                    else if (maxPromptLength > selectionRightColumn)
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = maxPromptLength;
                        selectionRightColumn = maxPromptLength;
                    }
                    else
                    {
                        selectionTopLine = editableLine;
                        selectionLeftColumn = Math.Max(maxPromptLength, selectionLeftColumn);
                    }
                }

                if (horizontallyReversed)
                {
                    // bottom-left <-> top-right 
                    selectionTop = new VirtualSnapshotPoint(selectionTopLine, selectionRightColumn);
                    selectionBottom = new VirtualSnapshotPoint(selectionBottomLine, selectionLeftColumn);
                }
                else
                {
                    // top-left <-> bottom-right
                    selectionTop = new VirtualSnapshotPoint(selectionTopLine, selectionLeftColumn);
                    selectionBottom = new VirtualSnapshotPoint(selectionBottomLine, selectionRightColumn);
                }

                return result;
            }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:87,代码来源:InteractiveWindow.UIThreadOnly.cs


注:本文中的VirtualSnapshotPoint.GetLineAndColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。