11using Microsoft . AspNetCore . Components ;
2- using Microsoft . AspNetCore . Components . Web ;
32using MudBlazor ;
4- using MudBlazor . Components . Highlighter ;
53using MudBlazor . Extensions ;
64using MudBlazor . Utilities ;
7- using System ;
8- using System . Collections . Generic ;
9- using System . Linq ;
10- using System . Text ;
11- using System . Threading . Tasks ;
12- using MudExtensions . Extensions ;
13- using static MudBlazor . CategoryTypes ;
145
156namespace MudExtensions
167{
@@ -21,13 +12,13 @@ public partial class MudSplitter : MudComponentBase
2112 MudSlider < double > _slider ;
2213
2314 protected string Classname => new CssBuilder ( "mud-splitter" )
24- . AddClass ( $ "border-solid border-8 mud-border-{ Color . ToDescriptionString ( ) } ", Bordered == true )
15+ . AddClass ( $ "border-solid border-2 mud-border-{ Color . ToDescriptionString ( ) } ", Bordered == true )
2516 . AddClass ( $ "mud-splitter-generate mud-splitter-generate-{ _styleGuid } ")
2617 . AddClass ( Class )
2718 . Build ( ) ;
2819
2920 protected string ContentClassname => new CssBuilder ( $ "mud-splitter-content mud-splitter-content-{ _styleGuid } d-flex")
30- . AddClass ( "ma-2" , ! DisableMargin )
21+ . AddClass ( "ma-2" , EnableMargin )
3122 . AddClass ( ClassContent )
3223 . Build ( ) ;
3324
@@ -40,24 +31,12 @@ public partial class MudSplitter : MudComponentBase
4031 [ Parameter ]
4132 public string ClassContent { get ; set ; }
4233
43- string _height ;
34+ // string _height;
4435 /// <summary>
4536 /// The height of splitter.
4637 /// </summary>
4738 [ Parameter ]
48- public string Height
49- {
50- get => _height ;
51- set
52- {
53- if ( value == _height )
54- {
55- return ;
56- }
57- _height = value ;
58- UpdateDimensions ( ) . AndForgetExt ( ) ;
59- }
60- }
39+ public string Height { get ; set ; }
6140
6241 /// <summary>
6342 /// The height of splitter.
@@ -81,25 +60,42 @@ public string Height
8160 /// The splitter bar's styles, seperated by space. All styles have to include !important and end with ';'
8261 /// </summary>
8362 [ Parameter ]
84- public string StyleBar { get ; set ; }
63+ public string StyleBar { get ; set ; } = "width:2px !important;" ;
8564
8665 /// <summary>
8766 /// The slide sensitivity that should between 0.01 and 10. Smaller values increase the smooth but reduce performance. Default is 0.1
8867 /// </summary>
8968 [ Parameter ]
9069 public double Sensitivity { get ; set ; } = 0.1d ;
9170
71+ [ Obsolete ( "DisableSlide is deprecated, please use property EnableSlide to set Slide." ) ]
72+ [ Parameter ]
73+ public bool DisableSlide
74+ {
75+ get { return ! EnableSlide ; }
76+ set { EnableSlide = ! value ; }
77+ }
9278 /// <summary>
93- /// If true, user cannot interact with splitter bar.
79+ /// If true, user can interact with splitter bar.
80+ /// Default is true.
9481 /// </summary>
9582 [ Parameter ]
96- public bool DisableSlide { get ; set ; }
83+ public bool EnableSlide { get ; set ; } = true ;
9784
85+ [ Obsolete ( "DisableMargin is deprecated, please use property EnableMargin to set Margin." ) ]
86+ [ Parameter ]
87+ public bool DisableMargin
88+ {
89+ get { return ! EnableMargin ; }
90+ set { EnableMargin = ! value ; }
91+ }
9892 /// <summary>
99- /// Disables the default margin.
93+ /// Enables the default margin.
94+ /// Default is true.
10095 /// </summary>
10196 [ Parameter ]
102- public bool DisableMargin { get ; set ; }
97+ public bool EnableMargin { get ; set ; } = true ;
98+
10399
104100 ///// <summary>
105101 ///// If true, splitter bar goes vertical.
@@ -113,47 +109,44 @@ public string Height
113109 [ Parameter ]
114110 public RenderFragment EndContent { get ; set ; }
115111
112+
113+ /// <summary>
114+ /// The start content's percentage.
115+ /// Default is 50.
116+ /// </summary>
117+ [ Parameter ]
118+ public double Dimension { get ; set ; } = 50 ;
119+
116120 [ Parameter ]
117- public EventCallback DimensionChanged { get ; set ; }
121+ public EventCallback < double > DimensionChanged { get ; set ; }
118122
119123 [ Parameter ]
120124 public EventCallback OnDoubleClicked { get ; set ; }
121125
122- protected override async Task OnInitializedAsync ( )
126+ protected override async Task OnInitializedAsync ( )
123127 {
124128 await base . OnInitializedAsync ( ) ;
125- await UpdateDimensions ( ) ;
129+ await UpdateDimension ( Dimension ) ;
126130 }
127131
128- double _firstContentDimension = 50 ;
129- double _secondContentDimension = 50 ;
130- protected async Task UpdateDimensions ( )
132+ protected async Task UpdateDimension ( double percentage )
131133 {
132- if ( _slider == null )
133- {
134- return ;
135- }
136- _firstContentDimension = _slider . Value ;
137- _secondContentDimension = 100d - _firstContentDimension ;
138- await DimensionChanged . InvokeAsync ( ) ;
134+ Dimension = percentage ;
135+ if ( DimensionChanged . HasDelegate )
136+ await DimensionChanged . InvokeAsync ( percentage ) ;
139137 }
140138
141- public double GetStartContentPercentage ( ) => _firstContentDimension ;
142-
143139 /// <summary>
144140 /// Updates the dimension with given the start content's percentage
145141 /// </summary>
146142 /// <param name="percentage"></param>
147- public async Task SetDimensions ( double percentage )
148- {
149- _slider . Value = percentage ;
150- await UpdateDimensions ( ) ;
151- }
143+ [ Obsolete ( "SetDimensions is deprecated, please use property Dimension to set start content's percentage." ) ]
144+ public Task SetDimensions ( double percentage ) => UpdateDimension ( percentage ) ;
152145
153146 async Task OnDoubleClick ( )
154147 {
155- if ( OnDoubleClicked . HasDelegate )
156- await OnDoubleClicked . InvokeAsync ( ) ;
148+ if ( OnDoubleClicked . HasDelegate )
149+ await OnDoubleClicked . InvokeAsync ( ) ;
157150 }
158151 }
159152}
0 commit comments