2
2
3
3
Toolkit for WPF
4
4
5
- Copyright (C) 2007-2020 Xceed Software Inc.
5
+ Copyright (C) 2007-2022 Xceed Software Inc.
6
6
7
7
This program is provided to you under the terms of the XCEED SOFTWARE, INC.
8
8
COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
@@ -15,148 +15,162 @@ COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
15
15
16
16
***********************************************************************************/
17
17
18
- using System ;
19
- using System . Collections . Generic ;
20
- using System . Linq ;
21
- using System . Text ;
22
18
using System . Windows ;
23
19
using System . Windows . Controls ;
24
- using System . Windows . Data ;
25
- using System . Windows . Documents ;
26
- using System . Windows . Input ;
27
20
using System . Windows . Media ;
28
- using System . Windows . Media . Imaging ;
29
- using System . Windows . Navigation ;
30
- using System . Windows . Shapes ;
31
21
32
22
namespace Xceed . Wpf . AvalonDock . Themes . Controls
33
23
{
34
- public class SplineBorder : Control
24
+ public class SplineBorder : Control
25
+ {
26
+
27
+ public SplineBorder ( )
28
+ {
29
+ //RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
30
+ }
31
+
32
+
33
+ #region Thickness
34
+
35
+ /// <summary>
36
+ /// Thickness Dependency Property
37
+ /// </summary>
38
+ public static readonly DependencyProperty ThicknessProperty =
39
+ DependencyProperty . Register ( "Thickness" , typeof ( double ) , typeof ( SplineBorder ) ,
40
+ new FrameworkPropertyMetadata ( ( double ) 1.0 , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
41
+
42
+ /// <summary>
43
+ /// Gets or sets the Thickness property. This dependency property
44
+ /// indicates the border thickness.
45
+ /// </summary>
46
+ public double Thickness
47
+ {
48
+ get
49
+ {
50
+ return ( double ) GetValue ( ThicknessProperty ) ;
51
+ }
52
+ set
53
+ {
54
+ SetValue ( ThicknessProperty , value ) ;
55
+ }
56
+ }
57
+
58
+ #endregion
59
+
60
+ #region Fill
61
+
62
+ /// <summary>
63
+ /// Fill Dependency Property
64
+ /// </summary>
65
+ public static readonly DependencyProperty FillProperty =
66
+ DependencyProperty . Register ( "Fill" , typeof ( Brush ) , typeof ( SplineBorder ) ,
67
+ new FrameworkPropertyMetadata ( ( Brush ) null , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
68
+
69
+ /// <summary>
70
+ /// Gets or sets the Fill property. This dependency property
71
+ /// indicates the fill color.
72
+ /// </summary>
73
+ public Brush Fill
74
+ {
75
+ get
76
+ {
77
+ return ( Brush ) GetValue ( FillProperty ) ;
78
+ }
79
+ set
80
+ {
81
+ SetValue ( FillProperty , value ) ;
82
+ }
83
+ }
84
+
85
+ #endregion
86
+
87
+ #region Stroke
88
+
89
+ /// <summary>
90
+ /// Stroke Dependency Property
91
+ /// </summary>
92
+ public static readonly DependencyProperty StrokeProperty =
93
+ DependencyProperty . Register ( "Stroke" , typeof ( Brush ) , typeof ( SplineBorder ) ,
94
+ new FrameworkPropertyMetadata ( Brushes . Black , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
95
+
96
+ /// <summary>
97
+ /// Gets or sets the Stroke property. This dependency property
98
+ /// indicates the stroke brush.
99
+ /// </summary>
100
+ public Brush Stroke
35
101
{
102
+ get
103
+ {
104
+ return ( Brush ) GetValue ( StrokeProperty ) ;
105
+ }
106
+ set
107
+ {
108
+ SetValue ( StrokeProperty , value ) ;
109
+ }
110
+ }
111
+
112
+ #endregion
113
+
114
+ #region BottomBorderMargin
115
+
116
+ /// <summary>
117
+ /// BottomBorderMargin Dependency Property
118
+ /// </summary>
119
+ public static readonly DependencyProperty BottomBorderMarginProperty =
120
+ DependencyProperty . Register ( "BottomBorderMargin" , typeof ( double ) , typeof ( SplineBorder ) ,
121
+ new FrameworkPropertyMetadata ( ( double ) 0.0 , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
122
+
123
+ /// <summary>
124
+ /// Gets or sets the BottomBorderMargin property. This dependency property
125
+ /// indicates the adjustment for the bottom margin.
126
+ /// </summary>
127
+ public double BottomBorderMargin
128
+ {
129
+ get
130
+ {
131
+ return ( double ) GetValue ( BottomBorderMarginProperty ) ;
132
+ }
133
+ set
134
+ {
135
+ SetValue ( BottomBorderMarginProperty , value ) ;
136
+ }
137
+ }
138
+
139
+ #endregion
140
+
141
+
142
+
143
+ protected override void OnRender ( DrawingContext drawingContext )
144
+ {
145
+ var pgFill = new PathGeometry ( ) ;
146
+ var pfFill = new PathFigure ( ) { IsFilled = true , IsClosed = true } ;
147
+ pfFill . StartPoint = new Point ( ActualWidth , 0.0 ) ;
148
+
149
+ var q1Fill = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth * 2 / 3 , 0.0 ) , Point2 = new Point ( ActualWidth / 2.0 , ActualHeight / 2.0 ) , IsStroked = false } ;
150
+ pfFill . Segments . Add ( q1Fill ) ;
151
+ var q2Fill = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth / 3 , ActualHeight ) , Point2 = new Point ( 0 , ActualHeight ) , IsStroked = false } ;
152
+ pfFill . Segments . Add ( q2Fill ) ;
153
+
154
+ pfFill . Segments . Add ( new LineSegment ( ) { Point = new Point ( ActualWidth , ActualHeight ) , IsStroked = false } ) ;
155
+
156
+ pgFill . Figures . Add ( pfFill ) ;
157
+
158
+ drawingContext . DrawGeometry ( Fill , null , pgFill ) ;
159
+
160
+ var pgBorder = new PathGeometry ( ) ;
161
+ var pfBorder = new PathFigure ( ) { IsFilled = false , IsClosed = false } ;
162
+ pfBorder . StartPoint = new Point ( ActualWidth , Thickness / 2 ) ;
163
+
164
+ var q1Border = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth * 2 / 3 , 0.0 ) , Point2 = new Point ( ActualWidth / 2.0 , ActualHeight / 2.0 ) } ;
165
+ pfBorder . Segments . Add ( q1Border ) ;
166
+ var q2Border = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth / 3 , ActualHeight ) , Point2 = new Point ( 0.0 , ActualHeight - BottomBorderMargin ) } ;
167
+ pfBorder . Segments . Add ( q2Border ) ;
168
+
169
+ pgBorder . Figures . Add ( pfBorder ) ;
36
170
37
- public SplineBorder ( )
38
- {
39
- //RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
40
- }
41
-
42
-
43
- #region Thickness
44
-
45
- /// <summary>
46
- /// Thickness Dependency Property
47
- /// </summary>
48
- public static readonly DependencyProperty ThicknessProperty =
49
- DependencyProperty . Register ( "Thickness" , typeof ( double ) , typeof ( SplineBorder ) ,
50
- new FrameworkPropertyMetadata ( ( double ) 1.0 , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
51
-
52
- /// <summary>
53
- /// Gets or sets the Thickness property. This dependency property
54
- /// indicates the border thickness.
55
- /// </summary>
56
- public double Thickness
57
- {
58
- get { return ( double ) GetValue ( ThicknessProperty ) ; }
59
- set { SetValue ( ThicknessProperty , value ) ; }
60
- }
61
-
62
- #endregion
63
-
64
- #region Fill
65
-
66
- /// <summary>
67
- /// Fill Dependency Property
68
- /// </summary>
69
- public static readonly DependencyProperty FillProperty =
70
- DependencyProperty . Register ( "Fill" , typeof ( Brush ) , typeof ( SplineBorder ) ,
71
- new FrameworkPropertyMetadata ( ( Brush ) null , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
72
-
73
- /// <summary>
74
- /// Gets or sets the Fill property. This dependency property
75
- /// indicates the fill color.
76
- /// </summary>
77
- public Brush Fill
78
- {
79
- get { return ( Brush ) GetValue ( FillProperty ) ; }
80
- set { SetValue ( FillProperty , value ) ; }
81
- }
82
-
83
- #endregion
84
-
85
- #region Stroke
86
-
87
- /// <summary>
88
- /// Stroke Dependency Property
89
- /// </summary>
90
- public static readonly DependencyProperty StrokeProperty =
91
- DependencyProperty . Register ( "Stroke" , typeof ( Brush ) , typeof ( SplineBorder ) ,
92
- new FrameworkPropertyMetadata ( Brushes . Black , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
93
-
94
- /// <summary>
95
- /// Gets or sets the Stroke property. This dependency property
96
- /// indicates the stroke brush.
97
- /// </summary>
98
- public Brush Stroke
99
- {
100
- get { return ( Brush ) GetValue ( StrokeProperty ) ; }
101
- set { SetValue ( StrokeProperty , value ) ; }
102
- }
103
-
104
- #endregion
105
-
106
- #region BottomBorderMargin
107
-
108
- /// <summary>
109
- /// BottomBorderMargin Dependency Property
110
- /// </summary>
111
- public static readonly DependencyProperty BottomBorderMarginProperty =
112
- DependencyProperty . Register ( "BottomBorderMargin" , typeof ( double ) , typeof ( SplineBorder ) ,
113
- new FrameworkPropertyMetadata ( ( double ) 0.0 , FrameworkPropertyMetadataOptions . AffectsRender ) ) ;
114
-
115
- /// <summary>
116
- /// Gets or sets the BottomBorderMargin property. This dependency property
117
- /// indicates the adjustment for the bottom margin.
118
- /// </summary>
119
- public double BottomBorderMargin
120
- {
121
- get { return ( double ) GetValue ( BottomBorderMarginProperty ) ; }
122
- set { SetValue ( BottomBorderMarginProperty , value ) ; }
123
- }
124
-
125
- #endregion
126
-
127
-
128
-
129
- protected override void OnRender ( DrawingContext drawingContext )
130
- {
131
- var pgFill = new PathGeometry ( ) ;
132
- var pfFill = new PathFigure ( ) { IsFilled = true , IsClosed = true } ;
133
- pfFill . StartPoint = new Point ( ActualWidth , 0.0 ) ;
134
-
135
- var q1Fill = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth * 2 / 3 , 0.0 ) , Point2 = new Point ( ActualWidth / 2.0 , ActualHeight / 2.0 ) , IsStroked = false } ;
136
- pfFill . Segments . Add ( q1Fill ) ;
137
- var q2Fill = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth / 3 , ActualHeight ) , Point2 = new Point ( 0 , ActualHeight ) , IsStroked = false } ;
138
- pfFill . Segments . Add ( q2Fill ) ;
139
-
140
- pfFill . Segments . Add ( new LineSegment ( ) { Point = new Point ( ActualWidth , ActualHeight ) , IsStroked = false } ) ;
141
-
142
- pgFill . Figures . Add ( pfFill ) ;
143
-
144
- drawingContext . DrawGeometry ( Fill , null , pgFill ) ;
145
-
146
- var pgBorder = new PathGeometry ( ) ;
147
- var pfBorder = new PathFigure ( ) { IsFilled = false , IsClosed = false } ;
148
- pfBorder . StartPoint = new Point ( ActualWidth , Thickness / 2 ) ;
149
-
150
- var q1Border = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth * 2 / 3 , 0.0 ) , Point2 = new Point ( ActualWidth / 2.0 , ActualHeight / 2.0 ) } ;
151
- pfBorder . Segments . Add ( q1Border ) ;
152
- var q2Border = new QuadraticBezierSegment ( ) { Point1 = new Point ( ActualWidth / 3 , ActualHeight ) , Point2 = new Point ( 0.0 , ActualHeight - BottomBorderMargin ) } ;
153
- pfBorder . Segments . Add ( q2Border ) ;
154
-
155
- pgBorder . Figures . Add ( pfBorder ) ;
156
-
157
- drawingContext . DrawGeometry ( null , new Pen ( Stroke , Thickness ) , pgBorder ) ;
171
+ drawingContext . DrawGeometry ( null , new Pen ( Stroke , Thickness ) , pgBorder ) ;
158
172
159
- base . OnRender ( drawingContext ) ;
160
- }
173
+ base . OnRender ( drawingContext ) ;
161
174
}
175
+ }
162
176
}
0 commit comments