public TouchscreenTabView(QueueDataView queueDataView) : base(Orientation.Vertical) { this.queueDataView = queueDataView; this.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); this.TabBar.Margin = new BorderDouble(4, 0, 0, 0); this.TabBar.Padding = new BorderDouble(0, 8); this.Margin = new BorderDouble(top: 0); this.TabTextSize = 18; string simpleModeString = UserSettings.Instance.get("IsSimpleMode"); if (simpleModeString == null) { simpleMode = true; UserSettings.Instance.set("IsSimpleMode", "true"); } else { simpleMode = Convert.ToBoolean(simpleModeString); } this.AddTab( "Part Preview Tab", "Preview".Localize().ToUpper(), generator: () => { partPreviewContainer = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, View3DWidget.WindowMode.Embeded, View3DWidget.AutoRotate.Enabled, View3DWidget.OpenMode.Viewing); return(partPreviewContainer); }); this.AddTab( "Slice Settings Tab", "Settings".Localize().ToUpper(), generator: () => { // sliceSettingsWidget = (ActiveSliceSettings.Instance.PrinterSelected) ? new SliceSettingsWidget() : new NoSettingsWidget(); if (ActiveSliceSettings.Instance.PrinterSelected) { sliceSettingsWidget = new SliceSettingsWidget(); } else { sliceSettingsWidget = new NoSettingsWidget(); } return(sliceSettingsWidget); }); this.TabBar.AddChild(new HorizontalLine() { Margin = new BorderDouble(4, 10) }); this.AddTab( "Controls Tab", "Controls".Localize().ToUpper(), () => new ManualPrinterControls()); // TODO: How to handle reload? Create .Reload on LazyTab? Create accessor for tabs["Controls Tab"].Reload()? //manualControlsPage = new TabPage(, printerControlsLabel); this.TabBar.AddChild(new HorizontalLine() { Margin = new BorderDouble(4, 10) }); this.AddTab( "Queue Tab", "Queue".Localize().ToUpper(), () => new QueueDataWidget(queueDataView)); QueueTabPage = this.GetTabPage("Queue Tab"); this.AddTab( "Library Tab", "Library".Localize().ToUpper(), () => new PrintLibraryWidget()); if (!simpleMode) { this.AddTab( "History Tab", "History".Localize().ToUpper(), () => new PrintHistoryWidget()); } this.TabBar.AddChild(new HorizontalLine() { Margin = new BorderDouble(4, 10) }); // Make sure we have the right scroll position when we create this view // This is not working well enough. So, I disabled it until it can be fixed. // Specifically, it has the wronge position on the app restarting. /* * if(false) * { * UiThread.RunOnIdle(() => * { * int scrollPosition = UserSettings.Instance.Fields.GetInt(CompactTabView_Options_ScrollPosition, -100000); * if (scrollPosition != -100000) * { * printerConfigurationWidget.ScrollPosition = new Vector2(0, scrollPosition); * } * }); * * printerConfigurationWidget.ScrollPositionChanged += (object sender, EventArgs e) => * { * UserSettings.Instance.Fields.SetInt(CompactTabView_Options_ScrollPosition, (int)printerConfigurationWidget.ScrollPosition.y); * }; * } */ this.AddTab( "Options Tab", "Options".Localize().ToUpper(), () => new PrinterConfigurationScrollWidget()); if (!simpleMode) { this.AddTab( "Terminal Tab", "Console".Localize().ToUpper(), () => new TerminalWidget(false)); } this.AddTab( "About Tab", "About".Localize().ToUpper(), () => new AboutWidget()); NumQueueItemsChanged(this, null); SetUpdateNotification(this, null); QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAdvancedControlsPanel(), ref unregisterEvents); PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent((s, e) => { // ReloadPartPreview UiThread.RunOnIdle(() => { partPreviewContainer?.Reload(PrinterConnectionAndCommunication.Instance.ActivePrintItem); }, 1); }, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadAdvancedControls), ref unregisterEvents); UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents); // Make sure we are on the right tab when we create this view { string selectedTab = UserSettings.Instance.get(CompactTabView_CurrentTab); this.SelectTab(selectedTab); TabBar.TabIndexChanged += (object sender, EventArgs e) => { string selectedTabName = TabBar.SelectedTabName; if (!string.IsNullOrEmpty(selectedTabName)) { UserSettings.Instance.set(CompactTabView_CurrentTab, selectedTabName); } }; } }
public TouchscreenTabView(QueueDataView queueDataView) : base(Orientation.Vertical) { this.queueDataView = queueDataView; this.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); this.TabBar.Margin = new BorderDouble(4, 0, 0, 0); this.TabBar.Padding = new BorderDouble(0, 8); this.Margin = new BorderDouble(top: 0); this.TabTextSize = 18; string simpleModeString = UserSettings.Instance.get("IsSimpleMode"); if (simpleModeString == null) { simpleMode = true; UserSettings.Instance.set("IsSimpleMode", "true"); } else { simpleMode = Convert.ToBoolean(simpleModeString); } QueueTabPage = new TabPage(new QueueDataWidget(queueDataView), LocalizedString.Get("Queue").ToUpper()); SimpleTextTabWidget queueTabWidget = new SimpleTextTabWidget(QueueTabPage, "Queue Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); partPreviewContainer = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, View3DWidget.WindowMode.Embeded, View3DWidget.AutoRotate.Enabled, View3DWidget.OpenMode.Viewing); string partPreviewLabel = LocalizedString.Get("Preview").ToUpper(); this.AddTab(new SimpleTextTabWidget(new TabPage(partPreviewContainer, partPreviewLabel), "Part Preview Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper(); sliceSettingsWidget = new SliceSettingsWidget(); sliceTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel); this.AddTab(new SimpleTextTabWidget(sliceTabPage, "Slice Settings Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); HorizontalLine lineSpacerZero = new HorizontalLine(); lineSpacerZero.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerZero); GuiWidget manualPrinterControls = new ManualControlsWidget(); #if __ANDROID__ //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); manualControlsPage = new TabPage(manualPrinterControls, printerControlsLabel); this.AddTab(new SimpleTextTabWidget(manualControlsPage, "Controls Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); #else ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; manualPrinterControlsScrollArea.AnchorAll(); manualPrinterControlsScrollArea.AddChild(manualPrinterControls); //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); manualControlsPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel); this.AddTab(new SimpleTextTabWidget(manualControlsPage, "Controls Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); #endif HorizontalLine lineSpacerOne = new HorizontalLine(); lineSpacerOne.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerOne); this.AddTab(queueTabWidget); LibraryTabPage = new TabPage(new PrintLibraryWidget(), LocalizedString.Get("Library").ToUpper()); this.AddTab(new SimpleTextTabWidget(LibraryTabPage, "Library Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); HistoryTabPage = new TabPage(new PrintHistoryWidget(), LocalizedString.Get("History").ToUpper()); SimpleTextTabWidget historyTabWidget = new SimpleTextTabWidget(HistoryTabPage, "History Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); if (!simpleMode) { this.AddTab(historyTabWidget); } HorizontalLine lineSpacerTwo = new HorizontalLine(); lineSpacerTwo.Margin = new BorderDouble(4, 10); this.TabBar.AddChild(lineSpacerTwo); string configurationLabel = LocalizedString.Get("Options").ToUpper(); PrinterConfigurationScrollWidget printerConfigurationWidget = new PrinterConfigurationScrollWidget(); // Make sure we have the right scroll position when we create this view // This is not working well enough. So, I disabled it until it can be fixed. // Specifically, it has the wronge position on the app restarting. if (false) { UiThread.RunOnIdle(() => { int scrollPosition = UserSettings.Instance.Fields.GetInt(CompactTabView_Options_ScrollPosition, -100000); if (scrollPosition != -100000) { printerConfigurationWidget.ScrollPosition = new Vector2(0, scrollPosition); } }); printerConfigurationWidget.ScrollPositionChanged += (object sender, EventArgs e) => { UserSettings.Instance.Fields.SetInt(CompactTabView_Options_ScrollPosition, (int)printerConfigurationWidget.ScrollPosition.y); }; } optionsPage = new TabPage(printerConfigurationWidget, configurationLabel); this.AddTab(new SimpleTextTabWidget(optionsPage, "Options Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); TerminalTabPage = new TabPage(new TerminalWidget(false), LocalizedString.Get("Console").ToUpper()); SimpleTextTabWidget terminalTabWidget = new SimpleTextTabWidget(TerminalTabPage, "Terminal Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); if (!simpleMode) { this.AddTab(terminalTabWidget); } AboutTabPage = new TabPage(new AboutWidget(), LocalizedString.Get("About").ToUpper()); aboutTabWidget = new SimpleTextTabWidget(AboutTabPage, "About Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); this.AddTab(aboutTabWidget); NumQueueItemsChanged(this, null); SetUpdateNotification(this, null); QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAdvancedControlsPanel(), ref unregisterEvents); PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent((s, e) => { // ReloadPartPreview UiThread.RunOnIdle(() => { partPreviewContainer.Reload(PrinterConnectionAndCommunication.Instance.ActivePrintItem); }, 1); }, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadAdvancedControls), ref unregisterEvents); UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents); // Make sure we are on the right tab when we create this view { string selectedTab = UserSettings.Instance.get(CompactTabView_CurrentTab); this.SelectTab(selectedTab); TabBar.TabIndexChanged += (object sender, EventArgs e) => { string selectedTabName = TabBar.SelectedTabName; if (!string.IsNullOrEmpty(selectedTabName)) { UserSettings.Instance.set(CompactTabView_CurrentTab, selectedTabName); } }; } }
private void ReloadPartPreview(object state = null) { partPreviewContainer.Reload(PrinterConnectionAndCommunication.Instance.ActivePrintItem); }