Exemplo n.º 1
0
        private TabControl CreateExtraSettingsSideTabsAndPages(int minSettingNameWidth, TabControl categoryTabs, out int count)
        {
            count = 0;
            TabControl sideTabs = new TabControl(Orientation.Vertical);

            sideTabs.Margin             = new BorderDouble(0, 0, 0, 5);
            sideTabs.TabBar.BorderColor = RGBA_Bytes.White;
            {
                TabPage             groupTabPage   = new TabPage("Extra Settings");
                SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14,
                                                                             ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                sideTabs.AddTab(groupTabWidget);

                FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
                subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;

                FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom);
                topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                foreach (KeyValuePair <string, DataStorage.SliceSetting> item in ActiveSliceSettings.Instance.DefaultSettings)
                {
                    if (!SliceSettingsOrganizer.Instance.Contains(UserLevel, item.Key))
                    {
                        OrganizerSettingsData settingInfo            = new OrganizerSettingsData(item.Key, item.Key, OrganizerSettingsData.DataEditTypes.STRING);
                        GuiWidget             controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth);
                        topToBottomSettings.AddChild(controlsForThisSetting);
                        count++;
                    }
                }

                GroupBox groupBox = new GroupBox(LocalizedString.Get("Extra"));
                groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
                groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
                groupBox.AddChild(topToBottomSettings);
                groupBox.VAnchor = VAnchor.FitToChildren;
                groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                subGroupLayoutTopToBottom.AddChild(groupBox);

                SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();
                scrollOnGroupTab.AnchorAll();
                scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
                groupTabPage.AddChild(scrollOnGroupTab);
            }
            return(sideTabs);
        }
		private TabControl CreateExtraSettingsSideTabsAndPages(int minSettingNameWidth, TabControl categoryTabs, out int count)
		{
			count = 0;
			TabControl sideTabs = new TabControl(Orientation.Vertical);
			sideTabs.Margin = new BorderDouble(0, 0, 0, 5);
			sideTabs.TabBar.BorderColor = RGBA_Bytes.White;
			{
				TabPage groupTabPage = new TabPage("Extra Settings");
				SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, "Extra Settings Tab", 14,
				   ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
				sideTabs.AddTab(groupTabWidget);

				FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
				subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
				subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;

				FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom);
				topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

				foreach (KeyValuePair<string, DataStorage.SliceSetting> item in ActiveSliceSettings.Instance.DefaultSettings)
				{
					if (!SliceSettingsOrganizer.Instance.Contains(UserLevel, item.Key))
					{
						OrganizerSettingsData settingInfo = new OrganizerSettingsData(item.Key, item.Key, OrganizerSettingsData.DataEditTypes.STRING);
						GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth, 0);
						topToBottomSettings.AddChild(controlsForThisSetting);
						count++;
					}
				}

				AltGroupBox groupBox = new AltGroupBox(LocalizedString.Get("Extra"));
				groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
				groupBox.AddChild(topToBottomSettings);
				groupBox.VAnchor = VAnchor.FitToChildren;
				groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

				subGroupLayoutTopToBottom.AddChild(groupBox);

				SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();
				scrollOnGroupTab.AnchorAll();
				scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
				groupTabPage.AddChild(scrollOnGroupTab);
			}
			return sideTabs;
		}
		private TabControl CreateSideTabsAndPages(int minSettingNameWidth, OrganizerCategory category)
		{
			TabControl groupTabs = new TabControl(Orientation.Vertical);
			groupTabs.Margin = new BorderDouble(0, 0, 0, 5);
			groupTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
			foreach (OrganizerGroup group in category.GroupsList)
			{
				tabIndexForItem = 0;
				string groupTabLabel = LocalizedString.Get(group.Name);
				TabPage groupTabPage = new TabPage(groupTabLabel);
				groupTabPage.HAnchor = HAnchor.ParentLeftRight;

				SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, group.Name + " Tab", 14,
				   ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
				groupTabWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

				FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
				subGroupLayoutTopToBottom.AnchorAll();

				bool needToAddSubGroup = false;
				foreach (OrganizerSubGroup subGroup in group.SubGroupsList)
				{
					string subGroupTitle = subGroup.Name;
					int numberOfCopies = 1;
					if (subGroup.Name == "Extruder X")
					{
						numberOfCopies = ActiveSliceSettings.Instance.ExtruderCount;
					}

					for (int copyIndex = 0; copyIndex < numberOfCopies; copyIndex++)
					{
						if (subGroup.Name == "Extruder X")
						{
							subGroupTitle = "{0} {1}".FormatWith("Extruder".Localize(), copyIndex + 1);
						}

						bool addedSettingToSubGroup = false;
						FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom);
						topToBottomSettings.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

						foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList)
						{
							if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingInfo.SlicerConfigName))
							{
								addedSettingToSubGroup = true;
								GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth, copyIndex);
								topToBottomSettings.AddChild(controlsForThisSetting);

								if (sliceSettingsDetailControl.ShowingHelp)
								{
									AddInHelpText(topToBottomSettings, settingInfo);
								}
							}
						}

						if (addedSettingToSubGroup)
						{
							needToAddSubGroup = true;
							string groupBoxLabel = subGroupTitle;
							AltGroupBox groupBox = new AltGroupBox(groupBoxLabel);
							groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
							groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
							groupBox.AddChild(topToBottomSettings);
							groupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
							groupBox.Margin = new BorderDouble(3, 3, 3, 0);

							subGroupLayoutTopToBottom.AddChild(groupBox);
						}
					}
				}

				if (needToAddSubGroup)
				{
					SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();

					subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;
					subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

					scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
					groupTabPage.AddChild(scrollOnGroupTab);
					groupTabs.AddTab(groupTabWidget);


					// Make sure we have the right scroll position when we create this view
					// This code is not working yet. Scroll widgets get a scroll event when the tab becomes visible that is always reseting them.
					// So it is not usefull to enable this and in fact makes the tabs inconsistently scrolled. It is just here for reference. // 2015 04 16, LBB
					if(false) 
					{
						string settingsScrollPosition = "SliceSettingsWidget_{0}_{1}_ScrollPosition".FormatWith(category.Name, group.Name);

						UiThread.RunOnIdle(()=>
						{
							int scrollPosition = UserSettings.Instance.Fields.GetInt(settingsScrollPosition, -100000);
							if (scrollPosition != -100000)
							{
								scrollOnGroupTab.ScrollPosition = new Vector2(0, scrollPosition);
							}
						});

						scrollOnGroupTab.ScrollPositionChanged += (object sender, EventArgs e) =>
						{
							if (scrollOnGroupTab.CanSelect)
							{
								UserSettings.Instance.Fields.SetInt(settingsScrollPosition, (int)scrollOnGroupTab.ScrollPosition.y);
							}
						};
					}
				}
			}

			// Make sure we are on the right tab when we create this view
			{
				string settingsTypeName = "SliceSettingsWidget_{0}_CurrentTab".FormatWith(category.Name);
				string selectedTab = UserSettings.Instance.get(settingsTypeName);
				groupTabs.SelectTab(selectedTab);

				groupTabs.TabBar.TabIndexChanged += (object sender, EventArgs e) =>
				{
					UserSettings.Instance.set(settingsTypeName, groupTabs.TabBar.SelectedTabName);
				};
			}

			return groupTabs;
		}
Exemplo n.º 4
0
        private TabControl CreateSideTabsAndPages(int minSettingNameWidth, OrganizerCategory category, UiState uiState)
        {
            TabControl groupTabs = new TabControl(Orientation.Vertical);

            groupTabs.Margin             = new BorderDouble(0, 0, 0, 5);
            groupTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            foreach (OrganizerGroup group in category.GroupsList)
            {
                tabIndexForItem = 0;
                string  groupTabLabel = LocalizedString.Get(group.Name);
                TabPage groupTabPage  = new TabPage(groupTabLabel);
                groupTabPage.HAnchor = HAnchor.ParentLeftRight;

                SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14,
                                                                             ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                groupTabWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
                subGroupLayoutTopToBottom.AnchorAll();

                bool needToAddSubGroup = false;
                foreach (OrganizerSubGroup subGroup in group.SubGroupsList)
                {
                    bool             addedSettingToSubGroup = false;
                    FlowLayoutWidget topToBottomSettings    = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    topToBottomSettings.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList)
                    {
                        if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingInfo.SlicerConfigName))
                        {
                            addedSettingToSubGroup = true;
                            GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth);
                            topToBottomSettings.AddChild(controlsForThisSetting);

                            if (showHelpBox.Checked)
                            {
                                AddInHelpText(topToBottomSettings, settingInfo);
                            }
                        }
                    }

                    if (addedSettingToSubGroup)
                    {
                        needToAddSubGroup = true;
                        string   groupBoxLabel = LocalizedString.Get(subGroup.Name);
                        GroupBox groupBox      = new GroupBox(groupBoxLabel);
                        groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.AddChild(topToBottomSettings);
                        groupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                        subGroupLayoutTopToBottom.AddChild(groupBox);
                    }
                }

                if (needToAddSubGroup)
                {
                    SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();

                    subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;
                    subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    //subGroupLayoutTopToBottom.DebugShowBounds = true;
                    //scrollOnGroupTab.DebugShowBounds = true;
                    scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
                    groupTabPage.AddChild(scrollOnGroupTab);
                    groupTabs.AddTab(groupTabWidget);
                }
            }

            if (!groupTabs.SelectTab(uiState.selectedGroup.name))
            {
                groupTabs.SelectTab(uiState.selectedGroup.index);
            }
            return(groupTabs);
        }
		private TabControl CreateExtraSettingsSideTabsAndPages(TabControl categoryTabs, out int count)
		{
			int rightContentWidth = (int)(280 * GuiWidget.DeviceScale + .5);
			count = 0;
			TabControl leftSideGroupTabs = new TabControl(Orientation.Vertical);
			leftSideGroupTabs.Margin = new BorderDouble(0, 0, 0, 5);
			leftSideGroupTabs.TabBar.BorderColor = RGBA_Bytes.White;
			{
				TabPage groupTabPage = new TabPage("Extra Settings");
				SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, "Extra Settings Tab", 14,
				   ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
				leftSideGroupTabs.AddTab(groupTabWidget);

				FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
				subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
				subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;

				FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom);
				topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

				this.HAnchor = HAnchor.ParentLeftRight;

				foreach (var keyValue in ActiveSliceSettings.Instance.BaseLayer)
				{
					if (!SliceSettingsOrganizer.Instance.Contains(UserLevel, keyValue.Key))
					{
						SliceSettingData settingData = new SliceSettingData(keyValue.Key, keyValue.Key, SliceSettingData.DataEditTypes.STRING);
						if (ActiveSliceSettings.Instance.Helpers.ActiveSliceEngine().MapContains(settingData.SlicerConfigName))
						{
							bool addControl;
							GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingData, layerCascade, persistenceLayer, viewFilter, 0, out addControl, ref tabIndexForItem);
							if (addControl)
							{
								topToBottomSettings.AddChild(controlsForThisSetting);
							}
							count++;
						}
					}
				}

				AltGroupBox groupBox = new AltGroupBox("Extra".Localize());
				groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
				groupBox.AddChild(topToBottomSettings);
				groupBox.VAnchor = VAnchor.FitToChildren;
				groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

				subGroupLayoutTopToBottom.AddChild(groupBox);

				SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();
				scrollOnGroupTab.AnchorAll();
				scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
				groupTabPage.AddChild(scrollOnGroupTab);
			}
			return leftSideGroupTabs;
		}
        private TabControl CreateSideTabsAndPages(int minSettingNameWidth, OrganizerCategory category, SliceSettingsWidgetUiState uiState)
        {
            TabControl groupTabs = new TabControl(Orientation.Vertical);
            groupTabs.Margin = new BorderDouble(0, 0, 0, 5);
            groupTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            foreach (OrganizerGroup group in category.GroupsList)
            {
                tabIndexForItem = 0;
                string groupTabLabel = LocalizedString.Get(group.Name);
                TabPage groupTabPage = new TabPage(groupTabLabel);
                groupTabPage.HAnchor = HAnchor.ParentLeftRight;

                SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, group.Name + " Tab", 14,
                   ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                groupTabWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
                subGroupLayoutTopToBottom.AnchorAll();

                bool needToAddSubGroup = false;
                foreach (OrganizerSubGroup subGroup in group.SubGroupsList)
                {
                    bool addedSettingToSubGroup = false;
                    FlowLayoutWidget topToBottomSettings = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    topToBottomSettings.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList)
                    {
                        if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingInfo.SlicerConfigName))
                        {
                            addedSettingToSubGroup = true;
                            GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth);
                            topToBottomSettings.AddChild(controlsForThisSetting);

                            if (showHelpBox.Checked)
                            {
                                AddInHelpText(topToBottomSettings, settingInfo);
                            }
                        }
                    }

                    if (addedSettingToSubGroup)
                    {
                        needToAddSubGroup = true;
                        string groupBoxLabel = LocalizedString.Get(subGroup.Name);
                        GroupBox groupBox = new GroupBox(groupBoxLabel);
                        groupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.AddChild(topToBottomSettings);
                        groupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                        subGroupLayoutTopToBottom.AddChild(groupBox);
                    }
                }

                if (needToAddSubGroup)
                {
                    SliceSettingListControl scrollOnGroupTab = new SliceSettingListControl();

                    subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;
                    subGroupLayoutTopToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    //subGroupLayoutTopToBottom.DebugShowBounds = true;
                    //scrollOnGroupTab.DebugShowBounds = true;
                    scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
                    groupTabPage.AddChild(scrollOnGroupTab);
                    groupTabs.AddTab(groupTabWidget);
                }
            }

            if (!groupTabs.SelectTab(uiState.selectedGroup.name))
            {
                groupTabs.SelectTab(uiState.selectedGroup.index);
            }
            return groupTabs;
        }