Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- CachedBitmap.cs
- RegexCode.cs
- ISFTagAndGuidCache.cs
- NativeBuffer.cs
- StrokeCollectionConverter.cs
- XDRSchema.cs
- ResourceReferenceExpression.cs
- XmlCodeExporter.cs
- SqlNamer.cs
- DBSchemaRow.cs
- _AutoWebProxyScriptHelper.cs
- TextChangedEventArgs.cs
- BindingValueChangedEventArgs.cs
- CompiledXpathExpr.cs
- IFlowDocumentViewer.cs
- ToggleButtonAutomationPeer.cs
- DbSetClause.cs
- SqlCacheDependencyDatabaseCollection.cs
- StorageEntitySetMapping.cs
- NetworkAddressChange.cs
- ToolStripGripRenderEventArgs.cs
- EmptyWorkItem.cs
- CodeArrayIndexerExpression.cs
- MissingMethodException.cs
- EventLogPermissionEntry.cs
- DataGridCellsPanel.cs
- SchemaNamespaceManager.cs
- TextCollapsingProperties.cs
- HyperLinkField.cs
- MessageBox.cs
- TransformGroup.cs
- NCryptNative.cs
- FreezableCollection.cs
- input.cs
- FontUnitConverter.cs
- ValueTypeFixupInfo.cs
- Transform3D.cs
- WindowsTokenRoleProvider.cs
- formatter.cs
- WebPartRestoreVerb.cs
- UInt16Storage.cs
- AlphaSortedEnumConverter.cs
- BoundField.cs
- InternalsVisibleToAttribute.cs
- ValueHandle.cs
- ButtonBase.cs
- ChtmlCommandAdapter.cs
- Figure.cs
- Point3D.cs
- ApplicationSecurityInfo.cs
- ReadOnlyTernaryTree.cs
- GridViewCommandEventArgs.cs
- NameValueFileSectionHandler.cs
- HotSpot.cs
- SafeCertificateStore.cs
- HttpModuleActionCollection.cs
- SmtpNetworkElement.cs
- IntegerValidatorAttribute.cs
- Funcletizer.cs
- MatrixAnimationUsingKeyFrames.cs
- LabelEditEvent.cs
- SiteMapDataSourceView.cs
- TextRunProperties.cs
- CharacterString.cs
- LinkLabelLinkClickedEvent.cs
- CustomErrorCollection.cs
- AsyncMethodInvoker.cs
- ImageListUtils.cs
- UpdateTracker.cs
- ControlCachePolicy.cs
- StringHelper.cs
- SafeHandles.cs
- RegisteredHiddenField.cs
- SkinBuilder.cs
- FileVersion.cs
- XmlSerializationWriter.cs
- HttpListener.cs
- OdbcReferenceCollection.cs
- CompilerLocalReference.cs
- DataGridViewRowPrePaintEventArgs.cs
- AesCryptoServiceProvider.cs
- HWStack.cs
- ChangeInterceptorAttribute.cs
- DbProviderFactories.cs
- HttpDebugHandler.cs
- PersonalizableAttribute.cs
- IResourceProvider.cs
- HttpRequestContext.cs
- DetailsViewUpdatedEventArgs.cs
- MimePart.cs
- EncoderReplacementFallback.cs
- Int16Converter.cs
- TypeSystemHelpers.cs
- Types.cs
- _LocalDataStoreMgr.cs
- TimeIntervalCollection.cs
- ScriptingRoleServiceSection.cs
- Axis.cs
- Propagator.JoinPropagator.cs
- _BasicClient.cs