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
- HtmlAnchor.cs
- SqlClientPermission.cs
- RSAPKCS1SignatureFormatter.cs
- ResourcesChangeInfo.cs
- XmlElement.cs
- PeerMaintainer.cs
- DbConnectionOptions.cs
- IMembershipProvider.cs
- CodeAttributeArgumentCollection.cs
- ResourceAttributes.cs
- SelectingProviderEventArgs.cs
- SkewTransform.cs
- SpoolingTaskBase.cs
- UrlPropertyAttribute.cs
- SqlTriggerAttribute.cs
- SqlDataSourceView.cs
- PatternMatchRules.cs
- AxisAngleRotation3D.cs
- NamespaceDecl.cs
- Wizard.cs
- UnknownWrapper.cs
- DataException.cs
- PropertyOverridesTypeEditor.cs
- LabelAutomationPeer.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- BitmapMetadata.cs
- EmptyReadOnlyDictionaryInternal.cs
- ISFTagAndGuidCache.cs
- ObjectDisposedException.cs
- Scene3D.cs
- BasicExpressionVisitor.cs
- WorkerRequest.cs
- ButtonFieldBase.cs
- FileStream.cs
- XPathItem.cs
- InstanceCreationEditor.cs
- Tag.cs
- MultitargetingHelpers.cs
- WebUtil.cs
- VariantWrapper.cs
- DisposableCollectionWrapper.cs
- WaitHandle.cs
- RolePrincipal.cs
- HttpClientChannel.cs
- SortKey.cs
- Ref.cs
- ClientConfigurationHost.cs
- Queue.cs
- Pair.cs
- CapabilitiesSection.cs
- XmlLinkedNode.cs
- SymmetricAlgorithm.cs
- TypedTableBase.cs
- ValueType.cs
- ColorAnimation.cs
- RepeaterCommandEventArgs.cs
- WorkerRequest.cs
- ProcessHostFactoryHelper.cs
- OleDbStruct.cs
- QilFunction.cs
- SrgsDocumentParser.cs
- MetadataPropertyvalue.cs
- ArgIterator.cs
- PropertyState.cs
- SynchronizationLockException.cs
- GeometryConverter.cs
- AuthenticationConfig.cs
- ListViewDataItem.cs
- XPathNode.cs
- sqlstateclientmanager.cs
- Panel.cs
- BufferedGenericXmlSecurityToken.cs
- Attributes.cs
- LogExtentCollection.cs
- QueryContinueDragEvent.cs
- SystemUdpStatistics.cs
- sqlser.cs
- ReservationNotFoundException.cs
- CompilerErrorCollection.cs
- ReadOnlyDataSource.cs
- XmlDataContract.cs
- Wildcard.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- RoutedEventArgs.cs
- DynamicILGenerator.cs
- XPathMessageContext.cs
- SurrogateSelector.cs
- Compensation.cs
- WsatConfiguration.cs
- Trace.cs
- ObjectDataSourceWizardForm.cs
- HwndSourceParameters.cs
- EntityDataSourceState.cs
- FragmentNavigationEventArgs.cs
- SoapCodeExporter.cs
- TypeDependencyAttribute.cs
- PackageDigitalSignatureManager.cs
- VSDExceptions.cs
- UriTemplateClientFormatter.cs
- DtrList.cs