init
This commit is contained in:
111
Common/DTS.Common/BusyIndicatorManager/BusyIndicatorManager.cs
Normal file
111
Common/DTS.Common/BusyIndicatorManager/BusyIndicatorManager.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.BusyIndicatorManager
|
||||
{
|
||||
public class BusyIndicatorManager : BindableBase
|
||||
{
|
||||
#region Membervariables
|
||||
|
||||
private Dictionary<int, string> busyParameters;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
private BusyIndicatorManager()
|
||||
{
|
||||
_isBusy = false;
|
||||
_message = string.Empty;
|
||||
busyParameters = new Dictionary<int, string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Singleton Implementation
|
||||
|
||||
private static BusyIndicatorManager _instance;
|
||||
private static readonly object SyncRoot = new object();
|
||||
|
||||
public static BusyIndicatorManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return _instance ?? (_instance = new BusyIndicatorManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
private bool _isBusy;
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
private set
|
||||
{
|
||||
_isBusy = value;
|
||||
RaisePropertyChanged("IsBusy");
|
||||
}
|
||||
}
|
||||
|
||||
private string _message;
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => _message;
|
||||
private set
|
||||
{
|
||||
_message = value;
|
||||
RaisePropertyChanged("Message");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void ShowBusy(int id, string busyMessage)
|
||||
{
|
||||
if (!busyParameters.ContainsKey(id))
|
||||
{
|
||||
busyParameters.Add(id, busyMessage);
|
||||
IsBusy = true;
|
||||
Message = busyMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
busyParameters[id] = busyMessage;
|
||||
IsBusy = true;
|
||||
Message = busyMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseBusy(int id)
|
||||
{
|
||||
if (busyParameters.ContainsKey(id))
|
||||
busyParameters.Remove(id);
|
||||
|
||||
if (busyParameters.Count == 0)
|
||||
{
|
||||
IsBusy = false;
|
||||
Message = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsBusy = true;
|
||||
Message = busyParameters.Last().Value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<xtoolkit:BusyIndicator x:Class="DTS.Common.BusyIndicatorManager.xBusyIndicator"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:xtoolkit="http://schemas.xceed.com/wpf/xaml/toolkit">
|
||||
|
||||
</xtoolkit:BusyIndicator>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Windows.Controls;
|
||||
using Xceed.Wpf.Toolkit;
|
||||
|
||||
namespace DTS.Common.BusyIndicatorManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for xBusyIndicator.xaml
|
||||
/// </summary>
|
||||
public partial class xBusyIndicator
|
||||
{
|
||||
public xBusyIndicator()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Connect(int connectionId, object target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user