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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UnsignedPublishLicense.cs
- XmlDictionaryReader.cs
- StorageComplexTypeMapping.cs
- NetCodeGroup.cs
- StringConcat.cs
- x509utils.cs
- SemanticResolver.cs
- PointCollection.cs
- ModifiableIteratorCollection.cs
- DiscoveryClientReferences.cs
- TypeNameConverter.cs
- ToolStripStatusLabel.cs
- PaperSource.cs
- DataGridAutoFormat.cs
- ErrorStyle.cs
- KeyConstraint.cs
- PiiTraceSource.cs
- SqlMethods.cs
- RepeatButtonAutomationPeer.cs
- precedingquery.cs
- RegistryExceptionHelper.cs
- StreamingContext.cs
- StateMachineWorkflow.cs
- SQLSingleStorage.cs
- DynamicQueryableWrapper.cs
- SignedXmlDebugLog.cs
- DesignerContextDescriptor.cs
- EventMappingSettingsCollection.cs
- FloaterParagraph.cs
- DataGridViewRowsRemovedEventArgs.cs
- OleDbErrorCollection.cs
- SqlXmlStorage.cs
- FontDialog.cs
- IndexObject.cs
- XmlParserContext.cs
- SafeFileMapViewHandle.cs
- RSAPKCS1SignatureFormatter.cs
- EntitySetDataBindingList.cs
- ToolboxItemCollection.cs
- MarkedHighlightComponent.cs
- BorderGapMaskConverter.cs
- Int64Animation.cs
- CodeConstructor.cs
- TrackBarDesigner.cs
- TransactionScope.cs
- ScaleTransform3D.cs
- ObjectContext.cs
- MdImport.cs
- SerializationInfoEnumerator.cs
- PhysicalAddress.cs
- CompositeTypefaceMetrics.cs
- PingOptions.cs
- ArrayTypeMismatchException.cs
- VectorCollectionConverter.cs
- HandoffBehavior.cs
- ConstraintConverter.cs
- LinearGradientBrush.cs
- TextRangeSerialization.cs
- ScrollEvent.cs
- NavigationWindowAutomationPeer.cs
- UnauthorizedWebPart.cs
- glyphs.cs
- FilteredDataSetHelper.cs
- SupportingTokenDuplexChannel.cs
- ScopeElement.cs
- RadioButtonStandardAdapter.cs
- TreeNodeCollectionEditor.cs
- SoapFault.cs
- AnnotationHighlightLayer.cs
- SystemThemeKey.cs
- UnmanagedMemoryStreamWrapper.cs
- RIPEMD160.cs
- DashStyle.cs
- ProviderConnectionPoint.cs
- DataObjectMethodAttribute.cs
- DivideByZeroException.cs
- TargetException.cs
- updateconfighost.cs
- PreviewKeyDownEventArgs.cs
- BooleanFunctions.cs
- ProfileSettings.cs
- PlanCompiler.cs
- SoapIncludeAttribute.cs
- DataGridViewImageColumn.cs
- SystemColorTracker.cs
- DataGridTableCollection.cs
- _TransmitFileOverlappedAsyncResult.cs
- QualifierSet.cs
- BitmapEffectDrawing.cs
- PropertyFilterAttribute.cs
- ProgressChangedEventArgs.cs
- Win32MouseDevice.cs
- BoolExpr.cs
- OleDbSchemaGuid.cs
- LinearGradientBrush.cs
- PasswordRecovery.cs
- TextTreeInsertUndoUnit.cs
- JournalNavigationScope.cs
- EventDescriptorCollection.cs
- ObjectListCommandsPage.cs