Exemplo n.º 1
0
        private void RreloadControlsWidget()
        {
            GuiWidget manualPrinterControls = new ManualControlsWidget();

            manualControlsPage.RemoveAllChildren();
            manualControlsPage.AddChild(manualPrinterControls);
        }
Exemplo n.º 2
0
 private void ReloadSliceSettingsWidget()
 {
     sliceTabPage.RemoveAllChildren();
     sliceSettingsWidget = new SliceSettingsWidget();
     sliceSettingsWidget.AnchorAll();
     sliceTabPage.AddChild(sliceSettingsWidget);
 }
Exemplo n.º 3
0
        public DemoRunner()
        {
            string searchPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Load plugins from all assemblies the startup directory
            var dlls          = Directory.GetFiles(searchPath, "*.dll");
            var allAssemblies = dlls.Concat(Directory.GetFiles(searchPath, "*.exe"));

            foreach (var file in allAssemblies)
            {
                try
                {
                    PluginFinder.LoadTypesFromAssembly(Assembly.LoadFile(file));
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Error loading assembly: " + ex.Message);
                }
            }

            var appWidgetFinder = PluginFinder.CreateInstancesOf <IDemoApp>().OrderBy(a => a.Title).ToList();

            TabControl tabControl = new TabControl(Orientation.Vertical);

            AddChild(tabControl);
            tabControl.AnchorAll();

            int count = appWidgetFinder.Count;

            for (int i = 0; i < count; i++)
            {
                TabPage tabPage = new TabPage(appWidgetFinder[i].Title);
                tabPage.AddChild(appWidgetFinder[i] as GuiWidget);
                tabControl.AddTab(tabPage, tabPage.Text);
            }

            // HACK: force width/height/color/position/spacing on default tab controls
            double maxWidth = tabControl.TabBar.Children.Select(c => c.Width).Max();

            foreach (var child in tabControl.TabBar.Children)
            {
                if (child is TextTab textTab)
                {
                    foreach (var viewWidget in textTab.Children)
                    {
                        viewWidget.BackgroundColor = new Color(viewWidget.BackgroundColor, 180);
                        viewWidget.HAnchor         = HAnchor.Absolute;
                        viewWidget.VAnchor         = VAnchor.Fit;
                        viewWidget.Margin          = 0;
                        viewWidget.Padding         = 6;
                        viewWidget.Position        = Vector2.Zero;
                        viewWidget.Width           = maxWidth;
                    }
                }
            }

            AnchorAll();
        }
Exemplo n.º 4
0
        void reloadSliceSettingsWidget()
        {
            //Store the UI state from the current display
            sliceSettingsUiState = new SliceSettingsWidgetUiState(sliceSettingsWidget);

            sliceTabPage.RemoveAllChildren();
            sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState);
            sliceSettingsWidget.AnchorAll();
            sliceTabPage.AddChild(sliceSettingsWidget);
        }
Exemplo n.º 5
0
        void reloadControlsWidget()
        {
            GuiWidget manualPrinterControls = new ManualPrinterControls();

            //ScrollableWidget manualPrinterControlsWidget = new ScrollableWidget(true);
            //manualPrinterControlsWidget.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            //manualPrinterControlsWidget.AnchorAll();
            //manualPrinterControlsWidget.AddChild(manualPrinterControls);

            manualControlsPage.RemoveAllChildren();
            manualControlsPage.AddChild(manualPrinterControls);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        private void ReloadAdvancedControls()
        {
            // ReloadControlsWidget
            manualControlsPage.RemoveAllChildren();
            manualControlsPage.AddChild(new ManualControlsWidget());

            // ReloadConfigurationWidget
            optionsPage.RemoveAllChildren();
            optionsPage.AddChild(new PrinterConfigurationScrollWidget());

            // ReloadSliceSettingsWidget
            sliceTabPage.RemoveAllChildren();
            sliceTabPage.AddChild(new SliceSettingsWidget()
            {
                HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop
            });

            this.Invalidate();
        }
Exemplo n.º 8
0
        public DemoRunner()
        {
            TabControl tabControl = new TabControl(Orientation.Vertical);

            AddChild(tabControl);
            tabControl.AnchorAll();

            int count = appWidgetFinder.Plugins.Count;

            for (int i = 0; i < count; i++)
            {
                if (appWidgetFinder.Plugins[i].GetAppParameters().title != "Demo Runner")
                {
                    TabPage tabPage = new TabPage(appWidgetFinder.Plugins[i].GetAppParameters().title);
                    tabPage.AddChild(appWidgetFinder.Plugins[i].NewWidget());
                    tabControl.AddTab(tabPage, "Demo Runner");
                }
            }

            AnchorAll();
        }
Exemplo n.º 9
0
        public DemoRunner()
        {
            var appWidgetFinder = PluginFinder.CreateInstancesOf <IDemoApp>().OrderBy(a => a.Title).ToList();

            TabControl tabControl = new TabControl(Orientation.Vertical);

            AddChild(tabControl);
            tabControl.AnchorAll();

            int count = appWidgetFinder.Count;

            for (int i = 0; i < count; i++)
            {
                TabPage tabPage = new TabPage(appWidgetFinder[i].Title);
                tabPage.AddChild(appWidgetFinder[i] as GuiWidget);
                tabControl.AddTab(tabPage, tabPage.Text);
            }

            // HACK: force width/height/color/position/spacing on default tab controls
            double maxWidth = tabControl.TabBar.Children.Select(c => c.Width).Max();

            foreach (var child in tabControl.TabBar.Children)
            {
                if (child is TextTab textTab)
                {
                    foreach (var viewWidget in textTab.Children)
                    {
                        viewWidget.BackgroundColor = new Color(viewWidget.BackgroundColor, 180);
                        viewWidget.HAnchor         = HAnchor.Absolute;
                        viewWidget.VAnchor         = VAnchor.Fit;
                        viewWidget.Margin          = 0;
                        viewWidget.Padding         = 6;
                        viewWidget.Position        = Vector2.Zero;
                        viewWidget.Width           = maxWidth;
                    }
                }
            }

            AnchorAll();
        }
Exemplo n.º 10
0
 void reloadConfigurationWidget()
 {
     configurationPage.RemoveAllChildren();
     configurationPage.AddChild(new PrinterConfigurationScrollWidget());
 }
Exemplo n.º 11
0
        public SliceSettingsWidget(UiState uiState)
        {
            int minSettingNameWidth = 220;

            buttonFactory.FixedHeight     = 20;
            buttonFactory.fontSize        = 10;
            buttonFactory.normalFillColor = RGBA_Bytes.White;
            buttonFactory.normalTextColor = RGBA_Bytes.DarkGray;

            showHelpBox         = new CheckBox(0, 0, LocalizedString.Get("Show Help"), textSize: 10);
            showHelpBox.Checked = UserSettings.Instance.get(SliceSettingsShowHelpEntry) == "true";

            showAllDetails         = new CheckBox(0, 0, LocalizedString.Get("Show All Settings"), textSize: 10);
            showAllDetails.Checked = UserSettings.Instance.get(SliceSettingsLevelEntry) == "Advanced";

            FlowLayoutWidget pageTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom, vAnchor: Agg.UI.VAnchor.ParentTop);

            pageTopToBottomLayout.AnchorAll();
            pageTopToBottomLayout.Padding = new BorderDouble(3, 0);
            this.AddChild(pageTopToBottomLayout);

            settingsControlBar = new SettingsControlBar();
            pageTopToBottomLayout.AddChild(settingsControlBar);

            noConnectionMessageContainer             = new GroupBox(LocalizedString.Get("No Printer Selected"));
            noConnectionMessageContainer.Margin      = new BorderDouble(top: 10);
            noConnectionMessageContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessageContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessageContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            noConnectionMessageContainer.Height      = 80;

            TextWidget noConnectionMessage = new TextWidget(LocalizedString.Get("No printer is currently selected. Select printer to edit slice settings."));

            noConnectionMessage.Margin    = new BorderDouble(5);
            noConnectionMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            noConnectionMessage.VAnchor   = VAnchor.ParentCenter;

            noConnectionMessageContainer.AddChild(noConnectionMessage);
            pageTopToBottomLayout.AddChild(noConnectionMessageContainer);

            categoryTabs = new TabControl();
            categoryTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            categoryTabs.Margin             = new BorderDouble(top: 8);
            categoryTabs.AnchorAll();
            List <TabBar> sideTabBarsListForLayout = new List <TabBar>();

            for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++)
            {
                OrganizerCategory   category          = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex];
                string              categoryPageLabel = LocalizedString.Get(category.Name);
                TabPage             categoryPage      = new TabPage(categoryPageLabel);
                SimpleTextTabWidget textTabWidget     = new SimpleTextTabWidget(categoryPage, 16,
                                                                                ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                categoryPage.AnchorAll();
                categoryTabs.AddTab(textTabWidget);

                TabControl sideTabs = CreateSideTabsAndPages(minSettingNameWidth, category, uiState);
                sideTabBarsListForLayout.Add(sideTabs.TabBar);

                categoryPage.AddChild(sideTabs);
            }

            if (showAllDetails.Checked && ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.Slic3r)
            {
                TabPage             extraSettingsPage          = new TabPage("Other");
                SimpleTextTabWidget extraSettingsTextTabWidget = new SimpleTextTabWidget(extraSettingsPage, 16,
                                                                                         ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());
                extraSettingsPage.AnchorAll();
                int        count;
                TabControl extraSettingsSideTabs = CreateExtraSettingsSideTabsAndPages(minSettingNameWidth, categoryTabs, out count);
                if (count > 0)
                {
                    categoryTabs.AddTab(extraSettingsTextTabWidget);
                    sideTabBarsListForLayout.Add(extraSettingsSideTabs.TabBar);
                    extraSettingsPage.AddChild(extraSettingsSideTabs);
                }
            }

            double sideTabBarsMinimumWidth = 0;

            foreach (TabBar tabBar in sideTabBarsListForLayout)
            {
                sideTabBarsMinimumWidth = Math.Max(sideTabBarsMinimumWidth, tabBar.Width);
            }
            foreach (TabBar tabBar in sideTabBarsListForLayout)
            {
                tabBar.MinimumSize = new Vector2(sideTabBarsMinimumWidth, tabBar.MinimumSize.y);
            }

            // space before checkboxes (hold the right aligned)
            {
                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                categoryTabs.TabBar.AddChild(hSpacer);
            }

            // add in the ability to turn on and off all details settings
            {
                showAllDetails.TextColor            = ActiveTheme.Instance.PrimaryTextColor;
                showAllDetails.Margin               = new BorderDouble(right: 8);
                showAllDetails.VAnchor              = VAnchor.ParentCenter;
                showAllDetails.Cursor               = Cursors.Hand;
                showAllDetails.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(RebuildSlicerSettings);

                categoryTabs.TabBar.AddChild(showAllDetails);
            }

            // add in the ability to turn on and off help text
            {
                showHelpBox.TextColor            = ActiveTheme.Instance.PrimaryTextColor;
                showHelpBox.Margin               = new BorderDouble(right: 3);
                showHelpBox.VAnchor              = VAnchor.ParentCenter;
                showHelpBox.Cursor               = Cursors.Hand;
                showHelpBox.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(RebuildSlicerSettings);

                categoryTabs.TabBar.AddChild(showHelpBox);
            }

            pageTopToBottomLayout.AddChild(categoryTabs);
            AddHandlers();
            SetVisibleControls();

            if (!categoryTabs.SelectTab(uiState.selectedCategory.name))
            {
                categoryTabs.SelectTab(uiState.selectedCategory.index);
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
 private void ReloadConfigurationWidget()
 {
     optionsPage.RemoveAllChildren();
     optionsPage.AddChild(new PrinterConfigurationScrollWidget());
 }