示例#1
0
        public StoreTabPage(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            this.AutoScroll         = true;
            this.ScrollArea.Padding = new BorderDouble(3);
            this.ScrollArea.HAnchor = HAnchor.Stretch;
            this.HAnchor            = HAnchor.Stretch;
            this.VAnchor            = VAnchor.Stretch;
            this.MinimumSize        = new Vector2(0, 200);
            this.BackgroundColor    = theme.TabBodyBackground;

            this.Name = "StoreTab";

            var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch
            };

            this.AddChild(topToBottom);

            if (OemSettings.Instance.ShowShopButton)
            {
                topToBottom.AddChild(new ExplorePanel(theme, "banners?sk=ii2gffs6e89c2cdd9er21v", "BannerFeed.json"));
            }

            if (OemSettings.Instance.ShowShopButton)
            {
                // actual feed
                topToBottom.AddChild(new ExplorePanel(theme, "explore?sk=2lhddgi3q67xoqa53pchpeddl6w1uf", "ExploreFeed.json"));
            }
        }
        void LoadColumnTwo(object state = null)
        {
            ColumnTwo.CloseAndRemoveAllChildren();

            double buildHeight = ActiveSliceSettings.Instance.BuildHeight;

#if NEW_TWO_COLUMN_MODE
            PartPreviewContent partViewContent = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, true, View3DWidget.AutoRotate.Enabled, false);
            partViewContent.AnchorAll();

            ColumnTwo.AddChild(partViewContent);
#else
            part3DView = new View3DWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem,
                                          new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight),
                                          ActiveSliceSettings.Instance.BedCenter,
                                          ActiveSliceSettings.Instance.BedShape,
                                          View3DWidget.WindowType.Embeded,
                                          View3DWidget.AutoRotate.Enabled);
            part3DView.Margin = new BorderDouble(bottom: 4);
            part3DView.AnchorAll();

            partGcodeView = new ViewGcodeBasic(PrinterConnectionAndCommunication.Instance.ActivePrintItem,
                                               new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight),
                                               ActiveSliceSettings.Instance.BedCenter,
                                               ActiveSliceSettings.Instance.BedShape,
                                               false);
            partGcodeView.AnchorAll();

            ColumnTwo.AddChild(part3DView);
            ColumnTwo.AddChild(partGcodeView);
#endif

            ColumnTwo.AnchorAll();
        }
示例#3
0
        public StartTabPage(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            this.AutoScroll         = true;
            this.ScrollArea.Padding = new BorderDouble(3);
            this.ScrollArea.HAnchor = HAnchor.Stretch;
            this.HAnchor            = HAnchor.Stretch;
            this.VAnchor            = VAnchor.Stretch;
            this.MinimumSize        = new Vector2(0, 200);
            this.BackgroundColor    = theme.TabBodyBackground;

            this.Name = "PlusTabPage";

            var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch
            };

            this.AddChild(topToBottom);

            var lastProfileID = ProfileManager.Instance.LastProfileID;
            var lastProfile   = ProfileManager.Instance[lastProfileID];

            topToBottom.AddChild(
                new PrinterBar(partPreviewContent, lastProfile, theme));

            if (OemSettings.Instance.ShowShopButton)
            {
                // actual feed
                topToBottom.AddChild(new ExplorePanel(theme, "explore?sk=2lhddgi3q67xoqa53pchpeddl6w1uf", "ExploreFeed.json"));
            }
        }
        private void LoadColumnTwo()
        {
            ColumnTwo.CloseAndRemoveAllChildren();

            PartPreviewContent partViewContent = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, View3DWidget.WindowMode.Embeded, View3DWidget.AutoRotate.Enabled);

            partViewContent.AnchorAll();

            ColumnTwo.AddChild(partViewContent);

            ColumnTwo.AnchorAll();
        }
示例#5
0
        public override void Initialize()
        {
            base.Initialize();

            this.AnchorAll();
            this.Name            = "WidescreenPanel";
            this.BackgroundColor = theme.ActiveTabColor;

            // Push TouchScreenMode into GuiWidget
            GuiWidget.TouchScreenMode = UserSettings.Instance.IsTouchScreen;

            // put in the right column
            var partPreviewContent = new PartPreviewContent(theme)
            {
                VAnchor = VAnchor.Bottom | VAnchor.Top,
                HAnchor = HAnchor.Left | HAnchor.Right
            };

            this.AddChild(partPreviewContent);
        }
示例#6
0
        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);
                    }
                };
            }
        }
示例#7
0
        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);
                    }
                };
            }
        }
示例#8
0
        public PrinterBar(PartPreviewContent partPreviewContent, PrinterInfo printerInfo, ThemeConfig theme)
            : base(printerInfo?.Name ?? "", theme)
        {
            headingBar.CloseAllChildren();
            headingBar.AddChild(printerSelector = new PrinterSelector(theme)
            {
                VAnchor         = VAnchor.Fit,
                HAnchor         = HAnchor.Absolute,
                Border          = 0,
                MinimumSize     = Vector2.Zero,
                Width           = 200,
                BackgroundColor = theme.MinimalShade
            });

            printerSelector.SelectionChanged += (s, e) =>
            {
                this.RebuildPlateOptions(partPreviewContent, theme);
            };

            var forcedHeight = printerSelector.Height;

            // add in the create printer button
            var createPrinter = new IconButton(AggContext.StaticData.LoadIcon("md-add-circle_18.png", 18, 18, theme.InvertIcons), theme)
            {
                Name        = "Create Printer",
                VAnchor     = VAnchor.Center,
                Margin      = theme.ButtonSpacing.Clone(left: theme.ButtonSpacing.Right),
                ToolTipText = "Create Printer".Localize(),
                Height      = forcedHeight,
                Width       = forcedHeight
            };

            createPrinter.Click += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    //simpleTabs.RemoveTab(simpleTabs.ActiveTab);

                    if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting ||
                        ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused)
                    {
                        StyledMessageBox.ShowMessageBox("Please wait until the print has finished and try again.".Localize(), "Can't add printers while printing".Localize());
                    }
                    else
                    {
                        DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowMakeModel));
                    }
                });
            };
            headingBar.AddChild(createPrinter);

            // add in the import printer button
            var importPrinter = new IconButton(AggContext.StaticData.LoadIcon("md-import_18.png", 18, 18, theme.InvertIcons), theme)
            {
                VAnchor     = VAnchor.Center,
                Margin      = theme.ButtonSpacing,
                ToolTipText = "Import Printer".Localize(),
                Height      = forcedHeight,
                Width       = forcedHeight
            };

            importPrinter.Click += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    AggContext.FileDialogs.OpenFileDialog(
                        new OpenFileDialogParams(
                            "settings files|*.ini;*.printer;*.slice"),
                        (result) =>
                    {
                        if (!string.IsNullOrEmpty(result.FileName) &&
                            File.Exists(result.FileName))
                        {
                            //simpleTabs.RemoveTab(simpleTabs.ActiveTab);
                            if (ProfileManager.ImportFromExisting(result.FileName))
                            {
                                string importPrinterSuccessMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize();
                                DialogWindow.Show(
                                    new ImportSucceeded(
                                        importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(result.FileName))));
                            }
                            else
                            {
                                StyledMessageBox.ShowMessageBox("Oops! Settings file '{0}' did not contain any settings we could import.".Localize().FormatWith(Path.GetFileName(result.FileName)), "Unable to Import".Localize());
                            }
                        }
                    });
                });
            };
            headingBar.AddChild(importPrinter);

            this.printerInfo = printerInfo;

            this.RebuildPlateOptions(partPreviewContent, theme);

            // Rebuild on change
            ProfileManager.ProfilesListChanged.RegisterEvent((s, e) =>
            {
                this.RebuildPlateOptions(partPreviewContent, theme);
            }, ref unregisterEvents);
        }
示例#9
0
        public PartsBar(PartPreviewContent partPreviewContent, ThemeConfig theme)
            : base("Parts".Localize(), theme)
        {
            var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("new-part.png", 70, 70))
            {
                Margin          = new BorderDouble(right: 5),
                Selectable      = true,
                BackgroundColor = theme.MinimalShade,
                Cursor          = Cursors.Hand,
                Name            = "Create Part Button"
            };

            emptyPlateButton.Click += (s, e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    UiThread.RunOnIdle(async() =>
                    {
                        var workspace = new BedConfig();
                        await workspace.LoadContent(
                            new EditContext()
                        {
                            ContentStore = ApplicationController.Instance.Library.PartHistory,
                            SourceItem   = BedConfig.NewPlatingItem(ApplicationController.Instance.Library.PartHistory)
                        });

                        ApplicationController.Instance.Workspaces.Add(workspace);

                        partPreviewContent.CreatePartTab("New Part", workspace, theme);
                    });
                }
            };
            toolbar.AddChild(emptyPlateButton);

            var recentParts = new DirectoryInfo(ApplicationDataStorage.Instance.PartHistoryDirectory).GetFiles("*.mcx").OrderByDescending(f => f.LastWriteTime);

            foreach (var item in recentParts.Where(f => f.Length > 500).Select(f => new SceneReplacementFileItem(f.FullName)).Take(10).ToList <ILibraryItem>())
            {
                var iconButton = new IconViewItem(new ListViewItem(item, ApplicationController.Instance.Library.PlatingHistory), 70, 70, theme)
                {
                    Margin     = new BorderDouble(right: 5),
                    Selectable = true,
                };

                iconButton.Click += async(s, e) =>
                {
                    // Activate selected item tab
                    if (partPreviewContent.TabControl.AllTabs.FirstOrDefault(t => t.Text == item.Name) is ChromeTab existingItemTab)
                    {
                        partPreviewContent.TabControl.ActiveTab = existingItemTab;
                    }
                    else
                    {
                        // Create tab for selected item
                        if (this.PositionWithinLocalBounds(e.X, e.Y) &&
                            e.Button == MouseButtons.Left)
                        {
                            var workspace = new BedConfig();
                            await workspace.LoadContent(
                                new EditContext()
                            {
                                ContentStore = ApplicationController.Instance.Library.PartHistory,
                                SourceItem   = item
                            });

                            ApplicationController.Instance.Workspaces.Add(workspace);

                            partPreviewContent.CreatePartTab(item.Name, workspace, theme);
                        }
                    }
                };

                toolbar.AddChild(iconButton);
            }
        }
示例#10
0
        private void RebuildPlateOptions(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            toolbar.ActionArea.CloseAllChildren();

            var lastProfileID = ProfileManager.Instance.LastProfileID;
            var lastProfile   = ProfileManager.Instance[lastProfileID];

            if (lastProfile == null)
            {
                if (ProfileManager.Instance.Profiles.Count > 0)
                {
                    toolbar.AddChild(new TextWidget("Select a printer to continue".Localize() + "...", textColor: theme.Colors.PrimaryTextColor, pointSize: theme.DefaultFontSize)
                    {
                        Margin = 15
                    });
                }
                else
                {
                    toolbar.AddChild(new TextWidget("Create a printer to continue".Localize() + "...", textColor: theme.Colors.PrimaryTextColor, pointSize: theme.DefaultFontSize)
                    {
                        Margin = 15
                    });
                }
            }
            else
            {
                var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("empty-workspace.png", 70, 70))
                {
                    Margin          = new BorderDouble(right: 5),
                    Selectable      = true,
                    BackgroundColor = theme.MinimalShade,
                    Name            = "Open Empty Plate Button",
                    Cursor          = Cursors.Hand
                };
                emptyPlateButton.Click += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        UiThread.RunOnIdle(async() =>
                        {
                            var printer = await ProfileManager.Instance.LoadPrinter();
                            printer.ViewState.ViewMode = PartViewMode.Model;

                            // Load empty plate
                            await printer.Bed.LoadContent(
                                new EditContext()
                            {
                                ContentStore = ApplicationController.Instance.Library.PlatingHistory,
                                SourceItem   = BedConfig.NewPlatingItem(ApplicationController.Instance.Library.PlatingHistory)
                            });

                            // Always switch to printer tab after changing plate
                            partPreviewContent.TabControl.SelectedTabIndex = 1;
                        });
                    }
                };

                toolbar.AddChild(emptyPlateButton);

                // Select the 25 most recent files and project onto FileSystemItems
                var recentFiles = new DirectoryInfo(ApplicationDataStorage.Instance.PlatingDirectory).GetFiles("*.mcx").OrderByDescending(f => f.LastWriteTime);
                foreach (var item in recentFiles.Where(f => f.Length > 500).Select(f => new SceneReplacementFileItem(f.FullName)).Take(10).ToList <ILibraryItem>())
                {
                    var iconButton = new IconViewItem(new ListViewItem(item, ApplicationController.Instance.Library.PlatingHistory), 70, 70, theme)
                    {
                        Margin     = new BorderDouble(right: 5),
                        Selectable = true,
                        Cursor     = Cursors.Hand
                    };

                    iconButton.Click += (s, e) =>
                    {
                        if (this.PositionWithinLocalBounds(e.X, e.Y) &&
                            e.Button == MouseButtons.Left)
                        {
                            UiThread.RunOnIdle(async() =>
                            {
                                await ProfileManager.Instance.LoadPrinterOpenItem(item);

                                var printer = ApplicationController.Instance.ActivePrinter;
                                printer.ViewState.ViewMode = PartViewMode.Model;

                                // Always switch to printer tab after changing plate
                                partPreviewContent.TabControl.SelectedTabIndex = 1;
                            });
                        }
                    };

                    toolbar.AddChild(iconButton);
                }
            }
        }
示例#11
0
        public override void Initialize()
        {
            base.Initialize();

            this.AnchorAll();
            this.Name            = "WidescreenPanel";
            this.BackgroundColor = theme.Colors.PrimaryBackgroundColor;

            // Push TouchScreenMode into GuiWidget
            GuiWidget.TouchScreenMode = UserSettings.Instance.IsTouchScreen;

            var library3DViewSplitter = new Splitter()
            {
                SplitterDistance   = UserSettings.Instance.LibraryViewWidth,
                SplitterSize       = theme.SplitterWidth,
                SplitterBackground = theme.SplitterBackground
            };

            library3DViewSplitter.AnchorAll();

            library3DViewSplitter.DistanceChanged += (s, e) =>
            {
                UserSettings.Instance.LibraryViewWidth = library3DViewSplitter.SplitterDistance;
            };

            this.AddChild(library3DViewSplitter);

            // put in the right column
            var partPreviewContent = new PartPreviewContent(theme)
            {
                VAnchor = VAnchor.Bottom | VAnchor.Top,
                HAnchor = HAnchor.Left | HAnchor.Right
            };

            library3DViewSplitter.Panel2.AddChild(partPreviewContent);

            // put in the left column
            var leftNav = new FlowLayoutWidget(FlowDirection.TopToBottom);

            using (leftNav.LayoutLock())
            {
                leftNav.AddChild(new BrandMenuButton(theme)
                {
                    HAnchor         = HAnchor.Stretch,
                    VAnchor         = VAnchor.Fit,
                    BackgroundColor = theme.TabBarBackground,
                    Border          = new BorderDouble(right: 1),
                    BorderColor     = theme.MinimalShade,
                    Padding         = theme.TabbarPadding.Clone(right: 0)
                });

                leftNav.AddChild(new PrintLibraryWidget(partPreviewContent, theme)
                {
                    BackgroundColor = theme.ActiveTabColor
                });
            }

            leftNav.AnchorAll();

            library3DViewSplitter.Panel1.AddChild(leftNav);
        }
示例#12
0
        public PrintLibraryWidget(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            this.theme = theme;
            this.partPreviewContent = partPreviewContent;
            this.Padding            = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryView = new ListView(ApplicationController.Instance.Library, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter = (container) => UserSettings.Instance.ShowContainers,
                BackgroundColor = theme.ActiveTabColor,
                Border          = new BorderDouble(top: 1)
            };

            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;

            ApplicationController.Instance.Library.ContainerChanged += Library_ContainerChanged;

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            allControls.AddChild(navBar);
            theme.ApplyBottomBorder(navBar);

            var toolbar = new OverflowBar(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Name    = "Folders Toolbar"
            };

            theme.ApplyBottomBorder(toolbar, shadedBorder: true);

            toolbar.OverflowButton.Name = "Print Library View Options";
            toolbar.Padding             = theme.ToolbarPadding;

            toolbar.ExtendOverflowMenu = (popupMenu) =>
            {
                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Date Created".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.CreatedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.CreatedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Date Modified".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.ModifiedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.ModifiedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Name".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.Name,
                    (v) => libraryView.ActiveSort = ListView.SortKey.Name,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateHorizontalLine();

                siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Ascending".Localize(),
                    () => libraryView.Ascending,
                    (v) => libraryView.Ascending = true,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Descending".Localize(),
                    () => !libraryView.Ascending,
                    (v) => libraryView.Ascending = false,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
            };

            allControls.AddChild(toolbar);

            var showFolders = new ExpandCheckboxButton("Folders".Localize(), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit | VAnchor.Center,
                Margin  = theme.ButtonSpacing,
                Name    = "Show Folders Toggle",
                Checked = UserSettings.Instance.ShowContainers,
            };

            showFolders.SetIconMargin(theme.ButtonSpacing);
            showFolders.CheckedStateChanged += async(s, e) =>
            {
                UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0");
                await libraryView.Reload();
            };
            toolbar.AddChild(showFolders);

            var openButton = new TextButton("Open", theme)
            {
                Margin = theme.ButtonSpacing,
            };

            openButton.Click += (s, e) =>
            {
                var extensionsWithoutPeriod = new HashSet <string>(ApplicationSettings.OpenDesignFileParams.Split('|').First().Split(',').Select(t => t.Trim().Trim('.')));

                foreach (var extension in ApplicationController.Instance.Library.ContentProviders.Keys)
                {
                    extensionsWithoutPeriod.Add(extension.ToUpper());
                }

                var extensionsArray = extensionsWithoutPeriod.OrderBy(t => t).ToArray();

                string filter = string.Format(
                    "{0}|{1}",
                    string.Join(",", extensionsArray),
                    string.Join("", extensionsArray.Select(t => $"*.{t.ToLower()};").ToArray()));

                UiThread.RunOnIdle(() =>
                {
                    AggContext.FileDialogs.OpenFileDialog(
                        new OpenFileDialogParams(filter, multiSelect: true),
                        (openParams) =>
                    {
                        ViewControls3D.LoadAndAddPartsToPlate(this, openParams.FileNames, ApplicationController.Instance.DragDropData.SceneContext);
                    });
                });
            };

            toolbar.AddChild(openButton);

            PopupMenuButton viewMenuButton;

            toolbar.AddChild(
                viewMenuButton = new PopupMenuButton(
                    new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons))
            {
                //VAnchor = VAnchor.Center
            },
                    theme)
            {
                AlignToRightEdge = true
            });

            viewMenuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                var listView = this.libraryView;

                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "View List".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView;
                    listView.ListContentView = new RowListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#if DEBUG
                popupMenu.CreateBoolMenuItem(
                    "View XSmall Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18;
                    listView.ListContentView = new IconListView(theme, 18);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Small Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70;
                    listView.ListContentView = new IconListView(theme, 70);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#endif
                popupMenu.CreateBoolMenuItem(
                    "View Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView;
                    listView.ListContentView = new IconListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Large Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256;
                    listView.ListContentView = new IconListView(theme, 256);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                return(popupMenu);
            };

            breadCrumbWidget = new FolderBreadCrumbWidget(libraryView, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new SearchInputBox(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };
            searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.searchInput.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.searchInput;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = ApplicationController.Instance.Library.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            allControls.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);
        }
示例#13
0
        public PrintLibraryWidget(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            this.theme = theme;
            this.partPreviewContent = partPreviewContent;
            this.Padding            = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryView = new ListView(ApplicationController.Instance.Library, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter = (container) => UserSettings.Instance.ShowContainers,
                BackgroundColor = theme.ActiveTabColor,
                Border          = new BorderDouble(top: 1)
            };

            ApplicationController.Instance.Library.ActiveViewWidget = libraryView;

            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;

            ApplicationController.Instance.Library.ContainerChanged += Library_ContainerChanged;

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            allControls.AddChild(navBar);
            theme.ApplyBottomBorder(navBar);

            navBar.OverflowButton.BeforePopup += (s, e) =>
            {
                this.EnableMenus();
            };

            var toolbar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Name    = "Folders Toolbar"
            };

            theme.ApplyBottomBorder(toolbar, shadedBorder: true);

            // Change the overflow button to a sort icon
            var firstChild = toolbar.OverflowButton.Children <ImageWidget>().FirstOrDefault();

            firstChild.Image = AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons);

            toolbar.OverflowButton.Name = "Print Library View Options";
            toolbar.Padding             = theme.ToolbarPadding;

            toolbar.ExtendOverflowMenu = (popupMenu) =>
            {
                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Date Created".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.CreatedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.CreatedDate,
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Date Modified".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.ModifiedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.ModifiedDate,
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Name".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.Name,
                    (v) => libraryView.ActiveSort = ListView.SortKey.Name,
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                popupMenu.CreateHorizontalLine();

                siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Ascending".Localize(),
                    () => libraryView.Ascending,
                    (v) => libraryView.Ascending = true,
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Descending".Localize(),
                    () => !libraryView.Ascending,
                    (v) => libraryView.Ascending = false,
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);
            };

            allControls.AddChild(toolbar);

            var showFolders = new ExpandCheckboxButton("Folders".Localize(), theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit | VAnchor.Center,
                Margin  = theme.ButtonSpacing,
                Name    = "Show Folders Toggle",
                Checked = UserSettings.Instance.ShowContainers,
            };

            showFolders.SetIconMargin(theme.ButtonSpacing);
            showFolders.CheckedStateChanged += async(s, e) =>
            {
                UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0");
                await libraryView.Reload();
            };
            toolbar.AddChild(showFolders);

            PopupMenuButton viewMenuButton;

            toolbar.AddChild(
                viewMenuButton = new PopupMenuButton(
                    new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons))
            {
                //VAnchor = VAnchor.Center
            },
                    theme)
            {
                AlignToRightEdge = true
            });

            viewMenuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                var listView = this.libraryView;

                var siblingList = new List <GuiWidget>();


                popupMenu.CreateBoolMenuItem(
                    "View List".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView;
                    listView.ListContentView = new RowListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);
#if DEBUG
                popupMenu.CreateBoolMenuItem(
                    "View XSmall Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18;
                    listView.ListContentView = new IconListView(theme, 18);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);


                popupMenu.CreateBoolMenuItem(
                    "View Small Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70;
                    listView.ListContentView = new IconListView(theme, 70);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);
#endif
                popupMenu.CreateBoolMenuItem(
                    "View Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView;
                    listView.ListContentView = new IconListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Large Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256;
                    listView.ListContentView = new IconListView(theme, 256);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    SiblingRadioButtonList: siblingList);

                return(popupMenu);
            };

            breadCrumbWidget = new FolderBreadCrumbWidget(libraryView, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new SearchInputBox(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };
            searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.searchInput.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.searchInput;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = ApplicationController.Instance.Library.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            allControls.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);
        }
示例#14
0
        public LibraryWidget(PartPreviewContent partPreviewContent, ThemeConfig theme)
        {
            this.theme = theme;
            this.partPreviewContent = partPreviewContent;
            this.Padding            = 0;
            this.AnchorAll();

            var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            libraryView = new ListView(ApplicationController.Instance.Library, theme)
            {
                Name = "LibraryView",
                // Drop containers if ShowContainers != 1
                ContainerFilter = (container) => UserSettings.Instance.ShowContainers,
                BackgroundColor = theme.ActiveTabColor,
                Border          = new BorderDouble(top: 1)
            };

            libraryView.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;

            ApplicationController.Instance.Library.ContainerChanged += Library_ContainerChanged;

            navBar = new OverflowBar(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };
            allControls.AddChild(navBar);
            theme.ApplyBottomBorder(navBar);

            breadCrumbWidget = new FolderBreadCrumbWidget(libraryView, theme);
            navBar.AddChild(breadCrumbWidget);

            var searchPanel = new SearchInputBox(theme)
            {
                Visible = false,
                Margin  = new BorderDouble(10, 0, 5, 0),
            };

            searchPanel.searchInput.ActualTextEditWidget.EnterPressed += (s, e) =>
            {
                this.PerformSearch();
            };
            searchPanel.ResetButton.Click += (s, e) =>
            {
                breadCrumbWidget.Visible = true;
                searchPanel.Visible      = false;

                searchPanel.searchInput.Text = "";

                this.ClearSearch();
            };

            // Store a reference to the input field
            this.searchInput = searchPanel.searchInput;

            navBar.AddChild(searchPanel);

            searchButton         = theme.CreateSearchButton();
            searchButton.Enabled = false;
            searchButton.Name    = "Search Library Button";
            searchButton.Click  += (s, e) =>
            {
                if (searchPanel.Visible)
                {
                    PerformSearch();
                }
                else
                {
                    searchContainer = ApplicationController.Instance.Library.ActiveContainer;

                    breadCrumbWidget.Visible = false;
                    searchPanel.Visible      = true;
                    searchInput.Focus();
                }
            };
            navBar.AddChild(searchButton);

            PopupMenuButton viewOptionsButton;

            navBar.AddChild(
                viewOptionsButton = new PopupMenuButton(
                    new ImageWidget(AggContext.StaticData.LoadIcon("fa-sort_16.png", 32, 32, theme.InvertIcons))
            {
                //VAnchor = VAnchor.Center
            },
                    theme)
            {
                AlignToRightEdge = true,
                Name             = "Print Library View Options"
            });

            viewOptionsButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Date Created".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.CreatedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.CreatedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Date Modified".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.ModifiedDate,
                    (v) => libraryView.ActiveSort = ListView.SortKey.ModifiedDate,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Name".Localize(),
                    () => libraryView.ActiveSort == ListView.SortKey.Name,
                    (v) => libraryView.ActiveSort = ListView.SortKey.Name,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateHorizontalLine();

                siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "Ascending".Localize(),
                    () => libraryView.Ascending,
                    (v) => libraryView.Ascending = true,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "Descending".Localize(),
                    () => !libraryView.Ascending,
                    (v) => libraryView.Ascending = false,
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                return(popupMenu);
            };

            PopupMenuButton viewMenuButton;

            navBar.AddChild(
                viewMenuButton = new PopupMenuButton(
                    new ImageWidget(AggContext.StaticData.LoadIcon("mi-view-list_10.png", 32, 32, theme.InvertIcons))
            {
                //VAnchor = VAnchor.Center
            },
                    theme)
            {
                AlignToRightEdge = true
            });

            viewMenuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                var listView = this.libraryView;

                var siblingList = new List <GuiWidget>();

                popupMenu.CreateBoolMenuItem(
                    "View List".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.RowListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.RowListView;
                    listView.ListContentView = new RowListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#if DEBUG
                popupMenu.CreateBoolMenuItem(
                    "View XSmall Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView18,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView18;
                    listView.ListContentView = new IconListView(theme, 18);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Small Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView70,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView70;
                    listView.ListContentView = new IconListView(theme, 70);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);
#endif
                popupMenu.CreateBoolMenuItem(
                    "View Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView;
                    listView.ListContentView = new IconListView(theme);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                popupMenu.CreateBoolMenuItem(
                    "View Large Icons".Localize(),
                    () => ApplicationController.Instance.ViewState.LibraryViewMode == ListViewModes.IconListView256,
                    (isChecked) =>
                {
                    ApplicationController.Instance.ViewState.LibraryViewMode = ListViewModes.IconListView256;
                    listView.ListContentView = new IconListView(theme, 256);
                    listView.Reload().ConfigureAwait(false);
                },
                    useRadioStyle: true,
                    siblingRadioButtonList: siblingList);

                return(popupMenu);
            };

            var horizontalSplitter = new Splitter()
            {
                SplitterDistance   = UserSettings.Instance.LibraryViewWidth,
                SplitterSize       = theme.SplitterWidth,
                SplitterBackground = theme.SplitterBackground
            };
            horizontalSplitter.AnchorAll();

            horizontalSplitter.DistanceChanged += (s, e) =>
            {
                UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance;
            };

            allControls.AddChild(horizontalSplitter);

            treeView = new TreeView(theme)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Margin  = 5
            };
            treeView.AfterSelect += async(s, e) =>
            {
                if (treeView.SelectedNode is ContainerTreeNode treeNode)
                {
                    if (!treeNode.ContainerAcquired)
                    {
                        await this.EnsureExpanded(treeNode.Tag as ILibraryItem, treeNode);
                    }

                    if (treeNode.ContainerAcquired)
                    {
                        ApplicationController.Instance.Library.ActiveContainer = treeNode.Container;
                    }
                }
            };
            horizontalSplitter.Panel1.AddChild(treeView);

            var rootColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Margin  = new BorderDouble(left: 10)
            };
            treeView.AddChild(rootColumn);

            UiThread.RunOnIdle(() =>
            {
                foreach (var item in ApplicationController.Instance.Library.ActiveContainer.ChildContainers)
                {
                    var rootNode      = this.CreateTreeNode(item);
                    rootNode.TreeView = treeView;

                    rootColumn.AddChild(rootNode);
                }
            }, 1);
            horizontalSplitter.Panel2.AddChild(libraryView);

            buttonPanel = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Padding = theme.ToolbarPadding,
            };
            AddLibraryButtonElements();
            allControls.AddChild(buttonPanel);

            allControls.AnchorAll();

            this.AddChild(allControls);
        }
示例#15
0
        public static void CreateMenuActions(ListView libraryView, List <PrintItemAction> menuActions, PartPreviewContent partPreviewContent, ThemeConfig theme, bool allowPrint)
        {
            menuActions.Add(new PrintItemAction()
            {
                Icon        = AggContext.StaticData.LoadIcon("cube.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons),
                Title       = "Add".Localize(),
                ToolTipText = "Add an.stl, .obj, .amf, .gcode or.zip file to the Library".Localize(),
                Action      = (selectedLibraryItems, listView) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        AggContext.FileDialogs.OpenFileDialog(
                            new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true),
                            (openParams) =>
                        {
                            if (openParams.FileNames != null)
                            {
                                var writableContainer = libraryView.ActiveContainer as ILibraryWritableContainer;
                                if (writableContainer != null &&
                                    openParams.FileNames.Length > 0)
                                {
                                    writableContainer.Add(openParams.FileNames.Select(f => new FileSystemFileItem(f)));
                                }
                            }
                        });
                    });
                },
                IsEnabled = (s, l) => libraryView.ActiveContainer is ILibraryWritableContainer
            });

            menuActions.Add(new PrintItemAction()
            {
                Title  = "Create Folder".Localize(),
                Icon   = AggContext.StaticData.LoadIcon("fa-folder-new_16.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons),
                Action = (selectedLibraryItems, listView) =>
                {
                    DialogWindow.Show(
                        new InputBoxPage(
                            "Create Folder".Localize(),
                            "Folder Name".Localize(),
                            "",
                            "Enter New Name Here".Localize(),
                            "Create".Localize(),
                            (newName) =>
                    {
                        if (!string.IsNullOrEmpty(newName) &&
                            libraryView.ActiveContainer is ILibraryWritableContainer writableContainer)
                        {
                            writableContainer.Add(new[]
                            {
                                new CreateFolderItem()
                                {
                                    Name = newName
                                }
                            });
                        }
                    }));
                },
                IsEnabled = (s, l) =>
                {
                    return(libraryView.ActiveContainer is ILibraryWritableContainer writableContainer &&
                           writableContainer?.AllowAction(ContainerActions.AddContainers) == true);
                }
            });