Wpf.BusyIndicatorEasy - Sample
Autor: Leonardo Melo Santos | Publicado: 2016-05-02T17:39:00-03:00








Source-code&nbsp;https://github.com/leonardomelosantos/Wpf.BusyIndicatorEasy
Nuget package&nbsp;https://www.nuget.org/packages/Wpf.BusyIndicatorEasy/



XAML code



&lt;Window x:Class="MyApplication.MainWindow"

&nbsp; &nbsp; &nbsp; &nbsp; xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

&nbsp; &nbsp; &nbsp; &nbsp; xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

&nbsp; &nbsp; &nbsp; &nbsp; xmlns:busyIndicatorEasy="clr-namespace:Wpf.BusyIndicatorEasy;assembly=Wpf.BusyIndicatorEasy"

&nbsp; &nbsp; &nbsp; &nbsp; Title="MainWindow" Height="424.403" Width="710.97"&gt;

&nbsp; &nbsp;&nbsp;

&nbsp; &nbsp; &lt;busyIndicatorEasy:BusyIndicator x:Name="MyBusyIndicator"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; BusyContent="Loading" MinValue="0" MaxValue="100"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; MouseDoubleClick="MyBusyIndicator_OnMouseDoubleClick"&gt;

&nbsp; &nbsp; &lt;StackPanel HorizontalAlignment="Center" Height="Auto"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; VerticalAlignment="Top" Width="Auto" Orientation="Vertical"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &lt;TabControl Height="378" Margin="0,10,0,0" Width="682"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;TabItem Header="My screen"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;StackPanel Orientation="Vertical"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Canvas Height="160"&gt;&lt;/Canvas&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;TabControl Height="167" Margin="10,10,10,0"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Width="Auto"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;TabItem Header="TabItem"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Canvas&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Button Content="Indeterminate" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Canvas.Left="534"

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Canvas.Top="94" Width="100"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Click="Button_Click_1"/&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Button Content="Progress" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Canvas.Left="534"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Canvas.Top="67" Width="100"&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Click="Button_Click"/&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/Canvas&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/TabItem&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;TabItem Header="TabItem"&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Canvas&gt;&lt;/Canvas&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/TabItem&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/TabControl&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/StackPanel&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/TabItem&gt;

&nbsp; &nbsp; &nbsp; &nbsp; &lt;/TabControl&gt;

&nbsp; &nbsp; &lt;/StackPanel&gt;

&nbsp; &nbsp; &lt;/busyIndicatorEasy:BusyIndicator&gt;

&lt;/Window&gt;





Backend code (C#)



private void Button_Click(object sender, RoutedEventArgs e)

{

&nbsp; &nbsp; // With progress

&nbsp; &nbsp; MyBusyIndicator.BusyContent="My text progress... (double click to close me)";

&nbsp; &nbsp; MyBusyIndicator.IsIndeterminate = false;

&nbsp; &nbsp; MyBusyIndicator.CurrentProgressValue = (DateTime.Now.Second/60.00)*100;

&nbsp; &nbsp; MyBusyIndicator.IsBusy = true;

}



private void Button_Click_1(object sender, RoutedEventArgs e)

{

&nbsp; &nbsp; // Indeterminate

&nbsp; &nbsp; MyBusyIndicator.BusyContent="Indeterminate... (double click to close me)";

&nbsp; &nbsp; MyBusyIndicator.IsIndeterminate = true;

&nbsp; &nbsp; MyBusyIndicator.IsBusy = true;

}



private void MyBusyIndicator_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)

{

&nbsp; &nbsp; // How to hide BusyIndicator

&nbsp; &nbsp; MyBusyIndicator.IsBusy = false;

}