From f0bcdcdbfa78ba705b8fa44591fa594a425352a9 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 15 Jun 2018 23:18:51 +0300 Subject: Implemented TouchLoadingPanel --- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 15 ++ .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 186 +++++++++++---------- .../PPCApplication/DefaultPPCApplicationManager.cs | 6 +- .../PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 5 - .../Tango.Touch/Controls/TouchLoadingPanel.cs | 41 +++++ .../Tango.Touch/Controls/TouchLoadingPanel.xaml | 59 +++++++ .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 5 + .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 3 +- 8 files changed, 218 insertions(+), 102 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index fabb57d10..3cbb44bbe 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -53,6 +53,17 @@ namespace Tango.PPC.Jobs.ViewModels } } + private bool _isLoadingJobs; + /// + /// Gets or sets a value indicating whether this instance is loading jobs. + /// + public bool IsLoadingJobs + { + get { return _isLoadingJobs; } + set { _isLoadingJobs = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -139,6 +150,8 @@ namespace Tango.PPC.Jobs.ViewModels { Task.Factory.StartNew(() => { + IsLoadingJobs = true; + Thread.Sleep(500); if (_jobsContext != null) @@ -151,6 +164,8 @@ namespace Tango.PPC.Jobs.ViewModels Jobs = _jobsContext.Jobs.Where(x => x.Machine.SerialNumber == Settings.MachineSerialNumber).ToObservableCollection(); JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs); JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + + IsLoadingJobs = false; }); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index 1686aef84..63e65f777 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -23,7 +23,7 @@ - + @@ -58,98 +58,100 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 233751ddb..554bd704c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -128,10 +128,8 @@ namespace Tango.PPC.UI.PPCApplication var settings = SettingsManager.Default.GetOrCreate(); ; - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - Machine = db.Machines.SingleOrDefault(x => x.SerialNumber == settings.MachineSerialNumber); - } + ObservablesEntitiesAdapter.Instance.Initialize(); + Machine = ObservablesEntitiesAdapter.Instance.Machines.FirstOrDefault(); }); ApplicationStarted?.Invoke(this, new EventArgs()); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index f6b06ca61..5bc02f829 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -36,11 +36,6 @@ namespace Tango.PPC.UI.ViewModels /// public async override void OnApplicationStarted() { - await Task.Factory.StartNew(() => - { - ObservablesEntitiesAdapter.Instance.Initialize(); - }); - ApplicationManager.ModulesInitialized += (_, __) => { NavigationManager.NavigateTo(NavigationView.HomeModule); diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs new file mode 100644 index 000000000..bb9745e68 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs @@ -0,0 +1,41 @@ +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.Touch.Controls +{ + public class TouchLoadingPanel : ContentControl + { + static TouchLoadingPanel() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchLoadingPanel), new FrameworkPropertyMetadata(typeof(TouchLoadingPanel))); + } + + public bool IsLoading + { + get { return (bool)GetValue(IsLoadingProperty); } + set { SetValue(IsLoadingProperty, value); } + } + public static readonly DependencyProperty IsLoadingProperty = + DependencyProperty.Register("IsLoading", typeof(bool), typeof(TouchLoadingPanel), new PropertyMetadata(false)); + + public String LoadingMessage + { + get { return (String)GetValue(LoadingMessageProperty); } + set { SetValue(LoadingMessageProperty, value); } + } + public static readonly DependencyProperty LoadingMessageProperty = + DependencyProperty.Register("LoadingMessage", typeof(String), typeof(TouchLoadingPanel), new PropertyMetadata("Loading...")); + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml new file mode 100644 index 000000000..d4c0c3d80 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 9dd79de83..be6c5add3 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -80,6 +80,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -159,6 +163,7 @@ + diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index eed986d3a..26faaa754 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -1,4 +1,4 @@ - @@ -21,6 +21,7 @@ + -- cgit v1.3.1