Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- prompt.cs
- TemplateBindingExtensionConverter.cs
- recordstatescratchpad.cs
- UpdatePanelTrigger.cs
- SoapUnknownHeader.cs
- ChtmlCalendarAdapter.cs
- LogReserveAndAppendState.cs
- MouseGestureConverter.cs
- MarkerProperties.cs
- XmlSignificantWhitespace.cs
- GetLedgerEntryForRecipientRequest.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ContentType.cs
- ProviderCollection.cs
- WebServiceClientProxyGenerator.cs
- DataGridViewColumnEventArgs.cs
- TextEmbeddedObject.cs
- PaperSize.cs
- SQLMembershipProvider.cs
- ProfileInfo.cs
- Point4DValueSerializer.cs
- ReflectionPermission.cs
- UnsafePeerToPeerMethods.cs
- SpeechAudioFormatInfo.cs
- EllipseGeometry.cs
- DataGridToolTip.cs
- Suspend.cs
- RtfToXamlReader.cs
- ViewCellRelation.cs
- TraceInternal.cs
- GeometryCombineModeValidation.cs
- ExceptionHandler.cs
- ModelItemDictionary.cs
- PermissionAttributes.cs
- EditorPartDesigner.cs
- Transactions.cs
- ClientOptions.cs
- XmlAnyAttributeAttribute.cs
- IssuanceLicense.cs
- RtType.cs
- HtmlAnchor.cs
- Publisher.cs
- GacUtil.cs
- MultiView.cs
- ItemList.cs
- ChangeProcessor.cs
- RangeExpression.cs
- PropertyInformationCollection.cs
- KeyInterop.cs
- Number.cs
- DisplayMemberTemplateSelector.cs
- PerformanceCounterPermissionEntryCollection.cs
- IndentedTextWriter.cs
- InlineCollection.cs
- UpdatePanelTrigger.cs
- SoapInteropTypes.cs
- ByteStack.cs
- SchemaElementLookUpTable.cs
- DesignerCatalogPartChrome.cs
- ApplicationHost.cs
- WebPartManager.cs
- ErrorHandler.cs
- XmlLangPropertyAttribute.cs
- QueryableFilterUserControl.cs
- GenericUriParser.cs
- OdbcConnection.cs
- SoapObjectReader.cs
- DbProviderConfigurationHandler.cs
- RectIndependentAnimationStorage.cs
- ComponentEditorPage.cs
- XappLauncher.cs
- ApplyHostConfigurationBehavior.cs
- InteropTrackingRecord.cs
- RMPermissions.cs
- UInt16Converter.cs
- DataGridCell.cs
- OutputScopeManager.cs
- PopupRootAutomationPeer.cs
- TextBlock.cs
- CursorConverter.cs
- Filter.cs
- Sql8ExpressionRewriter.cs
- ByeOperationAsyncResult.cs
- Crypto.cs
- HttpHeaderCollection.cs
- XmlSchemaComplexContentRestriction.cs
- AuthenticatedStream.cs
- GridEntryCollection.cs
- HtmlTableRowCollection.cs
- StorageEntityTypeMapping.cs
- ItemsChangedEventArgs.cs
- EntityDataSourceColumn.cs
- ShaperBuffers.cs
- safePerfProviderHandle.cs
- MarkerProperties.cs
- KeyFrames.cs
- DataGridViewColumnStateChangedEventArgs.cs
- Canvas.cs
- QilInvokeLateBound.cs
- ImportContext.cs