public void BoundDropListHonorsWhitelist() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); var manufacturers = new string[] { "3D Factory", "3D Stuffmaker", "Airwolf 3D", "BCN", "BeeVeryCreative", "Blue Eagle Labs", "Deezmaker", "FlashForge", "gCreate", "IRA3D", "JumpStart", "Leapfrog", "Lulzbot", "MAKEiT", "Maker's Tool Works", "MakerBot", "MakerGear", "Me3D", "OpenBeam", "Organic Thinking System", "Other", "Portabee", "Printrbot", "PrintSpace", "Revolution 3D Printers", "ROBO 3D", "SeeMeCNC", "Solidoodle", "Tosingraf", "Type A Machines", "Ultimaker", "Velleman", "Wanhao" }; var allManufacturers = manufacturers.Select(m => new KeyValuePair <string, string>(m, m)).ToList(); BoundDropList dropList; var theme = new ThemeConfig(); // Whitelist on non-OEM builds should contain all printers dropList = new BoundDropList("Test", theme); dropList.ListSource = allManufacturers; Assert.Greater(dropList.MenuItems.Count, 20); var whitelist = new List <string> { "3D Stuffmaker" }; OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(1, dropList.MenuItems.Count); whitelist.Add("Airwolf 3D"); OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(2, dropList.MenuItems.Count); }
public void PrinterChooserHonorsWhitelist() { AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); var manufacturers = new string[] { "3D Factory", "3D Stuffmaker", "Airwolf 3D", "BCN", "BeeVeryCreative", "Blue Eagle Labs", "Deezmaker", "FlashForge", "gCreate", "IRA3D", "JumpStart", "Leapfrog", "Lulzbot", "MAKEiT", "Maker's Tool Works", "MakerBot", "MakerGear", "Me3D", "OpenBeam", "Organic Thinking System", "Other", "Portabee", "Printrbot", "PrintSpace", "Revolution 3D Printers", "ROBO 3D", "SeeMeCNC", "Solidoodle", "Tosingraf", "Type A Machines", "Ultimaker", "Velleman", "Wanhao" }; var allManufacturers = manufacturers.Select(m => new KeyValuePair <string, string>(m, m)).ToList(); BoundDropList dropList; var theme = new ThemeConfig() { Colors = ActiveTheme.Instance }; // Whitelist on non-OEM builds should contain all printers dropList = new BoundDropList("Test", theme); dropList.ListSource = allManufacturers; Assert.Greater(dropList.MenuItems.Count, 20); var whitelist = new List <string> { "3D Stuffmaker" }; OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(1, dropList.MenuItems.Count); whitelist.Add("Airwolf 3D"); OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(2, dropList.MenuItems.Count); /* * Disable Esagono tests * * SetPrivatePrinterWhiteListMember(new List<string>() { "Esagono" }); * var manufacturerNameMapping = new ManufacturerNameMapping(); * manufacturerNameMapping.NameOnDisk = "Esagono"; * manufacturerNameMapping.NameToDisplay = "Esagonò"; * printChooser = new PrinterChooser(); * * string expectedItem = null; * foreach (var menuItem in printChooser.ManufacturerDropList.MenuItems) * { * if(menuItem.Text.StartsWith("Esa")) * { * expectedItem = menuItem.Text; * } * } * Assert.IsTrue(!string.IsNullOrEmpty(expectedItem) && expectedItem == "Esagonò"); */ }
public SetupStepMakeModelName() { printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), maxHeight: 200) { HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, Name = "Select Make", ListSource = OemSettings.Instance.AllOems, TabStop = true }; printerManufacturerSelector.SelectionChanged += ManufacturerDropList_SelectionChanged; printerMakeContainer = CreateSelectionContainer( "Make".Localize() + ":", "Select the printer manufacturer".Localize(), printerManufacturerSelector); printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, TabStop = true }; printerModelSelector.SelectionChanged += ModelDropList_SelectionChanged; printerModelContainer = CreateSelectionContainer("Model".Localize() + ":", "Select the printer model".Localize(), printerModelSelector); //Add inputs to main container contentRow.AddChild(printerMakeContainer); contentRow.AddChild(printerModelContainer); contentRow.AddChild(createPrinterNameContainer()); //Construct buttons nextButton = textImageButtonFactory.Generate("Save & Continue".Localize()); nextButton.Name = "Save & Continue Button"; nextButton.Click += async (s, e) => { bool controlsValid = this.ValidateControls(); if (controlsValid) { bool profileCreated = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName); if(!profileCreated) { this.printerNameError.Text = "Error creating profile".Localize(); this.printerNameError.Visible = true; return; } LoadCalibrationPrints(); #if __ANDROID__ UiThread.RunOnIdle(WizardWindow.ChangeToPage<AndroidConnectDevicePage>); #else if (OsInformation.OperatingSystem == OSType.Windows) { UiThread.RunOnIdle(WizardWindow.ChangeToPage<SetupStepInstallDriver>); } else { UiThread.RunOnIdle(WizardWindow.ChangeToPage<SetupStepComPortOne>); } #endif } }; //Add buttons to buttonContainer footerRow.AddChild(nextButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); usingDefaultName = true; if (printerManufacturerSelector.MenuItems.Count == 1) { printerManufacturerSelector.SelectedIndex = 0; } SetElementVisibility(); }
public SetupStepMakeModelName() { printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), maxHeight: 200) { HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, Name = "Select Make", ListSource = OemSettings.Instance.AllOems, TabStop = true }; printerManufacturerSelector.SelectionChanged += ManufacturerDropList_SelectionChanged; printerMakeContainer = CreateSelectionContainer( "Make".Localize() + ":", "Select the printer manufacturer".Localize(), printerManufacturerSelector); printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, TabStop = true }; printerModelSelector.SelectionChanged += ModelDropList_SelectionChanged; printerModelContainer = CreateSelectionContainer("Model".Localize() + ":", "Select the printer model".Localize(), printerModelSelector); //Add inputs to main container contentRow.AddChild(printerMakeContainer); contentRow.AddChild(printerModelContainer); contentRow.AddChild(createPrinterNameContainer()); //Construct buttons nextButton = textImageButtonFactory.Generate("Save & Continue".Localize()); nextButton.Name = "Save & Continue Button"; nextButton.Click += async(s, e) => { bool controlsValid = this.ValidateControls(); if (controlsValid) { bool profileCreated = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName); if (!profileCreated) { this.printerNameError.Text = "Error creating profile".Localize(); this.printerNameError.Visible = true; return; } LoadCalibrationPrints(); #if __ANDROID__ UiThread.RunOnIdle(WizardWindow.ChangeToPage <AndroidConnectDevicePage>); #else if (OsInformation.OperatingSystem == OSType.Windows) { UiThread.RunOnIdle(WizardWindow.ChangeToPage <SetupStepInstallDriver>); } else { UiThread.RunOnIdle(WizardWindow.ChangeToPage <SetupStepComPortOne>); } #endif } }; //Add buttons to buttonContainer footerRow.AddChild(nextButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); usingDefaultName = true; if (printerManufacturerSelector.MenuItems.Count == 1) { printerManufacturerSelector.SelectedIndex = 0; } SetElementVisibility(); }
public SetupStepMakeModelName() { bool userIsLoggedIn = !ApplicationController.GuestUserActive?.Invoke() ?? false; this.HeaderText = this.WindowTitle = "Printer Setup".Localize(); var addPrinterColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), theme, maxHeight: 200) { HAnchor = HAnchor.Stretch, Margin = elementMargin, Name = "Select Make", ListSource = OemSettings.Instance.AllOems, TabStop = true }; printerManufacturerSelector.SelectionChanged += ManufacturerDropList_SelectionChanged; printerMakeContainer = CreateSelectionContainer( "Make".Localize() + ":", "Select the printer manufacturer".Localize(), printerManufacturerSelector); printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), theme, maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.Stretch, Margin = elementMargin, TabStop = true }; printerModelSelector.SelectionChanged += ModelDropList_SelectionChanged; printerModelContainer = CreateSelectionContainer( "Model".Localize() + ":", "Select the printer model".Localize(), printerModelSelector); //Add inputs to main container addPrinterColumn.AddChild(printerMakeContainer); addPrinterColumn.AddChild(printerModelContainer); addPrinterColumn.AddChild(createPrinterNameContainer()); RadioButton signInRadioButton = null; if (userIsLoggedIn) { contentRow.AddChild(addPrinterColumn); } else { contentRow.Padding = 10; addPrinterColumn.Margin = new BorderDouble(28, 15, 15, 5); var commonMargin = new BorderDouble(4, 2); // Create export button for each plugin signInRadioButton = new RadioButton(new RadioButtonViewText("Sign in to access your existing printers".Localize(), theme.Colors.PrimaryTextColor)) { HAnchor = HAnchor.Left, Margin = commonMargin.Clone(bottom: 10), Cursor = Cursors.Hand, Name = "Sign In Radio Button", }; contentRow.AddChild(signInRadioButton); createPrinterRadioButton = new RadioButton(new RadioButtonViewText("Create a new printer", theme.Colors.PrimaryTextColor)) { HAnchor = HAnchor.Left, Margin = commonMargin, Cursor = Cursors.Hand, Name = "Create Printer Radio Button", Checked = true }; contentRow.AddChild(createPrinterRadioButton); createPrinterRadioButton.CheckedStateChanged += (s, e) => { addPrinterColumn.Enabled = createPrinterRadioButton.Checked; this.SetElementVisibility(); }; contentRow.AddChild(addPrinterColumn); } nextButton = theme.CreateDialogButton("Next".Localize()); nextButton.Name = "Next Button"; nextButton.Click += (s, e) => UiThread.RunOnIdle(async() => { if (signInRadioButton?.Checked == true) { var authContext = new AuthenticationContext(); authContext.SignInComplete += (s2, e2) => { this.DialogWindow.ChangeToPage(new SelectPrinterPage("Finish".Localize())); }; this.DialogWindow.ChangeToPage(ApplicationController.GetAuthPage(authContext)); } else { bool controlsValid = this.ValidateControls(); if (controlsValid) { var printer = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName); if (printer == null) { this.printerNameError.Text = "Error creating profile".Localize(); this.printerNameError.Visible = true; return; } this.LoadCalibrationPrints(); #if __ANDROID__ UiThread.RunOnIdle(() => DialogWindow.ChangeToPage <AndroidConnectDevicePage>()); #else UiThread.RunOnIdle(() => { DialogWindow.ChangeToPage(new SetupStepComPortOne(printer)); }); #endif } } }); this.AddPageAction(nextButton); usingDefaultName = true; if (printerManufacturerSelector.MenuItems.Count == 1) { printerManufacturerSelector.SelectedIndex = 0; } SetElementVisibility(); }
public SetupStepMakeModelName() { this.WindowTitle = "Setup Wizard".Localize(); printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), theme, maxHeight: 200) { HAnchor = HAnchor.Stretch, Margin = elementMargin, Name = "Select Make", ListSource = OemSettings.Instance.AllOems, TabStop = true }; printerManufacturerSelector.SelectionChanged += ManufacturerDropList_SelectionChanged; printerMakeContainer = CreateSelectionContainer( "Make".Localize() + ":", "Select the printer manufacturer".Localize(), printerManufacturerSelector); printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), theme, maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.Stretch, Margin = elementMargin, TabStop = true }; printerModelSelector.SelectionChanged += ModelDropList_SelectionChanged; printerModelContainer = CreateSelectionContainer("Model".Localize() + ":", "Select the printer model".Localize(), printerModelSelector); //Add inputs to main container contentRow.AddChild(printerMakeContainer); contentRow.AddChild(printerModelContainer); contentRow.AddChild(createPrinterNameContainer()); //Construct buttons nextButton = theme.CreateDialogButton("Next".Localize()); nextButton.Name = "Save & Continue Button"; nextButton.Click += async(s, e) => { bool controlsValid = this.ValidateControls(); if (controlsValid) { var printer = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName); if (printer == null) { this.printerNameError.Text = "Error creating profile".Localize(); this.printerNameError.Visible = true; return; } LoadCalibrationPrints(); #if __ANDROID__ UiThread.RunOnIdle(() => DialogWindow.ChangeToPage <AndroidConnectDevicePage>()); #else UiThread.RunOnIdle(() => { DialogWindow.ChangeToPage(new SetupStepComPortOne(printer)); }); #endif } }; this.AddPageAction(nextButton); usingDefaultName = true; if (printerManufacturerSelector.MenuItems.Count == 1) { printerManufacturerSelector.SelectedIndex = 0; } SetElementVisibility(); }
public SetupStepMakeModelName() { printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), maxHeight: 200) { HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, Name = "Select Make", ListSource = OemSettings.Instance.AllOems }; printerManufacturerSelector.SelectionChanged += ManufacturerDropList_SelectionChanged; printerMakeContainer = CreateSelectionContainer( "Make".Localize() + ":", "Select the printer manufacturer".Localize(), printerManufacturerSelector); if (printerManufacturerSelector.MenuItems.Count == 1) { ActivePrinter.Make = printerManufacturerSelector.SelectedValue; } printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.ParentLeftRight, Margin = elementMargin, }; printerModelSelector.SelectionChanged += ModelDropList_SelectionChanged; if (printerModelSelector.MenuItems.Count == 1) { // SelectIfOnlyOneModel printerModelSelector.SelectedIndex = 0; } printerModelContainer = CreateSelectionContainer("Model".Localize(), "Select the printer model".Localize(), printerModelSelector); //Add inputs to main container contentRow.AddChild(printerMakeContainer); contentRow.AddChild(printerModelContainer); contentRow.AddChild(createPrinterNameContainer()); //Construct buttons nextButton = textImageButtonFactory.Generate("Save & Continue".Localize()); nextButton.Name = "Save & Continue Button"; nextButton.Click += (s, e) => { bool canContinue = this.OnSave(); if (canContinue) { #if __ANDROID__ WizardWindow.ChangeToPage <AndroidConnectDevicePage>(); #else WizardWindow.ChangeToPage <SetupStepInstallDriver>(); #endif } }; //Add buttons to buttonContainer footerRow.AddChild(nextButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); usingDefaultName = true; SetElementVisibility(); }