public static void GoToPrinterSettings(string widgetNameToHighlight) { if (PrinterConnectionAndCommunication.Instance?.ActivePrinter?.ID != null) { Task.Run(() => { UiThread.RunOnIdle(() => { WizardWindow.Show <EditPrinterSettingsPage>("EditSettings", "Edit Printer Settings"); EventHandler unregisterEvents = null; ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => { WizardWindow openWindowInternal = WizardWindow.GetSystemWindow("EditSettings"); if (openWindowInternal != null) { UiThread.RunOnIdle(() => openWindowInternal.Close()); } }, ref unregisterEvents); WizardWindow openWindow = WizardWindow.GetSystemWindow("EditSettings"); openWindow.Closed += (s2, e2) => { UiThread.RunOnIdle(() => unregisterEvents?.Invoke(s2, null)); }; }); }); } }
// Called after every startup and at the completion of every authentication change public void UserChanged() { ProfileManager.Reload(); var profileManager = ProfileManager.Instance; // Ensure SQLite printers are imported profileManager.EnsurePrintersImported(); var guestDB = ProfileManager.LoadGuestDB(); // If profiles.json was created, run the import wizard to pull in any SQLite printers if (guestDB?.Profiles != null && guestDB.Profiles.Any() && !profileManager.IsGuestProfile && !profileManager.PrintersImported) { var wizardPage = new CopyGuestProfilesToUser(() => { // On success, set state indicating import has been run and update ProfileManager state profileManager.PrintersImported = true; profileManager.Save(); }); // Show the import printers wizard WizardWindow.Show("/CopyGuestProfiles", "Copy Printers", wizardPage); } }
public void OnLoadActions() { Load?.Invoke(this, null); // Pushing this after load fixes that empty printer list ApplicationController.Instance.UserChanged(); if (!System.IO.File.Exists(@"/storage/sdcard0/Download/LaunchTestPrint.stl")) { bool showAuthWindow = WizardWindow.ShouldShowAuthPanel?.Invoke() ?? false; if (showAuthWindow) { if (ApplicationSettings.Instance.get(ApplicationSettingsKey.SuppressAuthPanel) != "True") { //Launch window to prompt user to sign in UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup()); } } else { //If user in logged in sync before checking to prompt to create printer if (ApplicationController.SyncPrinterProfiles == null) { RunSetupIfRequired(); } else { ApplicationController.SyncPrinterProfiles.Invoke("ApplicationController.OnLoadActions()", null).ContinueWith((task) => { RunSetupIfRequired(); }); } } if (OsInformation.OperatingSystem == OSType.Android) { // show this last so it is on top if (UserSettings.Instance.get("SoftwareLicenseAccepted") != "true") { UiThread.RunOnIdle(() => WizardWindow.Show <LicenseAgreementPage>("SoftwareLicense", "Software License Agreement")); } } } else { StartPrintingTest(); } if (ActiveSliceSettings.Instance.PrinterSelected && ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.auto_connect)) { UiThread.RunOnIdle(() => { //PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); }, 2); } }
public static void OpenEditPrinterWizard(string widgetNameToHighlight) { if (PrinterConnectionAndCommunication.Instance?.ActivePrinter?.ID != null && ActiveSliceSettings.Instance.PrinterSelected && !WizardWindow.IsOpen("PrinterSetup")) { UiThread.RunOnIdle(() => { WizardWindow.Show <EditPrinterSettingsPage>("EditSettings", "Edit Printer Settings"); }); } }
protected override IEnumerable <MenuItemAction> GetMenuActions() { return(new List <MenuItemAction> { new MenuItemAction("Add Printer".Localize(), () => WizardWindow.Show()), 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("------------------------", null), new MenuItemAction("Exit".Localize(), () => { MatterControlApplication app = this.Parents <MatterControlApplication>().FirstOrDefault(); app.RestartOnClose = false; app.Close(); }) }); }
// Called after every startup and at the completion of every authentication change public void UserChanged() { ProfileManager.ReloadActiveUser(); // Ensure SQLite printers are imported ProfileManager.Instance.EnsurePrintersImported(); var guest = ProfileManager.Load("guest"); // If profiles.json was created, run the import wizard to pull in any SQLite printers if (guest?.Profiles?.Any() == true && !ProfileManager.Instance.IsGuestProfile && !ProfileManager.Instance.PrintersImported) { // Show the import printers wizard WizardWindow.Show <CopyGuestProfilesToUser>("/CopyGuestProfiles", "Copy Printers"); } }
public SetupAccountView(TextImageButtonFactory textImageButtonFactory) : base("My Account") { this.textImageButtonFactory = textImageButtonFactory; bool signedIn = true; string username = AuthenticationData.Instance.ActiveSessionUsername; if (username == null) { signedIn = false; username = "******"; } FlowLayoutWidget nameAndStatus = new FlowLayoutWidget(); nameAndStatus.AddChild(new TextWidget(username, pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)); connectionStatus = new TextWidget(AuthenticationString, pointSize: 8, textColor: ActiveTheme.Instance.SecondaryTextColor) { Margin = new BorderDouble(5, 0, 0, 0), AutoExpandBoundsToText = true, }; if (signedIn) { nameAndStatus.AddChild(connectionStatus); } mainContainer.AddChild(nameAndStatus); RefreshStatus(); FlowLayoutWidget buttonContainer = new FlowLayoutWidget(); buttonContainer.HAnchor = HAnchor.ParentLeftRight; buttonContainer.Margin = new BorderDouble(0, 14); signInButton = textImageButtonFactory.Generate("Sign In".Localize()); signInButton.Margin = new BorderDouble(left: 0); signInButton.VAnchor = VAnchor.ParentCenter; signInButton.Visible = !signedIn; signInButton.Click += (s, e) => { #if __ANDROID__ if (MatterControlApplication.Instance.IsNetworkConnected() && AuthenticationData.Instance.IsConnected) { UiThread.RunOnIdle(ApplicationController.Instance.StartSignIn); } else { WizardWindow.Show <NetworkTroubleshooting>("/networktroubleshooting", "Network Troubleshooting"); } #else UiThread.RunOnIdle(ApplicationController.Instance.StartSignIn); #endif }; buttonContainer.AddChild(signInButton); signOutButton = textImageButtonFactory.Generate("Sign Out".Localize()); signOutButton.Margin = new BorderDouble(left: 0); signOutButton.VAnchor = VAnchor.ParentCenter; signOutButton.Visible = signedIn; signOutButton.Click += (s, e) => UiThread.RunOnIdle(ApplicationController.Instance.StartSignOut); buttonContainer.AddChild(signOutButton); buttonContainer.AddChild(new HorizontalSpacer()); // the redeem design code button textImageButtonFactory.disabledTextColor = new RGBA_Bytes(textImageButtonFactory.normalTextColor, 100); Button redeemPurchaseButton = textImageButtonFactory.Generate("Redeem Purchase".Localize()); redeemPurchaseButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it. redeemPurchaseButton.Name = "Redeem Code Button"; redeemPurchaseButton.Margin = new BorderDouble(0, 0, 10, 0); redeemPurchaseButton.Click += (sender, e) => { ApplicationController.Instance.RedeemDesignCode?.Invoke(); }; buttonContainer.AddChild(redeemPurchaseButton); // the redeem a share code button Button redeemShareButton = textImageButtonFactory.Generate("Enter Share Code".Localize()); redeemShareButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it. redeemShareButton.Name = "Enter Share Code"; redeemShareButton.Margin = new BorderDouble(0, 0, 10, 0); redeemShareButton.Click += (sender, e) => { ApplicationController.Instance.EnterShareCode?.Invoke(); }; if (!signedIn) { redeemPurchaseButton.Enabled = false; redeemShareButton.Enabled = false; } buttonContainer.AddChild(redeemShareButton); statusMessage = new TextWidget("Please wait...", pointSize: 12, textColor: ActiveTheme.Instance.SecondaryAccentColor); statusMessage.Visible = false; buttonContainer.AddChild(statusMessage); mainContainer.AddChild(buttonContainer); ApplicationController.Instance.DoneReloadingAll.RegisterEvent(RemoveAndNewControl, ref unregisterEvents); }
public override void OnDraw(Graphics2D graphics2D) { totalDrawTime.Restart(); GuiWidget.DrawCount = 0; using (new PerformanceTimer("Draw Timer", "MC Draw")) { base.OnDraw(graphics2D); } totalDrawTime.Stop(); millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds); if (ShowMemoryUsed) { long memory = GC.GetTotalMemory(false); this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, widgetsDrawn = {7}".FormatWith(memory, millisecondTimer.GetAverage(), drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount); if (DoCGCollectEveryDraw) { GC.Collect(); } } if (firstDraw) { firstDraw = false; foreach (string arg in commandLineArgs) { string argExtension = Path.GetExtension(arg).ToUpper(); if (argExtension.Length > 1 && MeshFileIo.ValidFileExtensions().Contains(argExtension)) { QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg)))); } } TerminalWindow.ShowIfLeftOpen(); #if false { SystemWindow releaseNotes = new SystemWindow(640, 480); string releaseNotesFile = Path.Combine("C:/Users/LarsBrubaker/Downloads", "test1.html"); string releaseNotesContent = StaticData.Instance.ReadAllText(releaseNotesFile); HtmlWidget content = new HtmlWidget(releaseNotesContent, RGBA_Bytes.Black); content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop)); content.VAnchor |= VAnchor.ParentTop; content.BackgroundColor = RGBA_Bytes.White; releaseNotes.AddChild(content); releaseNotes.BackgroundColor = RGBA_Bytes.Cyan; UiThread.RunOnIdle((state) => { releaseNotes.ShowAsSystemWindow(); }, 1); } #endif AfterFirstDraw?.Invoke(); if (false && UserSettings.Instance.get("SoftwareLicenseAccepted") != "true") { UiThread.RunOnIdle(() => WizardWindow.Show <LicenseAgreementPage>("SoftwareLicense", "Software License Agreement")); } if (!ProfileManager.Instance.ActiveProfiles.Any()) { // Start the setup wizard if no profiles exist UiThread.RunOnIdle(() => WizardWindow.Show()); } } //msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds); //msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D); }