Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs @ 12395

Last change on this file since 12395 was 12395, checked in by dglaser, 9 years ago

#2388 merged trunk into hive statistics branch

  • Property svn:mergeinfo set to (toggle deleted branches)
    /stable/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.csmergedeligible
    /trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.csmergedeligible
    /branches/1721-RandomForestPersistence/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs10321-10322
    /branches/Algorithms.GradientDescent/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5516-5520
    /branches/Benchmarking/sources/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6917-7005
    /branches/CloningRefactoring/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs4656-4721
    /branches/CodeEditor/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs11700-11806
    /branches/DataAnalysis Refactoring/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5471-5808
    /branches/DataAnalysis SolutionEnsembles/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5815-6180
    /branches/DataAnalysis/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs4458-4459,​4462,​4464
    /branches/DataPreprocessing/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs10085-11101
    /branches/ExportSymbolicDataAnalysisSolutions/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs9510-9584
    /branches/GP.Grammar.Editor/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6284-6795
    /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5060
    /branches/HLScript/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs10331-10358
    /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6123-9799
    /branches/LogResidualEvaluator/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs10202-10483
    /branches/NET40/sources/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5138-5162
    /branches/ParallelEngine/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5175-5192
    /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs7568-7810
    /branches/QAPAlgorithms/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6350-6627
    /branches/Restructure trunk solution/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6828
    /branches/RuntimeOptimizer/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs8943-9078
    /branches/ScatterSearch (trunk integration)/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs7787-8333
    /branches/SlaveShutdown/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs8944-8956
    /branches/SpectralKernelForGaussianProcesses/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs10204-10479
    /branches/SuccessProgressAnalysis/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5370-5682
    /branches/Trunk/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs6829-6865
    /branches/UnloadJobs/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs9168-9215
    /branches/VNS/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5594-5752
    /branches/histogram/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/SelectionSegment.cs5959-6341
File size: 3.1 KB
Line 
1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20#if NREFACTORY
21using ICSharpCode.NRefactory.Editor;
22#else
23using ICSharpCode.AvalonEdit.Document;
24#endif
25
26namespace ICSharpCode.AvalonEdit.Editing
27{
28  /// <summary>
29  /// Represents a selected segment.
30  /// </summary>
31  public class SelectionSegment : ISegment
32  {
33    readonly int startOffset, endOffset;
34    readonly int startVC, endVC;
35   
36    /// <summary>
37    /// Creates a SelectionSegment from two offsets.
38    /// </summary>
39    public SelectionSegment(int startOffset, int endOffset)
40    {
41      this.startOffset = Math.Min(startOffset, endOffset);
42      this.endOffset = Math.Max(startOffset, endOffset);
43      this.startVC = this.endVC = -1;
44    }
45   
46    /// <summary>
47    /// Creates a SelectionSegment from two offsets and visual columns.
48    /// </summary>
49    public SelectionSegment(int startOffset, int startVC, int endOffset, int endVC)
50    {
51      if (startOffset < endOffset || (startOffset == endOffset && startVC <= endVC)) {
52        this.startOffset = startOffset;
53        this.startVC = startVC;
54        this.endOffset = endOffset;
55        this.endVC = endVC;
56      } else {
57        this.startOffset = endOffset;
58        this.startVC = endVC;
59        this.endOffset = startOffset;
60        this.endVC = startVC;
61      }
62    }
63   
64    /// <summary>
65    /// Gets the start offset.
66    /// </summary>
67    public int StartOffset {
68      get { return startOffset; }
69    }
70   
71    /// <summary>
72    /// Gets the end offset.
73    /// </summary>
74    public int EndOffset {
75      get { return endOffset; }
76    }
77   
78    /// <summary>
79    /// Gets the start visual column.
80    /// </summary>
81    public int StartVisualColumn {
82      get { return startVC; }
83    }
84   
85    /// <summary>
86    /// Gets the end visual column.
87    /// </summary>
88    public int EndVisualColumn {
89      get { return endVC; }
90    }
91   
92    /// <inheritdoc/>
93    int ISegment.Offset {
94      get { return startOffset; }
95    }
96   
97    /// <inheritdoc/>
98    public int Length {
99      get { return endOffset - startOffset; }
100    }
101   
102    /// <inheritdoc/>
103    public override string ToString()
104    {
105      return string.Format("[SelectionSegment StartOffset={0}, EndOffset={1}, StartVC={2}, EndVC={3}]", startOffset, endOffset, startVC, endVC);
106    }
107  }
108}
Note: See TracBrowser for help on using the repository browser.