private void ItemSelectedCommandExecute (SettingsItem parameter) { Page page = null; switch (parameter) { case SettingsItem.About: page = new AboutPage (); break; case SettingsItem.ExportData: page = new ExportDataPage { BindingContext = new ExportDataViewModel () }; break; case SettingsItem.LockoutScreenConfig: page = new LockoutScreenConfigPage { BindingContext = new LockScreenConfigViewModel () }; break; case SettingsItem.ParticipantViewConfig: page = new ParticipantViewConfigPage { BindingContext = new ParticipantViewConfigViewModel () }; break; case SettingsItem.SetupBeacons: page = new SetupBeaconsPage { BindingContext = new SetupBeaconsViewModel () }; break; } App.Navigation.PushAsync (page); _isInSettings = true; }
public void AddItem(SettingsItem item) { settings.Add(item); item.Draw(itemPanel); }
public void Load(string fileName) { FileName = fileName; if (File.Exists(fileName)) { var contents = File.ReadAllText(fileName, Encoding.UTF8); var jObjectSettings = JArray.Parse(contents); Items.Clear(); SuspendAutoSave(); foreach (JObject jObjectSettingsItem in jObjectSettings) { try { var name = JObjectHelper.GetString(jObjectSettingsItem, "name", string.Empty); var type = JObjectHelper.GetString(jObjectSettingsItem, "type", string.Empty); object value = null; if (type == "string") { value = JObjectHelper.GetString(jObjectSettingsItem, "value", string.Empty); } else if (type == "integer") { value = JObjectHelper.GetInt32(jObjectSettingsItem, "value", 0); } else if (type == "double") { value = JObjectHelper.GetDecimal(jObjectSettingsItem, "value", 0); } else if (type == "boolean") { value = JObjectHelper.GetBoolean(jObjectSettingsItem, "value", false); } else if (type == "guid") { value = JObjectHelper.GetGuid(jObjectSettingsItem, "value", Guid.Empty); } else if (type == "point") { var x = JObjectHelper.GetInt32(jObjectSettingsItem, "x", 0); var y = JObjectHelper.GetInt32(jObjectSettingsItem, "y", 0); value = new Point(x, y); } else if (type == "size") { var width = JObjectHelper.GetInt32(jObjectSettingsItem, "width", 0); var height = JObjectHelper.GetInt32(jObjectSettingsItem, "height", 0); value = new Size(width, height); } else if (type == "datetime") { var valueStr = JObjectHelper.GetString(jObjectSettingsItem, "value", DateTime.UtcNow.ToString("o")); value = DateTime.Parse(valueStr); } else if (type == "version") { value = new Version(JObjectHelper.GetString(jObjectSettingsItem, "value")); } else if (type == "list:String") { value = new List <string>(); var jArrayStrings = (JArray)jObjectSettingsItem["value"]; foreach (string str in jArrayStrings) { ((List <string>)value).Add(str); } } var settingsItem = new SettingsItem(name); settingsItem.OnChange += settingsItem_OnChange; settingsItem.Value = value; Items.Add(settingsItem); } catch (Exception ex) { } } ResumeAutoSave(); } }
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 = "Configure Camera View".Localize() }; previewButton.Click += (s, e) => { AppContext.Platform.OpenCameraPreview(); }; var printer = ApplicationController.Instance.ActivePrinter; 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)), 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(); } }); }; 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) => { GuiWidget.DeviceScale = textSizeSlider.Value; ApplicationController.Instance.ReloadAll(); }; 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); ApplicationController.Instance.ReloadAll(); } } }), 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); 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); } } }
private GuiWidget GetPopupContent(ThemeConfig menuTheme) { var widget = new IgnoredPopupWidget() { Width = 300, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Fit, Padding = new BorderDouble(12, 0), BackgroundColor = menuTheme.BackgroundColor }; var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Top, }; widget.AddChild(container); GuiWidget hotendRow; container.AddChild(hotendRow = new SettingsItem( "Heated Bed".Localize(), menuTheme, new SettingsItem.ToggleSwitchConfig() { Checked = printer.Connection.TargetBedTemperature > 0, ToggleAction = (itemChecked) => { var goalTemp = itemChecked ? printer.Settings.GetValue <double>(SettingsKey.bed_temperature) : 0; printer.Connection.TargetBedTemperature = goalTemp; } }, enforceGutter: false)); var toggleWidget = hotendRow.Children.Where(o => o is ICheckbox).FirstOrDefault(); toggleWidget.Name = "Toggle Heater"; heatToggle = toggleWidget as ICheckbox; int tabIndex = 0; var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); var settingsData = PrinterSettings.SettingsData[SettingsKey.bed_temperature]; var temperatureRow = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, menuTheme, ref tabIndex, allUiFields); container.AddChild(temperatureRow); // Add the temperature row to the always enabled list ensuring the field can be set when disconnected alwaysEnabled.Add(temperatureRow); alwaysEnabled.Add(hotendRow); // add in the temp graph var graph = new DataViewGraph() { DynamicallyScaleRange = false, MinValue = 0, ShowGoal = true, GoalColor = menuTheme.PrimaryAccentColor, GoalValue = printer.Settings.GetValue <double>(SettingsKey.bed_temperature), MaxValue = 150, // could come from some profile value in the future Width = widget.Width - 20, Height = 35, // this works better if it is a common multiple of the Width Margin = new BorderDouble(0, 5, 0, 0), }; runningInterval = UiThread.SetInterval(() => { graph.AddData(this.ActualTemperature); }, 1); var settingsRow = temperatureRow.DescendantsAndSelf <SliceSettingsRow>().FirstOrDefault(); void Printer_SettingChanged(object s, StringEventArgs stringEvent) { if (stringEvent != null) { string settingsKey = stringEvent.Data; if (this.allUiFields.TryGetValue(settingsKey, out UIField uifield)) { string currentValue = settingsContext.GetValue(settingsKey); if (uifield.Value != currentValue) { uifield.SetValue( currentValue, userInitiated: false); } } if (stringEvent.Data == SettingsKey.bed_temperature) { var temp = printer.Settings.GetValue <double>(SettingsKey.bed_temperature); graph.GoalValue = temp; settingsRow.UpdateStyle(); } } } printer.Settings.SettingChanged += Printer_SettingChanged; printer.Disposed += (s, e) => printer.Settings.SettingChanged -= Printer_SettingChanged; container.AddChild(graph); return(widget); }
public SettingsItemControl(SettingsItem item) : this() { _item = item; UpdateState(_chkIsActive.Checked = item.IsActive); }
public gRPCDAL(SettingsItem settings) : base(settings) { }
private GuiWidget GetPopupContent(ThemeConfig theme) { var widget = new IgnoredPopupWidget() { Width = 300, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Fit, BackgroundColor = theme.Colors.PrimaryBackgroundColor, Padding = new BorderDouble(12, 0) }; var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Top, }; widget.AddChild(container); GuiWidget hotendRow; container.AddChild(hotendRow = new SettingsItem( "Heated Bed".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = false, ToggleAction = (itemChecked) => { var goalTemp = itemChecked ? printer.Settings.GetValue <double>(SettingsKey.bed_temperature) : 0; if (itemChecked) { SetTargetTemperature(goalTemp); } else { SetTargetTemperature(0); } } }, enforceGutter: false)); var toggleWidget = hotendRow.Children.Where(o => o is ICheckbox).FirstOrDefault(); toggleWidget.Name = "Toggle Heater"; heatToggle = toggleWidget as ICheckbox; int tabIndex = 0; var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); var settingsData = SettingsOrganizer.Instance.GetSettingsData(SettingsKey.bed_temperature); var temperatureRow = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex); SliceSettingsRow.AddBordersToEditFields(temperatureRow); container.AddChild(temperatureRow); alwaysEnabled.Add(hotendRow); // add in the temp graph var graph = new DataViewGraph() { DynamiclyScaleRange = false, MinValue = 0, ShowGoal = true, GoalColor = ActiveTheme.Instance.PrimaryAccentColor, GoalValue = printer.Settings.GetValue <double>(SettingsKey.bed_temperature), MaxValue = 150, // could come from some profile value in the future Width = widget.Width - 20, Height = 35, // this works better if it is a common multiple of the Width Margin = new BorderDouble(0, 5, 0, 0), }; var runningInterval = UiThread.SetInterval(() => { graph.AddData(this.ActualTemperature); }, 1); this.Closed += (s, e) => runningInterval.Continue = false; var valueField = temperatureRow.Descendants <MHNumberEdit>().FirstOrDefault(); var settingsRow = temperatureRow.DescendantsAndSelf <SliceSettingsRow>().FirstOrDefault(); PrinterSettings.SettingChanged.RegisterEvent((s, e) => { if (e is StringEventArgs stringEvent) { var temp = printer.Settings.GetValue <double>(SettingsKey.bed_temperature); valueField.Value = temp; graph.GoalValue = temp; settingsRow.UpdateStyle(); if (stringEvent.Data == SettingsKey.bed_temperature && heatToggle.Checked) { SetTargetTemperature(temp); } } ; }, ref unregisterEvents); container.AddChild(graph); return(widget); }
private void AddGeneralPannel(GuiWidget settingsColumn) { 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, }; 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, 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(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); }
// Abre el picker en el caso de que hagas click a la opción private void FocusPicker_OnClick(SettingsItem item, Picker picker) { picker.Focus(); }
// Crea una axes section private void CrearAxesSection() { // Elementos de la Section axesSection = new StackLayout(); axesTitleSection = new SettingsSectionTitle(); settingAxesSelect = new SettingsItem(TypeItemsGrid.Button); settingAxesVisible = new SettingsItem(TypeItemsGrid.Switch); settingAxesInverted = new SettingsItem(TypeItemsGrid.Switch); settingAxesGrid = new SettingsItem(TypeItemsGrid.Switch); pickerSelectAxes = new Picker(); switchVisibleAxes = new SettingsSwitchItem(); switchInvertedAxes = new SettingsSwitchItem(); switchGridAxes = new SettingsSwitchItem(); // Add Section settingsPanelComponent.AddChildren = axesSection; // Axes axesTitleSection.Text = "Axes"; axesSection.Children.Add(axesTitleSection); axesSection.Children.Add(settingAxesSelect); settingsPanelComponent.AddSeparation(axesSection, true); axesSection.Children.Add(settingAxesVisible); settingsPanelComponent.AddSeparation(axesSection, true); axesSection.Children.Add(settingAxesInverted); settingsPanelComponent.AddSeparation(axesSection, true); axesSection.Children.Add(settingAxesGrid); settingAxesSelect.TitleText = "Axis"; settingAxesSelect.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => FocusPicker_OnClick(settingAxesSelect, pickerSelectAxes)) }); settingAxesSelect.AddChildrenPicker = pickerSelectAxes; pickerSelectAxes.IsVisible = false; selectAxis = new string[6] { "Left", "Right", "Top", "Bottom", "Depth", "Depth Top" }; pickerSelectAxes.Title = "Axis"; pickerSelectAxes.ItemsSource = selectAxis; pickerSelectAxes.SelectedItem = selectAxis[0]; pickerSelectAxes.SelectedIndexChanged += PickerAxis_SelectedIndexChanged; settingAxesVisible.TitleText = "Visible"; settingAxesVisible.AddChildrenSwitch = switchVisibleAxes; settingAxesVisible.isToogled = chart.Chart.Axes.Left.Visible; switchVisibleAxes.Toggled += SwitchVisibleAxis_Toggled; settingAxesInverted.TitleText = "Inverted"; settingAxesInverted.AddChildrenSwitch = switchInvertedAxes; settingAxesInverted.isToogled = chart.Chart.Axes.Left.Inverted; switchInvertedAxes.Toggled += SwitchInvertedAxes_Toggled; settingAxesGrid.TitleText = "Grid"; settingAxesGrid.AddChildrenSwitch = switchGridAxes; settingAxesGrid.isToogled = chart.Chart.Axes.Left.Grid.Visible; switchGridAxes.Toggled += SwitchGridAxes_Toggled; axisSelected = chart.Chart.Axes.Left; settingAxesSelect.ValueItemText = pickerSelectAxes.SelectedItem.ToString(); }
// Crea una series section private void CrearSeriesSection(int valueAboutSlider, bool is3D) { // Elementos de la Section seriesSection = new StackLayout(); seriesTitleSection = new SettingsSectionTitle(); settingSeriesValues = new SettingsItem(TypeItemsGrid.Slider); settingSeriesMarks = new SettingsItem(TypeItemsGrid.Switch); settingSeriesTitle = new SettingsItem(TypeItemsGrid.Entry); settingSeries3D = new SettingsItem(TypeItemsGrid.Switch); sliderValues = new SettingsSliderItem(); entryTitle = new Entry(); switch3D = new SettingsSwitchItem(); // Add Section settingsPanelComponent.AddChildren = seriesSection; // Series seriesTitleSection.Text = "Series"; seriesSection.Children.Add(seriesTitleSection); if (valueAboutSlider != 3) { if (valueAboutSlider == 1) { seriesSection.Children.Add(settingSeriesValues); settingSeriesValues.TitleText = "Values"; settingSeriesValues.DetailText = "Change the values from this chart"; settingSeriesValues.AddChildrenSlider = sliderValues; settingsPanelComponent.AddSeparation(seriesSection, true); } if (valueAboutSlider != 2) { seriesSection.Children.Add(settingSeriesMarks); settingsPanelComponent.AddSeparation(seriesSection, true); } } seriesSection.Children.Add(settingSeriesTitle); //settingSeriesValues.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => settingSeriesValues.OnClickItem(settingSeriesValues)) }); settingSeriesMarks.TitleText = "Marks"; settingSeriesMarks.AddChildrenSwitch = switchMarks; settingSeriesMarks.isToogled = chart.Chart.Series[0].Marks.Visible; switchMarks.Toggled += SwitchMarks_Toggled; settingSeriesTitle.TitleText = "Title"; settingSeriesTitle.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => SettingItem3_Clicked(settingSeriesTitle)) }); settingSeriesTitle.AddChildrenEntry = entryTitle; settingSeriesTitle.GetButtonEntry.Clicked += GetButtonEntry_Clicked; entryTitle.IsVisible = false; if (is3D) { //settingsPanelComponent.AddSeparation(seriesSection, true); settingSeries3D.TitleText = "3D View"; settingSeries3D.AddChildrenSwitch = switch3D; settingSeries3D.isToogled = chart.Chart.Aspect.View3D; switch3D.Toggled += Switch3D_Toggled; //seriesSection.Children.Add(settingSeries3D); } }
private void CrearSettings() { // Declarar variables settingItemHandStyle = new SettingsItem(TypeItemsGrid.Button); switchMarks = new SettingsSwitchItem(); picker = new Picker(); itemsPickerHand = new List <PointerStyles>(); // Sections Propiedades seriesSection.VerticalOptions = LayoutOptions.FillAndExpand; // Creación de las Sections ItemsForEachChart(); // Vuelve a pintar el componente con las nuevas Sections settingsPanelComponent.Repaint(); switch (titleChart) { case "Line": case "Column Bar": case "Area": case "Pie": case "Fast Line": case "Horizontal Line": case "Horizontal Area": case "Horizontal Bar": case "Donut": case "Bubble": case "Shape": case "Gantt": case "Point/Scatter": case "Interpolating Line": case "Bar Styles": case "Zoom & Panning": case "Bar Gradient": case "Bubble Transparent": case "Real Time": case "Stack Area": case "Multiple Pies": case "Semi-Pie": case "Semi-Donut": break; case "Circular Gauge": case "Car Fuel": case "Custom Hand": case "Acceleration": case "Knob Gauge": case "Temperature Knob": case "Compass": case "Linear Gauge": case "Scales": case "SubLines": case "Mobile Battery": // Series if (chart.Chart.Series[0] is CircularGauge) { settingSeriesMarks.isToogled = ((CircularGauge)chart.Chart.Series[0]).Axis.Labels.Visible; sliderValues.Maximum = ((CircularGauge)chart.Chart.Series[0]).Maximum; sliderValues.Minimum = ((CircularGauge)chart.Chart.Series[0]).Minimum; sliderValues.Value = Math.Round(((CircularGauge)chart.Chart.Series[0]).Value, 2); } else if (chart.Chart.Series[0] is KnobGauge) { settingSeriesMarks.isToogled = ((KnobGauge)chart.Chart.Series[0]).Axis.Labels.Visible; sliderValues.Maximum = ((KnobGauge)chart.Chart.Series[0]).Maximum; sliderValues.Minimum = ((KnobGauge)chart.Chart.Series[0]).Minimum; sliderValues.Value = Math.Round(((KnobGauge)chart.Chart.Series[0]).Value, 2); } else if (chart.Chart.Series[0] is LinearGauge) { settingSeriesMarks.isToogled = ((LinearGauge)chart.Chart.Series[0]).Marks.Visible; sliderValues.Maximum = ((LinearGauge)chart.Chart.Series[0]).Maximum; sliderValues.Minimum = ((LinearGauge)chart.Chart.Series[0]).Minimum; if (titleChart != "Mobile Battery") { sliderValues.Value = Math.Round(((LinearGauge)chart.Chart.Series[0]).Value, 2); } else { sliderValues.Value = Math.Round(100 - ((LinearGauge)chart.Chart.Series[0]).Value, 2); } } sliderValues.ValueChanged += SliderValues_ValueChanged; settingSeriesValues.ValueItemText = sliderValues.Value.ToString(); if (titleChart == "Custom Hand") { settingsPanelComponent.AddSeparation(seriesSection, true); seriesSection.Children.Add(settingItemHandStyle); settingItemHandStyle.TitleText = "Hand Style"; settingItemHandStyle.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => FocusPicker_OnClick(settingItemHandStyle, picker)) }); settingItemHandStyle.AddChildrenPicker = picker; picker.IsVisible = false; pointerStyles = (PointerStyles[])MyConvert.ToArray("PointerStyles"); for (int i = 0; i < pointerStyles.Length; i++) { if (i != 2 && i != 3 && i != 6 && i != 11 && i != 13 && i != 12 && i != 14) { itemsPickerHand.Add(pointerStyles[i]); } } picker.Title = "Select a style hand"; picker.ItemsSource = itemsPickerHand; picker.SelectedItem = (PointerStyles)((CircularGauge)(chart.Chart.Series[0])).Hand.Style.Value; picker.SelectedIndexChanged += PickerHand_SelectedIndexChanged; settingItemHandStyle.ValueItemText = picker.SelectedItem.ToString(); } break; } }