private void AddGeneralPannel(GuiWidget settingsColumn) { var generalPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var configureIcon = StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(theme.TextColor); var generalSection = new SectionWidget("General".Localize(), generalPanel, theme, expandingContent: false) { Name = "General Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; settingsColumn.AddChild(generalSection); theme.ApplyBoxStyle(generalSection); #if __ANDROID__ // Camera Monitoring bool hasCamera = true || ApplicationSettings.Instance.get(ApplicationSettingsKey.HardwareHasCamera) == "true"; var previewButton = new IconButton(configureIcon, theme) { ToolTipText = "Preview".Localize() }; previewButton.Click += (s, e) => { AppContext.Platform.OpenCameraPreview(); }; var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault(); // TODO: Sort out how handle this better on Android and in a multi-printer setup if (printer != null) { this.AddSettingsRow( new SettingsItem( "Camera Monitoring".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = printer.Settings.GetValue <bool>(SettingsKey.publish_bed_image), ToggleAction = (itemChecked) => { printer.Settings.SetValue(SettingsKey.publish_bed_image, itemChecked ? "1" : "0"); } }, previewButton, StaticData.Instance.LoadIcon("camera-24x24.png", 24, 24)) { Enabled = printer.Settings.PrinterSelected }, generalPanel ); } #endif // Print Notifications var configureNotificationsButton = new IconButton(configureIcon, theme) { Name = "Configure Notification Settings Button", ToolTipText = "Configure Notifications".Localize(), Margin = new BorderDouble(left: 6), VAnchor = VAnchor.Center }; configureNotificationsButton.Click += (s, e) => { if (ApplicationController.ChangeToPrintNotification != null) { UiThread.RunOnIdle(() => { ApplicationController.ChangeToPrintNotification(this.DialogWindow); }); } }; this.AddSettingsRow( new SettingsItem( "Notifications".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.PrintNotificationsEnabled) == "true", ToggleAction = (itemChecked) => { UserSettings.Instance.set(UserSettingsKey.PrintNotificationsEnabled, itemChecked ? "true" : "false"); } }, configureNotificationsButton, StaticData.Instance.LoadIcon("notify-24x24.png", 16, 16).SetToColor(theme.TextColor)), generalPanel); // LanguageControl var languageSelector = new LanguageSelector(theme); languageSelector.SelectionChanged += (s, e) => { UiThread.RunOnIdle(() => { string languageCode = languageSelector.SelectedValue; if (languageCode != UserSettings.Instance.get(UserSettingsKey.Language)) { UserSettings.Instance.set(UserSettingsKey.Language, languageCode); if (languageCode == "L10N") { #if DEBUG AppContext.Platform.GenerateLocalizationValidationFile(); #endif } ApplicationController.Instance.ResetTranslationMap(); ApplicationController.Instance.ReloadAll().ConfigureAwait(false); } }); }; this.AddSettingsRow(new SettingsItem("Language".Localize(), languageSelector, theme), generalPanel); #if !__ANDROID__ // ThumbnailRendering var thumbnailsModeDropList = new MHDropDownList("", theme, maxHeight: 200 * GuiWidget.DeviceScale); thumbnailsModeDropList.AddItem("Flat".Localize(), "orthographic"); thumbnailsModeDropList.AddItem("3D".Localize(), "raytraced"); thumbnailsModeDropList.SelectedValue = UserSettings.Instance.ThumbnailRenderingMode; thumbnailsModeDropList.SelectionChanged += (s, e) => { string thumbnailRenderingMode = thumbnailsModeDropList.SelectedValue; if (thumbnailRenderingMode != UserSettings.Instance.ThumbnailRenderingMode) { UserSettings.Instance.ThumbnailRenderingMode = thumbnailRenderingMode; UiThread.RunOnIdle(() => { // Ask if the user they would like to rebuild their thumbnails StyledMessageBox.ShowMessageBox( (bool rebuildThumbnails) => { if (rebuildThumbnails) { string[] thumbnails = new string[] { ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Content"), ""), ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Library"), "") }; foreach (var directoryToRemove in thumbnails) { try { if (Directory.Exists(directoryToRemove)) { Directory.Delete(directoryToRemove, true); } } catch (Exception) { GuiWidget.BreakInDebugger(); } Directory.CreateDirectory(directoryToRemove); } ApplicationController.Instance.Library.NotifyContainerChanged(); } }, "You are switching to a different thumbnail rendering mode. If you want, your current thumbnails can be removed and recreated in the new style. You can switch back and forth at any time. There will be some processing overhead while the new thumbnails are created.\n\nDo you want to rebuild your existing thumbnails now?".Localize(), "Rebuild Thumbnails Now".Localize(), StyledMessageBox.MessageType.YES_NO, "Rebuild".Localize()); }); } }; this.AddSettingsRow( new SettingsItem( "Thumbnails".Localize(), thumbnailsModeDropList, theme), generalPanel); #endif // TextSize if (!double.TryParse(UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize), out double currentTextSize)) { currentTextSize = 1.0; } double sliderThumbWidth = 10 * GuiWidget.DeviceScale; double sliderWidth = 100 * GuiWidget.DeviceScale; var textSizeSlider = new SolidSlider(default(Vector2), sliderThumbWidth, theme, .7, 2.5) { Name = "Text Size Slider", Margin = new BorderDouble(5, 0), Value = currentTextSize, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Center, TotalWidthInPixels = sliderWidth, }; theme.ApplySliderStyle(textSizeSlider); var optionalContainer = new FlowLayoutWidget() { VAnchor = VAnchor.Center | VAnchor.Fit, HAnchor = HAnchor.Fit }; TextWidget sectionLabel = null; var textSizeApplyButton = new TextButton("Apply".Localize(), theme) { VAnchor = VAnchor.Center, BackgroundColor = theme.SlightShade, Visible = false, Margin = new BorderDouble(right: 6) }; textSizeApplyButton.Click += (s, e) => UiThread.RunOnIdle(() => { GuiWidget.DeviceScale = textSizeSlider.Value; ApplicationController.Instance.ReloadAll().ConfigureAwait(false); }); optionalContainer.AddChild(textSizeApplyButton); textSizeSlider.ValueChanged += (s, e) => { double textSizeNew = textSizeSlider.Value; UserSettings.Instance.set(UserSettingsKey.ApplicationTextSize, textSizeNew.ToString("0.0")); sectionLabel.Text = "Text Size".Localize() + $" : {textSizeNew:0.0}"; textSizeApplyButton.Visible = textSizeNew != currentTextSize; }; var textSizeRow = new SettingsItem( "Text Size".Localize() + $" : {currentTextSize:0.0}", textSizeSlider, theme, optionalContainer); sectionLabel = textSizeRow.Children <TextWidget>().FirstOrDefault(); this.AddSettingsRow(textSizeRow, generalPanel); var themeSection = CreateThemePanel(theme); settingsColumn.AddChild(themeSection); theme.ApplyBoxStyle(themeSection); }
public CheckForUpdatesPage() : base("Close".Localize()) { this.WindowTitle = this.HeaderText = "Check for Update".Localize(); this.Padding = 0; this.AnchorAll(); // Clear padding so UpdateControlView toolbar appears like toolbar contentRow.Padding = 0; // Update Status Widget contentRow.AddChild( new UpdateControlView(theme)); var contentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Padding = 8 }; contentRow.AddChild(contentPanel); var currentBuildInfo = new TextWidget("Current Build".Localize() + $" : {VersionInfo.Instance.BuildVersion}") { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(left: 5, bottom: 15, top: 20), TextColor = theme.TextColor }; contentPanel.AddChild(currentBuildInfo); var currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight) { VAnchor = VAnchor.Fit, HAnchor = HAnchor.Stretch, }; contentPanel.AddChild(currentFeedAndDropDownContainer); var feedLabel = new TextWidget("Update Channel".Localize(), pointSize: 12) { TextColor = theme.TextColor, VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 5) }; currentFeedAndDropDownContainer.AddChild(feedLabel); FlowLayoutWidget additionalInfoContainer = null; var whatsThisLink = new LinkLabel("What's this?".Localize(), theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 6), }; whatsThisLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (!additionalInfoContainer.Visible) { additionalInfoContainer.Visible = true; } else { additionalInfoContainer.Visible = false; } }); }; currentFeedAndDropDownContainer.AddChild(whatsThisLink); currentFeedAndDropDownContainer.AddChild(new HorizontalSpacer()); var acceptableUpdateFeedTypeValues = new List <string>() { "release", "pre-release", "development" }; string currentUpdateFeedType = UserSettings.Instance.get(UserSettingsKey.UpdateFeedType); if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1) { UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, "release"); } var releaseOptionsDropList = new MHDropDownList("Development", theme, maxHeight: 200) { HAnchor = HAnchor.Fit, }; releaseOptionsDropList.AddItem("Stable".Localize(), "release"); releaseOptionsDropList.AddItem("Beta".Localize(), "pre-release"); releaseOptionsDropList.AddItem("Alpha".Localize(), "development"); releaseOptionsDropList.SelectedValue = currentUpdateFeedType; releaseOptionsDropList.SelectionChanged += (s, e) => { string releaseCode = releaseOptionsDropList.SelectedValue; if (releaseCode != UserSettings.Instance.get(UserSettingsKey.UpdateFeedType)) { UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, releaseCode); } UpdateControlData.Instance.CheckForUpdate(); }; currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList); additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { BackgroundColor = theme.MinimalShade, HAnchor = HAnchor.Stretch, Padding = new BorderDouble(left: 6, top: 6), Visible = false }; additionalInfoContainer.AddChild( new WrappedTextWidget("Changing your update channel will change the version of MatterControl that you receive when updating".Localize() + ":") { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 20) }); additionalInfoContainer.AddChild( new WrappedTextWidget("Stable: The current release version of MatterControl (recommended)".Localize()) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 10) }); additionalInfoContainer.AddChild( new WrappedTextWidget("Beta: The release candidate version of MatterControl".Localize()) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 10) }); additionalInfoContainer.AddChild( new WrappedTextWidget("Alpha: The in development version of MatterControl".Localize()) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 10) }); contentPanel.AddChild(additionalInfoContainer); }
public ApplicationSettingsPage() : base("Close".Localize()) { this.AlwaysOnTopOfMain = true; this.WindowTitle = this.HeaderText = "MatterControl " + "Settings".Localize(); this.WindowSize = new Vector2(700 * GuiWidget.DeviceScale, 600 * GuiWidget.DeviceScale); contentRow.Padding = theme.DefaultContainerPadding; contentRow.Padding = 0; contentRow.BackgroundColor = Color.Transparent; var generalPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var configureIcon = AggContext.StaticData.LoadIcon("fa-cog_16.png", 16, 16, theme.InvertIcons); var generalSection = new SectionWidget("General".Localize(), generalPanel, theme, expandingContent: false) { Name = "General Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; contentRow.AddChild(generalSection); theme.ApplyBoxStyle(generalSection); #if __ANDROID__ // Camera Monitoring bool hasCamera = true || ApplicationSettings.Instance.get(ApplicationSettingsKey.HardwareHasCamera) == "true"; var previewButton = new IconButton(configureIcon, theme) { ToolTipText = "Preview".Localize() }; previewButton.Click += (s, e) => { AppContext.Platform.OpenCameraPreview(); }; var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault() ?? PrinterConfig.EmptyPrinter; this.AddSettingsRow( new SettingsItem( "Camera Monitoring".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = printer.Settings.GetValue <bool>(SettingsKey.publish_bed_image), ToggleAction = (itemChecked) => { printer.Settings.SetValue(SettingsKey.publish_bed_image, itemChecked ? "1" : "0"); } }, previewButton, AggContext.StaticData.LoadIcon("camera-24x24.png", 24, 24)) { Enabled = printer.Settings.PrinterSelected }, generalPanel ); #endif // Print Notifications var configureNotificationsButton = new IconButton(configureIcon, theme) { Name = "Configure Notification Settings Button", ToolTipText = "Configure Notifications".Localize(), Margin = new BorderDouble(left: 6), VAnchor = VAnchor.Center }; configureNotificationsButton.Click += (s, e) => { if (ApplicationController.ChangeToPrintNotification != null) { UiThread.RunOnIdle(() => { ApplicationController.ChangeToPrintNotification(this.DialogWindow); }); } }; this.AddSettingsRow( new SettingsItem( "Notifications".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.PrintNotificationsEnabled) == "true", ToggleAction = (itemChecked) => { UserSettings.Instance.set(UserSettingsKey.PrintNotificationsEnabled, itemChecked ? "true" : "false"); } }, configureNotificationsButton, AggContext.StaticData.LoadIcon("notify-24x24.png", 16, 16, theme.InvertIcons)), generalPanel); // LanguageControl var languageSelector = new LanguageSelector(theme); languageSelector.SelectionChanged += (s, e) => { UiThread.RunOnIdle(() => { string languageCode = languageSelector.SelectedValue; if (languageCode != UserSettings.Instance.get(UserSettingsKey.Language)) { UserSettings.Instance.set(UserSettingsKey.Language, languageCode); if (languageCode == "L10N") { #if DEBUG AppContext.Platform.GenerateLocalizationValidationFile(); #endif } ApplicationController.Instance.ResetTranslationMap(); ApplicationController.Instance.ReloadAll().ConfigureAwait(false); } }); }; this.AddSettingsRow(new SettingsItem("Language".Localize(), languageSelector, theme), generalPanel); #if !__ANDROID__ // ThumbnailRendering var thumbnailsModeDropList = new MHDropDownList("", theme, maxHeight: 200); thumbnailsModeDropList.AddItem("Flat".Localize(), "orthographic"); thumbnailsModeDropList.AddItem("3D".Localize(), "raytraced"); thumbnailsModeDropList.SelectedValue = UserSettings.Instance.ThumbnailRenderingMode; thumbnailsModeDropList.SelectionChanged += (s, e) => { string thumbnailRenderingMode = thumbnailsModeDropList.SelectedValue; if (thumbnailRenderingMode != UserSettings.Instance.ThumbnailRenderingMode) { UserSettings.Instance.ThumbnailRenderingMode = thumbnailRenderingMode; UiThread.RunOnIdle(() => { // Ask if the user they would like to rebuild their thumbnails StyledMessageBox.ShowMessageBox( (bool rebuildThumbnails) => { if (rebuildThumbnails) { string[] thumbnails = new string[] { ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Content"), ""), ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Library"), "") }; foreach (var directoryToRemove in thumbnails) { try { if (Directory.Exists(directoryToRemove)) { Directory.Delete(directoryToRemove, true); } } catch (Exception) { GuiWidget.BreakInDebugger(); } Directory.CreateDirectory(directoryToRemove); } ApplicationController.Instance.Library.NotifyContainerChanged(); } }, "You are switching to a different thumbnail rendering mode. If you want, your current thumbnails can be removed and recreated in the new style. You can switch back and forth at any time. There will be some processing overhead while the new thumbnails are created.\n\nDo you want to rebuild your existing thumbnails now?".Localize(), "Rebuild Thumbnails Now".Localize(), StyledMessageBox.MessageType.YES_NO, "Rebuild".Localize()); }); } }; this.AddSettingsRow( new SettingsItem( "Thumbnails".Localize(), thumbnailsModeDropList, theme), generalPanel); #endif // TextSize if (!double.TryParse(UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize), out double currentTextSize)) { currentTextSize = 1.0; } double sliderThumbWidth = 10 * GuiWidget.DeviceScale; double sliderWidth = 100 * GuiWidget.DeviceScale; var textSizeSlider = new SolidSlider(new Vector2(), sliderThumbWidth, theme, .7, 1.4) { Name = "Text Size Slider", Margin = new BorderDouble(5, 0), Value = currentTextSize, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Center, TotalWidthInPixels = sliderWidth, }; theme.ApplySliderStyle(textSizeSlider); var optionalContainer = new FlowLayoutWidget() { VAnchor = VAnchor.Center | VAnchor.Fit, HAnchor = HAnchor.Fit }; TextWidget sectionLabel = null; var textSizeApplyButton = new TextButton("Apply".Localize(), theme) { VAnchor = VAnchor.Center, BackgroundColor = theme.SlightShade, Visible = false, Margin = new BorderDouble(right: 6) }; textSizeApplyButton.Click += (s, e) => UiThread.RunOnIdle(() => { GuiWidget.DeviceScale = textSizeSlider.Value; ApplicationController.Instance.ReloadAll().ConfigureAwait(false); }); optionalContainer.AddChild(textSizeApplyButton); textSizeSlider.ValueChanged += (s, e) => { double textSizeNew = textSizeSlider.Value; UserSettings.Instance.set(UserSettingsKey.ApplicationTextSize, textSizeNew.ToString("0.0")); sectionLabel.Text = "Text Size".Localize() + $" : {textSizeNew:0.0}"; textSizeApplyButton.Visible = textSizeNew != currentTextSize; }; var textSizeRow = new SettingsItem( "Text Size".Localize() + $" : {currentTextSize:0.0}", textSizeSlider, theme, optionalContainer); sectionLabel = textSizeRow.Children <TextWidget>().FirstOrDefault(); this.AddSettingsRow(textSizeRow, generalPanel); var themeSection = CreateThemePanel(theme); contentRow.AddChild(themeSection); theme.ApplyBoxStyle(themeSection); var advancedPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); var advancedSection = new SectionWidget("Advanced".Localize(), advancedPanel, theme, serializationKey: "ApplicationSettings-Advanced", expanded: false) { Name = "Advanced Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = 0 }; contentRow.AddChild(advancedSection); theme.ApplyBoxStyle(advancedSection); // Touch Screen Mode this.AddSettingsRow( new SettingsItem( "Touch Screen Mode".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode) == "touchscreen", ToggleAction = (itemChecked) => { string displayMode = itemChecked ? "touchscreen" : "responsive"; if (displayMode != UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode)) { UserSettings.Instance.set(UserSettingsKey.ApplicationDisplayMode, displayMode); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); } } }), advancedPanel); var openCacheButton = new IconButton(AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Open Folder".Localize(), }; openCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { Process.Start(ApplicationDataStorage.ApplicationUserDataPath); }); this.AddSettingsRow( new SettingsItem( "Application Storage".Localize(), openCacheButton, theme), advancedPanel); var clearCacheButton = new HoverIconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Clear Cache".Localize(), }; clearCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { CacheDirectory.DeleteCacheData(); }); this.AddSettingsRow( new SettingsItem( "Application Cache".Localize(), clearCacheButton, theme), advancedPanel); #if DEBUG var configurePluginsButton = new IconButton(configureIcon, theme) { ToolTipText = "Configure Plugins".Localize(), Margin = 0 }; configurePluginsButton.Click += (s, e) => { UiThread.RunOnIdle(() => { DialogWindow.Show <PluginsPage>(); }); }; this.AddSettingsRow( new SettingsItem( "Plugins".Localize(), configurePluginsButton, theme), advancedPanel); #endif advancedPanel.Children <SettingsItem>().First().Border = new BorderDouble(0, 1); // Enforce consistent SectionWidget spacing and last child borders foreach (var section in contentRow.Children <SectionWidget>()) { section.Margin = new BorderDouble(0, 10, 0, 0); if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) { // If we're in a contentPanel that has SettingsItems... // Clear the last items bottom border lastRow.Border = lastRow.Border.Clone(bottom: 0); // Set a common margin on the parent container section.ContentPanel.Margin = new BorderDouble(2, 0); } } }