@@ -58,20 +58,71 @@ public GraphControl()
58
58
public event EventHandler < NodeConnectionEventArgs > ConnectionRemoved ;
59
59
60
60
#region Grid
61
- public bool ShowGrid = true ;
62
- public float GridStep = 16.0f ;
63
- private Color internalGridColor = Color . LightGray ;
64
- private Pen GridPen = new Pen ( Color . LightGray ) ;
65
- public Color GridColor
61
+ public bool ShowGrid = true ;
62
+ public float internalSmallGridStep = 16.0f ;
63
+ [ Description ( "The distance between the smallest grid lines" ) , Category ( "Appearance" ) ]
64
+ public float SmallGridStep
65
+ {
66
+ get
67
+ {
68
+ return internalSmallGridStep ;
69
+ }
70
+ set
71
+ {
72
+ if ( internalSmallGridStep == value )
73
+ return ;
74
+
75
+ internalSmallGridStep = value ;
76
+ this . Invalidate ( ) ;
77
+ }
78
+ }
79
+ public float internalLargeGridStep = 16.0f * 8.0f ;
80
+ [ Description ( "The distance between the largest grid lines" ) , Category ( "Appearance" ) ]
81
+ public float LargeGridStep
82
+ {
83
+ get
84
+ {
85
+ return internalLargeGridStep ;
86
+ }
87
+ set
88
+ {
89
+ if ( internalLargeGridStep == value )
90
+ return ;
91
+
92
+ internalLargeGridStep = value ;
93
+ this . Invalidate ( ) ;
94
+ }
95
+ }
96
+ private Color internalSmallStepGridColor = Color . Gray ;
97
+ private Pen SmallGridPen = new Pen ( Color . Gray ) ;
98
+ [ Description ( "The color for the grid lines with the smallest gap between them" ) , Category ( "Appearance" ) ]
99
+ public Color SmallStepGridColor
66
100
{
67
- get { return internalGridColor ; }
101
+ get { return internalSmallStepGridColor ; }
68
102
set
69
103
{
70
- if ( internalGridColor == value )
104
+ if ( internalSmallStepGridColor == value )
71
105
return ;
72
106
73
- internalGridColor = value ;
74
- GridPen = new Pen ( internalGridColor ) ;
107
+ internalSmallStepGridColor = value ;
108
+ SmallGridPen = new Pen ( internalSmallStepGridColor ) ;
109
+ this . Invalidate ( ) ;
110
+ }
111
+ }
112
+ private Color internalLargeStepGridColor = Color . LightGray ;
113
+ private Pen LargeGridPen = new Pen ( Color . LightGray ) ;
114
+ [ Description ( "The color for the grid lines with the largest gap between them" ) , Category ( "Appearance" ) ]
115
+ public Color LargeStepGridColor
116
+ {
117
+ get { return internalLargeStepGridColor ; }
118
+ set
119
+ {
120
+ if ( internalLargeStepGridColor == value )
121
+ return ;
122
+
123
+ internalLargeStepGridColor = value ;
124
+ LargeGridPen = new Pen ( internalLargeStepGridColor ) ;
125
+ this . Invalidate ( ) ;
75
126
}
76
127
}
77
128
#endregion
@@ -114,6 +165,7 @@ IElement HoverElement
114
165
115
166
#region FocusElement
116
167
IElement internalFocusElement ;
168
+ [ Browsable ( false ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
117
169
public IElement FocusElement
118
170
{
119
171
get { return internalFocusElement ; }
@@ -356,6 +408,7 @@ bool HasFocus(IElement element)
356
408
357
409
#region ShowLabels
358
410
bool internalShowLabels = false ;
411
+ [ Description ( "Show labels on the lines that connect the graph nodes" ) , Category ( "Appearance" ) ]
359
412
public bool ShowLabels
360
413
{
361
414
get
@@ -384,12 +437,14 @@ public bool ShowLabels
384
437
/// <summary>
385
438
/// The strategy that will be applied to determine if two node item connectors are compatible with each other
386
439
/// </summary>
440
+ [ Browsable ( false ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
387
441
public ICompatibilityStrategy CompatibilityStrategy { get ; set ; }
388
442
#endregion
389
443
390
444
391
445
#region Nodes
392
446
readonly List < Node > graphNodes = new List < Node > ( ) ;
447
+ [ Browsable ( false ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
393
448
public IEnumerable < Node > Nodes { get { return graphNodes ; } }
394
449
#endregion
395
450
@@ -938,7 +993,7 @@ protected override void OnPaint(PaintEventArgs e)
938
993
#region OnDrawBackground
939
994
virtual protected void OnDrawBackground ( PaintEventArgs e )
940
995
{
941
- e . Graphics . Clear ( Color . White ) ;
996
+ e . Graphics . Clear ( BackColor ) ;
942
997
943
998
if ( ! ShowGrid )
944
999
return ;
@@ -950,22 +1005,35 @@ virtual protected void OnDrawBackground(PaintEventArgs e)
950
1005
951
1006
inverse_transformation . TransformPoints ( points ) ;
952
1007
953
- var left = points [ 0 ] . X ;
954
- var right = points [ 1 ] . X ;
955
- var top = points [ 0 ] . Y ;
956
- var bottom = points [ 1 ] . Y ;
957
- var stepScaled = GridStep ;
1008
+ var left = points [ 0 ] . X ;
1009
+ var right = points [ 1 ] . X ;
1010
+ var top = points [ 0 ] . Y ;
1011
+ var bottom = points [ 1 ] . Y ;
1012
+ var smallStepScaled = SmallGridStep ;
958
1013
959
- var xOffset = ( ( float ) Math . Round ( left / stepScaled ) * stepScaled ) ;
960
- var yOffset = ( ( float ) Math . Round ( top / stepScaled ) * stepScaled ) ;
1014
+ var smallXOffset = ( ( float ) Math . Round ( left / smallStepScaled ) * smallStepScaled ) ;
1015
+ var smallYOffset = ( ( float ) Math . Round ( top / smallStepScaled ) * smallStepScaled ) ;
1016
+
1017
+ if ( smallStepScaled > 3 )
1018
+ {
1019
+ for ( float x = smallXOffset ; x < right ; x += smallStepScaled )
1020
+ e . Graphics . DrawLine ( SmallGridPen , x , top , x , bottom ) ;
1021
+
1022
+ for ( float y = smallYOffset ; y < bottom ; y += smallStepScaled )
1023
+ e . Graphics . DrawLine ( SmallGridPen , left , y , right , y ) ;
1024
+ }
1025
+
1026
+ var largeStepScaled = LargeGridStep ;
1027
+ var largeXOffset = ( ( float ) Math . Round ( left / largeStepScaled ) * largeStepScaled ) ;
1028
+ var largeYOffset = ( ( float ) Math . Round ( top / largeStepScaled ) * largeStepScaled ) ;
961
1029
962
- if ( stepScaled > 3 )
1030
+ if ( largeStepScaled > 3 )
963
1031
{
964
- for ( float x = xOffset ; x < right ; x += stepScaled )
965
- e . Graphics . DrawLine ( GridPen , x , top , x , bottom ) ;
1032
+ for ( float x = largeXOffset ; x < right ; x += largeStepScaled )
1033
+ e . Graphics . DrawLine ( LargeGridPen , x , top , x , bottom ) ;
966
1034
967
- for ( float y = yOffset ; y < bottom ; y += stepScaled )
968
- e . Graphics . DrawLine ( GridPen , left , y , right , y ) ;
1035
+ for ( float y = largeYOffset ; y < bottom ; y += largeStepScaled )
1036
+ e . Graphics . DrawLine ( LargeGridPen , left , y , right , y ) ;
969
1037
}
970
1038
}
971
1039
#endregion
0 commit comments