diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index 112509e23..1a3b63243 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -496,29 +496,35 @@ namespace MatterHackers.MatterControl public LibraryDataView CurrentLibraryDataView = null; public void SwitchToPurchasedLibrary() { - // Switch to the purchased library - LibraryProviderSelector libraryProviderSelector = CurrentLibraryDataView.CurrentLibraryProvider.GetRootProvider() as LibraryProviderSelector; - if (libraryProviderSelector != null) + if (CurrentLibraryDataView?.CurrentLibraryProvider?.GetRootProvider() != null) { - LibraryProvider purchaseProvider = libraryProviderSelector.GetPurchasedLibrary(); - UiThread.RunOnIdle(() => + // Switch to the purchased library + LibraryProviderSelector libraryProviderSelector = CurrentLibraryDataView.CurrentLibraryProvider.GetRootProvider() as LibraryProviderSelector; + if (libraryProviderSelector != null) { - CurrentLibraryDataView.CurrentLibraryProvider = purchaseProvider; - }); + LibraryProvider purchaseProvider = libraryProviderSelector.GetPurchasedLibrary(); + UiThread.RunOnIdle(() => + { + CurrentLibraryDataView.CurrentLibraryProvider = purchaseProvider; + }); + } } } public void SwitchToSharedLibrary() { // Switch to the shared library - LibraryProviderSelector libraryProviderSelector = CurrentLibraryDataView.CurrentLibraryProvider.GetRootProvider() as LibraryProviderSelector; - if (libraryProviderSelector != null) + if (CurrentLibraryDataView?.CurrentLibraryProvider?.GetRootProvider() != null) { - LibraryProvider sharedProvider = libraryProviderSelector.GetSharedLibrary(); - UiThread.RunOnIdle(() => + LibraryProviderSelector libraryProviderSelector = CurrentLibraryDataView.CurrentLibraryProvider.GetRootProvider() as LibraryProviderSelector; + if (libraryProviderSelector != null) { - CurrentLibraryDataView.CurrentLibraryProvider = sharedProvider; - }); + LibraryProvider sharedProvider = libraryProviderSelector.GetSharedLibrary(); + UiThread.RunOnIdle(() => + { + CurrentLibraryDataView.CurrentLibraryProvider = sharedProvider; + }); + } } } diff --git a/ApplicationView/MenuRow/MenuOptionFile.cs b/ApplicationView/MenuRow/MenuOptionFile.cs index 45b0874b0..5473674be 100644 --- a/ApplicationView/MenuRow/MenuOptionFile.cs +++ b/ApplicationView/MenuRow/MenuOptionFile.cs @@ -18,9 +18,6 @@ namespace MatterHackers.MatterControl { public static MenuOptionFile CurrentMenuOptionFile = null; - public EventHandler RedeemDesignCode; - public EventHandler EnterShareCode; - public MenuOptionFile() : base("File".Localize()) { @@ -36,8 +33,8 @@ namespace MatterHackers.MatterControl new MenuItemAction("Add Printer".Localize(), AddPrinter_Click), new MenuItemAction("Import Printer".Localize(), ImportPrinter), new MenuItemAction("Add File To Queue".Localize(), importFile_Click), - new MenuItemAction("Redeem Design Code".Localize(), () => RedeemDesignCode?.Invoke(this, null)), - new MenuItemAction("Enter Share Code".Localize(), () => EnterShareCode?.Invoke(this, null)), + new MenuItemAction("Redeem Design Code".Localize(), () => MatterControlApplication.Instance.RedeemDesignCode?.Invoke()), + new MenuItemAction("Enter Share Code".Localize(), () => MatterControlApplication.Instance.EnterShareCode?.Invoke()), new MenuItemAction("------------------------", null), new MenuItemAction("Exit".Localize(), () => { diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 9d727be3d..d8bfc37f6 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -64,6 +64,9 @@ namespace MatterHackers.MatterControl public static string MCWSBaseUri { get; } = "https://mattercontrol.appspot.com"; #endif + public Action RedeemDesignCode; + public Action EnterShareCode; + public static bool CameraInUseByExternalProcess { get; set; } = false; public bool RestartOnClose = false; private static readonly Vector2 minSize = new Vector2(600, 600); diff --git a/SetupWizard/AndroidSetupOptionsPage.cs b/SetupWizard/AndroidSetupOptionsPage.cs index 98c167484..49c18bbe5 100644 --- a/SetupWizard/AndroidSetupOptionsPage.cs +++ b/SetupWizard/AndroidSetupOptionsPage.cs @@ -131,9 +131,6 @@ namespace MatterHackers.MatterControl public class SetupAccountView : SetupViewBase { - public static EventHandler RedeemDesignCode; - public static EventHandler EnterShareCode; - private event EventHandler unregisterEvents; private Button signInButton; private Button signOutButton; @@ -222,7 +219,7 @@ namespace MatterHackers.MatterControl redeemPurchaseButton.Margin = new BorderDouble(0, 0, 10, 0); redeemPurchaseButton.Click += (sender, e) => { - RedeemDesignCode?.Invoke(this, null); + MatterControlApplication.Instance.RedeemDesignCode?.Invoke(); }; buttonContainer.AddChild(redeemPurchaseButton); @@ -233,7 +230,7 @@ namespace MatterHackers.MatterControl redeemShareButton.Margin = new BorderDouble(0, 0, 10, 0); redeemShareButton.Click += (sender, e) => { - EnterShareCode?.Invoke(this, null); + MatterControlApplication.Instance.EnterShareCode?.Invoke(); }; if (!signedIn) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0e49a5d44..33cde2807 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0e49a5d44f523c36015b3b0f3b4bc93145ce8a8c +Subproject commit 33cde2807c65fe1a1ec020b5527c891cfa815cc4