diff --git a/docker/linux b/docker/linux
index 6037d094b..aedfd79e0 160000
--- a/docker/linux
+++ b/docker/linux
@@ -1 +1 @@
-Subproject commit 6037d094b7ce931f526394644be5e35629cdb3a0
+Subproject commit aedfd79e025ddfff2af16f9366776f0822b1fc0e
diff --git a/externals b/externals
index 281bd00a2..433d41328 160000
--- a/externals
+++ b/externals
@@ -1 +1 @@
-Subproject commit 281bd00a2d1f33bf6613358999355671ff4a9af5
+Subproject commit 433d413283f568f556c8966d24996efac20f2c2d
diff --git a/src/client/spark/Images/Icons.cs b/src/client/spark/Images/Icons.cs
index 36348abd6..49359e894 100644
--- a/src/client/spark/Images/Icons.cs
+++ b/src/client/spark/Images/Icons.cs
@@ -47,7 +47,7 @@ namespace mbts.ui
//public static ImageSource Ticket { get { return load_image("Ticket.png"); } } // replaced with AddOrders
public static ImageSource Date { get { return load_image("Date.png"); } }
- public static ImageSource Cube3d { get { return (DrawingImage)_resources["Cube"]; /*return load_image("Cube-Molecule.png");*/ } }
+ public static ImageSource Cube3d { get { return (DrawingImage)_resources["Cube"]; } }
public static ImageSource Algo { get { return Cube3d; } }
public static ImageSource Quote { get { return Math; } }
public static ImageSource Math { get { return (DrawingImage)_resources["Surface"]; } }
@@ -62,9 +62,7 @@ namespace mbts.ui
#pragma warning restore CS0618
// Vector icons
- public static ImageSource Favorites { get { return Favorites_Gold; } }
- public static ImageSource Favorites_Gold { get { return (DrawingImage)_resources["FavoritesGold"]; } }
- public static ImageSource Favorites_White { get { return (DrawingImage)_resources["FavoritesWhite"]; } }
+ public static ImageSource Bookmarks { get { return (DrawingImage)_resources["Bookmarks"]; } }
public static ImageSource Window { get { return (DrawingImage)_resources["Window"]; } }
public static ImageSource ActiveWindow { get { return (DrawingImage)_resources["ActiveWindow"]; } }
public static ImageSource Trash { get { return (DrawingImage)_resources["Trash"]; } }
diff --git a/src/client/spark/Images/Icons/Cube-Molecule.png b/src/client/spark/Images/Icons/Cube-Molecule.png
deleted file mode 100644
index dd0356eba..000000000
Binary files a/src/client/spark/Images/Icons/Cube-Molecule.png and /dev/null differ
diff --git a/src/client/spark/Images/Vector/Icons.xaml b/src/client/spark/Images/Vector/Icons.xaml
index aebe68c31..4ea28281e 100644
--- a/src/client/spark/Images/Vector/Icons.xaml
+++ b/src/client/spark/Images/Vector/Icons.xaml
@@ -3,33 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mbts="clr-namespace:mbts.ui">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
diff --git a/src/client/spark/Modules/Bookmarks/BookmarkShellModule.cs b/src/client/spark/Modules/Bookmarks/BookmarkShellModule.cs
new file mode 100644
index 000000000..ced47e89a
--- /dev/null
+++ b/src/client/spark/Modules/Bookmarks/BookmarkShellModule.cs
@@ -0,0 +1,81 @@
+using bts.spark;
+using mbts.spark;
+using mbts.ui;
+using mbts.ui.settings;
+using mbts.ui.shell;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace bts.ui {
+ [Export(typeof(IShellModule))]
+ public class BookmarkShellModule : ILazyMenuModule {
+ readonly WindowManager _wm;
+ readonly IBookmarks _bookmarks;
+ readonly ISavedWindowFactory _window_factory;
+ readonly WorkspacesModel _workspaces;
+
+ [ImportingConstructor]
+ public BookmarkShellModule(
+ WorkspacesModel workspaces,
+ WindowManager wm,
+ IBookmarks bm,
+ ISavedWindowFactory swf) {
+ _workspaces = workspaces;
+ _wm = wm;
+ _bookmarks = bm;
+ _window_factory = swf;
+ }
+
+ public ImageSource icon => Icons.Bookmarks;
+
+ public string name => "My Windows";
+
+ public int priority => 35;
+
+ public IEnumerable actions {
+ get {
+ // The windows that are open
+ var open =
+ _wm.list_documents()
+ .Select(td => td.ViewModel)
+ .Where(vm => vm.HasCustomTitle)
+ .Select(vm =>
+ SparkCommand.create(vm.Title, vm.Icon, SparkTags.ActivateWindow, () => vm.Model))
+ .Cast();
+
+ var open_set = new HashSet(open.Select(c => c.title));
+
+ // The windows that are not open
+ var closed =
+ _bookmarks.bookmarks
+ .Where(state => !open_set.Contains(state.title))
+ .Select(state =>
+ SparkCommand.create(state.title, Icons.Bookmarks, SparkTags.ShowWindowAsync,
+ () => {
+ _bookmarks.remove(state);
+ return _window_factory.restore(state);
+ }))
+ .Cast();
+
+ // todo: The windows that are closed
+ foreach (var w in open.Concat(closed).OrderBy(w => w.title)) {
+ yield return w;
+ }
+ }
+ }
+
+ public Task create(Stream load_stream) {
+ // This module shouldn't have any windows
+ throw new NotImplementedException();
+ }
+
+ public void Dispose() { }
+
+ }
+}
diff --git a/src/client/spark/Modules/Bookmarks/BookmarksModel.cs b/src/client/spark/Modules/Bookmarks/BookmarksModel.cs
new file mode 100644
index 000000000..3ab4d399c
--- /dev/null
+++ b/src/client/spark/Modules/Bookmarks/BookmarksModel.cs
@@ -0,0 +1,48 @@
+using mbts.ui.settings;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace mbts.ui.shell {
+
+ public interface IBookmarks {
+ void save_bookmark(IShellWindow window);
+ void save_bookmark(WindowState window);
+ void remove(WindowState window);
+ void clear();
+ IEnumerable bookmarks { get; }
+ }
+
+ [Export(typeof(IBookmarks))]
+ public class BookmarksModel : IBookmarks {
+ readonly ISettingsCollector _settings_collector;
+ readonly Dictionary _bookmarks = new Dictionary();
+
+ [ImportingConstructor]
+ public BookmarksModel(ISettingsCollector settings) {
+ _settings_collector = settings;
+ }
+ public void save_bookmark(IShellWindow window) {
+ var state = _settings_collector.get_window_state(window);
+ if (state != null) {
+ _bookmarks[state.title] = state;
+ }
+ }
+ public void save_bookmark(WindowState window) {
+ _bookmarks[window.title] = window;
+ }
+
+ public void clear() {
+ _bookmarks.Clear();
+ }
+
+ public void remove(WindowState window) {
+ _bookmarks.Remove(window.title);
+ }
+
+ public IEnumerable bookmarks => _bookmarks.Values;
+ }
+}
diff --git a/src/client/spark/Modules/Settings/SettingsShellModule.cs b/src/client/spark/Modules/Settings/SettingsShellModule.cs
index c485d2ab7..87e8ffa8a 100644
--- a/src/client/spark/Modules/Settings/SettingsShellModule.cs
+++ b/src/client/spark/Modules/Settings/SettingsShellModule.cs
@@ -34,7 +34,7 @@ namespace bts.ui {
public int priority => 40;
- public IEnumerable actions => new []{
+ public IEnumerable actions => new SparkCommand[]{
SparkCommands.ShowWorkspaces
//SparkCommands.ShowSettings
};
diff --git a/src/client/spark/Tests/ViewTests/WindowManagementTests.cs b/src/client/spark/Tests/ViewTests/WindowManagementTests.cs
index 74d756c17..d089c4423 100644
--- a/src/client/spark/Tests/ViewTests/WindowManagementTests.cs
+++ b/src/client/spark/Tests/ViewTests/WindowManagementTests.cs
@@ -75,7 +75,7 @@ namespace mbts.ui.tests
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Begin: test_windows_disposed");
// Make sure that an IShellWindow and ISlowWindow added to the Windows collection is eventually disposed
var thread_factory = new ShellThreadFactory();
- IWindowManager wm = new WindowManager(thread_factory, new Lazy(() => new TestSettingsCollector()), new TestSavedWindowFactory(), new TestUndo(), new SimpleBus());
+ IWindowManager wm = new WindowManager(thread_factory, new Lazy(() => new TestSettingsCollector()), new TestSavedWindowFactory(), null, new SimpleBus());
Assert.IsNotNull(Application.Current);
Assert.IsNotNull(Application.Current.Windows);
Assert.AreEqual(Application.Current.Windows.Count, 0);
@@ -100,7 +100,7 @@ namespace mbts.ui.tests
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Begin: test_slow_windows_disposed");
// Make sure that an IShellWindow and ISlowWindow added to the Windows collection is eventually disposed
var thread_factory = new ShellThreadFactory();
- IWindowManager wm = new WindowManager(thread_factory, new Lazy(() => new TestSettingsCollector()), new TestSavedWindowFactory(), new TestUndo(), new SimpleBus());
+ IWindowManager wm = new WindowManager(thread_factory, new Lazy(() => new TestSettingsCollector()), new TestSavedWindowFactory(), null, new SimpleBus());
Assert.AreEqual(Application.Current.Windows.Count, 0);
// an ISlowWindow gets its own thread
diff --git a/src/client/spark/core/Bus/SparkTags.cs b/src/client/spark/core/Bus/SparkTags.cs
index 0c8325738..52bb8c570 100644
--- a/src/client/spark/core/Bus/SparkTags.cs
+++ b/src/client/spark/core/Bus/SparkTags.cs
@@ -5,6 +5,7 @@ using bts.spark;
using mbts.ui;
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
using static mbts.spark.SparkBusData;
namespace mbts.spark
@@ -34,6 +35,8 @@ namespace mbts.spark
public static ITag<(PartialCommand, SecurityCriteria)> FilterPickOne { get; } = new SparkTag<(PartialCommand, SecurityCriteria)>("FilterPick1");
public static ITag ShowWindow { get; } = new SparkTag("Show Window");
+ public static ITag> ShowWindowAsync { get; } = new SparkTag>("ShowWindowAsync");
+ public static ITag ActivateWindow { get; } = new SparkTag("Activate Window");
public static ITag ShowWorkspaces { get; } = new SparkTag(nameof(ShowWorkspaces));
public static ITag ShowSettings { get; } = new SparkTag(nameof(ShowSettings));
public static ITag ShowUri { get; } = new SparkTag("ShowUri");
diff --git a/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs b/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
index d933cb243..cd602776b 100644
--- a/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
+++ b/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
@@ -48,10 +48,10 @@ namespace System.Collections.Generic {
return rv;
}
-
- public static IEnumerable ToIEnumerable(this T item) {
- yield return item;
- }
+ // use "new [] { item }" - avoid putting this on the intellisense for every item everywhere
+ //public static IEnumerable ToIEnumerable(this T item) {
+ // yield return item;
+ //}
public static IEnumerable TakeWhile(this IEnumerable source, TAccumulate seed, Func accumulate, Func predicate) {
TAccumulate a = seed;
diff --git a/src/client/spark/core/Settings/ISettingsCollector.cs b/src/client/spark/core/Settings/ISettingsCollector.cs
index 75f3e2f97..ea737ffa2 100644
--- a/src/client/spark/core/Settings/ISettingsCollector.cs
+++ b/src/client/spark/core/Settings/ISettingsCollector.cs
@@ -69,16 +69,18 @@ namespace mbts.ui.settings
if (window == null || window.Owner == null) return null;
MemoryStream out_stream = new MemoryStream();
window.GetState(out_stream);
+
+ var pos = _interop.GetPosition(window);
var state = new WindowState() {
owner = window.Owner.key(),
app_data = out_stream.ToArray(),
- position = _interop.GetPosition(window),
- title = window.Title
+ position = pos,
+ title = string.IsNullOrEmpty(pos.custom_title) ? window.Title : pos.custom_title
};
return state;
}
catch (Exception e) {
- Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "Error saving window state for type {0}.\n {1}".fmt(window.GetType(), e.Message));
+ Logger.log(Level.Error, Subsystem.Ui, "Error saving window state for type {0}.\n {1}".fmt(window.GetType(), e.Message));
}
return null;
}
diff --git a/src/client/spark/core/Settings/Workspaces/WorkspaceProtos.cs b/src/client/spark/core/Settings/Workspaces/WorkspaceProtos.cs
index cb6b86c1b..7758953e6 100644
--- a/src/client/spark/core/Settings/Workspaces/WorkspaceProtos.cs
+++ b/src/client/spark/core/Settings/Workspaces/WorkspaceProtos.cs
@@ -39,6 +39,9 @@ namespace mbts.ui.shell {
[ProtoMember(102), DefaultValue(true)]
public bool always_on_top = true;
//[ProtoMember(103)] //used
+
+ [ProtoMember(104)]
+ public string custom_title;
}
[ProtoContract]
@@ -58,7 +61,7 @@ namespace mbts.ui.shell {
public WindowPosition position;
[ProtoMember(9)]
- public string title;
+ public string title; // for debugging
}
[ProtoContract]
diff --git a/src/client/spark/core/ShellInterface/IShellModule.cs b/src/client/spark/core/ShellInterface/IShellModule.cs
index b6aa85c8b..bf66c6eeb 100644
--- a/src/client/spark/core/ShellInterface/IShellModule.cs
+++ b/src/client/spark/core/ShellInterface/IShellModule.cs
@@ -23,6 +23,9 @@ namespace mbts.ui
Task create(Stream load_stream);
}
+ // ILazyModule may also impement IShellMenu to get opening/closing notification
+ public interface ILazyMenuModule : IShellModule { }
+
public interface IPersistShellModule : IShellModule {
// Called at startup before the UI is shown
// This is an opportunity for you to kick off background services
diff --git a/src/client/spark/core/ShellInterface/IWindowsInterop.cs b/src/client/spark/core/ShellInterface/IWindowsInterop.cs
index de8cc6abb..3d3ce11e3 100644
--- a/src/client/spark/core/ShellInterface/IWindowsInterop.cs
+++ b/src/client/spark/core/ShellInterface/IWindowsInterop.cs
@@ -17,5 +17,5 @@ namespace mbts.ui
WindowPosition GetPosition(IShellWindow window);
bool IsVisible(IShellWindow window);
void PinWindow(IShellWindow window);
- }
+ }
}
diff --git a/src/client/spark/view/Controls/SparkMenu/SparkMenu.cs b/src/client/spark/view/Controls/SparkMenu/SparkMenu.cs
index ae9d32476..3f71f7013 100644
--- a/src/client/spark/view/Controls/SparkMenu/SparkMenu.cs
+++ b/src/client/spark/view/Controls/SparkMenu/SparkMenu.cs
@@ -10,9 +10,11 @@ namespace mbts.ui.controls {
static SparkMenu() =>
DefaultStyleKeyProperty.OverrideMetadata(typeof(SparkMenu), new FrameworkPropertyMetadata(typeof(SparkMenu)));
- public SparkMenu() =>
+ public SparkMenu() {
SetCurrentValue(FocusableProperty, false);
+ }
+
public SparkMenu(IEnumerable commands, IBus bus) : this() =>
ItemsSource = commands.Select(c => new SparkCommandVM(c, bus)).ToList();
diff --git a/src/client/spark/view/DragDrop/DragDropHelper.cs b/src/client/spark/view/DragDrop/DragDropHelper.cs
index e0cf43065..6b9daf298 100644
--- a/src/client/spark/view/DragDrop/DragDropHelper.cs
+++ b/src/client/spark/view/DragDrop/DragDropHelper.cs
@@ -61,16 +61,16 @@ namespace mbts.ui
_source_window = window as FloatingWindow;
if (_source != null) {
_mouse_start = e.GetPosition(window);
- if (!is_button_descendant((DependencyObject)e.OriginalSource)) {
+ if (!is_clickable_descendant((DependencyObject)e.OriginalSource)) {
Mouse.Capture(_source);
}
}
}
- static bool is_button_descendant(DependencyObject target) {
+ static bool is_clickable_descendant(DependencyObject target) {
while (target != null && !(target is TabDocument)) {
target = VisualTreeHelper.GetParent(target);
- if (target is Button) return true;
+ if (target is Button || target is TextBox) return true;
}
return false;
}
diff --git a/src/client/spark/view/Extensions/AsyncExtensions.cs b/src/client/spark/view/Extensions/AsyncExtensions.cs
index 82ab00912..762745e28 100644
--- a/src/client/spark/view/Extensions/AsyncExtensions.cs
+++ b/src/client/spark/view/Extensions/AsyncExtensions.cs
@@ -24,38 +24,7 @@ namespace mbts.ui
}
}
- public static async Task FromEvent(this object target, string event_name) {
- var evt = target.GetType().GetEvent(event_name);
- var delegate_type = evt.EventHandlerType;
- var tcs = new TaskCompletionSource