Skip to content

Commit 5f3ae7c

Browse files
committed
-Add/update documentation
-Add feature to Dialog: allow modal dialog and allow to prevent user from closing the dialog. -refactoring
1 parent 50c5a47 commit 5f3ae7c

File tree

1,222 files changed

+16036
-10630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,222 files changed

+16036
-10630
lines changed

BionicCode.Net/BionicCode.Net.Framework.Wpf.BionicCharts.Ui.Test/MainWindow.xaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@
66
xmlns:local="clr-namespace:BionicCode.Net.Framework.Wpf.BionicCharts.Ui.Test"
77
xmlns:bionicCharts="clr-namespace:BionicCode.Controls.Net.Framework.Wpf.BionicCharts;assembly=BionicCode.Controls.Net.Framework.Wpf"
88
xmlns:bionicFramework="clr-namespace:BionicCode.Utilities.Net.Framework.Wpf.Markup;assembly=BionicCode.Utilities.Net.Framework.Wpf"
9+
xmlns:attachedBehaviors="clr-namespace:BionicCode.Utilities.Net.Framework.Wpf.AttachedBehaviors;assembly=BionicCode.Utilities.Net.Framework.Wpf"
910
mc:Ignorable="d"
1011
Title="MainWindow" Height="800" Width="800">
1112
<Window.DataContext>
1213
<local:CartesianChartViewModel />
1314
</Window.DataContext>
1415
<StackPanel>
15-
<ComboBox ItemsSource="{bionicFramework:Enum EnumType={x:Type local:MyEnum}}"/>
16+
<TextBlock attachedBehaviors:TextControl.HighlightBackground="Chocolate" attachedBehaviors:TextControl.HighlightForeground="Cornsilk" attachedBehaviors:TextControl.IsHighlightingEnabled="True" attachedBehaviors:TextControl.Text="0123456789" >
17+
<attachedBehaviors:TextControl.HighlightRanges>
18+
<attachedBehaviors:HighlightRange StartIndex="2" EndIndex="8"/>
19+
</attachedBehaviors:TextControl.HighlightRanges>
20+
</TextBlock>
21+
<ComboBox ItemsSource="{bionicFramework:Enum {x:Type local:MyEnum}}"/>
1622
<TextBox Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Text, UpdateSourceTrigger=PropertyChanged}"/>
1723
<TextBlock Text="{bionicFramework:Invert {Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Text}}"/>
1824
<TextBlock Text="{bionicFramework:Invert 12}"/>
1925
<TextBlock Text="{bionicFramework:Invert {x:Static Visibility.Visible}}"/>
2026
<TextBlock Text="{bionicFramework:Invert True}"/>
21-
<TextBlock Text="{bionicFramework:Invert 0.12}"/>
27+
<TextBlock Text="{bionicFramework:Invert Value=0.12}"/>
2228
<TextBlock Text="{bionicFramework:Invert False}"/>
2329
<TextBox Text="{bionicFramework:Invert {Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Text}, Mode=TwoWay}"/>
2430
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Text}"/>

BionicCode.Net/BionicCode.Net.Framework.Wpf.BionicCharts.Ui.Test/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public partial class MainWindow : Window
3636
public MainWindow()
3737
{
3838
InitializeComponent();
39+
this.Text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3940
}
4041

4142
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)

BionicCode.Net/BionicCode.Utilities.Net.Core.Wpf/AsyncAsyncRelayCommand.cs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,23 @@ namespace BionicCode.Utilities.Net.Core.Wpf
1212
/// <remarks><c>AsyncRelayCommand</c> implements <see cref="System.Windows.Input.ICommand" /></remarks>
1313
public class AsyncRelayCommand : IAsyncRelayCommand
1414
{
15+
/// <summary>
16+
/// The registered parameterless async execute delegate.
17+
/// </summary>
18+
/// <value>
19+
/// A delegate that takes no parameter and returns a <see cref="Task"/>.</value>
1520
protected readonly Func<Task> ExecuteAsyncNoParam;
21+
/// <summary>
22+
/// The registered parameterless synchronous execute delegate.
23+
/// </summary>
24+
/// <value>
25+
/// A delegate that takes no parameter and returns void.</value>
1626
protected readonly Action ExecuteNoParam;
27+
/// <summary>
28+
/// The registered parameterless CanExecute delegate.
29+
/// </summary>
30+
/// <value>
31+
/// <c>true</c> if the command can execute, otherwise <c>false</c>.</value>
1732
protected readonly Func<bool> CanExecuteNoParam;
1833
private readonly Func<object, Task> executeAsync;
1934
private readonly Action<object> execute;
@@ -29,7 +44,7 @@ public event EventHandler CanExecuteChanged
2944
}
3045

3146
/// <summary>
32-
/// Creates a new command that can always execute (<see cref="CanExecute()"/> always returns <code>true</code>).
47+
/// Creates a new command that can always execute (<see cref="CanExecute()"/> will always return <c>true</c>).
3348
/// </summary>
3449
/// <param name="execute">The awaitable execution handler.</param>
3550
public AsyncRelayCommand(Action<object> execute)
@@ -38,7 +53,7 @@ public AsyncRelayCommand(Action<object> execute)
3853
}
3954

4055
/// <summary>
41-
/// Creates a new parameterless command that can always execute (<see cref="CanExecute()"/> always returns <code>true</code>).
56+
/// Creates a new parameterless command that can always execute (<see cref="CanExecute()"/> will always return <c>true</c>).
4257
/// </summary>
4358
/// <param name="executeNoParam">The awaitable execution handler.</param>
4459
public AsyncRelayCommand(Action executeNoParam)
@@ -47,7 +62,7 @@ public AsyncRelayCommand(Action executeNoParam)
4762
}
4863

4964
/// <summary>
50-
/// Creates a new command that can always execute (<see cref="CanExecute()"/> always returns <code>true</code>).
65+
/// Creates a new command that can always execute (<see cref="CanExecute()"/> will always return <c>true</c>).
5166
/// </summary>
5267
/// <param name="executeAsync">The awaitable execution handler.</param>
5368
public AsyncRelayCommand(Func<object, Task> executeAsync)
@@ -56,7 +71,7 @@ public AsyncRelayCommand(Func<object, Task> executeAsync)
5671
}
5772

5873
/// <summary>
59-
/// Creates a new parameterless asynchronous command that can always execute (<see cref="CanExecute()")/> always returns <code>true</code>).
74+
/// Creates a new parameterless asynchronous command that can always execute (<see cref="CanExecute()"/> will always return <c>true</c>).
6075
/// </summary>
6176
/// <param name="executeAsyncNoParam">The awaitable execution handler.</param>
6277
public AsyncRelayCommand(Func<Task> executeAsyncNoParam)
@@ -111,16 +126,15 @@ public AsyncRelayCommand(Func<object, Task> executeAsync, Predicate<object> canE
111126
/// <summary>
112127
/// Determines whether this AsyncRelayCommand can execute.
113128
/// </summary>
114-
/// <returns><code>true</code>code> if this command can be executed, otherwise <code>false</code>.</returns>
129+
/// <returns><c>true</c> if this command can be executed, otherwise <c>false</c>.</returns>
115130
public bool CanExecute() => this.CanExecuteNoParam != null && this.CanExecuteNoParam() || this.canExecute != null && this.canExecute(null);
116-
131+
117132
/// <summary>
118-
/// Executes the AsyncRelayCommand on the current command target.
133+
/// Executes the <see cref="ICommand"/> on the current command target.
119134
/// </summary>
120-
/// <param name="parameter">
121-
/// Data used by the command.
122-
/// </param>
123-
/// <remarks>If the execute delegate is asynchronous (awaitable) then the execution is asynchronous otherwise synchronous.</remarks>
135+
/// <remarks> When this method is called although an asynchronous execute delegate was registered, this asynchronous delegate will be executed asynchronously, but since the <see cref="Execute()"/> does not return a <see cref="Task"/> and is declared as <c>async void</c>, the execution is not awaitable and more important exceptions from an <c>async void</c> method can’t be caught with <c>catch</c>!
136+
/// <para></para>Async void methods have different error-handling semantics. When an exception is thrown out of an <c>async Task</c> or <c>async Task&lt;T&gt;</c> method, that exception is captured and placed on the <see cref="Task"/> object. With <c>async void</c> methods, there is no Task object, so any exceptions thrown out of an <c>async void</c> method will be raised directly on the SynchronizationContext that was active when the async void method started. Exceptions thrown from <c>async void</c> methods can’t be caught naturally.
137+
/// <para></para>In such a scenario it is highly recommended to always call <see cref="ExecuteAsync()"/> instead.</remarks>
124138
public async void Execute()
125139
{
126140
if (this.executeAsync != null)
@@ -171,7 +185,7 @@ public async Task ExecuteAsync()
171185
/// <param name="parameter">
172186
/// Data used by the command.
173187
/// </param>
174-
/// <returns><code>true</code>code> if this command can be executed, otherwise <code>false</code>.</returns>
188+
/// <returns><c>true</c> if this command can be executed, otherwise <c>false</c>.</returns>
175189
public bool CanExecute(object parameter) => this.canExecute != null && this.canExecute(parameter) || this.CanExecuteNoParam != null && this.CanExecuteNoParam();
176190

177191
/// <summary>

BionicCode.Net/BionicCode.Utilities.Net.Core.Wpf/AttachedBehaviors/HighLightRangeCollection.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99

1010
namespace BionicCode.Utilities.Net.Core.Wpf.AttachedBehaviors
1111
{
12-
public class HighLightRangeCollection : ObservableCollection<HighlightRange>
12+
/// <summary>
13+
/// A collection of <see cref="HighlightRange"/> items. Can be used in XAML.
14+
/// </summary>
15+
/// <example>
16+
/// <code>
17+
/// &lt;HighlightRangeCollection&gt;
18+
/// &lt;HighlightRange StartIndex="5" EndIndex="20" /&gt;
19+
/// &lt;/HighlightRangeCollection&gt;
20+
/// </code>
21+
/// </example>
22+
public class HighlightRangeCollection : ObservableCollection<HighlightRange>
1323
{
1424

1525
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
namespace BionicCode.Utilities.Net.Core.Wpf.AttachedBehaviors
22
{
3+
/// <summary>
4+
/// Represents a text range, described by a <see cref="StartIndex"/> and <see cref="EndIndex"/>.
5+
/// </summary>
36
public struct HighlightRange
47
{
8+
/// <summary>
9+
/// Creates a new instance of <see cref="HighlightRange"/>
10+
/// </summary>
11+
/// <param name="startIndex"></param>
12+
/// <param name="endIndex"></param>
513
public HighlightRange(int startIndex, int endIndex)
614
{
715
this.StartIndex = startIndex;
816
this.EndIndex = endIndex;
917
}
1018

19+
/// <summary>
20+
/// Holds the starting index of the text range.
21+
/// </summary>
22+
/// <value>An integer that describes the starting index of a index based text representation.</value>
1123
public int StartIndex { get; set; }
24+
/// <summary>
25+
/// Holds the end index of the text range.
26+
/// </summary>
27+
/// <value>An integer that describes the end index of a index based text representation.</value>
1228
public int EndIndex { get; set; }
1329
}
1430
}

BionicCode.Net/BionicCode.Utilities.Net.Core.Wpf/AttachedBehaviors/PasswordBox.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
11
using System;
22
using System.Security;
33
using System.Windows;
4+
using System.Windows.Controls;
45
using System.Windows.Input;
56

67
namespace BionicCode.Utilities.Net.Core.Wpf.AttachedBehaviors
78
{
9+
/// <summary>
10+
/// Attached behavior for <see cref="System.Windows.Controls.PasswordBox"/> that will send the <see cref="SecureString"/> of the <see cref="System.Windows.Controls.PasswordBox.SecurePassword"/> property to a command target e.g., view model using a registered <see cref="ICommand"/> registered with the <see cref="CommandProperty"/> attached property.
11+
/// </summary>
12+
/// <remarks>The attached behavior does at no point unwrap the the <see cref="SecureString"/> returned from the <see cref="System.Windows.Controls.PasswordBox.SecurePassword"/> property, nor does it access the security critical <see cref="System.Windows.Controls.PasswordBox.Password"/> property. The <see cref="System.Windows.Controls.PasswordBox.SecurePassword"/> value is simply forwarded to the command target of the registered <see cref="CommandProperty"/> attached property.</remarks>
13+
/// <seealso href="https://github.com/BionicCode/BionicCode.Net#passwordbox">See advanced example</seealso>
814
public class PasswordBox : DependencyObject
915
{
1016
#region Command attached property
1117

18+
/// <summary>
19+
/// Holds the <see cref="ICommand"/> which will be invoked with the <see cref="System.Windows.Controls.PasswordBox.SecurePassword"/> of type <see cref="SecureString"/> as command parameter.
20+
/// </summary>
21+
/// <value>An <see cref="ICommand"/> implementation.</value>
1222
public static readonly DependencyProperty CommandProperty =
1323
DependencyProperty.RegisterAttached(
1424
"Command",
1525
typeof(ICommand),
1626
typeof(PasswordBox),
1727
new PropertyMetadata(default(bool), PasswordBox.OnSendPasswordCommandChanged));
1828

29+
/// <summary>
30+
/// The set method of the attached <see cref="PasswordBox"/> property.
31+
/// </summary>
32+
/// <param name="attachingElement">The <see cref="System.Windows.Controls.PasswordBox"/> element.</param>
33+
/// <param name="value">An <see cref="ICommand"/> implementation.</param>
1934
public static void SetCommand(DependencyObject attachingElement, ICommand value) =>
2035
attachingElement.SetValue(PasswordBox.CommandProperty, value);
2136

37+
/// <summary>
38+
/// The set method of the attached <see cref="PasswordBox"/> property.
39+
/// </summary>
40+
/// <param name="attachingElement">The <see cref="System.Windows.Controls.PasswordBox"/> element.</param>
41+
/// <returns>The <see cref="ICommand"/> implementation registered with the <paramref name="attachingElement"/>.</returns>
2242
public static ICommand GetCommand(DependencyObject attachingElement) =>
2343
(ICommand)attachingElement.GetValue(PasswordBox.CommandProperty);
2444

BionicCode.Net/BionicCode.Utilities.Net.Core.Wpf/AttachedBehaviors/Popup.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,42 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Windows;
5+
using System.Windows.Controls.Primitives;
56
using BionicCode.Utilities.Net.Core.Wpf.Extensions;
67

78
namespace BionicCode.Utilities.Net.Core.Wpf.AttachedBehaviors
89
{
10+
/// <summary>
11+
/// Set of attached behaviors for the <see cref="System.Windows.Controls.Primitives.Popup"/> control.
12+
/// </summary>
13+
/// <seealso href="https://github.com/BionicCode/BionicCode.Net#popup">See advanced example</seealso>
914
public class Popup : DependencyObject
1015
{
1116
#region IsFollowPlacementTargetPositionEnabled attached property
1217

18+
/// <summary>
19+
/// When set to <c>true</c>, the <see cref="System.Windows.Controls.Primitives.Popup"/> is forced to stick to the current <see cref="System.Windows.Controls.Primitives.Popup.PlacementTarget"/>. The <see cref="System.Windows.Controls.Primitives.Popup"/> will follow the <see cref="System.Windows.Controls.Primitives.Popup.PlacementTarget"/> whenever it changes it's screen coordinates.
20+
/// </summary>
1321
public static readonly DependencyProperty IsStickyProperty =
1422
DependencyProperty.RegisterAttached(
1523
"IsSticky",
1624
typeof(bool),
1725
typeof(Popup),
1826
new PropertyMetadata(default(bool), Popup.OnIsStickyChanged));
1927

28+
/// <summary>
29+
/// The set method of the attached <see cref="IsStickyProperty"/> property.
30+
/// </summary>
31+
/// <param name="attachingElement">The <see cref="System.Windows.Controls.Primitives.Popup"/> element.</param>
32+
/// <param name="value"><c>true</c> to enable the behavior or <c>false</c> to disable it.</param>
2033
public static void SetIsSticky(DependencyObject attachingElement, bool value) =>
2134
attachingElement.SetValue(Popup.IsStickyProperty, value);
2235

36+
/// <summary>
37+
/// Get method of the attachecd <see cref="IsStickyProperty"/> property.
38+
/// </summary>
39+
/// <param name="attachingElement">The <see cref="System.Windows.Controls.Primitives.Popup"/> element.</param>
40+
/// <returns><c>true</c> if the behavior is enabled or <c>false</c> if disabled.</returns>
2341
public static bool GetIsSticky(DependencyObject attachingElement) =>
2442
(bool)attachingElement.GetValue(Popup.IsStickyProperty);
2543

0 commit comments

Comments
 (0)