Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / FixedSOMLineRanges.cs / 1305600 / FixedSOMLineRanges.cs
/*++ File: FixedSOMLineRanges.cs Copyright (C) 2005 Microsoft Corporation. All rights reserved. Description: Internal helper class that can store a set of sorted lines by their start and end indices History: 05/17/2005: eleese - Created --*/ namespace System.Windows.Documents { using System.Collections; using System.Collections.Generic; using System.Windows.Shapes; using System.Windows.Controls; using System.Diagnostics; using System.Windows.Media; internal class FixedSOMLineRanges { public void AddRange(double start, double end) { for (int i = 0; i < Start.Count; ) { if (start > End[i] + _minLineSeparation) { i++; } else if (end + _minLineSeparation < Start[i]) { Start.Insert(i, start); End.Insert(i, end); return; } else { // overlap !! if (Start[i] < start) { start = Start[i]; } if (End[i] > end) { end = End[i]; } Start.RemoveAt(i); End.RemoveAt(i); } } Start.Add(start); End.Add(end); } public int GetLineAt(double line) { //use binary search int startIndex = 0; int endIndex = Start.Count - 1; while (endIndex > startIndex) { int i = (startIndex + endIndex) >> 1; // Invariant: i < endIndex if (line > End[i]) { startIndex = i + 1; } else { endIndex = i; } } if (startIndex == endIndex && line <= End[startIndex] && line >= Start[startIndex]) { return startIndex; } else { return -1; } } public double Line { set { _line = value; } get { return _line; } } public ListStart { get { if (_start == null) { _start = new List (); } return _start; } } public List End { get { if (_end == null) { _end = new List (); } return _end; } } public int Count { get { return Start.Count; } } static public double MinLineSeparation { get { return _minLineSeparation; } } private double _line; // X or Y value for set of lines private List _start; // where lines start. Invariant: _start[i] < _end[i] private List _end; // where lines end. Invariant: _end[i] < _start[i+1] private const double _minLineSeparation = 3; // lines closer than this are considered one line } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /*++ File: FixedSOMLineRanges.cs Copyright (C) 2005 Microsoft Corporation. All rights reserved. Description: Internal helper class that can store a set of sorted lines by their start and end indices History: 05/17/2005: eleese - Created --*/ namespace System.Windows.Documents { using System.Collections; using System.Collections.Generic; using System.Windows.Shapes; using System.Windows.Controls; using System.Diagnostics; using System.Windows.Media; internal class FixedSOMLineRanges { public void AddRange(double start, double end) { for (int i = 0; i < Start.Count; ) { if (start > End[i] + _minLineSeparation) { i++; } else if (end + _minLineSeparation < Start[i]) { Start.Insert(i, start); End.Insert(i, end); return; } else { // overlap !! if (Start[i] < start) { start = Start[i]; } if (End[i] > end) { end = End[i]; } Start.RemoveAt(i); End.RemoveAt(i); } } Start.Add(start); End.Add(end); } public int GetLineAt(double line) { //use binary search int startIndex = 0; int endIndex = Start.Count - 1; while (endIndex > startIndex) { int i = (startIndex + endIndex) >> 1; // Invariant: i < endIndex if (line > End[i]) { startIndex = i + 1; } else { endIndex = i; } } if (startIndex == endIndex && line <= End[startIndex] && line >= Start[startIndex]) { return startIndex; } else { return -1; } } public double Line { set { _line = value; } get { return _line; } } public List Start { get { if (_start == null) { _start = new List (); } return _start; } } public List End { get { if (_end == null) { _end = new List (); } return _end; } } public int Count { get { return Start.Count; } } static public double MinLineSeparation { get { return _minLineSeparation; } } private double _line; // X or Y value for set of lines private List _start; // where lines start. Invariant: _start[i] < _end[i] private List _end; // where lines end. Invariant: _end[i] < _start[i+1] private const double _minLineSeparation = 3; // lines closer than this are considered one line } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlWebEventProvider.cs
- CharUnicodeInfo.cs
- TypeValidationEventArgs.cs
- TreeNode.cs
- DocumentsTrace.cs
- MemberAssignment.cs
- ClaimSet.cs
- XmlSubtreeReader.cs
- TypeNameConverter.cs
- UrlPath.cs
- SqlDataSourceCommandEventArgs.cs
- FSWPathEditor.cs
- XPathScanner.cs
- SqlRewriteScalarSubqueries.cs
- glyphs.cs
- ObjectViewQueryResultData.cs
- Vector.cs
- HttpCapabilitiesEvaluator.cs
- StringStorage.cs
- DbExpressionVisitor_TResultType.cs
- SelectionItemPattern.cs
- DispatchChannelSink.cs
- TrackBar.cs
- DataGridViewDesigner.cs
- ThaiBuddhistCalendar.cs
- EmissiveMaterial.cs
- XmlCDATASection.cs
- HierarchicalDataSourceConverter.cs
- ToolStripScrollButton.cs
- RemotingSurrogateSelector.cs
- FacetDescriptionElement.cs
- NativeMethods.cs
- ScrollChangedEventArgs.cs
- DbDeleteCommandTree.cs
- BookmarkEventArgs.cs
- MessageQueueTransaction.cs
- BooleanConverter.cs
- SelectedCellsCollection.cs
- CorePropertiesFilter.cs
- RuleSettingsCollection.cs
- BinHexEncoding.cs
- ProtocolsConfiguration.cs
- PresentationTraceSources.cs
- TableItemPatternIdentifiers.cs
- ScrollChrome.cs
- DescendantQuery.cs
- ContextBase.cs
- XmlKeywords.cs
- WpfWebRequestHelper.cs
- DurationConverter.cs
- GridLengthConverter.cs
- WebRequestModulesSection.cs
- SynchronizingStream.cs
- WebPartCatalogAddVerb.cs
- BitVector32.cs
- NetworkInformationPermission.cs
- HtmlShimManager.cs
- DataGridBoundColumn.cs
- HijriCalendar.cs
- DataServiceHost.cs
- CodeAttributeArgumentCollection.cs
- InstanceLockQueryResult.cs
- StartUpEventArgs.cs
- WebPartDescriptionCollection.cs
- AdobeCFFWrapper.cs
- CommandHelpers.cs
- ServicePointManager.cs
- MetadataCache.cs
- ClientFormsAuthenticationMembershipProvider.cs
- PropertiesTab.cs
- SmtpCommands.cs
- PropertyGridCommands.cs
- TypeSystem.cs
- CodeExpressionCollection.cs
- ServiceMemoryGates.cs
- Authorization.cs
- Span.cs
- X509Utils.cs
- DesignerWidgets.cs
- HttpProfileBase.cs
- FrameworkTextComposition.cs
- ExtensionDataObject.cs
- SoapSchemaExporter.cs
- ImageUrlEditor.cs
- DataColumnMapping.cs
- BamlResourceContent.cs
- FileSystemWatcher.cs
- QilFactory.cs
- DataGridViewRowEventArgs.cs
- Light.cs
- TogglePattern.cs
- SqlXmlStorage.cs
- HttpCachePolicy.cs
- Vector3DAnimationUsingKeyFrames.cs
- PartialCachingAttribute.cs
- GetFileNameResult.cs
- DiscoveryDocumentSerializer.cs
- InheritanceRules.cs
- MemberDomainMap.cs
- Trace.cs