Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / FixedSOMLineRanges.cs / 1 / 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
- InputLanguageProfileNotifySink.cs
- DeferredReference.cs
- Rethrow.cs
- OleDbPropertySetGuid.cs
- DbConnectionHelper.cs
- XmlResolver.cs
- _LocalDataStore.cs
- SqlTriggerAttribute.cs
- Update.cs
- Border.cs
- GeneralTransformCollection.cs
- WebPartConnectionsCancelEventArgs.cs
- CapacityStreamGeometryContext.cs
- XmlToDatasetMap.cs
- ClassicBorderDecorator.cs
- EncodingNLS.cs
- SecurityElement.cs
- ObjectConverter.cs
- FunctionImportMapping.cs
- SqlInternalConnectionTds.cs
- BuildManagerHost.cs
- DetailsViewPagerRow.cs
- SqlConnectionHelper.cs
- Scripts.cs
- Number.cs
- ReflectionServiceProvider.cs
- TransactionOptions.cs
- MessageProperties.cs
- FreeFormDragDropManager.cs
- SafeViewOfFileHandle.cs
- Properties.cs
- Vector3DValueSerializer.cs
- TextServicesCompartmentEventSink.cs
- TextTreeDeleteContentUndoUnit.cs
- PtsHost.cs
- SingleAnimationBase.cs
- ExpandedWrapper.cs
- InteropAutomationProvider.cs
- Single.cs
- ObjectSet.cs
- AlgoModule.cs
- InstancePersistence.cs
- streamingZipPartStream.cs
- MaskedTextProvider.cs
- Vector.cs
- ScrollEvent.cs
- Point.cs
- PeerCollaborationPermission.cs
- InvalidFilterCriteriaException.cs
- WebZone.cs
- WebPartMovingEventArgs.cs
- PointCollection.cs
- DateTimeUtil.cs
- Storyboard.cs
- MessageQueuePermissionEntryCollection.cs
- Html32TextWriter.cs
- StandardBindingImporter.cs
- Utility.cs
- ObsoleteAttribute.cs
- ReadOnlyObservableCollection.cs
- wgx_commands.cs
- TransformPattern.cs
- WorkflowViewStateService.cs
- ElementProxy.cs
- UserControlBuildProvider.cs
- ClientSettingsSection.cs
- BeginStoryboard.cs
- DodSequenceMerge.cs
- PointAnimation.cs
- objectresult_tresulttype.cs
- VisualTreeHelper.cs
- UInt64Converter.cs
- DynamicValidator.cs
- PropertyValueChangedEvent.cs
- EdmError.cs
- _FtpDataStream.cs
- SignatureToken.cs
- CustomSignedXml.cs
- WinEventTracker.cs
- PathSegment.cs
- XmlSignificantWhitespace.cs
- WebPartZoneAutoFormat.cs
- ComponentChangingEvent.cs
- ElapsedEventArgs.cs
- SqlConnectionPoolGroupProviderInfo.cs
- LocalBuilder.cs
- FontWeight.cs
- DialogWindow.cs
- Types.cs
- embossbitmapeffect.cs
- TreeNodeBinding.cs
- GeneralTransform.cs
- BinHexDecoder.cs
- CharacterMetricsDictionary.cs
- StopStoryboard.cs
- ProbeMatchesApril2005.cs
- FeedUtils.cs
- Soap.cs
- NetSectionGroup.cs
- MetadataItem_Static.cs