Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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: [....] - 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IndependentAnimationStorage.cs
- CodeAssignStatement.cs
- ColorMap.cs
- Html32TextWriter.cs
- NamedPipeConnectionPool.cs
- BackgroundWorker.cs
- TemplateControl.cs
- HttpListenerException.cs
- ArrangedElement.cs
- StrongNamePublicKeyBlob.cs
- DataGridItemEventArgs.cs
- DataGridViewButtonColumn.cs
- TemplatedWizardStep.cs
- WebPartConnectionsConfigureVerb.cs
- BitmapDownload.cs
- EntityTypeEmitter.cs
- LocalizabilityAttribute.cs
- CopyNodeSetAction.cs
- MessageQuerySet.cs
- DefaultBindingPropertyAttribute.cs
- GridViewDeletedEventArgs.cs
- TypeConverterHelper.cs
- MemoryRecordBuffer.cs
- WindowsBrush.cs
- UnaryNode.cs
- KeyProperty.cs
- OleDbReferenceCollection.cs
- ToolStripControlHost.cs
- Lazy.cs
- ProviderUtil.cs
- FormViewPagerRow.cs
- NativeActivityContext.cs
- SaveFileDialogDesigner.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- SizeFConverter.cs
- GridViewDeletedEventArgs.cs
- Timeline.cs
- AssemblyBuilderData.cs
- CodeTypeReferenceExpression.cs
- SpinLock.cs
- FrameworkElement.cs
- MobileControlsSection.cs
- DataControlReferenceCollection.cs
- ZipIOExtraFieldZip64Element.cs
- RedirectionProxy.cs
- GridItemProviderWrapper.cs
- ButtonFieldBase.cs
- FixedTextView.cs
- QuadraticBezierSegment.cs
- DataGridViewSelectedColumnCollection.cs
- Point3DAnimation.cs
- CodeDomSerializerBase.cs
- XmlSchemaExporter.cs
- EmbeddedObject.cs
- DrawListViewSubItemEventArgs.cs
- ChtmlTextWriter.cs
- Button.cs
- ImagingCache.cs
- FrameworkElementFactory.cs
- XmlRawWriterWrapper.cs
- HtmlMeta.cs
- AuthenticatingEventArgs.cs
- WebPartConnectionCollection.cs
- ViewGenerator.cs
- Size.cs
- CodeGroup.cs
- SpotLight.cs
- ConstructorExpr.cs
- MethodRental.cs
- SynchronizingStream.cs
- XmlLangPropertyAttribute.cs
- XmlIlVisitor.cs
- DbConnectionPoolGroup.cs
- WaitForChangedResult.cs
- MasterPageBuildProvider.cs
- WebPartVerbsEventArgs.cs
- SerializationInfoEnumerator.cs
- FileLoadException.cs
- ErrorInfoXmlDocument.cs
- COM2ExtendedTypeConverter.cs
- InfiniteTimeSpanConverter.cs
- BasicCellRelation.cs
- configsystem.cs
- SafeWaitHandle.cs
- DateTimeOffsetConverter.cs
- WebPageTraceListener.cs
- CategoryNameCollection.cs
- CodePageEncoding.cs
- SymmetricAlgorithm.cs
- RoleManagerEventArgs.cs
- DataListItem.cs
- Utils.cs
- BroadcastEventHelper.cs
- XmlElement.cs
- ResXResourceSet.cs
- StringPropertyBuilder.cs
- DesignerEditorPartChrome.cs
- AtomicFile.cs
- ClientScriptManagerWrapper.cs
- AuthenticatingEventArgs.cs