From a20fd4bd769aeccd1fd1f20273f895c92a5b5bb8 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 14 Jan 2018 15:24:49 +0200 Subject: Added code comments for: MachineStudio.Common. --- .../Authentication/IAuthenticationProvider.cs | 18 ++++++ .../Controls/MdiChild.cs | 24 ++++++++ .../Controls/MdiContainerControl.xaml.cs | 6 +- .../Converters/PointToMarginConverter.cs | 5 ++ .../ExtensionMethods/IStudioMessageExtensions.cs | 7 +++ .../ExtensionMethods/UserExtensions.cs | 14 ----- .../Tango.MachineStudio.Common/IStudioModule.cs | 25 ++++++++ .../Messages/IStudioMessage.cs | 3 + .../Modules/IStudioModuleLoader.cs | 12 ++++ .../Navigation/INavigationManager.cs | 7 +++ .../Navigation/NavigationView.cs | 3 + .../Notifications/DialogViewVM.cs | 23 ++++++- .../Notifications/INotificationProvider.cs | 71 +++++++++++++++++++++- .../Notifications/TaskItem.cs | 21 +++++++ .../StudioApplication/IShutdownRequestBlocker.cs | 8 +++ .../StudioApplication/IStudioApplicationManager.cs | 22 +++++++ .../Tango.MachineStudio.Common.csproj | 1 - .../ValidationRules/Required.cs | 12 ++++ 18 files changed, 262 insertions(+), 20 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs index 488a2f6dc..e2d4072ba 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs @@ -7,14 +7,32 @@ using Tango.DAL.Observables; namespace Tango.MachineStudio.Common.Authentication { + /// + /// Represents the Machine Studio user authentication provider responsible for the current logged-in user. + /// public interface IAuthenticationProvider { + /// + /// Occurs when the current logged-in user has changed. + /// event EventHandler CurrentUserChanged; + /// + /// Gets the current logged-in user. + /// User CurrentUser { get; } + /// + /// Performs a user login by the specified email and password. + /// + /// The email. + /// The password. + /// User Login(String email, String password); + /// + /// Logs-out the current logged-in user. + /// void Logout(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiChild.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiChild.cs index 469e3fda5..109b00531 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiChild.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiChild.cs @@ -10,19 +10,34 @@ using Tango.Core.Commands; namespace Tango.MachineStudio.Common.Controls { + /// + /// Represents an child control. + /// + /// public class MdiChild : DependencyObject { + /// + /// Initializes a new instance of the class. + /// public MdiChild() { } + /// + /// Initializes a new instance of the class. + /// + /// The header. + /// The view. public MdiChild(String header, FrameworkElement view) : this() { Header = header; View = view; } + /// + /// Gets or sets the icon. + /// public PackIconKind Icon { get { return (PackIconKind)GetValue(IconProperty); } @@ -31,6 +46,9 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(PackIconKind), typeof(MdiChild), new PropertyMetadata(PackIconKind.LaptopWindows)); + /// + /// Gets or sets the header. + /// public String Header { get { return (String)GetValue(HeaderProperty); } @@ -39,6 +57,9 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(String), typeof(MdiChild), new PropertyMetadata(null)); + /// + /// Gets or sets the view. + /// public FrameworkElement View { get { return (FrameworkElement)GetValue(ViewProperty); } @@ -47,6 +68,9 @@ namespace Tango.MachineStudio.Common.Controls public static readonly DependencyProperty ViewProperty = DependencyProperty.Register("View", typeof(FrameworkElement), typeof(MdiChild), new PropertyMetadata(null)); + /// + /// Gets or sets the location. + /// public Point Location { get { return (Point)GetValue(LocationProperty); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiContainerControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiContainerControl.xaml.cs index dbf4ee74b..ceeda050b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiContainerControl.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/MdiContainerControl.xaml.cs @@ -20,8 +20,11 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Common.Controls { /// - /// Interaction logic for MdiContainerControl.xaml + /// Represents an MDI-style container /// + /// + /// + /// public partial class MdiContainerControl : UserControl { private const int MIN_SIZE = 200; @@ -63,7 +66,6 @@ namespace Tango.MachineStudio.Common.Controls return UIHelper.FindChild(itemsControl, "canvas"); } - private void OnControlMouseDown(object sender, MouseButtonEventArgs e) { Canvas.SetZIndex(sender as FrameworkElement, GetCanvas().Children.OfType().Max(x => Canvas.GetZIndex(x) + 1)); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PointToMarginConverter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PointToMarginConverter.cs index e6587b1ee..94748fb26 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PointToMarginConverter.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PointToMarginConverter.cs @@ -9,8 +9,13 @@ using System.Windows.Data; namespace Tango.MachineStudio.Common.Converters { + /// + /// Represents a to binding converter. + /// + /// public class PointToMarginConverter : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Point p = (Point)value; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs index 83183f328..7ae259e04 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs @@ -6,8 +6,15 @@ using System.Text; using System.Threading.Tasks; using Tango.MachineStudio.Common.Messages; +/// +/// Contains extension methods. +/// public static class IStudioMessageExtensions { + /// + /// Sends the message. + /// + /// The message. public static void Send(this IStudioMessage message) { Messenger.Default.Send(message); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs deleted file mode 100644 index a6c98319e..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DAL.Observables; - -public static class UserExtensions -{ - public static bool HasPermission(this User user, Permissions permission) - { - return user.UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).ToList().Exists(x => x.Permission.Code == permission.ToInt32()); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs index 902a45a2f..21377fb5f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs @@ -9,20 +9,45 @@ using Tango.DAL.Observables; namespace Tango.MachineStudio.Common { + /// + /// Represents a Machine Studio module. + /// + /// public interface IStudioModule : IDisposable { + /// + /// Gets the module name. + /// String Name { get; } + /// + /// Gets the module description. + /// String Description { get; } + /// + /// Gets the module cover image. + /// BitmapSource Image { get; } + /// + /// Gets the module entry point view. + /// FrameworkElement MainView { get; } + /// + /// Gets the permission required to see and load this module. + /// Permissions Permission { get; } + /// + /// Gets a value indicating whether this module has been initialized. + /// bool IsInitialized { get; } + /// + /// Perform any operations required to initialize this module. + /// void Initialize(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Messages/IStudioMessage.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Messages/IStudioMessage.cs index 7d1232c7b..61056ab16 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Messages/IStudioMessage.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Messages/IStudioMessage.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Common.Messages { + /// + /// Represents an MVVM base interface for MVVM Light Messenger messages. + /// public interface IStudioMessage { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs index d67accbc1..cb9f1122f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs @@ -7,12 +7,24 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Common.Modules { + /// + /// Represents a Machine Studio modules loading engine. + /// public interface IStudioModuleLoader { + /// + /// Gets all loaded modules. + /// ObservableCollection AllModules { get; } + /// + /// Gets all the user permitted modules. + /// ObservableCollection UserModules { get; } + /// + /// Loads all available Machine Studio modules. + /// void LoadModules(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs index 631f9e2eb..4d1cbea8c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs @@ -6,8 +6,15 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Common.Navigation { + /// + /// Represents the Machine Studio views navigation manager. + /// public interface INavigationManager { + /// + /// Navigates to the specified view. + /// + /// The view. void NavigateTo(NavigationView view); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs index 77dbaf5b4..db0f0471f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Common.Navigation { + /// + /// Represents the available views to navigate to using the . + /// public enum NavigationView { LoadingView, diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs index e5e4cac78..5fcd63071 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs @@ -8,11 +8,18 @@ using Tango.SharedUI; namespace Tango.MachineStudio.Common.Notifications { + /// + /// Represents a dialog view model base class. + /// + /// public abstract class DialogViewVM : ViewModel { public event Action Accepted; public event Action Canceled; + /// + /// Initializes a new instance of the class. + /// public DialogViewVM() { CanClose = true; @@ -20,25 +27,39 @@ namespace Tango.MachineStudio.Common.Notifications } private bool _canClose; - + /// + /// Gets or sets a value indicating whether this dialog can be closed. + /// public bool CanClose { get { return _canClose; } set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + /// + /// Gets or sets the close command. + /// public RelayCommand CloseCommand { get; set; } + /// + /// Called when the dialog has been shown. + /// public virtual void OnShow() { } + /// + /// Invokes the event. + /// protected virtual void Accept() { Accepted?.Invoke(); } + /// + /// Invokes the event. + /// protected virtual void Cancel() { Canceled?.Invoke(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs index 937a39ec2..30e5626a1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -10,34 +10,101 @@ using System.Windows.Media; namespace Tango.MachineStudio.Common.Notifications { + /// + /// Represents the Machine Studio user notification provider responsible for displaying information, alerts and dialogs to the user. + /// public interface INotificationProvider { + /// + /// Gets the collection of active task items. + /// ObservableCollection TaskItems { get; } + /// + /// Gets the current displayed task item. + /// TaskItem CurrentTaskItem { get; } + /// + /// Gets a value indicating whether there are any queued task items. + /// bool HasTaskItems { get; } + /// + /// Pushes the specified task item to the queue. + /// + /// The task item. void PushTaskItem(TaskItem taskItem); + /// + /// Create and push a new task item from the specified message. + /// + /// The message. + /// TaskItem PushTaskItem(String message); + /// + /// Removed the specified task item from the queue. + /// + /// The task item. void PopTaskItem(TaskItem taskItem); + /// + /// Creates a new instance of the specified View type and displays it as a modal dialog. + /// + /// The type of the view. + /// The type of the view model. + /// Accept button callback. + /// Cancel button callback. void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM; + /// + /// Creates a new view by a naming convention of the specified view model type. + /// + /// The type of the view model. + /// Accept button callback. + /// Cancel button callback. void ShowModalDialog(Action onAccept, Action onCancel) where VM : DialogViewVM; + /// + /// Creates a new view by a naming convention of the specified view model type. + /// + /// The type of the view model. + /// Accept button callback. void ShowModalDialog(Action onAccept) where VM : DialogViewVM; - bool? ShowDialog(PackIconKind icon, Brush iconColor, String message, bool hasCancel); + /// + /// Display a message box. + /// + /// The icon. + /// Color of the icon. + /// The message. + /// if set to true displays the cancel button. + /// + bool? ShowMessageBox(PackIconKind icon, Brush iconColor, String message, bool hasCancel); + /// + /// Shows an information message box. + /// + /// The message. void ShowInfo(String message); - void ShowWarnning(String message); + /// + /// Shows warning message box. + /// + /// The message. + void ShowWarning(String message); + /// + /// Shows an error message box. + /// + /// The message. void ShowError(String message); + /// + /// Shows a question message box. + /// + /// The message. bool ShowQuestion(String message); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/TaskItem.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/TaskItem.cs index 0cf5e2c8e..110fbfa74 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/TaskItem.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/TaskItem.cs @@ -7,32 +7,53 @@ using Tango.Core; namespace Tango.MachineStudio.Common.Notifications { + /// + /// Represents a Machine Studio "work-bar" item. + /// + /// + /// public class TaskItem : ExtendedObject, IDisposable { private INotificationProvider _notificationProvider; + /// + /// Initializes a new instance of the class. + /// + /// The notification provider. public TaskItem(INotificationProvider notificationProvider) { _notificationProvider = notificationProvider; } private String _message; + /// + /// Gets or sets the message. + /// public String Message { get { return _message; } set { _message = value; RaisePropertyChangedAuto(); } } + /// + /// Removed this item from the queue. + /// public void Pop() { _notificationProvider.PopTaskItem(this); } + /// + /// Pushes this item to the queue. + /// public void Push() { _notificationProvider.PushTaskItem(this); } + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// public void Dispose() { Pop(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs index a157bd598..4d5f968a4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs @@ -6,8 +6,16 @@ using System.Threading.Tasks; namespace Tango.MachineStudio.Common.StudioApplication { + /// + /// Represents a component capable of receiving notification for when the Machine Studio shuts down. + /// The component can perform it's own shutdown operations, or cancel the current shutdown operation. + /// public interface IShutdownRequestBlocker { + /// + /// Called when the application is shutting down. + /// + /// Task OnShutdownRequest(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs index 42f4f7b65..dfdac67c7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -7,12 +7,34 @@ using Tango.Integration.Services; namespace Tango.MachineStudio.Common.StudioApplication { + /// + /// Represents the Machine Studio application manager. + /// public interface IStudioApplicationManager { + /// + /// Gets a value indicating whether Machine Studio is shutting down. + /// bool IsShuttingDown { get;} + + /// + /// Shutdown the application. + /// void ShutDown(); + + /// + /// Gets or sets the currently connected machine if any. + /// IExternalBridgeClient ConnectedMachine { get; set; } + + /// + /// Gets a value indicating whether the is valid. + /// bool IsMachineConnected { get; } + + /// + /// Gets a value indicating whether the is valid and connected through TCP/IP. + /// bool IsMachineConnectedViaTCP { get; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 49fee31f1..42eae3c1e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -91,7 +91,6 @@ MdiContainerControl.xaml - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ValidationRules/Required.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ValidationRules/Required.cs index 84f274965..aac00fdf1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ValidationRules/Required.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ValidationRules/Required.cs @@ -8,8 +8,20 @@ using System.Windows.Controls; namespace Tango.MachineStudio.Common.ValidationRules { + /// + /// Represents a required field validation rule. + /// + /// public class Required : ValidationRule { + /// + /// When overridden in a derived class, performs validation checks on a value. + /// + /// The value from the binding target to check. + /// The culture to use in this rule. + /// + /// A object. + /// public override ValidationResult Validate(object value, CultureInfo cultureInfo) { return new ValidationResult(!String.IsNullOrWhiteSpace(value.ToStringSafe()), "Required"); -- cgit v1.3.1