本文整理汇总了C#中TextRange类的典型用法代码示例。如果您正苦于以下问题:C# TextRange类的具体用法?C# TextRange怎么用?C# TextRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextRange类属于命名空间,在下文中一共展示了TextRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AcceptExpression
protected override void AcceptExpression(
ITextControl textControl, ISolution solution, TextRange resultRange, ICSharpExpression expression)
{
// set selection for introduce field
textControl.Selection.SetRanges(new[] {TextControlPosRange.FromDocRange(textControl, resultRange)});
const string name = "IntroFieldAction";
var rules = DataRules
.AddRule(name, ProjectModel.DataContext.DataConstants.SOLUTION, solution)
.AddRule(name, DataConstants.DOCUMENT, textControl.Document)
.AddRule(name, TextControl.DataContext.DataConstants.TEXT_CONTROL, textControl)
.AddRule(name, Psi.Services.DataConstants.SELECTED_EXPRESSION, expression);
Lifetimes.Using(lifetime =>
WorkflowExecuter.ExecuteBatch(
Shell.Instance.GetComponent<DataContexts>().CreateWithDataRules(lifetime, rules),
new IntroFieldWorkflow(solution, null)));
// todo: rename hotspots
var ranges = textControl.Selection.Ranges.Value;
if (ranges.Count == 1) // reset selection
{
var endPos = ranges[0].End;
textControl.Selection.SetRanges(new[] {new TextControlPosRange(endPos, endPos)});
}
}
开发者ID:Restuta,项目名称:PostfixCompletion,代码行数:27,代码来源:IntroduceFieldTemplateProvider.cs
示例2: PostfixTemplateAcceptanceContext
public PostfixTemplateAcceptanceContext(
[NotNull] IReferenceExpression referenceExpression,
[NotNull] ICSharpExpression expression,
TextRange replaceRange, TextRange expressionRange,
bool canBeStatement, bool looseChecks)
{
ReferenceExpression = referenceExpression;
Expression = expression;
ExpressionType = expression.Type();
ReplaceRange = replaceRange;
ExpressionRange = expressionRange;
CanBeStatement = canBeStatement;
LooseChecks = looseChecks;
ContainingFunction = Expression.GetContainingNode<ICSharpFunctionDeclaration>();
var expressionReference = expression as IReferenceExpression;
if (expressionReference != null)
{
ExpressionReferencedElement = expressionReference.Reference.Resolve().DeclaredElement;
}
else
{
var typeExpression = expression as IPredefinedTypeExpression;
if (typeExpression != null)
{
var typeName = typeExpression.PredefinedTypeName;
if (typeName != null)
ExpressionReferencedElement = typeName.Reference.Resolve().DeclaredElement;
}
}
}
开发者ID:Restuta,项目名称:PostfixCompletion,代码行数:32,代码来源:PostfixTemplateAcceptanceContext.cs
示例3: GetTagAttributeValuePos
/// <summary>
/// Locate value of attribute position for specified html tag
/// </summary>
public static TextRange GetTagAttributeValuePos(ref string pageHtml, string tagName, string attributeName, int start)
{
int tagStart, tagEnd;
int attrStart;
int valueStart;
// Allocate result with default values
TextRange result = new TextRange(-1, -1);
// Incorrect input
if (start >= pageHtml.Length)
return result;
// Correct tag name
if (tagName[0] != '<')
tagName = '<' + tagName;
//=============================================================//
// Find tag first position
tagStart = StringCompare.IndexOfIgnoreCase(ref pageHtml, tagName, start);
if (tagStart == -1)
return result;
// Locate end of tag
tagEnd = StringCompare.IndexOfMatchCase(ref pageHtml, ">", tagStart);
// Wrong html code
if (tagEnd == -1)
return result;
// Find the Attribute position
attrStart = StringCompare.IndexOfIgnoreCase(ref pageHtml, attributeName, tagStart);
// There is no attribute, so go away!
if (attrStart == -1 || attrStart >= tagEnd)
{
// Set found start position to result
result.Start = tagStart;
result.End = -1;
return result;
}
// Find value start position
valueStart = StringCompare.IndexOfMatchCase(ref pageHtml, '=', attrStart);
// There is no value, so go away!
if (valueStart == -1 || valueStart >= tagEnd)
{
// Set found start position to result
result.Start = attrStart;
result.End = -1;
return result;
}
// Locate value of attribute position
result = FindAttributeValuePosition(ref pageHtml, tagEnd, valueStart);
return result;
}
开发者ID:wangscript,项目名称:tcgcms,代码行数:63,代码来源:HtmlParser.cs
示例4: divideToLines
public static void divideToLines(Slides slides, Slide slide, TextRange textRange)
{
var slideNumber = slide.SlideIndex;
float slideDuration = slide.SlideShowTransition.AdvanceTime;
int divisionNumber = textRange.Lines().Count;
float duration = durationAfterDivisions(slideDuration, divisionNumber / 2);
string textFrmLines = "";
foreach (TextRange line in textRange.Lines())
{
if (textFrmLines.Length > 0)
{
textFrmLines += line.Text;
SlidesManipulation.createNewSlide(slides, ++slideNumber, textFrmLines.Trim(), duration);
SlidesManipulation.createNewSlide(slides, ++slideNumber, "", 0.01F);
textFrmLines = "";
}
else
{
textFrmLines += line.Text;
}
}
//add the rest of textFrmLines
if (textFrmLines.Length > 0)
{
SlidesManipulation.createNewSlide(slides, ++slideNumber, textFrmLines, duration);
SlidesManipulation.createNewSlide(slides, ++slideNumber, "", 0.1F);
}
//delete slides
slide.Delete();
slides[slideNumber].Delete();
}
开发者ID:dariukas,项目名称:Scanorama,代码行数:31,代码来源:TwoLines.cs
示例5: TypefaceListItem
public TypefaceListItem(Typeface typeface)
{
_displayName = GetDisplayName(typeface);
_simulated = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;
this.FontFamily = typeface.FontFamily;
this.FontWeight = typeface.Weight;
this.FontStyle = typeface.Style;
this.FontStretch = typeface.Stretch;
string itemLabel = _displayName;
if (_simulated)
{
string formatString = Properties.FontDialogResources.ResourceManager.GetString(
"simulated",
CultureInfo.CurrentUICulture
);
itemLabel = string.Format(formatString, itemLabel);
}
Text = itemLabel;
ToolTip = itemLabel;
// In the case of symbol font, apply the default message font to the text so it can be read.
if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
{
var range = new TextRange(ContentStart, ContentEnd);
range.ApplyPropertyValue(TextBlock.FontFamilyProperty, SystemFonts.MessageFontFamily);
}
}
开发者ID:mhusen,项目名称:Eto,代码行数:31,代码来源:typefacelistitem.cs
示例6: Assign
public Assign(string name, Element value, bool isMaybe, TextRange range)
: base(isMaybe, range)
{
Contract.Requires<ArgumentNullException>(name != null);
this.Name = name;
this.Value = value;
}
开发者ID:irxground,项目名称:kurogane,代码行数:7,代码来源:Ast.cs
示例7: JasmineElement
protected JasmineElement(KarmaServiceProvider provider, string name,
ProjectModelElementEnvoy projectFileEnvoy,
TextRange textRange, IList<string> referencedFiles)
: base(provider, name, projectFileEnvoy, textRange)
{
_referencedFiles = referencedFiles ?? new List<string>().AsReadOnly();
}
开发者ID:sergeyt,项目名称:karma-resharper,代码行数:7,代码来源:JasmineElement.cs
示例8: BuildDisposition
public static UnitTestElementDisposition BuildDisposition(UnitTestElement element, ScenarioLocation location, IProjectFile projectFile)
{
var contents = File.ReadAllText(location.Path);
var range = new TextRange(LineToOffset(contents, location.FromLine), LineToOffset(contents, location.ToLine));
return new UnitTestElementDisposition(element, projectFile, range, new TextRange(0));
}
开发者ID:paulbatum,项目名称:storevil,代码行数:7,代码来源:DispositionBuilder.cs
示例9: SelectElement
/// <summary>
/// Selects the element.
/// </summary>
public override IEnumerable<TextRange> SelectElement(TextRange textRange)
{
return base.SelectElement(textRange).Where(line => {
var text = TextRangeExtensions.GetText(line);
return IsEmptyLineIncluded || !String.IsNullOrWhiteSpace(text);
});
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:10,代码来源:LineSelector.cs
示例10: CompilationUnit
public CsvCompilationUnit CompilationUnit(TextRange textRange, IEnumerable<RowDeclarationSyntax> rows)
{
Assume.NotNull(textRange, nameof(textRange));
Assume.NotNull(rows, nameof(rows));
return new CsvCompilationUnit(textRange, rows);
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:7,代码来源:CsvSyntaxTreeFactory.cs
示例11: FindImportRuleUrlPosition
/// <summary>
/// Locates @import rule value
/// </summary>
/// <param name="cssCodes"></param>
/// <param name="startindex"></param>
/// <param name="onlyWithoutUrlOption">Specifies that operator should not catch rule with URL attribute.</param>
/// <param name="captureExactInUrl">Specifies that operator should strip the URL attribute if there is any</param>
/// <returns></returns>
public static TextRange FindImportRuleUrlPosition(ref string cssCodes, int startindex, bool onlyWithoutUrlOption, bool captureExactlyInUrl)
{
int valueStart, valueEnd;
TextRange result = new TextRange(-1, -1);
const string strCSSImportRule = "@import";
const string strCSSUrlValue = "url(";
//==============================
if (startindex >= cssCodes.Length)
return result;
// Find first position
valueStart = StringCompare.IndexOfIgnoreCase(ref cssCodes, strCSSImportRule, startindex);
if (valueStart == -1)
return result;
valueStart += strCSSImportRule.Length;
//
if (cssCodes.Substring(valueStart, 1).Trim().Length > 0)
return result;
else
valueStart++;
valueEnd = StringCompare.IndexOfMatchCase(ref cssCodes, ";", valueStart);
if (valueEnd == -1)
return result;
else
{
int urlPos = StringCompare.IndexOfIgnoreCase(ref cssCodes, strCSSUrlValue, valueStart);
if (urlPos != -1 && urlPos < valueEnd)
{
if (onlyWithoutUrlOption)
{
result.Start = valueEnd;
result.End = -1;
return result;
}
if (captureExactlyInUrl)
{
valueStart = urlPos + strCSSUrlValue.Length;
urlPos = StringCompare.IndexOfMatchCase(ref cssCodes, ")", valueStart);
if (urlPos != -1 && urlPos < valueEnd)
{
valueEnd = urlPos;
}
}
}
}
result.Start = valueStart;
result.End = valueEnd;
return result;
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:67,代码来源:CSSParser.cs
示例12: GetDisposition
public override UnitTestElementDisposition GetDisposition()
{
var projectFile = GetProjectFile(Scenario.Location.Path);
var contents = File.ReadAllText(Scenario.Location.Path);
var range = new TextRange(LineToOffset(contents, Scenario.Location.FromLine), LineToOffset(contents, Scenario.Location.ToLine));
return new UnitTestElementDisposition(this, projectFile, range, new TextRange(0));
}
开发者ID:pawelpabich,项目名称:storevil,代码行数:8,代码来源:StorEvilScenarioElement.cs
示例13: CreateRow
/// <summary>
/// Creates row node and appends it to actual document node
/// </summary>
public ICsvTreeFactory CreateRow(TextRange textRange)
{
Assume.NotNull(textRange, nameof(textRange));
checkIsDocumentDefined();
_actualRowDeclaration = new RowDeclarationSyntax(textRange);
_csvCompilationUnits.Peek().AppendChild(_actualRowDeclaration);
return this;
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:11,代码来源:CsvStandardTreeFactory.cs
示例14: Element
protected Element(KarmaServiceProvider serviceProvider, string name, ProjectModelElementEnvoy projectFileEnvoy, TextRange textRange)
{
ServiceProvider = serviceProvider;
ShortName = name;
ProjectFileEnvoy = projectFileEnvoy;
TextRange = textRange;
State = UnitTestElementState.Valid;
}
开发者ID:sergeyt,项目名称:karma-resharper,代码行数:8,代码来源:Element.cs
示例15: CsvCompilationUnit
/// <summary>
/// Initializes a new instance of the <see cref="CsvCompilationUnit"/> class.
/// </summary>
public CsvCompilationUnit(TextRange textRange, IEnumerable<RowDeclarationSyntax> rows)
: base(textRange)
{
Assume.NotNull(rows, nameof(rows));
Rows = rows;
this.AttachChildren(rows);
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:11,代码来源:CsvCompilationUnit.cs
示例16: TextDocument
/// <summary>
/// Initializes a new instance of the <see cref="TextDocument"/> class.
/// </summary>
public TextDocument(String text)
{
Assume.NotNull("text", text);
Text = text;
TextRange = CreateOrGetTextRange(0, text.Length);
_root = TextRange;
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:11,代码来源:TextDocument-old.cs
示例17: DeclaredElementInfo
public DeclaredElementInfo([NotNull] IDeclaredElement declaredElement, [NotNull] ISubstitution substitution, [NotNull] IFile file,
TextRange sourceRange, [CanBeNull] IReference reference) {
DeclaredElement = declaredElement;
Substitution = substitution;
File = file;
SourceRange = sourceRange;
Reference = reference;
}
开发者ID:ShaunTGO,项目名称:ReSharper.EnhancedTooltip,代码行数:8,代码来源:IdentifierTooltipContentProvider.cs
示例18: RemoveText
/// <summary>
/// Removes the text.
/// </summary>
/// <param name="textRange">The text range.</param>
/// <returns></returns>
public TextDocument RemoveText(TextRange textRange)
{
Assume.NotNull(textRange, "textRange");
ChangeText(textRange, String.Empty);
removeTextRange(textRange);
return this;
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:14,代码来源:TextDocument-old.cs
示例19: CreateDocument
/// <summary>
/// Creates the document node
/// </summary>
public ICsvTreeFactory CreateDocument(TextRange textRange)
{
Assume.NotNull(textRange, nameof(textRange));
var csvCompilationUnit = new CsvCompilationUnit(textRange);
_csvCompilationUnits.Push(csvCompilationUnit);
return this;
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:12,代码来源:CsvStandardTreeFactory.cs
示例20: Row
public RowDeclarationSyntax Row(TextRange textRange, IEnumerable<CommaToken> commas, IEnumerable<FieldDeclarationSyntax> fields)
{
Assume.NotNull(commas, nameof(commas));
Assume.NotNull(fields, nameof(fields));
return new RowDeclarationSyntax(textRange) {
Commas = commas,
Fields = fields
};
}
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:10,代码来源:CsvSyntaxTreeFactory.cs
注:本文中的TextRange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论