Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistentDataStructures/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Editing/DottedLineMargin.cs @ 16724

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

#2077: created branch and added first version

File size: 2.7 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;
21using System.Windows.Data;
22using System.Windows.Media;
23using System.Windows.Shapes;
24
25namespace ICSharpCode.AvalonEdit.Editing
26{
27  /// <summary>
28  /// Margin for use with the text area.
29  /// A vertical dotted line to separate the line numbers from the text view.
30  /// </summary>
31  public static class DottedLineMargin
32  {
33    static readonly object tag = new object();
34   
35    /// <summary>
36    /// Creates a vertical dotted line to separate the line numbers from the text view.
37    /// </summary>
38    public static UIElement Create()
39    {
40      Line line = new Line {
41        X1 = 0, Y1 = 0, X2 = 0, Y2 = 1,
42        StrokeDashArray = { 0, 2 },
43        Stretch = Stretch.Fill,
44        StrokeThickness = 1,
45        StrokeDashCap = PenLineCap.Round,
46        Margin = new Thickness(2, 0, 2, 0),
47        Tag = tag
48      };
49     
50      return line;
51    }
52   
53    /// <summary>
54    /// Creates a vertical dotted line to separate the line numbers from the text view.
55    /// </summary>
56    [Obsolete("This method got published accidentally; and will be removed again in a future version. Use the parameterless overload instead.")]
57    public static UIElement Create(TextEditor editor)
58    {
59      Line line = (Line)Create();
60     
61      line.SetBinding(
62        Line.StrokeProperty,
63        new Binding("LineNumbersForeground") { Source = editor }
64      );
65     
66      return line;
67    }
68   
69    /// <summary>
70    /// Gets whether the specified UIElement is the result of a DottedLineMargin.Create call.
71    /// </summary>
72    public static bool IsDottedLineMargin(UIElement element)
73    {
74      Line l = element as Line;
75      return l != null && l.Tag == tag;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.