Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Rendering/LayerPosition.cs @ 12062

Last change on this file since 12062 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 3.6 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;
20using System.Windows;
21
22namespace ICSharpCode.AvalonEdit.Rendering
23{
24  /// <summary>
25  /// An enumeration of well-known layers.
26  /// </summary>
27  public enum KnownLayer
28  {
29    /// <summary>
30    /// This layer is in the background.
31    /// There is no UIElement to represent this layer, it is directly drawn in the TextView.
32    /// It is not possible to replace the background layer or insert new layers below it.
33    /// </summary>
34    /// <remarks>This layer is below the Selection layer.</remarks>
35    Background,
36    /// <summary>
37    /// This layer contains the selection rectangle.
38    /// </summary>
39    /// <remarks>This layer is between the Background and the Text layers.</remarks>
40    Selection,
41    /// <summary>
42    /// This layer contains the text and inline UI elements.
43    /// </summary>
44    /// <remarks>This layer is between the Selection and the Caret layers.</remarks>
45    Text,
46    /// <summary>
47    /// This layer contains the blinking caret.
48    /// </summary>
49    /// <remarks>This layer is above the Text layer.</remarks>
50    Caret
51  }
52 
53  /// <summary>
54  /// Specifies where a new layer is inserted, in relation to an old layer.
55  /// </summary>
56  public enum LayerInsertionPosition
57  {
58    /// <summary>
59    /// The new layer is inserted below the specified layer.
60    /// </summary>
61    Below,
62    /// <summary>
63    /// The new layer replaces the specified layer. The old layer is removed
64    /// from the <see cref="TextView.Layers"/> collection.
65    /// </summary>
66    Replace,
67    /// <summary>
68    /// The new layer is inserted above the specified layer.
69    /// </summary>
70    Above
71  }
72 
73  sealed class LayerPosition : IComparable<LayerPosition>
74  {
75    internal static readonly DependencyProperty LayerPositionProperty =
76      DependencyProperty.RegisterAttached("LayerPosition", typeof(LayerPosition), typeof(LayerPosition));
77   
78    public static void SetLayerPosition(UIElement layer, LayerPosition value)
79    {
80      layer.SetValue(LayerPositionProperty, value);
81    }
82   
83    public static LayerPosition GetLayerPosition(UIElement layer)
84    {
85      return (LayerPosition)layer.GetValue(LayerPositionProperty);
86    }
87   
88    internal readonly KnownLayer KnownLayer;
89    internal readonly LayerInsertionPosition Position;
90   
91    public LayerPosition(KnownLayer knownLayer, LayerInsertionPosition position)
92    {
93      this.KnownLayer = knownLayer;
94      this.Position = position;
95    }
96   
97    public int CompareTo(LayerPosition other)
98    {
99      int r = this.KnownLayer.CompareTo(other.KnownLayer);
100      if (r != 0)
101        return r;
102      else
103        return this.Position.CompareTo(other.Position);
104    }
105  }
106}
Note: See TracBrowser for help on using the repository browser.