diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-26 10:55:44 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-26 10:55:44 +0300 |
| commit | 6e2fbaffeec9d6e3518ea9706eea107a4f1b348c (patch) | |
| tree | f50b3d8962dd37188061f8f52c1a7aeff1642232 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | db3dc558ec5fe5f3584081795865cd22f912da7d (diff) | |
| parent | e6704dce7a2b7f6d5f9bbf1b8374cc7f00ea061e (diff) | |
| download | Tango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.tar.gz Tango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
17 files changed, 329 insertions, 179 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs index e486ec79a..ec23fefee 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs @@ -23,7 +23,7 @@ namespace Tango.MachineStudio.Common.AutoComplete /// <returns></returns> public IEnumerable GetSuggestions(string filter) { - return ObservablesEntitiesAdapter.Instance.Machines.Where(x => x.SerialNumber.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase) || x.Name.ToLower().Contains(filter.ToLower())).ToList(); + return ObservablesStaticCollections.Instance.Machines.Where(x => x.SerialNumber.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase) || x.Name.ToLower().Contains(filter.ToLower())).ToList(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/LoadingPanel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/LoadingPanel.cs new file mode 100644 index 000000000..665d6995b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/LoadingPanel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Common.Controls +{ + public class LoadingPanel : ContentControl + { + + + public bool IsLoading + { + get { return (bool)GetValue(IsLoadingProperty); } + set { SetValue(IsLoadingProperty, value); } + } + public static readonly DependencyProperty IsLoadingProperty = + DependencyProperty.Register("IsLoading", typeof(bool), typeof(LoadingPanel), new PropertyMetadata(false)); + + + + static LoadingPanel() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(LoadingPanel), new FrameworkPropertyMetadata(typeof(LoadingPanel))); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs index c5b9c63cb..cb4611cad 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs @@ -81,7 +81,6 @@ namespace Tango.MachineStudio.Common.EventLogging try { _db = ObservablesContext.CreateDefault(); - _db.Configuration.LazyLoadingEnabled = false; _db.ActionTypes.ToList(); _db.EventTypesActions.ToList(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs index 4203a1e8b..be0906fc4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs @@ -3,25 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static Tango.SharedUI.Controls.NavigationControl; namespace Tango.MachineStudio.Common { /// <summary> /// Represents a Machine Studio view model. /// </summary> - public interface IStudioViewModel + public interface IStudioViewModel : INavigationViewModel { /// <summary> - /// Called when the user has navigated in to the module. - /// </summary> - void OnNavigatedTo(); - - /// <summary> - /// Called when the user has navigated out of the module. - /// </summary> - void OnNavigatedFrom(); - - /// <summary> /// Called when application is shutting down. /// </summary> void OnShuttingDown(); @@ -34,14 +25,13 @@ namespace Tango.MachineStudio.Common Task<bool> OnShutdownRequest(); /// <summary> - /// Called when another module has wants to navigate to this module with some arguments. + /// Called when the application has been started /// </summary> - /// <param name="args">The arguments.</param> - void OnModuleRequest(params object[] args); + void OnApplicationStarted(); /// <summary> - /// Called when the application has been started + /// Called when the application is ready and all modules are loaded. /// </summary> - void OnApplicationStarted(); + void OnApplicationReady(); } } 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 1fd72c53a..990300143 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs @@ -13,6 +13,11 @@ namespace Tango.MachineStudio.Common.Modules public interface IStudioModuleLoader { /// <summary> + /// Occurs when all modules are initialized. + /// </summary> + event EventHandler ModulesLoaded; + + /// <summary> /// Gets all loaded modules. /// </summary> ObservableCollection<IStudioModule> AllModules { get; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs new file mode 100644 index 000000000..abd6db172 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// <summary> + /// Represents an object which can abort the navigation from it. + /// </summary> + public interface INavigationBlocker + { + /// <summary> + /// Called before the navigation system navigates from this object. + /// Return false to abort the navigation. + /// </summary> + /// <returns></returns> + Task<bool> OnNavigateOutRequest(); + + /// <summary> + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// </summary> + /// <returns></returns> + Task<bool> OnNavigateBackRequest(); + } +} 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 4d1cbea8c..e20940c8d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; namespace Tango.MachineStudio.Common.Navigation { @@ -12,9 +13,102 @@ namespace Tango.MachineStudio.Common.Navigation public interface INavigationManager { /// <summary> - /// Navigates to the specified view. + /// Gets the current module. + /// </summary> + IStudioModule CurrentModule { get; } + + /// <summary> + /// Gets the current view model. + /// </summary> + StudioViewModel CurrentVM { get; } + + /// <summary> + /// Gets a value indicating whether the navigation system is able to navigate to the previous view. + /// </summary> + bool CanNavigateBack { get; } + + /// <summary> + /// Navigates to the previous view if <see cref="CanNavigateBack"/> is true. + /// </summary> + Task<bool> NavigateBack(); + + /// <summary> + /// Navigates to the previous view.. + /// </summary> + RelayCommand NavigateBackCommand { get; } + + /// <summary> + /// Navigates to the specified full path in command parameter. + /// </summary> + RelayCommand<String> NavigateToCommand { get; } + + /// <summary> + /// Navigates to the specified PPC view. /// </summary> /// <param name="view">The view.</param> - void NavigateTo(NavigationView view); + Task<bool> NavigateTo(NavigationView view, bool pushToHistory = true); + + /// <summary> + /// Navigates to the specified PPC view with the specified receive object. + /// </summary> + /// <param name="view">The view.</param> + Task<bool> NavigateWithObject<TPass>(NavigationView view, TPass obj, bool pushToHistory = true); + + /// <summary> + /// Navigates to the specified module. + /// </summary> + /// <typeparam name="T"></typeparam> + Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IStudioModule; + + /// <summary> + /// Navigates to the specified module using the view path (e.g MainView.JobsView). + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="viewPath">The view path.</param> + Task<bool> NavigateTo<T>(String viewPath, bool pushToHistory = true) where T : IStudioModule; + + /// <summary> + /// Navigates to the specified module using the view path (e.g MainView,JobsView). + /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView)); + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="viewPath">The view path.</param> + Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IStudioModule; + + /// <summary> + /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). + /// </summary> + /// <param name="fullPath">The full path.</param> + Task<bool> NavigateTo(String fullPath, bool pushToHistory = true); + + /// <summary> + /// Navigates to the specified module and view with the specified object and expecting a return parameter. + /// The view must be of type INavigationResultProvider<TResult>. + /// </summary> + /// <param name="fullPath">The full path.</param> + Task<TResult> NavigateForResult<TModule, TView, TResult, TPass>(TPass obj, bool pushToHistory = true) + where TModule : IStudioModule; + + /// <summary> + /// Navigates to the specified module and view with the specified object. + /// </summary> + /// <typeparam name="TModule">The type of the module.</typeparam> + /// <typeparam name="TView">The type of the view.</typeparam> + /// <typeparam name="TPass">The type of the pass.</typeparam> + /// <param name="obj">The object.</param> + /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param> + /// <returns></returns> + Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true) + where TModule : IStudioModule; + + /// <summary> + /// Clears the navigation back history. + /// </summary> + void ClearHistory(); + + /// <summary> + /// Clears the navigation back history except the specified view type. + /// </summary> + void ClearHistoryExcept<T>(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs new file mode 100644 index 000000000..5072881d2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// <summary> + /// Represents an object which supports receiving an object as part of the navigation to it. + /// </summary> + /// <typeparam name="T"></typeparam> + public interface INavigationObjectReceiver<T> + { + /// <summary> + /// Called when navigation system is going to navigate to this instance with the specified object. + /// </summary> + /// <param name="obj">The object.</param> + void OnNavigatedToWithObject(T obj); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs new file mode 100644 index 000000000..dee037432 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// <summary> + /// Represents a object which provides a result the navigation system navigates away from it. + /// </summary> + /// <typeparam name="TResult">The type of the result.</typeparam> + /// <typeparam name="TPass">The type of the pass.</typeparam> + public interface INavigationResultProvider<TResult, TPass> + { + /// <summary> + /// Called when the navigation system requests a result when it is navigating away from this instance. + /// </summary> + /// <returns></returns> + TResult GetNavigationResult(); + + /// <summary> + /// Called when navigation system is going to navigate to this instance with the specified object. + /// </summary> + /// <param name="obj">The object.</param> + void OnNavigationObjectReceived(TPass obj); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs index 4b671e2e1..cd70982d5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Windows; [assembly: AssemblyTitle("Tango - Machine Studio Common Components")] -[assembly: AssemblyVersion("2.0.24.1647")] +[assembly: AssemblyVersion("2.0.26.1159")] [assembly: ComVisible(false)] [assembly:ThemeInfo( diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml index 07818269b..6fcf6dd72 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -3,6 +3,7 @@ xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf" xmlns:editors="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:Tango.MachineStudio.Common.Resources"> 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 07f02df3a..96de3eea0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -45,13 +45,6 @@ namespace Tango.MachineStudio.Common.StudioApplication bool IsMachineConnectedViaTCP { get; } /// <summary> - /// Loads the specified module if permitted. - /// </summary> - /// <param name="moduleName">Name of the module.</param> - /// <param name="args">The arguments.</param> - void RequestModule(String moduleName, params object[] args); - - /// <summary> /// Gets the machine studio application version. /// </summary> Version Version { get; } @@ -77,5 +70,10 @@ namespace Tango.MachineStudio.Common.StudioApplication /// </summary> /// <param name="window">The window.</param> void RegisterOpenedWindow(Window window); + + /// <summary> + /// Raises the application ready event. + /// </summary> + void NotifyApplicationReady(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 96715dc20..63ff2119a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.DI; using Tango.SharedUI; namespace Tango.MachineStudio.Common @@ -10,51 +11,42 @@ namespace Tango.MachineStudio.Common /// <summary> /// Represents a Machine Studio view model /// </summary> - /// <typeparam name="Module">The type of the module.</typeparam> /// <seealso cref="Tango.SharedUI.ViewModel" /> /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> - public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel + public abstract class StudioViewModel : ViewModel, IStudioViewModel { - public bool IsVisible { get; private set; } - - /// <summary> - /// Gets or sets a value indicating whether this view model studio module is currently loaded. - /// </summary> - public bool IsModuleLoaded { get; private set; } - + private bool _isVisible; /// <summary> - /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class. + /// Gets or sets a value indicating whether this view model view's is visible. /// </summary> - public StudioViewModelInternal() : base() + public bool IsVisible { - + get { return _isVisible; } + set { _isVisible = value; RaisePropertyChangedAuto(); } } /// <summary> - /// Called when another module has wants to navigate to this module with some arguments. + /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class. /// </summary> - /// <param name="args">The arguments.</param> - public virtual void OnModuleRequest(params object[] args) + public StudioViewModel() : base() { } /// <summary> - /// Called when the user has navigated out of the module. + /// Called when the user has navigated out of this view model. /// </summary> public virtual void OnNavigatedFrom() { IsVisible = false; - IsModuleLoaded = false; } /// <summary> - /// Called when the user has navigated in to the module. + /// Called when the user has navigated in to this view model. /// </summary> public virtual void OnNavigatedTo() { IsVisible = true; - IsModuleLoaded = true; } /// <summary> @@ -82,153 +74,42 @@ namespace Tango.MachineStudio.Common { } - } - - /// <summary> - /// Represents a Machine Studio view model - /// </summary> - /// <typeparam name="Module">The type of the module.</typeparam> - /// <seealso cref="Tango.SharedUI.ViewModel" /> - /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> - public abstract class StudioViewModel<Module> : ViewModel, IStudioViewModel where Module : IStudioModule - { - public bool IsVisible { get; private set; } - - /// <summary> - /// Gets or sets a value indicating whether this view model studio module is currently loaded. - /// </summary> - public bool IsModuleLoaded { get; private set; } - - /// <summary> - /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class. - /// </summary> - public StudioViewModel() : base() - { - - } - - /// <summary> - /// Called when another module has wants to navigate to this module with some arguments. - /// </summary> - /// <param name="args">The arguments.</param> - public virtual void OnModuleRequest(params object[] args) - { - - } /// <summary> - /// Called when the user has navigated out of the module. - /// </summary> - public virtual void OnNavigatedFrom() - { - IsVisible = false; - IsModuleLoaded = false; - } - - /// <summary> - /// Called when the user has navigated in to the module. - /// </summary> - public virtual void OnNavigatedTo() - { - IsVisible = true; - IsModuleLoaded = true; - } - - /// <summary> - /// Called before the application is shutting down. - /// Return false to cancel the shutdown in case an important process is in progress. - /// </summary> - /// <returns></returns> - public virtual Task<bool> OnShutdownRequest() - { - return Task.FromResult(true); - } - - /// <summary> - /// Called when application is shutting down. + /// Called when the application is ready and all modules are loaded. /// </summary> - public virtual void OnShuttingDown() - { - - } - - /// <summary> - /// Called when the application has been started - /// </summary> - public virtual void OnApplicationStarted() - { - - } + public abstract void OnApplicationReady(); } /// <summary> - /// Represents a Machine Studio view model. + /// Represents a Machine Studio view model with a support for a view contract. /// </summary> - /// <typeparam name="Module">The type of the module.</typeparam> - /// <typeparam name="T"></typeparam> + /// <typeparam name="TView"></typeparam> /// <seealso cref="Tango.SharedUI.ViewModel" /> - /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> - public abstract class StudioViewModel<Module, T> : ViewModel<T>, IStudioViewModel where Module : IStudioModule where T : IView + public abstract class StudioViewModel<TView> : StudioViewModel where TView : IView { /// <summary> - /// Initializes a new instance of the <see cref="StudioViewModel{Module, T}"/> class. + /// Gets the view model's view. /// </summary> - /// <param name="view">The view.</param> - public StudioViewModel(T view) : base(view) - { - - } - - /// <summary> - /// Called when the application has been started - /// </summary> - public virtual void OnApplicationStarted() - { - - } + public TView View { get; private set; } /// <summary> - /// Called when another module has wants to navigate to this module with some arguments. + /// Initializes a new instance of the <see cref="StudioViewModel{TView}"/> class. /// </summary> - /// <param name="args">The arguments.</param> - public virtual void OnModuleRequest(params object[] args) - { - - } - - /// <summary> - /// Called when the user has navigated out of the module. - /// </summary> - public virtual void OnNavigatedFrom() - { - - } - - /// <summary> - /// Called when the user has navigated in to the module. - /// </summary> - public virtual void OnNavigatedTo() - { - - } - - /// <summary> - /// Called before the application is shutting down. - /// Return false to cancel the shutdown in case an important process is in progress. - /// </summary> - /// <returns></returns> - public virtual Task<bool> OnShutdownRequest() + public StudioViewModel() : base() { - return Task.FromResult(true); + TangoIOC.Default.GetInstanceWhenAvailable<TView>((view) => + { + View = view; + OnViewAttached(view); + }); } /// <summary> - /// Called when application is shutting down. + /// Called when the view has been attached /// </summary> - public virtual void OnShuttingDown() - { - - } + /// <param name="view">The view.</param> + protected abstract void OnViewAttached(TView view); } } 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 6d6803076..09678b515 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 @@ -8,7 +8,7 @@ <OutputType>library</OutputType> <RootNamespace>Tango.MachineStudio.Common</RootNamespace> <AssemblyName>Tango.MachineStudio.Common</AssemblyName> - <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <WarningLevel>4</WarningLevel> @@ -85,6 +85,7 @@ <DependentUpon>HiveComboControl.xaml</DependentUpon> </Compile> <Compile Include="Controls\IRealTimeGraph.cs" /> + <Compile Include="Controls\LoadingPanel.cs" /> <Compile Include="Controls\RealTimeGraphMultiControl.xaml.cs"> <DependentUpon>RealTimeGraphMultiControl.xaml</DependentUpon> </Compile> @@ -105,6 +106,9 @@ <Compile Include="IStudioViewModel.cs" /> <Compile Include="MachineStudioSettings.cs" /> <Compile Include="Messages\MachineConnectionChangedMessage.cs" /> + <Compile Include="Navigation\INavigationBlocker.cs" /> + <Compile Include="Navigation\INavigationObjectReceiver.cs" /> + <Compile Include="Navigation\INavigationResultProvider.cs" /> <Compile Include="Notifications\BarItem.cs" /> <Compile Include="Speech\DefaultSpeechProvider.cs" /> <Compile Include="Speech\ISpeechProvider.cs" /> @@ -114,6 +118,7 @@ <Compile Include="StudioModuleAttribute.cs" /> <Compile Include="StudioModuleBase.cs" /> <Compile Include="StudioViewModel.cs" /> + <Compile Include="Threading\IDispatcherProvider.cs" /> <Compile Include="Update\CheckForUpdatesResponse.cs" /> <Compile Include="Update\CheckForUpdatesRequest.cs" /> <Compile Include="Update\IMachineStudioUpdateService.cs" /> @@ -163,6 +168,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Themes\Generic.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> @@ -287,9 +296,7 @@ <EmbedInteropTypes>True</EmbedInteropTypes> </COMReference> </ItemGroup> - <ItemGroup> - <Folder Include="MarkupExtensions\" /> - </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/Generic.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/Generic.xaml new file mode 100644 index 000000000..9cc398753 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/Generic.xaml @@ -0,0 +1,31 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:local="clr-namespace:Tango.MachineStudio.Common.Controls"> + + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> + <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" /> + + <Style TargetType="{x:Type local:LoadingPanel}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:LoadingPanel}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}"> + + <Grid> + <ContentPresenter Content="{TemplateBinding Content}" /> + + <Grid Background="#60FFFFFF" Visibility="{TemplateBinding IsLoading,Converter={StaticResource BooleanToVisibilityConverter}}"> + <mahApps:ProgressRing IsActive="{TemplateBinding IsLoading}" /> + </Grid> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> +</ResourceDictionary> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Threading/IDispatcherProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Threading/IDispatcherProvider.cs new file mode 100644 index 000000000..1c960ed3a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Threading/IDispatcherProvider.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Threading +{ + /// <summary> + /// Represents a mechanism for invoking actions on the main application thread. + /// </summary> + public interface IDispatcherProvider + { + /// <summary> + /// Invokes the specified action asynchronously. + /// </summary> + /// <param name="action">The action.</param> + void Invoke(Action action); + + /// <summary> + /// Invokes the specified action synchronously. + /// </summary> + /// <param name="action">The action.</param> + void InvokeSync(Action action); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config index 77b7003e2..0e58ccf54 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config @@ -50,6 +50,10 @@ <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> |
