From 133581303177791316c9656b1061de9a02c07cca Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:10:30 -0500 Subject: [PATCH 01/13] bringing order to Workspaces dialog UI --- .../Workspaces/WorkspacesDialogView.xaml | 92 +++++++++---------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index 38f388d91..a3fd90db6 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -14,53 +14,47 @@ Style="{StaticResource BTSDialog}" Title="Workspaces" > - - - - - - - - - - - - - - - - - - - - - - Save Current Workspace As: - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ed10545d8a10c147069fe279a017567934ab6e8d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:12:41 -0500 Subject: [PATCH 02/13] Removing no longer valid VisualState changes --- .../Shell/Workspaces/WorkspaceViewModel.cs | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs index 49bb41138..476e6a438 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs @@ -9,8 +9,6 @@ namespace mbts.ui.shell { public class WorkspaceViewModel : ViewModelBase { - private const string INITIAL_VISUAL_STATE = "Normal"; - WorkspacesModel _parent; public WorkspaceViewModel(WorkspacesModel parent, string name, WorkspaceDefinition definition) { _parent = parent; @@ -24,24 +22,6 @@ namespace mbts.ui.shell get { return Icons.Window; } } - private string _vstate = INITIAL_VISUAL_STATE; - public string VisualState { - get { - // this unconventional getter acts as a reset after the VisualStateManager has played - // i.e. if we overwrite a workspace then save, then close the window, when we open the - // window back up, we'll see item animate b/c it has never been reset from the animate - // state. This is necessary b/c the lifetime of Workspaces is not tied to the lifetime - // of the View, rather it lives in the Model and is only instantiated on startup via MEF - var return_val = _vstate; - _vstate = INITIAL_VISUAL_STATE; - return return_val; - } - set { - _vstate = value; - RaisePropertyChanged("VisualState"); - } - } - internal WorkspaceDefinition Definition { get; private set; } public ICommand ActivateCommand { From 02062ee07b3a46653bcaee6e4b9861b400d5520c Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:13:40 -0500 Subject: [PATCH 03/13] removing commands --- .../view/Shell/Workspaces/WorkspaceViewModel.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs index 476e6a438..054c7b922 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs @@ -23,21 +23,5 @@ namespace mbts.ui.shell } internal WorkspaceDefinition Definition { get; private set; } - - public ICommand ActivateCommand { - get { - return new DelegateCommand(param => { - var unused = _parent.load_workspace(Definition, Name); - }); - } - } - - public ICommand DeleteCommand { - get { - return new DelegateCommand(param => { - _parent.delete_workspace(Name, Definition); - }); - } - } } } From 4e789388278ab77baa781e3f08ebebafb054149e Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:14:45 -0500 Subject: [PATCH 04/13] adding last_save_lldatetime ulong to proto; populing said field in save_workspace --- src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs index 867c34b18..7f55387d7 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs @@ -179,6 +179,7 @@ namespace mbts.ui.shell public void save_workspace(string name, bool persist=true, bool ispublic=false) { WorkspaceDefinition workspace = get_workspace(); workspace.is_shared = ispublic; + workspace.last_save_lldatetime = LLDateTime.now().value; if (ispublic) { name += SHARED_MONIKER; } // Remove the old one if a workspace by this name exists already @@ -282,5 +283,8 @@ namespace mbts.ui.shell [ProtoMember(10, IsRequired = false)] public bool is_shared { get; set; } + [ProtoMember(11, IsRequired = false)] + public ulong last_save_lldatetime { get; set; } + } } From aa3dda2c574ae76326e62c809907feeb36da16aa Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:15:34 -0500 Subject: [PATCH 05/13] adding DisplayName property that displays last save info if available --- src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs index 054c7b922..baf9b6f6d 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs @@ -1,4 +1,5 @@ -using System; +using mbts.utils; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,6 +18,7 @@ namespace mbts.ui.shell } public string Name { get; private set; } + public string DisplayName => Definition.last_save_lldatetime > 0 ? $"{Name} - {Definition.last_save_lldatetime.lldatetime().ToLocalTime()}" : Name; public bool IsShared { get { return Definition.is_shared; } } public object Icon { get { return Icons.Window; } From a8cd07e4d4541f3db0c48aebb1bf2da9fa572d70 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 10:16:21 -0500 Subject: [PATCH 06/13] relocating commands here, adding confirmations, etc --- .../Workspaces/WorkspacesDialogViewModel.cs | 75 ++++++++++++++----- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs index 80282e25e..3c2f01901 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs @@ -8,12 +8,15 @@ using System.Threading.Tasks; using mbts; using mbts.ui; using mbts.ui.shell; +using bts.spark; +using System.Windows; namespace mbts.ui.shell { public class WorkspacesDialogViewModel : ViewModelBaseWithValidation { private WorkspacesModel _work_model; + IRaiseCanExecuteChangedCommand _load_command, _delete_command, _save_command; public WorkspacesDialogViewModel(WorkspacesModel wm) { @@ -25,36 +28,74 @@ namespace mbts.ui.shell public bool IsPublicWorkspace { get; set; } public bool ShowWorkspaces { get; set; } - public ICommand SaveWorkspace + WorkspaceViewModel _selected_workspace; + public WorkspaceViewModel selected_workspace { + get => _selected_workspace; + set { + if (Set(ref _selected_workspace, value)) { + LoadCommand.TryRaiseCanExecuteChanged(); + DeleteCommand.TryRaiseCanExecuteChanged(); + SaveCommand.TryRaiseCanExecuteChanged(); + } + } + } + + private bool _command_can_execute() => selected_workspace != null; + private void _clear_error_state() => clear_error(nameof(SaveName)); + + public ICommand LoadCommand => _load_command ?? + (_load_command = new DelegateCommand( + () => { + _work_model.load_workspace(selected_workspace.Definition, selected_workspace.Name).ignore(); + _clear_error_state(); + }, _command_can_execute)); + public ICommand DeleteCommand => _delete_command ?? + (_delete_command = new DelegateCommand( + () => { + if (BTSMessageBox.Show( + $"Are you sure you with to delete the {selected_workspace.Name} workspace?", + "Delete Existing Workspace", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No + , MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { + _work_model.delete_workspace(selected_workspace.Name, selected_workspace.Definition).ignore(); + _clear_error_state(); + } + }, _command_can_execute)); + public ICommand SaveCommand => _save_command ?? + (_save_command = new DelegateCommand( + () => { + if (BTSMessageBox.Show( + $"Overwrite {selected_workspace.Name} with current layout?", + "Save Existing Workspace", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No + , MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { + _work_model.save_workspace(selected_workspace.Name, ispublic:selected_workspace.Definition.is_shared); + _clear_error_state(); + } + }, _command_can_execute)); + + public ICommand SaveNewWorkspace { get { return new DelegateCommand(arg => { + _clear_error_state(); // Check for errors in the input - if (string.IsNullOrEmpty(SaveName)) - { - set_error("SaveName", "Workspace must be named"); + if (string.IsNullOrEmpty(SaveName)) { + set_error(nameof(SaveName), "Workspace must be named"); return; } - if (SaveName.Contains(WorkspacesModel.ACTIVE_WORKSPACE_PREFIX)) - { - set_error("SaveName", "Workspace name cannot contains '{0}'".fmt(WorkspacesModel.ACTIVE_WORKSPACE_PREFIX)); + if (SaveName.Contains(WorkspacesModel.ACTIVE_WORKSPACE_PREFIX)) { + set_error(nameof(SaveName), "Workspace name cannot contains '{0}'".fmt(WorkspacesModel.ACTIVE_WORKSPACE_PREFIX)); return; } - else - { - clear_error("SaveName"); + if (Workspaces.Any(x => x.Name.Replace(WorkspacesModel.SHARED_MONIKER, string.Empty) == SaveName && x.IsShared == IsPublicWorkspace)) { + set_error(nameof(SaveName), $"Workspace already exists '{SaveName}'"); + return; } - var save_candidate_already_exists = Workspaces.Any(x => x.Name.Replace(WorkspacesModel.SHARED_MONIKER, string.Empty) == SaveName && x.IsShared == IsPublicWorkspace); - // Save _work_model.save_workspace(SaveName, ispublic: IsPublicWorkspace); - - // if we just overwrote something, have the vm reflect it - if (save_candidate_already_exists) - Workspaces.Where(x => x.Name.Replace(WorkspacesModel.SHARED_MONIKER, string.Empty) == SaveName && x.IsShared == IsPublicWorkspace).ForEach(x => x.VisualState = "Overridden"); }); } } - } } From 9a13fb36260fa5d70878b762622677aa8560e3bc Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 13:00:39 -0500 Subject: [PATCH 07/13] adding LastSaveTime to VM for use in UI --- src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs index baf9b6f6d..a25bcc6ea 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs @@ -18,7 +18,7 @@ namespace mbts.ui.shell } public string Name { get; private set; } - public string DisplayName => Definition.last_save_lldatetime > 0 ? $"{Name} - {Definition.last_save_lldatetime.lldatetime().ToLocalTime()}" : Name; + public string LastSaveTime => Definition.last_save_lldatetime > 0 ? Definition.last_save_lldatetime.lldatetime().ToLocalTime().ToString() : string.Empty; public bool IsShared { get { return Definition.is_shared; } } public object Icon { get { return Icons.Window; } From 380d263c5ee3f72bd0d518fe8dbdac137ea787cd Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 13:01:09 -0500 Subject: [PATCH 08/13] stylizing ComboBox for a 2 column layout --- .../Workspaces/WorkspacesDialogView.xaml | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index a3fd90db6..06e7524af 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -31,7 +31,45 @@ - + + + + + + + + + + From b2be4c58c4767ab2bee010ab318bf46a8c0da881 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 13:43:10 -0500 Subject: [PATCH 09/13] Workspaces ComboBox now has a table-like appearance --- .../Workspaces/WorkspacesDialogView.xaml | 65 ++++++++----------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index 06e7524af..275c295fc 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -31,44 +31,35 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + From e8b1786411d348b281c47fc974de7e882ab85c6d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 14:24:07 -0500 Subject: [PATCH 10/13] splitting date and time in UI into separate columns; formatting DateTime is now done in Style --- .../Shell/Workspaces/WorkspaceViewModel.cs | 2 +- .../Workspaces/WorkspacesDialogView.xaml | 42 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs index a25bcc6ea..0ce33b9eb 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspaceViewModel.cs @@ -18,7 +18,7 @@ namespace mbts.ui.shell } public string Name { get; private set; } - public string LastSaveTime => Definition.last_save_lldatetime > 0 ? Definition.last_save_lldatetime.lldatetime().ToLocalTime().ToString() : string.Empty; + public DateTime LastSaveTime => Definition.last_save_lldatetime.lldatetime().ToLocalTime(); public bool IsShared { get { return Definition.is_shared; } } public object Icon { get { return Icons.Window; } diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index 275c295fc..be390baef 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:mbts.ui.shell" mc:Ignorable="d" xmlns:controls="clr-namespace:mbts.ui.controls" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:ui="clr-namespace:mbts.ui" Width="250" MaxHeight="700" @@ -31,32 +32,59 @@ - + - + - + + + - + - + - + + + - + + + + + + + + + + From 8d5715d51079545d15d42c6f4aed5b39295a29d9 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 14:37:29 -0500 Subject: [PATCH 11/13] adding comment --- .../spark/view/Shell/Workspaces/WorkspacesDialogView.xaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index be390baef..a4e333963 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -33,6 +33,9 @@ + From 63434516f85b85ba799318d94cb7cb176ce23e4d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 20 Aug 2019 14:44:14 -0500 Subject: [PATCH 12/13] quoting workspace names in confirmation dialogs --- .../Workspaces/WorkspacesDialogViewModel.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs index 3c2f01901..72c80dc7d 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogViewModel.cs @@ -53,10 +53,10 @@ namespace mbts.ui.shell (_delete_command = new DelegateCommand( () => { if (BTSMessageBox.Show( - $"Are you sure you with to delete the {selected_workspace.Name} workspace?", - "Delete Existing Workspace", - BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No - , MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { + $"Delete the \"{selected_workspace.Name}\" workspace?", + "Delete Existing Workspace Confirmation", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { _work_model.delete_workspace(selected_workspace.Name, selected_workspace.Definition).ignore(); _clear_error_state(); } @@ -65,10 +65,10 @@ namespace mbts.ui.shell (_save_command = new DelegateCommand( () => { if (BTSMessageBox.Show( - $"Overwrite {selected_workspace.Name} with current layout?", - "Save Existing Workspace", - BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No - , MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { + $"Overwrite \"{selected_workspace.Name}\" with current layout?", + "Save Existing Workspace Confirmation", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question) == BTSMessageBoxButtons.Yes) { _work_model.save_workspace(selected_workspace.Name, ispublic:selected_workspace.Definition.is_shared); _clear_error_state(); } From 068e762f4485233d483e5ee43bcfe29f580d3513 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 21 Aug 2019 11:28:19 -0500 Subject: [PATCH 13/13] PR feedback - Workspaces are now Topmost true; gret suggestion Eric! --- src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml index a4e333963..19ecd7978 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesDialogView.xaml @@ -14,6 +14,7 @@ ui:WindowStyle.ShowMinimizeButton="False" Style="{StaticResource BTSDialog}" Title="Workspaces" + Topmost="True" >