public GamePanelWidget(WidgetGroup parentGroup, GamePanelStyle gamePanelStyle, float x, float y)
        : base(parentGroup, gamePanelStyle.Width, gamePanelStyle.Height, x, y)
    {
        float statsX = BORDER_WIDTH;
        float statsY = BORDER_WIDTH;

        // Background for the character info
        m_background = new ImageWidget(this, gamePanelStyle.Width, gamePanelStyle.Height, gamePanelStyle.Background, 0, 0);

        // Game name
        m_nameLabel = new LabelWidget(this, STATS_LABEL_WIDTH, STATS_LABEL_HEIGHT, statsX, statsY, "Name:");
        m_nameLabel.Visible = false;

        m_nameText = new LabelWidget(this, STATS_LABEL_WIDTH, STATS_LABEL_HEIGHT, statsX + STATS_LABEL_WIDTH, statsY, "");
        m_nameText.Visible = false;

        // Game Owner
        statsY += STATS_LABEL_HEIGHT;
        m_ownerLabel = new LabelWidget(this, STATS_LABEL_WIDTH, STATS_LABEL_HEIGHT, statsX, statsY, "Owner:");
        m_ownerLabel.Visible = false;

        m_ownerText = new LabelWidget(this, STATS_LABEL_WIDTH, STATS_LABEL_HEIGHT, statsX + STATS_LABEL_WIDTH, statsY, "");
        m_ownerText.Visible = false;

        // Characters
        statsY += STATS_LABEL_HEIGHT;
        m_charactersLabel = new LabelWidget(this, STATS_LABEL_WIDTH, STATS_LABEL_HEIGHT, statsX, statsY, "Characters:");
        m_charactersLabel.Visible = false;

        statsY += STATS_LABEL_HEIGHT;
        m_charactersText = new LabelWidget(this, m_background.Width - 2*BORDER_WIDTH, STATS_LABEL_HEIGHT, statsX, statsY, "");
        m_charactersText.Visible = false;
    }
    public ScrollListWidget(
        WidgetGroup parentGroup, 
        WidgetFactory widgetFactory,
        ScrollListStyle style,
        float x, 
        float y)
        : base(parentGroup, style.Width, style.Height, x, y)
    {
        m_widgetFactory = widgetFactory;
        m_widgetList = new List<IWidget>();
        m_scrollIndex = 0;

        m_scrollFrame = new ImageWidget(this, style.Width, style.Height, style.Background, 0.0f, 0.0f);

        m_scrollUpButton =
            new ButtonWidget(this, style.ButtonStyle, 0, 0, "Previous");
        m_scrollUpButton.SetLocalPosition(
            m_scrollFrame.Width / 2 - m_scrollUpButton.Width / 2,
            BORDER_WIDTH);
        m_scrollUpButton.Visible = false;

        m_scrollDownButton =
            new ButtonWidget(this, style.ButtonStyle, 0, 0, "Next");
        m_scrollDownButton.SetLocalPosition(
            m_scrollUpButton.LocalX,
            m_scrollFrame.Height - m_scrollDownButton.Height - BORDER_WIDTH);
        m_scrollDownButton.Visible = false;
    }
Exemple #3
0
 protected ImageWidget(ImageWidget other)
     : base(other)
 {
     ClickThrough = other.ClickThrough;
     ImageName = other.ImageName;
     GetImageName = other.GetImageName;
     ImageCollection = other.ImageCollection;
     GetImageCollection = other.GetImageCollection;
 }
Exemple #4
0
        protected ImageWidget(ImageWidget other)
            : base(other)
        {
            ClickThrough = other.ClickThrough;
            ImageName = other.ImageName;
            GetImageName = other.GetImageName;
            ImageCollection = other.ImageCollection;
            GetImageCollection = other.GetImageCollection;

            TooltipTemplate = other.TooltipTemplate;
            TooltipContainer = other.TooltipContainer;
            GetTooltipText = other.GetTooltipText;
            tooltipContainer = Exts.Lazy(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
        }
    public CharacterThumbnailWidget(
        WidgetGroup parentGroup, 
        CharacterThumbnailStyle style, 
        CharacterData characterData)
        : base(parentGroup, style.BackgroundWidth, style.BackgroundHeight, 0, 0)
    {
        new ImageWidget(this, style.BackgroundWidth, style.BackgroundHeight, style.Background, 0.0f, 0.0f);

        // Background for the character info
        string portraitResource = ClientGameConstants.GetResourceNameForPicture((uint)characterData.picture_id);
        ImageWidget portrait=
            new ImageWidget(
                this,
                style.PortraitWidth, style.PortraitHeight,
                Resources.Load<Texture>(portraitResource),
                5, 5);

        // Character name
        LabelWidget nameLabel=
            new LabelWidget(
                this,
                style.LabelWidth, style.LabelHeight,
                portrait.LocalX + portrait.Width + 3, 0,
                characterData.character_name);

        // Character info
        string archetype = GameConstants.GetArchetypeString(ClientGameConstants.GetArchetypeForPicture((uint)characterData.picture_id));
        string infoString = "Lvl " + characterData.power_level.ToString() + " " + archetype;
        new LabelWidget(
            this,
            style.LabelWidth, style.LabelHeight,
            portrait.LocalX + portrait.Width + 3,
            nameLabel.LocalY + nameLabel.Height,
            infoString);

        this.Visible = false;
    }
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            AltGroupBox eePromControlsGroupBox = new AltGroupBox(groupBoxTitle);

            eePromControlsGroupBox.Margin      = new BorderDouble(0);
            eePromControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;
            eePromControlsGroupBox.Height      = 68;
            {
                FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
                eePromControlsLayout.HAnchor |= HAnchor.ParentCenter;
                eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                eePromControlsLayout.Margin   = new BorderDouble(3, 0, 3, 6);
                eePromControlsLayout.Padding  = new BorderDouble(0);
                {
                    Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
                    ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
                    ImageWidget eePromIcon = new ImageWidget(eePromImage);
                    eePromIcon.Margin = new BorderDouble(right: 6);

                    Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
                        switch (PrinterConnectionAndCommunication.Instance.FirmwareType)
                        {
                        case PrinterConnectionAndCommunication.FirmwareTypes.Repetier:
                            if (openEePromRepetierWidget != null)
                            {
                                openEePromRepetierWidget.BringToFront();
                            }
                            else
                            {
                                openEePromRepetierWidget         = new EePromRepetierWidget();
                                openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) =>
                                {
                                    openEePromRepetierWidget = null;
                                };
                            }
                            break;

                        case PrinterConnectionAndCommunication.FirmwareTypes.Marlin:
                            if (openEePromMarlinWidget != null)
                            {
                                openEePromMarlinWidget.BringToFront();
                            }
                            else
                            {
                                openEePromMarlinWidget         = new EePromMarlinWidget();
                                openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) =>
                                {
                                    openEePromMarlinWidget = null;
                                };
                            }
                            break;

                        default:
                            UiThread.RunOnIdle((state) =>
                            {
                                StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
                            }
                                               );
                            break;
                        }
#endif
                    };
                    //eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
Exemple #7
0
        public GuiWidget Create(IObject3D item, UndoBuffer undoBuffer, ThemeConfig theme)
        {
            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.MaxFitOrStretch
            };

            var imageObject = item as ImageObject3D;

            var activeImage = imageObject.Image;

            var imageSection = new SearchableSectionWidget("Image".Localize(), new FlowLayoutWidget(FlowDirection.TopToBottom), theme, emptyText: "Search Google".Localize());

            imageSection.SearchInvoked += (s, e) =>
            {
                string imageType = " silhouette";

                if (item.Parent.GetType().Name.Contains("Lithophane"))
                {
                    imageType = "";
                }

                ApplicationController.Instance.LaunchBrowser($"http://www.google.com/search?q={e.Data}{imageType}&tbm=isch");
            };

            theme.ApplyBoxStyle(imageSection, margin: 0);

            column.AddChild(imageSection);

            ImageBuffer thumbnailImage = SetImage(theme, imageObject);

            ImageWidget thumbnailWidget;

            imageSection.ContentPanel.AddChild(thumbnailWidget = new ImageWidget(thumbnailImage)
            {
                Margin  = new BorderDouble(bottom: 5),
                HAnchor = HAnchor.Center
            });

            thumbnailWidget.Click += (s, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    var popupMenu = new PopupMenu(theme);

                    var pasteMenu = popupMenu.CreateMenuItem("Paste".Localize());
                    pasteMenu.Click += (s2, e2) =>
                    {
                        activeImage = Clipboard.Instance.GetImage();

                        thumbnailWidget.Image = activeImage;

                        // Persist
                        string filePath = ApplicationDataStorage.Instance.GetNewLibraryFilePath(".png");
                        AggContext.ImageIO.SaveImageData(
                            filePath,
                            activeImage);

                        imageObject.AssetPath = filePath;
                        imageObject.Mesh      = null;

                        thumbnailWidget.Image = SetImage(theme, imageObject);

                        column.Invalidate();
                        imageObject.Invalidate(InvalidateType.Image);
                    };

                    pasteMenu.Enabled = Clipboard.Instance.ContainsImage;

                    var copyMenu = popupMenu.CreateMenuItem("Copy".Localize());
                    copyMenu.Click += (s2, e2) =>
                    {
                        Clipboard.Instance.SetImage(thumbnailWidget.Image);
                    };

                    popupMenu.ShowMenu(thumbnailWidget, e);
                }
            };

            // add in the invert checkbox and change image button
            var changeButton = new TextButton("Change".Localize(), theme)
            {
                BackgroundColor = theme.MinimalShade
            };

            changeButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    // we do this using to make sure that the stream is closed before we try and insert the Picture
                    AggContext.FileDialogs.OpenFileDialog(
                        new OpenFileDialogParams(
                            "Select an image file|*.jpg;*.png;*.bmp;*.gif;*.pdf",
                            multiSelect: false,
                            title: "Add Image".Localize()),
                        (openParams) =>
                    {
                        if (!File.Exists(openParams.FileName))
                        {
                            return;
                        }

                        imageObject.AssetPath = openParams.FileName;
                        using (imageObject.RebuildLock())
                        {
                            imageObject.Mesh = null;
                        }

                        thumbnailWidget.Image = SetImage(theme, imageObject);

                        column.Invalidate();
                        imageObject.Invalidate(InvalidateType.Image);
                    });
                });
            };

            var row = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Margin  = new BorderDouble(8, 5)
            };

            imageSection.ContentPanel.AddChild(row);

            // Invert checkbox
            var invertCheckbox = new CheckBox(new CheckBoxViewText("Invert".Localize(), textColor: theme.TextColor))
            {
                Checked = imageObject.Invert,
                Margin  = new BorderDouble(0),
                VAnchor = VAnchor.Center,
            };

            invertCheckbox.CheckedStateChanged += (s, e) =>
            {
                imageObject.Invert = invertCheckbox.Checked;
            };
            row.AddChild(invertCheckbox);

            row.AddChild(new HorizontalSpacer());

            row.AddChild(changeButton);

            imageObject.Invalidated += (s, e) =>
            {
                if (e.InvalidateType.HasFlag(InvalidateType.Image) &&
                    activeImage != imageObject.Image)
                {
                    thumbnailImage        = SetImage(theme, imageObject);
                    thumbnailWidget.Image = thumbnailImage;

                    activeImage = imageObject.Image;
                }
            };

            return(column);
        }
Exemple #8
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;

                            var historyContainer = ApplicationController.Instance.Library.PlatingHistory;

                            // Load empty plate
                            await printer.Bed.LoadContent(
                                new EditContext()
                            {
                                ContentStore = historyContainer,
                                SourceItem   = historyContainer.NewPlatingItem()
                            });

                            // 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);
                }
            }
        }
Exemple #9
0
        public ExploreItem(FeedItemData item, ThemeConfig theme)
        {
            this.HAnchor = HAnchor.Absolute;
            this.Width   = 400 * GuiWidget.DeviceScale;
            //this.Border = spacing;
            this.Padding = ItemSpacing;
            this.item    = item;
            this.theme   = theme;

            image = new ImageBuffer(IconSize, IconSize);

            if (item.icon != null)
            {
                imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Top,
                    Margin     = new BorderDouble(right: ItemSpacing)
                };

                imageWidget.Load += async(s, e) =>
                {
                    var loadInto = new ImageBuffer(IconSize, IconSize);
                    await ApplicationController.Instance.LoadRemoteImage(loadInto, item.icon, true, new BlenderPreMultBGRA());

                    var grayscale = new ImageBuffer(loadInto);
                    ApplicationController.Instance.MakeGrayscale(grayscale);

                    image             = grayscale;
                    imageWidget.Image = image;

                    hoverImage = loadInto;
                };
                this.AddChild(imageWidget);
            }
            else if (item.widget_url != null)
            {
                var whiteBackground = new GuiWidget(IconSize, IconSize)
                {
                    // these images expect to be on white so change the background to white
                    BackgroundColor = Color.White,
                    Margin          = new BorderDouble(right: ItemSpacing)
                };
                this.AddChild(whiteBackground);

                imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Center,
                };

                imageWidget.Load += async(s, e) =>
                {
                    var loadInto = new ImageBuffer(IconSize, IconSize);
                    await ApplicationController.Instance.LoadRemoteImage(loadInto, item.widget_url, true, new BlenderPreMultBGRA());

                    var grayscale = new ImageBuffer(loadInto);
                    ApplicationController.Instance.MakeGrayscale(grayscale);

                    image             = grayscale;
                    imageWidget.Image = image;

                    hoverImage = loadInto;
                };
                whiteBackground.AddChild(imageWidget);
            }

            var wrappedText = new WrappedTextWidget(item.title, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: theme.DefaultFontSize)
            {
                Selectable = false,
                VAnchor    = VAnchor.Center | VAnchor.Fit,
                Margin     = 3
            };

            this.AddChild(wrappedText);
            wrappedText.Load += (s, e) =>
            {
                wrappedText.VAnchor = VAnchor.Top | VAnchor.Fit;
            };

            this.Cursor = Cursors.Hand;
        }
Exemple #10
0
        private FlowLayoutWidget GetCloudMonitorControls()
        {
            FlowLayoutWidget buttonBar = new FlowLayoutWidget();

            buttonBar.HAnchor |= HAnchor.ParentLeftRight;
            buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
            buttonBar.Margin   = new BorderDouble(0, 0, 0, 0);
            buttonBar.Padding  = new BorderDouble(0);

            this.textImageButtonFactory.FixedHeight = TallButtonHeight;

            Agg.Image.ImageBuffer cloudMonitorImage = new Agg.Image.ImageBuffer();
            ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "cloud-24x24.png"), cloudMonitorImage);
            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                InvertLightness.DoInvertLightness(cloudMonitorImage);
            }

            ImageWidget cloudMonitoringIcon = new ImageWidget(cloudMonitorImage);

            cloudMonitoringIcon.Margin = new BorderDouble(right: 6);

            enableCloudMonitorButton         = textImageButtonFactory.Generate("Enable".Localize().ToUpper());
            enableCloudMonitorButton.Margin  = new BorderDouble(left: 6);
            enableCloudMonitorButton.VAnchor = VAnchor.ParentCenter;
            enableCloudMonitorButton.Click  += new EventHandler(enableCloudMonitor_Click);

            disableCloudMonitorButton         = textImageButtonFactory.Generate("Disable".Localize().ToUpper());
            disableCloudMonitorButton.Margin  = new BorderDouble(left: 6);
            disableCloudMonitorButton.VAnchor = VAnchor.ParentCenter;
            disableCloudMonitorButton.Click  += new EventHandler(disableCloudMonitor_Click);

            cloudMonitorInstructionsLink         = linkButtonFactory.Generate("More Info".Localize().ToUpper());
            cloudMonitorInstructionsLink.VAnchor = VAnchor.ParentCenter;
            cloudMonitorInstructionsLink.Click  += new EventHandler(goCloudMonitoringInstructionsButton_Click);
            cloudMonitorInstructionsLink.Margin  = new BorderDouble(left: 6);

            goCloudMonitoringWebPageButton         = linkButtonFactory.Generate("View Status".Localize().ToUpper());
            goCloudMonitoringWebPageButton.VAnchor = VAnchor.ParentCenter;
            goCloudMonitoringWebPageButton.Click  += new EventHandler(goCloudMonitoringWebPageButton_Click);
            goCloudMonitoringWebPageButton.Margin  = new BorderDouble(left: 6);

            cloudMonitorStatusLabel = new TextWidget("");
            cloudMonitorStatusLabel.AutoExpandBoundsToText = true;
            cloudMonitorStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            cloudMonitorStatusLabel.VAnchor   = VAnchor.ParentCenter;

            GuiWidget hSpacer = new GuiWidget();

            hSpacer.HAnchor = HAnchor.ParentLeftRight;

            buttonBar.AddChild(cloudMonitoringIcon);
            buttonBar.AddChild(cloudMonitorStatusLabel);
            buttonBar.AddChild(cloudMonitorInstructionsLink);
            buttonBar.AddChild(goCloudMonitoringWebPageButton);
            buttonBar.AddChild(hSpacer);
            buttonBar.AddChild(enableCloudMonitorButton);
            buttonBar.AddChild(disableCloudMonitorButton);

            return(buttonBar);
        }
Exemple #11
0
        public TemperatureWidgetBase(PrinterConfig printer, string textValue, ThemeConfig theme)
            : base(theme)
        {
            this.printer = printer;

            this.AlignToRightEdge = true;
            this.DrawArrow        = true;
            this.HAnchor          = HAnchor.Fit;
            this.VAnchor          = VAnchor.Fit | VAnchor.Center;
            this.Cursor           = Cursors.Hand;
            this.MakeScrollable   = false;
            this.AlignToRightEdge = true;

            ImageWidget = new ImageWidget(AggContext.StaticData.LoadIcon("hotend.png", theme.InvertIcons))
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(right: 5)
            };

            alwaysEnabled = new List <GuiWidget>();

            var container = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Padding = new BorderDouble(10, 5, 0, 5)
            };

            this.AddChild(container);

            container.AddChild(this.ImageWidget);

            CurrentTempIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.Colors.PrimaryTextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true
            };
            container.AddChild(CurrentTempIndicator);

            container.AddChild(new TextWidget("/")
            {
                TextColor = theme.Colors.PrimaryTextColor
            });

            goalTempIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.Colors.PrimaryTextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true
            };
            container.AddChild(goalTempIndicator);

            DirectionIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.Colors.PrimaryTextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true,
                Margin = new BorderDouble(left: 5)
            };
            container.AddChild(DirectionIndicator);

            bool isEnabled = printer.Connection.IsConnected;

            printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) =>
            {
                if (isEnabled != printer.Connection.IsConnected)
                {
                    isEnabled = printer.Connection.IsConnected;

                    var flowLayout = this.PopupContent.Children.OfType <FlowLayoutWidget>().FirstOrDefault();
                    if (flowLayout != null)
                    {
                        foreach (var child in flowLayout.Children.Except(alwaysEnabled))
                        {
                            child.Enabled = isEnabled;
                        }
                    }
                }
            }, ref unregisterEvents);
        }
        private FlowLayoutWidget GetAutoLevelControl()
        {
            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Margin  = new BorderDouble(0, 4);

            TextWidget notificationSettingsLabel = new TextWidget("Software Print Leveling");

            notificationSettingsLabel.AutoExpandBoundsToText = true;
            notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            notificationSettingsLabel.VAnchor   = VAnchor.ParentCenter;

            Button editButton = textImageButtonFactory.GenerateEditButton();

            editButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
            editButton.Click  += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    if (editLevelingSettingsWindow == null)
                    {
                        editLevelingSettingsWindow         = new EditLevelingSettingsWindow();
                        editLevelingSettingsWindow.Closed += (sender2, e2) =>
                        {
                            editLevelingSettingsWindow = null;
                        };
                    }
                    else
                    {
                        editLevelingSettingsWindow.BringToFront();
                    }
                });
            };

            Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());

            runPrintLevelingButton.Margin  = new BorderDouble(left: 6);
            runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
            runPrintLevelingButton.Click  += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration);
                });
            };

            Agg.Image.ImageBuffer levelingImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "leveling-24x24.png"));
            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                InvertLightness.DoInvertLightness(levelingImage);
            }

            ImageWidget levelingIcon = new ImageWidget(levelingImage);

            levelingIcon.Margin = new BorderDouble(right: 6);

            CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActivePrinterProfile.Instance.DoPrintLeveling);

            printLevelingSwitch.VAnchor              = VAnchor.ParentCenter;
            printLevelingSwitch.Margin               = new BorderDouble(left: 16);
            printLevelingSwitch.CheckedStateChanged += (sender, e) =>
            {
                ActivePrinterProfile.Instance.DoPrintLeveling = printLevelingSwitch.Checked;
            };

            printLevelingStatusLabel = new TextWidget("");
            printLevelingStatusLabel.AutoExpandBoundsToText = true;
            printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingStatusLabel.VAnchor   = VAnchor.ParentCenter;

            GuiWidget hSpacer = new GuiWidget();

            hSpacer.HAnchor = HAnchor.ParentLeftRight;

            ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
            {
                SetPrintLevelButtonVisiblity();
                printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling;
            }, ref unregisterEvents);

            buttonRow.AddChild(levelingIcon);
            buttonRow.AddChild(printLevelingStatusLabel);
            buttonRow.AddChild(editButton);
            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(runPrintLevelingButton);
            buttonRow.AddChild(printLevelingSwitch);

            SetPrintLevelButtonVisiblity();
            return(buttonRow);
        }
    public void Start()
    {
        SessionData sessionData = SessionData.GetInstance();

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, gamePanelStyle.Width, gamePanelStyle.Height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Background for the game info
        ImageWidget gamePanel =
            new ImageWidget(
                m_rootWidgetGroup,
                gamePanelStyle.Width,
                gamePanelStyle.Height,
                gamePanelStyle.Background,
                0.0f, 0.0f);

        float statsLabelWidth = (gamePanel.Width - 2 * BORDER_WIDTH) / 2 - 3;
        float statsX          = 10;
        float statsY          = 10;

        // Owner Name
        LabelWidget ownerNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Owner Name:");

        ownerNameLabel.Alignment = TextAnchor.UpperRight;
        m_ownerNameLabel         =
            new LabelWidget(
                m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT,
                statsX + statsLabelWidth, statsY, sessionData.UserName);
        m_ownerNameLabel.Text = "";

        // Game name
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget gameNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Game Name:");

        gameNameLabel.Alignment = TextAnchor.UpperRight;
        m_gameNameTextField     = new TextEntryWidget(m_rootWidgetGroup,
                                                      statsLabelWidth, STATS_LABEL_HEIGHT, statsX + statsLabelWidth, statsY, "");

        // IRC Server
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCServerLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Server:");

        IRCServerLabel.Alignment = TextAnchor.UpperRight;
        m_IRCServerTextField     = new TextEntryWidget(m_rootWidgetGroup,
                                                       statsLabelWidth, STATS_LABEL_HEIGHT, statsX + statsLabelWidth, statsY, "");
        m_IRCServerTextField.Text = ServerConstants.DEFAULT_IRC_SERVER;

        // IRC Port
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCPortLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Port:");

        IRCPortLabel.Alignment = TextAnchor.UpperRight;
        m_IRCPortTextField     = new TextEntryWidget(m_rootWidgetGroup,
                                                     statsLabelWidth, STATS_LABEL_HEIGHT, statsX + statsLabelWidth, statsY, "");
        m_IRCPortTextField.Restrict  = @"[^0-9]";
        m_IRCPortTextField.MaxLength = 6;
        m_IRCPortTextField.Text      = ServerConstants.DEFAULT_IRC_PORT.ToString();

        // IRC Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Enabled:");

        IRCEnabledLabel.Alignment  = TextAnchor.UpperRight;
        m_IRCEnabledToggle         = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEnabledToggle.Enabled = true;

        // IRC Encryption Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEncryptionEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Encryption Enabled:");

        IRCEncryptionEnabledLabel.Alignment  = TextAnchor.UpperRight;
        m_IRCEncryptionEnabledToggle         = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEncryptionEnabledToggle.Enabled = true;

        // Creation status
        m_statusLabel = new LabelWidget(m_rootWidgetGroup, gamePanel.Width, STATS_LABEL_HEIGHT, 0.0f, 0.0f, "");
        m_statusLabel.SetLocalPosition(0, gamePanel.Height - m_statusLabel.Height - BORDER_WIDTH);
        m_statusLabel.Alignment = TextAnchor.UpperCenter;

        // Create button
        m_createButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Create");
        m_createButton.SetLocalPosition(gamePanel.Width / 3 - m_createButton.Width / 2, m_statusLabel.LocalY - m_createButton.Height - 5);

        // Cancel button
        m_cancelButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Cancel");
        m_cancelButton.SetLocalPosition((2 * gamePanel.Width) / 3 - m_cancelButton.Width / 2, m_statusLabel.LocalY - m_cancelButton.Height - 5);

        // Center the group info widgets
        m_rootWidgetGroup.SetLocalPosition(Screen.width / 2 - gamePanel.Width / 2, Screen.height / 2 - gamePanel.Height / 2);
    }
Exemple #14
0
        public override void OnLoad(EventArgs args)
        {
            base.OnLoad(args);

            bool smallScreen = Parent.Width <= 1180;

            Padding = smallScreen ? new BorderDouble(20, 5) : new BorderDouble(50, 30);

            var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                VAnchor = VAnchor.ParentBottomTop,
                HAnchor = HAnchor.ParentLeftRight
            };

            AddChild(topToBottom);

            var bodyRow = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor = VAnchor.ParentBottomTop,
                HAnchor = HAnchor.ParentLeftRight,
                Margin  = smallScreen ? new BorderDouble(30, 5, 30, 0) : new BorderDouble(30, 20, 30, 0),               // the -12 is to take out the top bar
            };

            topToBottom.AddChild(bodyRow);

            // Thumbnail section
            {
                int         imageSize   = smallScreen ? 300 : 500;
                ImageBuffer imageBuffer = PartThumbnailWidget.GetImageForItem(PrinterConnectionAndCommunication.Instance.ActivePrintItem, imageSize, imageSize);

                if (imageBuffer == null)
                {
                    imageBuffer = StaticData.Instance.LoadImage(Path.Combine("Images", "Screensaver", "part_thumbnail.png"));
                }

                WhiteToColor.DoWhiteToColor(imageBuffer, ActiveTheme.Instance.PrimaryAccentColor);

                var partThumbnail = new ImageWidget(imageBuffer)
                {
                    VAnchor = VAnchor.ParentCenter,
                    Margin  = smallScreen ? new BorderDouble(right: 20) : new BorderDouble(right: 50),
                };
                bodyRow.AddChild(partThumbnail);
            }

            bodyRow.AddChild(PrintingWindow.CreateVerticalLine());

            // Progress section
            {
                var expandingContainer = new HorizontalSpacer()
                {
                    VAnchor = VAnchor.FitToChildren | VAnchor.ParentCenter
                };
                bodyRow.AddChild(expandingContainer);

                var progressContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
                {
                    Margin  = new BorderDouble(50, 0),
                    VAnchor = VAnchor.ParentCenter | VAnchor.FitToChildren,
                    HAnchor = HAnchor.ParentCenter | HAnchor.FitToChildren,
                };
                expandingContainer.AddChild(progressContainer);

                progressDial = new ProgressDial()
                {
                    HAnchor = HAnchor.ParentCenter,
                    Height  = 200 * DeviceScale,
                    Width   = 200 * DeviceScale
                };
                progressContainer.AddChild(progressDial);

                var timeContainer = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.ParentCenter | HAnchor.FitToChildren,
                    Margin  = 3
                };
                progressContainer.AddChild(timeContainer);

                var timeImage = StaticData.Instance.LoadImage(Path.Combine("Images", "Screensaver", "time.png"));
                if (!ActiveTheme.Instance.IsDarkTheme)
                {
                    timeImage.InvertLightness();
                }

                timeContainer.AddChild(new ImageWidget(timeImage));

                timeWidget = new TextWidget("", pointSize: 22, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    AutoExpandBoundsToText = true,
                    Margin  = new BorderDouble(10, 0, 0, 0),
                    VAnchor = VAnchor.ParentCenter,
                };

                timeContainer.AddChild(timeWidget);

                int maxTextWidth = 350;
                printerName = new TextWidget(ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name), pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    HAnchor     = HAnchor.ParentCenter,
                    MinimumSize = new Vector2(maxTextWidth, MinimumSize.y),
                    Width       = maxTextWidth,
                    Margin      = new BorderDouble(0, 3),
                };

                progressContainer.AddChild(printerName);

                partName = new TextWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem.GetFriendlyName(), pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    HAnchor     = HAnchor.ParentCenter,
                    MinimumSize = new Vector2(maxTextWidth, MinimumSize.y),
                    Width       = maxTextWidth,
                    Margin      = new BorderDouble(0, 3)
                };
                progressContainer.AddChild(partName);
            }

            bodyRow.AddChild(PrintingWindow.CreateVerticalLine());

            // ZControls
            {
                var widget = new ZAxisControls(smallScreen)
                {
                    Margin  = new BorderDouble(left: 50),
                    VAnchor = VAnchor.ParentCenter,
                    Width   = 135
                };
                bodyRow.AddChild(widget);
            }

            var footerBar = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor = VAnchor.ParentBottom | VAnchor.FitToChildren,
                HAnchor = HAnchor.ParentCenter | HAnchor.FitToChildren,
                Margin  = new BorderDouble(bottom: 0),
            };

            topToBottom.AddChild(footerBar);

            int extruderCount = ActiveSliceSettings.Instance.GetValue <int>(SettingsKey.extruder_count);

            extruderStatusWidgets = Enumerable.Range(0, extruderCount).Select((i) => new ExtruderStatusWidget(i)).ToList();

            bool hasHeatedBed = ActiveSliceSettings.Instance.GetValue <bool>("has_heated_bed");

            if (hasHeatedBed)
            {
                var extruderColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                footerBar.AddChild(extruderColumn);

                // Add each status widget into the scene, placing into the appropriate column
                for (var i = 0; i < extruderCount; i++)
                {
                    var widget = extruderStatusWidgets[i];
                    widget.Margin = new BorderDouble(right: 20);
                    extruderColumn.AddChild(widget);
                }

                footerBar.AddChild(new BedStatusWidget(smallScreen)
                {
                    VAnchor = VAnchor.ParentCenter,
                });
            }
            else
            {
                if (extruderCount == 1)
                {
                    footerBar.AddChild(extruderStatusWidgets[0]);
                }
                else
                {
                    var columnA = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    footerBar.AddChild(columnA);

                    var columnB = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    footerBar.AddChild(columnB);

                    // Add each status widget into the scene, placing into the appropriate column
                    for (var i = 0; i < extruderCount; i++)
                    {
                        var widget = extruderStatusWidgets[i];
                        if (i % 2 == 0)
                        {
                            widget.Margin = new BorderDouble(right: 20);
                            columnA.AddChild(widget);
                        }
                        else
                        {
                            columnB.AddChild(widget);
                        }
                    }
                }
            }

            UiThread.RunOnIdle(() =>
            {
                CheckOnPrinter();
            });
        }
Exemple #15
0
        public ImageLinkAdvancedX(string url)
        {
            HAnchor  = HAnchor.Fit;
            VAnchor  = VAnchor.Fit;
            this.Url = url;

            var imageBuffer = new ImageBuffer(icon);
            var imageWidget = new ImageWidget(imageBuffer);

            this.AddChild(imageWidget);

            try
            {
                if (url.StartsWith("http"))
                {
                    client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead).ContinueWith(task =>
                    {
                        var response = task.Result;

                        if (response.IsSuccessStatusCode)
                        {
                            Console.WriteLine(task.Result.Headers);

                            response.Content.ReadAsStreamAsync().ContinueWith(streamTask =>
                            {
                                //response.Headers.TryGetValues("", s[""] == "" ||
                                if (string.Equals(Path.GetExtension(url), ".svg", StringComparison.OrdinalIgnoreCase))
                                {
                                    // Load svg into SvgWidget, swap for ImageWidget
                                    try
                                    {
                                        var svgWidget = new SvgWidget(streamTask.Result, 1)
                                        {
                                            Border      = 1,
                                            BorderColor = Color.YellowGreen
                                        };

                                        this.ReplaceChild(imageWidget, svgWidget);
                                    }
                                    catch (Exception svgEx)
                                    {
                                        Debug.WriteLine("Error loading svg: {0} :: {1}", url, svgEx.Message);
                                    }
                                }
                                else
                                {
                                    // Load img
                                    if (!AggContext.ImageIO.LoadImageData(streamTask.Result, imageBuffer))
                                    {
                                        Debug.WriteLine("Error loading image: " + url);
                                    }
                                }
                            });
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private FlowLayoutWidget GetHomeButtonBar()
        {
            FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();

            homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
            homeButtonBar.Margin  = new BorderDouble(3, 0, 3, 6);
            homeButtonBar.Padding = new BorderDouble(0);

            textImageButtonFactory.borderWidth       = 1;
            textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
            textImageButtonFactory.hoverBorderColor  = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

            ImageBuffer helpIconImage = StaticData.Instance.LoadIcon("icon_home_white_24x24.png", 24, 24);

            if (ActiveTheme.Instance.IsDarkTheme)
            {
                helpIconImage.InvertLightness();
            }
            ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);

            homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0);
            homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * GuiWidget.DeviceScale;
            RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;

            textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180);
            homeAllButton = textImageButtonFactory.Generate("ALL".Localize());
            this.textImageButtonFactory.normalFillColor = oldColor;
            homeAllButton.ToolTipText = "Home X, Y and Z".Localize();
            homeAllButton.Margin      = new BorderDouble(0, 0, 6, 0);
            homeAllButton.Click      += homeAll_Click;

            textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * GuiWidget.DeviceScale;
            homeXButton             = textImageButtonFactory.Generate("X", centerText: true);
            homeXButton.ToolTipText = "Home X".Localize();
            homeXButton.Margin      = new BorderDouble(0, 0, 6, 0);
            homeXButton.Click      += homeXButton_Click;

            homeYButton             = textImageButtonFactory.Generate("Y", centerText: true);
            homeYButton.ToolTipText = "Home Y".Localize();
            homeYButton.Margin      = new BorderDouble(0, 0, 6, 0);
            homeYButton.Click      += homeYButton_Click;

            homeZButton             = textImageButtonFactory.Generate("Z", centerText: true);
            homeZButton.ToolTipText = "Home Z".Localize();
            homeZButton.Margin      = new BorderDouble(0, 0, 6, 0);
            homeZButton.Click      += homeZButton_Click;

            textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
            textImageButtonFactory.FixedWidth      = 0;

            disableMotors        = textImageButtonFactory.Generate("Release".Localize().ToUpper());
            disableMotors.Margin = new BorderDouble(0);
            disableMotors.Click += disableMotors_Click;
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            GuiWidget spacerReleaseShow = new GuiWidget(10 * GuiWidget.DeviceScale, 0);

            homeButtonBar.AddChild(homeIconImageWidget);
            homeButtonBar.AddChild(homeAllButton);
            homeButtonBar.AddChild(homeXButton);
            homeButtonBar.AddChild(homeYButton);
            homeButtonBar.AddChild(homeZButton);

            offsetStreamLabel = new TextWidget("Z Offset".Localize() + ":", pointSize: 8)
            {
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                Margin    = new BorderDouble(left: 10),
                AutoExpandBoundsToText = true,
                VAnchor = VAnchor.ParentCenter
            };
            homeButtonBar.AddChild(offsetStreamLabel);

            var ztuningWidget = new ZTuningWidget();

            homeButtonBar.AddChild(ztuningWidget);

            homeButtonBar.AddChild(new HorizontalSpacer());
            homeButtonBar.AddChild(disableMotors);
            homeButtonBar.AddChild(spacerReleaseShow);

            return(homeButtonBar);
        }
Exemple #17
0
        public LibraryView(int ID, Element2D parent, GLControl glControl, GUIHost host, MessagePopUp infobox, ModelLoadingManager model_loading_manager)
            : base(ID, parent)
        {
            bUpdateWhenNotVisible        = true;
            m_gui_host                   = host;
            Sprite.texture_height_pixels = 1024;
            Sprite.texture_width_pixels  = 1024;
            m_gui_host.SetFontProperty(FontSize.VeryLarge, 20f);
            m_gui_host.SetFontProperty(FontSize.Large, 14f);
            m_gui_host.SetFontProperty(FontSize.Medium, 11f);
            m_gui_host.SetFontProperty(FontSize.Small, 8f);
            RelativeX      = 0.51f;
            RelativeY      = 0.11f;
            RelativeWidth  = 0.423f;
            RelativeHeight = 0.83f;
            var imageWidget1 = new ImageWidget(1008, null);

            imageWidget1.Init(host, "extendedcontrols3", 3f, 288f, 84f, 374f, 3f, 288f, 84f, 374f, 3f, 288f, 84f, 374f);
            imageWidget1.Text           = "Remove From List";
            imageWidget1.Color          = new Color4(0.5f, 0.5f, 0.5f, 1f);
            imageWidget1.VAlignment     = TextVerticalAlignment.Bottom;
            imageWidget1.TextAreaHeight = 32;
            imageWidget1.ImageAreaWidth = 80;
            imageWidget1.SetSize(80, 115);
            imageWidget1.Visible = false;
            AddChildElement(imageWidget1);
            imageWidget1.SetPosition(-12, -115);
            var imageWidget2 = new ImageWidget(1009, null);

            imageWidget2.Init(host, "extendedcontrols3", 92f, 285f, 173f, 346f, 92f, 285f, 173f, 346f, 92f, 285f, 173f, 346f);
            imageWidget2.Text           = "Save";
            imageWidget2.Color          = new Color4(0.5f, 0.5f, 0.5f, 1f);
            imageWidget2.VAlignment     = TextVerticalAlignment.Bottom;
            imageWidget2.TextAreaHeight = 20;
            imageWidget2.ImageAreaWidth = 81;
            imageWidget2.SetSize(81, 85);
            imageWidget2.Visible = false;
            AddChildElement(imageWidget2);
            imageWidget2.SetPosition(-12, -240);
            search_filter = "";
            var editBoxWidget = new EditBoxWidget(1001, null);

            editBoxWidget.Init(host, "guicontrols", 513f, 0.0f, 608f, 63f);
            editBoxWidget.SetGrowableWidth(40, 16, 64);
            editBoxWidget.Size  = FontSize.Large;
            editBoxWidget.Color = new Color4(0.71f, 0.71f, 0.71f, 1f);
            editBoxWidget.SetTextWindowBorders(48, 16, 22, 16);
            editBoxWidget.SetToolTipRegion(0, 48, 0, 60);
            editBoxWidget.ToolTipMessage = host.Locale.T("T_TOOLTIP_SEARCH");
            editBoxWidget.Hint           = m_gui_host.Locale.T("T_SEARCH");
            tabsFrame = new HorizontalLayout(0, null)
            {
                FixedColumnWidth = true,
                BorderWidth      = 0,
                BorderHeight     = 0,
                RelativeWidth    = 1f
            };
            navigation      = new Frame(0, null);
            navigation_left = new ButtonWidget(1005, null)
            {
                Text   = "",
                X      = 16,
                Y      = 0,
                Width  = 32,
                Height = 32
            };
            navigation_left.SetCallback(new ButtonCallback(MyButtonCallback));
            navigation_left.Init(host, "guicontrols", 608f, 0.0f, 639f, 31f, 640f, 0.0f, 671f, 31f, 672f, 0.0f, 703f, 31f, 704f, 0.0f, 735f, 31f);
            navigation_right = new ButtonWidget(1006, null)
            {
                Text   = "",
                X      = -48,
                Y      = 0,
                Width  = 32,
                Height = 32
            };
            navigation_right.SetCallback(new ButtonCallback(MyButtonCallback));
            navigation_right.Init(host, "guicontrols", 608f, 32f, 639f, 63f, 640f, 32f, 671f, 63f, 672f, 32f, 703f, 63f, 704f, 32f, 735f, 63f);
            pagebuttons = new ButtonWidget[32];
            for (var ID1 = 1032; ID1 <= 1063; ++ID1)
            {
                var index = ID1 - 1032;
                pagebuttons[index] = new ButtonWidget(ID1, null)
                {
                    Text   = "",
                    X      = 48 + (ID1 - 1032) * 24,
                    Y      = 8,
                    Width  = 16,
                    Height = 16
                };
                pagebuttons[index].SetCallback(new ButtonCallback(MyButtonCallback));
                pagebuttons[index].Init(host, "guicontrols", 448f, 192f, 463f, 208f, 480f, 192f, 495f, 208f, 464f, 192f, 479f, 208f);
                pagebuttons[index].DontMove  = true;
                pagebuttons[index].GroupID   = 1;
                pagebuttons[index].ClickType = ButtonType.Checkable;
                pagebuttons[index].Visible   = false;
                navigation.AddChildElement(pagebuttons[index]);
            }
            navigation.AddChildElement(navigation_left);
            navigation.AddChildElement(navigation_right);
            LibraryGrid = new GridLayout(1)
            {
                ColumnWidth  = 130,
                RowHeight    = 150,
                BorderWidth  = 0,
                BorderHeight = 0
            };
            var verticalLayout = new VerticalLayout(0)
            {
                RelativeHeight = 1f,
                RelativeWidth  = 1f,
                BorderHeight   = 10
            };

            verticalLayout.AddChildElement(editBoxWidget, 0, 64 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(tabsFrame, 1, 64 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(navigation, 2, 32 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(LibraryGrid, 3, -1);
            AddChildElement(verticalLayout);
            library_status = new TextWidget(1007)
            {
                Text           = m_gui_host.Locale.T("T_NOMODELS"),
                Size           = FontSize.VeryLarge,
                Alignment      = QFontAlignment.Centre,
                RelativeHeight = 1f,
                RelativeWidth  = 1f,
                X     = 0,
                Y     = 0,
                Color = new Color4(0.9922f, 0.3765f, 0.2471f, 1f)
            };
            AddChildElement(library_status);
            recentModelsTab = new RecentModelTab(this, model_loading_manager, infobox, glControl);
            ButtonWidget buttonWidget = AddTabButton(host, recentModelsTab, LibraryView.TabButtonStyle.Left, m_gui_host.Locale.T("T_RECENT_MODELS"), 1002);

            recentPrintsTab = new RecentPrintsTab(this, model_loading_manager);
            AddTabButton(host, recentPrintsTab, LibraryView.TabButtonStyle.Right, m_gui_host.Locale.T("T_RECENT_PRINTS"), 1004);
            var num = 1;

            buttonWidget.SetChecked(num != 0);
            ShowView(true);
            viewstate = ViewState.Active;
        }
    public void Start()
    {
        // Create the root widget group
        m_rootWidgetGroup =
            new WidgetGroup(
                null,
                panelWidth, panelHeight,
                Screen.width/2 - panelWidth/2, Screen.height/2 - panelHeight/2);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Background for the game info
        new ImageWidget(m_rootWidgetGroup, panelWidth, panelHeight, panelTexture, 0.0f, 0.0f);

        // Character portraits
        m_portraits = new List<ImageWidget>();
        for (int portraitIndex = 0; portraitIndex < ClientGameConstants.GetPortraitCount(); portraitIndex++ )
        {
            ImageWidget portrait = new ImageWidget(
                m_rootWidgetGroup,
                portraitWidth, portraitHeight,
                Resources.Load<Texture>(ClientGameConstants.GetResourceNameForPicture((uint)portraitIndex)),
                PORTRAIT_X, PORTRAIT_Y);

            portrait.Visible = false;
            m_portraits.Add(portrait);
        }

        float statsX = PORTRAIT_X + portraitWidth + BORDER_WIDTH;
        float statsY = PORTRAIT_Y;

        // Character Name
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Name:");
        m_nameTextField =
            new TextEntryWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX + labelWidth, statsY, "");
        m_nameTextField.Restrict = @"[^0-9A-Za-z]";
        m_nameTextField.MaxLength = 12;

        // Character Gender
        statsY += labelHeight;
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Gender:");
        m_genderLabel = new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX+labelWidth, statsY, "");

        // Character Archetype
        statsY += labelHeight;
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Archetype:");
        m_archetypeLabel = new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX + labelWidth, statsY, "");

        // Creation Status Label
        m_statusLabel = new LabelWidget(m_rootWidgetGroup, panelWidth, panelHeight, 0, panelHeight - labelHeight, "");
        m_statusLabel.Alignment = TextAnchor.UpperCenter;

        // Create Button
        m_createButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                panelWidth / 3 - buttonStyle.Width / 2, m_statusLabel.LocalY - buttonStyle.Height - 5,
                "Create");

        // Cancel Button
        m_cancelButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                (2*panelWidth) / 3 - buttonStyle.Width / 2, m_statusLabel.LocalY - buttonStyle.Height - 5,
                "Cancel");

        // Previous Portrait Button
        m_previousPortraitButton=
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                m_createButton.LocalX, m_createButton.LocalY - buttonStyle.Height - 5,
                "<");

        // Next Portrait Button
        m_nextPortraitButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                m_cancelButton.LocalX, m_cancelButton.LocalY - buttonStyle.Height - 5,
                ">");
    }
        private void AddContent(HtmlParser htmlParser, string htmlContent)
        {
            ElementState elementState = htmlParser.CurrentElementState;

            htmlContent = replaceMultipleWhiteSpacesWithSingleWhitespaceRegex.Replace(htmlContent, " ");
            string decodedHtml = HtmlParser.UrlDecode(htmlContent);

            switch (elementState.TypeName)
            {
            case "a":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "a";

                if (decodedHtml != null && decodedHtml != "")
                {
                    Button         linkButton      = linkButtonFactory.Generate(decodedHtml.Replace("\r\n", "\n"));
                    StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                    double         descentInPixels = styled.DescentInPixels;
                    linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels);
                    linkButton.Click += (sender, mouseEvent) =>
                    {
                        MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
                    };
                    elementsUnderConstruction.Peek().AddChild(linkButton);
                }
            }
            break;

            case "h1":
            case "p":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name    = "p";
                elementsUnderConstruction.Peek().HAnchor = HAnchor.ParentLeftRight;

                if (decodedHtml != null && decodedHtml != "")
                {
                    WrappingTextWidget content = new WrappingTextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    //content.VAnchor = VAnchor.ParentTop;
                    elementsUnderConstruction.Peek().AddChild(content);
                }
            }
            break;

            case "div":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "div";

                if (decodedHtml != null && decodedHtml != "")
                {
                    TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    elementsUnderConstruction.Peek().AddChild(content);
                }
            }
            break;

            case "!DOCTYPE":
                break;

            case "body":
                break;

            case "html":
                break;

            case "img":
            {
                ImageBuffer image       = new ImageBuffer(Math.Max(elementState.SizeFixed.x, 1), Math.Max(elementState.SizeFixed.y, 1));
                ImageWidget imageWidget = new ImageWidget(image);
                imageWidget.Load += (s, e) => StaticData.DownloadToImageAsync(image, elementState.src, elementState.SizeFixed.x == 0 ? true : false);
                // put the image into the widget when it is done downloading.

                if (elementsUnderConstruction.Peek().Name == "a")
                {
                    Button linkButton = new Button(0, 0, imageWidget);
                    linkButton.Cursor = Cursors.Hand;
                    linkButton.Click += (sender, mouseEvent) =>
                    {
                        MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
                    };
                    elementsUnderConstruction.Peek().AddChild(linkButton);
                }
                else
                {
                    elementsUnderConstruction.Peek().AddChild(imageWidget);
                }
            }
            break;

            case "input":
                break;

            case "table":
                break;

            case "td":
            case "span":
                GuiWidget widgetToAdd;

                if (elementState.Classes.Contains("translate"))
                {
                    decodedHtml = decodedHtml.Localize();
                }
                if (elementState.Classes.Contains("toUpper"))
                {
                    decodedHtml = decodedHtml.ToUpper();
                }
                if (elementState.Classes.Contains("versionNumber"))
                {
                    decodedHtml = VersionInfo.Instance.ReleaseVersion;
                }
                if (elementState.Classes.Contains("buildNumber"))
                {
                    decodedHtml = VersionInfo.Instance.BuildVersion;
                }

                Button createdButton = null;
                if (elementState.Classes.Contains("centeredButton"))
                {
                    createdButton = textImageButtonFactory.Generate(decodedHtml);
                    widgetToAdd   = createdButton;
                }
                else if (elementState.Classes.Contains("linkButton"))
                {
                    double oldFontSize = linkButtonFactory.fontSize;
                    linkButtonFactory.fontSize = elementState.PointSize;
                    createdButton = linkButtonFactory.Generate(decodedHtml);
                    StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                    double         descentInPixels = styled.DescentInPixels;
                    createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels);
                    widgetToAdd = createdButton;
                    linkButtonFactory.fontSize = oldFontSize;
                }
                else
                {
                    TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    widgetToAdd = content;
                }

                if (createdButton != null)
                {
                    if (elementState.Id == "sendFeedback")
                    {
                        createdButton.Click += (s, e) => ContactFormWindow.Open();
                    }
                    else if (elementState.Id == "clearCache")
                    {
                        createdButton.Click += (s, e) => AboutWidget.DeleteCacheData(0);
                    }
                }

                if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top)
                {
                    widgetToAdd.VAnchor = VAnchor.ParentTop;
                }

                elementsUnderConstruction.Peek().AddChild(widgetToAdd);
                break;

            case "tr":
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "tr";
                if (elementState.SizePercent.y == 100)
                {
                    elementsUnderConstruction.Peek().VAnchor = VAnchor.ParentBottomTop;
                }
                if (elementState.Alignment == ElementState.AlignType.center)
                {
                    elementsUnderConstruction.Peek().HAnchor |= HAnchor.ParentCenter;
                }
                break;

            default:
                throw new NotImplementedException("Don't know what to do with '{0}'".FormatWith(elementState.TypeName));
            }
        }
        private GuiWidget CreatePrintLevelingControlsContainer()
        {
            Button      editButton;
            AltGroupBox printLevelingControlsContainer = new AltGroupBox(textImageButtonFactory.GenerateGroupBoxLabelWithEdit(LocalizedString.Get("Automatic Calibration"), out editButton));

            editButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle((state) =>
                {
                    if (editLevelingSettingsWindow == null)
                    {
                        editLevelingSettingsWindow         = new EditLevelingSettingsWindow();
                        editLevelingSettingsWindow.Closed += (sender2, e2) =>
                        {
                            editLevelingSettingsWindow = null;
                        };
                    }
                    else
                    {
                        editLevelingSettingsWindow.BringToFront();
                    }
                });
            };

            printLevelingControlsContainer.Margin      = new BorderDouble(0);
            printLevelingControlsContainer.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.HAnchor     = Agg.UI.HAnchor.ParentLeftRight;
            printLevelingControlsContainer.Height      = 68;

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                buttonBar.Margin   = new BorderDouble(0, 0, 0, 0);
                buttonBar.Padding  = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                runPrintLevelingButton.Margin  = new BorderDouble(left: 6);
                runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                runPrintLevelingButton.Click  += (sender, e) =>
                {
                    UiThread.RunOnIdle((state) =>
                    {
                        LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration);
                    });
                };

                Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
                ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
                if (!ActiveTheme.Instance.IsDarkTheme)
                {
                    InvertLightness.DoInvertLightness(levelingImage);
                }

                ImageWidget levelingIcon = new ImageWidget(levelingImage);
                levelingIcon.Margin = new BorderDouble(right: 6);

                enablePrintLevelingButton         = textImageButtonFactory.Generate("Enable".Localize().ToUpper());
                enablePrintLevelingButton.Margin  = new BorderDouble(left: 6);
                enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                enablePrintLevelingButton.Click  += new EventHandler(enablePrintLeveling_Click);

                disablePrintLevelingButton         = textImageButtonFactory.Generate("Disable".Localize().ToUpper());
                disablePrintLevelingButton.Margin  = new BorderDouble(left: 6);
                disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                disablePrintLevelingButton.Click  += new EventHandler(disablePrintLeveling_Click);

                printLevelingStatusLabel = new TextWidget("");
                printLevelingStatusLabel.AutoExpandBoundsToText = true;
                printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                printLevelingStatusLabel.VAnchor   = VAnchor.ParentCenter;

                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                buttonBar.AddChild(levelingIcon);
                buttonBar.AddChild(printLevelingStatusLabel);
                buttonBar.AddChild(hSpacer);
                buttonBar.AddChild(enablePrintLevelingButton);
                buttonBar.AddChild(disablePrintLevelingButton);
                buttonBar.AddChild(runPrintLevelingButton);
                ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
                {
                    SetPrintLevelButtonVisiblity();
                }, ref unregisterEvents);

                printLevelingControlsContainer.AddChild(buttonBar);
            }
            SetPrintLevelButtonVisiblity();
            return(printLevelingControlsContainer);
        }
        public PrintingWindow(Action onCloseCallback, bool mockMode = false)
            : base(1280, 750)
        {
            this.BackgroundColor = new RGBA_Bytes(35, 40, 49);
            this.onCloseCallback = onCloseCallback;
            this.Title           = "Print Monitor".Localize();

            var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                VAnchor = VAnchor.ParentBottomTop,
                HAnchor = HAnchor.ParentLeftRight
            };

            this.AddChild(topToBottom);

            var actionBar = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor         = VAnchor.ParentTop | VAnchor.FitToChildren,
                HAnchor         = HAnchor.ParentLeftRight,
                BackgroundColor = new RGBA_Bytes(34, 38, 46),
                //DebugShowBounds = true
            };

            topToBottom.AddChild(actionBar);

            var logo = new ImageWidget(StaticData.Instance.LoadIcon(Path.Combine("Screensaver", "logo.png")));

            actionBar.AddChild(logo);

            actionBar.AddChild(new HorizontalSpacer());

            var pauseButton  = CreateButton("Pause".Localize().ToUpper());
            var resumeButton = CreateButton("Resume".Localize().ToUpper());

            pauseButton.Click += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    //PrinterConnectionAndCommunication.Instance.RequestPause();
                    pauseButton.Visible  = false;
                    resumeButton.Visible = true;
                });
            };
            actionBar.AddChild(pauseButton);

            resumeButton.Visible = false;
            resumeButton.Click  += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    //PrinterConnectionAndCommunication.Instance.Resume();
                    resumeButton.Visible = false;
                    pauseButton.Visible  = true;
                });
            };
            actionBar.AddChild(resumeButton);

            actionBar.AddChild(CreateVerticalLine());

            var cancelButton = CreateButton("Cancel".Localize().ToUpper());

            //cancelButton.Click += (sender, e) => UiThread.RunOnIdle(CancelButton_Click);
            actionBar.AddChild(cancelButton);

            actionBar.AddChild(CreateVerticalLine());

            var advancedButton = CreateButton("Advanced".Localize().ToUpper());

            actionBar.AddChild(advancedButton);

            var bodyContainer = new GuiWidget()
            {
                VAnchor         = VAnchor.ParentBottomTop,
                HAnchor         = HAnchor.ParentLeftRight,
                Padding         = new BorderDouble(50),
                BackgroundColor = new RGBA_Bytes(35, 40, 49),
            };

            topToBottom.AddChild(bodyContainer);

            var bodyRow = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor = VAnchor.ParentBottomTop,
                HAnchor = HAnchor.ParentLeftRight,
                //BackgroundColor = new RGBA_Bytes(125, 255, 46, 20),
            };

            bodyContainer.AddChild(bodyRow);

            // Thumbnail section
            {
                ImageBuffer imageBuffer = null;

                string stlHashCode = PrinterConnectionAndCommunication.Instance.ActivePrintItem?.FileHashCode.ToString();
                if (!string.IsNullOrEmpty(stlHashCode) && stlHashCode != "0")
                {
                    imageBuffer = PartThumbnailWidget.LoadImageFromDisk(stlHashCode);
                    if (imageBuffer != null)
                    {
                        imageBuffer = ImageBuffer.CreateScaledImage(imageBuffer, 500, 500);
                    }
                }

                if (imageBuffer == null)
                {
                    imageBuffer = StaticData.Instance.LoadIcon(Path.Combine("Screensaver", "part_thumbnail.png"));
                }

                var partThumbnail = new ImageWidget(imageBuffer)
                {
                    VAnchor = VAnchor.ParentCenter,
                    Margin  = new BorderDouble(right: 50)
                };
                bodyRow.AddChild(partThumbnail);
            }

            bodyRow.AddChild(CreateVerticalLine());

            // Progress section
            {
                var expandingContainer = new HorizontalSpacer()
                {
                    VAnchor = VAnchor.FitToChildren | VAnchor.ParentCenter
                };
                bodyRow.AddChild(expandingContainer);

                var progressContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
                {
                    Margin  = new BorderDouble(50, 0),
                    VAnchor = VAnchor.ParentCenter | VAnchor.FitToChildren,
                    HAnchor = HAnchor.ParentCenter | HAnchor.FitToChildren,
                    //BackgroundColor = new RGBA_Bytes(125, 255, 46, 20),
                };
                expandingContainer.AddChild(progressContainer);

                progressDial = new ProgressDial()
                {
                    HAnchor = HAnchor.ParentCenter,
                    Height  = 200,
                    Width   = 200
                };
                progressContainer.AddChild(progressDial);

                var timeContainer = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.ParentLeftRight,
                    Margin  = new BorderDouble(50, 3)
                };
                progressContainer.AddChild(timeContainer);

                var timeImage = new ImageWidget(StaticData.Instance.LoadIcon(Path.Combine("Screensaver", "time.png")));
                timeContainer.AddChild(timeImage);

                timeWidget = new TextWidget("", pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    AutoExpandBoundsToText = true,
                    Margin = new BorderDouble(10, 0)
                };

                timeContainer.AddChild(timeWidget);

                printerName = new TextWidget(ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name), pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    AutoExpandBoundsToText = true,
                    HAnchor = HAnchor.ParentLeftRight,
                    Margin  = new BorderDouble(50, 3)
                };

                progressContainer.AddChild(printerName);

                partName = new TextWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem.GetFriendlyName(), pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    AutoExpandBoundsToText = true,
                    HAnchor = HAnchor.ParentLeftRight,
                    Margin  = new BorderDouble(50, 3)
                };
                progressContainer.AddChild(partName);
            }

            bodyRow.AddChild(CreateVerticalLine());

            // ZControls
            {
                var widget = new ZAxisControls()
                {
                    Margin  = new BorderDouble(left: 50),
                    VAnchor = VAnchor.ParentCenter,
                    Width   = 120
                };
                bodyRow.AddChild(widget);
            }

            var footerBar = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor         = VAnchor.ParentBottom | VAnchor.FitToChildren,
                HAnchor         = HAnchor.ParentCenter | HAnchor.FitToChildren,
                BackgroundColor = new RGBA_Bytes(35, 40, 49),
                Margin          = new BorderDouble(bottom: 30)
            };

            topToBottom.AddChild(footerBar);

            int extruderCount = mockMode ? 3 : ActiveSliceSettings.Instance.GetValue <int>(SettingsKey.extruder_count);

            var borderColor = bodyContainer.BackgroundColor.AdjustLightness(1.5).GetAsRGBA_Bytes();

            extruderStatusWidgets = Enumerable.Range(0, extruderCount).Select((i) => new ExtruderStatusWidget(i)
            {
                BorderColor = borderColor
            }).ToList();

            if (extruderCount == 1)
            {
                footerBar.AddChild(extruderStatusWidgets[0]);
            }
            else
            {
                var columnA = new FlowLayoutWidget(FlowDirection.TopToBottom);
                footerBar.AddChild(columnA);

                var columnB = new FlowLayoutWidget(FlowDirection.TopToBottom);
                footerBar.AddChild(columnB);

                // Add each status widget into the scene, placing into the appropriate column
                for (var i = 0; i < extruderCount; i++)
                {
                    var widget = extruderStatusWidgets[i];
                    if (i % 2 == 0)
                    {
                        widget.Margin = new BorderDouble(right: 20);
                        columnA.AddChild(widget);
                    }
                    else
                    {
                        columnB.AddChild(widget);
                    }
                }
            }

            UiThread.RunOnIdle(() =>
            {
                if (mockMode)
                {
                    MockProgress();
                }
                else
                {
                    CheckOnPrinter();
                }
            });

            PrinterConnectionAndCommunication.Instance.ExtruderTemperatureRead.RegisterEvent((s, e) =>
            {
                var eventArgs = e as TemperatureEventArgs;
                if (eventArgs != null && eventArgs.Index0Based < extruderStatusWidgets.Count)
                {
                    extruderStatusWidgets[eventArgs.Index0Based].UpdateTemperatures();
                }
            }, ref unregisterEvents);
        }
        public PluginChooserWindow()
            : base(360, 300)
        {
            Title = new LocalizedString("Installed Plugins").Translated;

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.HAnchor = HAnchor.ParentLeftRight;
            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);

            {
                string     elementHeaderLblBeg  = new LocalizedString("Select a Design Tool").Translated;
                string     elementHeaderLblFull = string.Format("{0}:", elementHeaderLblBeg);
                string     elementHeaderLbl     = elementHeaderLblFull;
                TextWidget elementHeader        = new TextWidget(string.Format(elementHeaderLbl), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

            GuiWidget presetsFormContainer = new GuiWidget();
            //ListBox printerListContainer = new ListBox();
            {
                presetsFormContainer.HAnchor         = HAnchor.ParentLeftRight;
                presetsFormContainer.VAnchor         = VAnchor.ParentBottomTop;
                presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            pluginRowContainer.AnchorAll();
            presetsFormContainer.AddChild(pluginRowContainer);

            foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
            {
                ClickWidget pluginRow = new ClickWidget();
                pluginRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                pluginRow.Height          = 38;
                pluginRow.BackgroundColor = RGBA_Bytes.White;
                pluginRow.Padding         = new BorderDouble(3);
                pluginRow.Margin          = new BorderDouble(6, 0, 6, 6);

                GuiWidget overlay = new GuiWidget();
                overlay.AnchorAll();
                overlay.Cursor = Cursors.Hand;

                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.AnchorAll();
                macroRow.BackgroundColor = RGBA_Bytes.White;

                if (creatorInfo.iconPath != "")
                {
                    ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
                    ImageWidget imageWidget = new ImageWidget(imageBuffer);
                    macroRow.AddChild(imageWidget);
                }

                TextWidget buttonLabel = new TextWidget(creatorInfo.description, pointSize: 14);

                buttonLabel.Margin  = new BorderDouble(left: 10);
                buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                macroRow.AddChild(buttonLabel);

                FlowLayoutWidget hSpacer = new FlowLayoutWidget();
                hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.AddChild(hSpacer);

                CreatorInformation callCorrectFunctionHold = creatorInfo;
                pluginRow.Click += (sender, e) =>
                {
                    if (RegisteredCreators.Instance.Creators.Count > 0)
                    {
                        callCorrectFunctionHold.functionToLaunchCreator(null, null);
                    }
                    UiThread.RunOnIdle(CloseOnIdle);
                };
                pluginRow.AddChild(macroRow);
                pluginRow.AddChild(overlay);
                pluginRowContainer.AddChild(pluginRow);
            }

            topToBottom.AddChild(presetsFormContainer);
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            //ShowAsSystemWindow();

            Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);

            cancelPresetsButton.Click += (sender, e) => { Close(); };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Padding = new BorderDouble(0, 3);

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
Exemple #23
0
        public IconViewItem(ListViewItem item, int thumbWidth, int thumbHeight, ThemeConfig theme)
            : base(item, thumbWidth, thumbHeight, theme)
        {
            this.VAnchor = VAnchor.Fit;
            this.HAnchor = HAnchor.Fit;
            this.Padding = IconViewItem.ItemPadding;
            this.Margin  = new BorderDouble(6, 0, 0, 6);
            this.Border  = 1;

            int scaledWidth  = (int)(thumbWidth * GuiWidget.DeviceScale);
            int scaledHeight = (int)(thumbHeight * GuiWidget.DeviceScale);

            int maxWidth = scaledWidth - 4;

            if (thumbWidth < 75)
            {
                imageWidget = new ImageWidget(scaledWidth, scaledHeight)
                {
                    AutoResize      = false,
                    Name            = "List Item Thumbnail",
                    BackgroundColor = theme.ThumbnailBackground,
                    Margin          = 0,
                    Selectable      = false
                };
                this.AddChild(imageWidget);
            }
            else
            {
                var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
                {
                    Selectable = false
                };
                this.AddChild(container);

                imageWidget = new ImageWidget(scaledWidth, scaledHeight)
                {
                    AutoResize      = false,
                    Name            = "List Item Thumbnail",
                    BackgroundColor = theme.ThumbnailBackground,
                    Margin          = 0,
                    Selectable      = false
                };
                container.AddChild(imageWidget);

                text = new TextWidget(item.Model.Name, 0, 0, 9, textColor: theme.TextColor)
                {
                    AutoExpandBoundsToText = false,
                    EllipsisIfClipped      = true,
                    HAnchor    = HAnchor.Center,
                    Margin     = new BorderDouble(0, 0, 0, 3),
                    Selectable = false
                };

                text.MaximumSize = new Vector2(maxWidth, 20);
                if (text.Printer.LocalBounds.Width > maxWidth)
                {
                    text.Width = maxWidth;
                    text.Text  = item.Model.Name;
                }

                container.AddChild(text);
            }
        }
        public PrintProgressBar(bool widgetIsExtended = true)
        {
            MinimumSize = new Vector2(0, 24);

            HAnchor         = HAnchor.ParentLeftRight;
            BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            Margin          = new BorderDouble(0);

            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);

            container.AnchorAll();
            container.Padding = new BorderDouble(6, 0);

            printTimeElapsed = new TextWidget("", pointSize: 11);
            printTimeElapsed.Printer.DrawFromHintedCache = true;
            printTimeElapsed.AutoExpandBoundsToText      = true;
            printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;

            printTimeRemaining = new TextWidget("", pointSize: 11);
            printTimeRemaining.Printer.DrawFromHintedCache = true;
            printTimeRemaining.AutoExpandBoundsToText      = true;
            printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;

            GuiWidget spacer = new GuiWidget();

            spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

            container.AddChild(printTimeElapsed);
            container.AddChild(spacer);
            container.AddChild(printTimeRemaining);

            AddChild(container);

            if (ActiveTheme.Instance.IsTouchScreen)
            {
                upImageBuffer   = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
                downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");

                indicatorWidget         = new ImageWidget(upImageBuffer);
                indicatorWidget.HAnchor = HAnchor.ParentCenter;
                indicatorWidget.VAnchor = VAnchor.ParentCenter;

                WidgetIsExtended = widgetIsExtended;

                GuiWidget indicatorOverlay = new GuiWidget();
                indicatorOverlay.AnchorAll();
                indicatorOverlay.AddChild(indicatorWidget);

                AddChild(indicatorOverlay);
            }

            ClickWidget clickOverlay = new ClickWidget();

            clickOverlay.AnchorAll();
            clickOverlay.Click += onProgressBarClick;

            AddChild(clickOverlay);

            AddHandlers();
            SetThemedColors();
            UpdatePrintStatus();
            UiThread.RunOnIdle(OnIdle);
        }
        public TemperatureWidgetBase(PrinterConfig printer, string textValue, ThemeConfig theme)
            : base(theme)
        {
            this.printer = printer;

            this.AlignToRightEdge = true;
            this.DrawArrow        = true;
            this.HAnchor          = HAnchor.Fit;
            this.VAnchor          = VAnchor.Fit | VAnchor.Center;
            this.Cursor           = Cursors.Hand;
            this.MakeScrollable   = false;
            this.AlignToRightEdge = true;

            ImageWidget = new ImageWidget(AggContext.StaticData.LoadIcon("hotend.png", theme.InvertIcons))
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(right: 5)
            };

            alwaysEnabled = new List <GuiWidget>();

            var container = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit,
                Padding = new BorderDouble(10, 5, 0, 5)
            };

            this.AddChild(container);

            container.AddChild(this.ImageWidget);

            CurrentTempIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.TextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true
            };
            container.AddChild(CurrentTempIndicator);

            container.AddChild(new TextWidget("/")
            {
                TextColor = theme.TextColor
            });

            goalTempIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.TextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true
            };
            container.AddChild(goalTempIndicator);

            DirectionIndicator = new TextWidget(textValue, pointSize: 11)
            {
                TextColor = theme.TextColor,
                VAnchor   = VAnchor.Center,
                AutoExpandBoundsToText = true,
                Margin = new BorderDouble(left: 5)
            };
            container.AddChild(DirectionIndicator);

            // Register listeners
            printer.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged;

            foreach (var child in this.Children)
            {
                child.Selectable = false;
            }
        }
        private FlowLayoutWidget GetAutoLevelControl()
        {
            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.Name    = "AutoLevelRowItem";
            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Margin  = new BorderDouble(0, 4);

            ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24).InvertLightness();

            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                levelingImage.InvertLightness();
            }

            ImageWidget levelingIcon = new ImageWidget(levelingImage);

            levelingIcon.Margin = new BorderDouble(right: 6);

            buttonRow.AddChild(levelingIcon);

            // label
            printLevelingStatusLabel = new TextWidget("")
            {
                AutoExpandBoundsToText = true,
                TextColor = ActiveTheme.Instance.PrimaryTextColor,
                VAnchor   = VAnchor.ParentCenter,
                Text      = "Software Print Leveling".Localize()
            };

            buttonRow.AddChild(printLevelingStatusLabel);

            // edit button
            Button editButton = TextImageButtonFactory.GetThemedEditButton();

            editButton.Margin  = new BorderDouble(2, 2, 2, 0);
            editButton.VAnchor = Agg.UI.VAnchor.ParentTop;

            editButton.VAnchor = VAnchor.ParentCenter;
            editButton.Click  += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    if (editLevelingSettingsWindow == null)
                    {
                        editLevelingSettingsWindow         = new EditLevelingSettingsWindow();
                        editLevelingSettingsWindow.Closed += (sender2, e2) =>
                        {
                            editLevelingSettingsWindow = null;
                        };
                    }
                    else
                    {
                        editLevelingSettingsWindow.BringToFront();
                    }
                });
            };

            buttonRow.AddChild(editButton);

            buttonRow.AddChild(new HorizontalSpacer());

            // configure button
            runPrintLevelingButton         = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
            runPrintLevelingButton.Margin  = new BorderDouble(left: 6);
            runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
            runPrintLevelingButton.Click  += (sender, e) =>
            {
                UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration));
            };
            buttonRow.AddChild(runPrintLevelingButton);

            // put in the switch
            CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled));

            printLevelingSwitch.VAnchor              = VAnchor.ParentCenter;
            printLevelingSwitch.Margin               = new BorderDouble(left: 16);
            printLevelingSwitch.CheckedStateChanged += (sender, e) =>
            {
                ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(printLevelingSwitch.Checked);
            };

            PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) =>
            {
                printLevelingSwitch.Checked = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled);
            }, ref unregisterEvents);

            // only show the switch if leveling can be turned off (it can't if it is required).
            if (!ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_required_to_print))
            {
                buttonRow.AddChild(printLevelingSwitch);
            }

            return(buttonRow);
        }
Exemple #27
0
 public void OnRemoval(Element2D parent_element)
 {
     DestroyPreviewImageWidget();
     parent_element.RemoveChildElement(status_dialog_frame);
     preview_image = null;
 }
Exemple #28
0
        public TreeNode(ThemeConfig theme, bool useIcon = true)
            : base(FlowDirection.TopToBottom)
        {
            this.HAnchor = HAnchor.Fit | HAnchor.Left;
            this.VAnchor = VAnchor.Fit;

            this.TitleBar        = new FlowLayoutWidget();
            this.TitleBar.Click += (s, e) =>
            {
                if (TreeView != null)
                {
                    TreeView.SelectedNode = this;
                }

                this.TreeView.NotifyItemClicked(this.TitleBar, e);
            };

            this.TitleBar.MouseDown += (s, e) =>
            {
                if (TreeView != null &&
                    e.Button == MouseButtons.Left &&
                    e.Clicks == 2)
                {
                    TreeView.SelectedNode = this;
                    this.TreeView.NotifyItemDoubleClicked(this.TitleBar, e);
                }
            };

            this.AddChild(this.TitleBar);

            // add a check box
            expandWidget = new TreeExpandWidget(theme)
            {
                Expandable = GetNodeCount(false) != 0,
                VAnchor    = VAnchor.Fit | VAnchor.Center,
                Height     = 16,
                Width      = 16
            };

            expandWidget.Click += (s, e) =>
            {
                this.Expanded         = !this.Expanded;
                expandWidget.Expanded = this.Expanded;
            };

            this.TitleBar.AddChild(expandWidget);

            this.HighlightRegion = new FlowLayoutWidget()
            {
                VAnchor    = VAnchor.Fit,
                HAnchor    = HAnchor.Fit,
                Padding    = useIcon ? new BorderDouble(2) : new BorderDouble(4, 2),
                Selectable = false
            };
            this.TitleBar.AddChild(this.HighlightRegion);

            // add a check box
            if (useIcon)
            {
                _image = new ImageBuffer(16, 16);

                this.HighlightRegion.AddChild(imageWidget = new ImageWidget(this.Image)
                {
                    VAnchor    = VAnchor.Center,
                    Margin     = new BorderDouble(right: 4),
                    Selectable = false
                });
            }
            ;

            this.HighlightRegion.AddChild(textWidget = new TextWidget(this.Text, pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
            {
                Selectable             = false,
                AutoExpandBoundsToText = true,
                VAnchor = VAnchor.Center
            });

            content = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Fit | HAnchor.Left,
                Visible = false,                 // content starts out not visible
                Name    = "content",
                Margin  = new BorderDouble(12, 3),
            };
            this.AddChild(content);

            this.Nodes.CollectionChanged += (s, e) => isDirty = true;
        }
Exemple #29
0
        public GuiWidget Create(IObject3D item, ThemeConfig theme)
        {
            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.MaxFitOrStretch
            };

            var imageObject = item as ImageObject3D;

            var activeImage = imageObject.Image;

            var imageSection = new SectionWidget(
                "Image".Localize(),
                new FlowLayoutWidget(FlowDirection.TopToBottom),
                theme);

            theme.ApplyBoxStyle(imageSection, margin: 0);

            column.AddChild(imageSection);

            ImageBuffer thumbnailImage = SetImage(theme, imageObject);

            ImageWidget thumbnailWidget;

            imageSection.ContentPanel.AddChild(thumbnailWidget = new ImageWidget(thumbnailImage)
            {
                Margin  = new BorderDouble(bottom: 5),
                HAnchor = HAnchor.Center
            });

            bool addImageSearch = true;

            if (addImageSearch)
            {
                // add a search Google box
                var searchRow = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.Stretch,
                    VAnchor = VAnchor.Fit,
                };
                imageSection.ContentPanel.AddChild(searchRow);

                MHTextEditWidget textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Search Google".Localize());
                textToAddWidget.HAnchor = HAnchor.Stretch;
                searchRow.AddChild(textToAddWidget);
                textToAddWidget.ActualTextEditWidget.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        textToAddWidget.Unfocus();
                        string search = "http://www.google.com/search?q={0} silhouette&tbm=isch".FormatWith(textToAddWidget.Text);
                        ApplicationController.Instance.LaunchBrowser(search);
                    });
                };
            }

            // add in the invert checkbox and change image button
            var changeButton = new TextButton("Change".Localize(), theme)
            {
                BackgroundColor = theme.MinimalShade
            };

            changeButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    // we do this using to make sure that the stream is closed before we try and insert the Picture
                    AggContext.FileDialogs.OpenFileDialog(
                        new OpenFileDialogParams(
                            "Select an image file|*.jpg;*.png;*.bmp;*.gif;*.pdf",
                            multiSelect: false,
                            title: "Add Image".Localize()),
                        (openParams) =>
                    {
                        if (!File.Exists(openParams.FileName))
                        {
                            return;
                        }

                        imageObject.AssetPath = openParams.FileName;
                        imageObject.Mesh      = null;

                        thumbnailWidget.Image = SetImage(theme, imageObject);

                        column.Invalidate();
                        imageObject.Invalidate(new InvalidateArgs(imageObject, InvalidateType.Image));
                    });
                });
            };

            var row = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
            };

            imageSection.ContentPanel.AddChild(row);

            // Invert checkbox
            var invertCheckbox = new CheckBox(new CheckBoxViewText("Invert".Localize(), textColor: theme.Colors.PrimaryTextColor))
            {
                Checked = imageObject.Invert,
                Margin  = new BorderDouble(0),
            };

            invertCheckbox.CheckedStateChanged += (s, e) =>
            {
                imageObject.Invert = invertCheckbox.Checked;
            };
            row.AddChild(invertCheckbox);

            row.AddChild(new HorizontalSpacer());

            row.AddChild(changeButton);

            imageObject.Invalidated += (s, e) =>
            {
                if (e.InvalidateType == InvalidateType.Image &&
                    activeImage != imageObject.Image)
                {
                    thumbnailImage        = SetImage(theme, imageObject);
                    thumbnailWidget.Image = thumbnailImage;

                    activeImage = imageObject.Image;
                }
            };

            return(column);
        }
        public RunningMacroPage(MacroCommandData macroData)
            : base("Cancel", macroData.title)
        {
            //TextWidget syncingText = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor);
            //contentRow.AddChild(syncingText);

            cancelButton.Click += (s, e) =>
            {
                PrinterConnectionAndCommunication.Instance.MacroCancel();
            };

            if (macroData.showMaterialSelector)
            {
                int extruderIndex    = 0;
                var materialSelector = new PresetSelectorWidget(string.Format($"{"Material".Localize()} {extruderIndex + 1}"), RGBA_Bytes.Transparent, NamedSettingsLayers.Material, extruderIndex);
                materialSelector.BackgroundColor = RGBA_Bytes.Transparent;
                materialSelector.Margin          = new BorderDouble(0, 0, 0, 15);
                contentRow.AddChild(materialSelector);
            }

            PrinterConnectionAndCommunication.Instance.WroteLine.RegisterEvent(LookForTempRequest, ref unregisterEvents);

            if (macroData.waitOk | macroData.expireTime > 0)
            {
                Button okButton = textImageButtonFactory.Generate("Continue".Localize());

                okButton.Click += (s, e) =>
                {
                    PrinterConnectionAndCommunication.Instance.MacroContinue();
                    UiThread.RunOnIdle(() => WizardWindow?.Close());
                };

                footerRow.AddChild(okButton);
            }

            if (macroData.image != null)
            {
                var imageWidget = new ImageWidget(macroData.image)
                {
                    HAnchor = HAnchor.ParentCenter,
                    Margin  = new BorderDouble(5, 15),
                };

                contentRow.AddChild(imageWidget);
            }

            var holder = new FlowLayoutWidget();

            progressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
            {
                FillColor       = ActiveTheme.Instance.PrimaryAccentColor,
                BorderColor     = ActiveTheme.Instance.PrimaryTextColor,
                BackgroundColor = RGBA_Bytes.White,
                Margin          = new BorderDouble(3, 0, 0, 10),
            };
            progressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
            {
                AutoExpandBoundsToText = true,
                Margin = new BorderDouble(5, 0, 0, 0),
            };
            holder.AddChild(progressBar);
            holder.AddChild(progressBarText);
            contentRow.AddChild(holder);
            progressBar.Visible = false;

            if (macroData.countDown > 0)
            {
                timeToWaitMs = (long)(macroData.countDown * 1000);
                startTimeMs  = UiThread.CurrentTimerMs;
                UiThread.RunOnIdle(CountDownTime);
            }

            footerRow.AddChild(new HorizontalSpacer());
            footerRow.AddChild(cancelButton);
        }
        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);
            }
        }
Exemple #32
0
        private FlowLayoutWidget GetHomeButtonBar()
        {
            FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();

            homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
            homeButtonBar.Margin  = new BorderDouble(3, 0, 3, 6) * TextWidget.GlobalPointSizeScaleRatio;
            homeButtonBar.Padding = new BorderDouble(0);

            textImageButtonFactory.borderWidth       = 1;
            textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
            textImageButtonFactory.hoverBorderColor  = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

            ImageBuffer helpIconImage       = StaticData.Instance.LoadIcon("icon_home_white_24x24.png");
            ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);

            homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
            homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * TextWidget.GlobalPointSizeScaleRatio;
            RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;

            textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180);
            homeAllButton = textImageButtonFactory.Generate(LocalizedString.Get("ALL"));
            this.textImageButtonFactory.normalFillColor = oldColor;
            homeAllButton.ToolTipText = "Home X, Y and Z";
            homeAllButton.Margin      = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
            homeAllButton.Click      += new EventHandler(homeAll_Click);

            textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * TextWidget.GlobalPointSizeScaleRatio;
            homeXButton             = textImageButtonFactory.Generate("X", centerText: true);
            homeXButton.ToolTipText = "Home X";
            homeXButton.Margin      = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
            homeXButton.Click      += new EventHandler(homeXButton_Click);

            homeYButton             = textImageButtonFactory.Generate("Y", centerText: true);
            homeYButton.ToolTipText = "Home Y";
            homeYButton.Margin      = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
            homeYButton.Click      += new EventHandler(homeYButton_Click);

            homeZButton             = textImageButtonFactory.Generate("Z", centerText: true);
            homeZButton.ToolTipText = "Home Z";
            homeZButton.Margin      = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
            homeZButton.Click      += new EventHandler(homeZButton_Click);

            textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
            textImageButtonFactory.FixedWidth      = 0;

            GuiWidget spacer = new GuiWidget();

            spacer.HAnchor = HAnchor.ParentLeftRight;

            disableMotors        = textImageButtonFactory.Generate("Release".Localize().ToUpper());
            disableMotors.Margin = new BorderDouble(0);
            disableMotors.Click += new EventHandler(disableMotors_Click);
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            GuiWidget spacerReleaseShow = new GuiWidget(10 * TextWidget.GlobalPointSizeScaleRatio, 0);

            homeButtonBar.AddChild(homeIconImageWidget);
            homeButtonBar.AddChild(homeAllButton);
            homeButtonBar.AddChild(homeXButton);
            homeButtonBar.AddChild(homeYButton);
            homeButtonBar.AddChild(homeZButton);

            offsetStreamLabel = new TextWidget("", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);
            offsetStreamLabel.AutoExpandBoundsToText = true;
            offsetStreamLabel.VAnchor = VAnchor.ParentCenter;
            homeButtonBar.AddChild(offsetStreamLabel);

            homeButtonBar.AddChild(spacer);
            homeButtonBar.AddChild(disableMotors);
            homeButtonBar.AddChild(spacerReleaseShow);

            PrinterConnectionAndCommunication.Instance.OffsetStreamChanged += OffsetStreamChanged;

            return(homeButtonBar);
        }
Exemple #33
0
    public CharacterPanelWidget(WidgetGroup parentGroup, CharacterPanelStyle style, float x, float y)
        : base(parentGroup, style.BackgroundWidth, style.BackgroundHeight, x, y)
    {
        // Background for the character info
        new ImageWidget(this, style.BackgroundWidth, style.BackgroundHeight, style.Background, 0, 0);

        // Create a group to hold the data
        m_characterDataGroup = new WidgetGroup(this, style.BackgroundWidth, style.BackgroundHeight, 0.0f, 0.0f);

        // Character Portraits
        m_portraits = new List <ImageWidget>();
        for (int portraitIndex = 0; portraitIndex < ClientGameConstants.GetPortraitCount(); portraitIndex++)
        {
            ImageWidget portrait =
                new ImageWidget(
                    m_characterDataGroup,
                    style.PortraitWidth,
                    style.PortraitHeight,
                    Resources.Load(ClientGameConstants.GetResourceNameForPicture((uint)portraitIndex)) as Texture,
                    5.0f, 5.0f);

            portrait.Visible = false;
            m_portraits.Add(portrait);
        }

        {
            float statsX = style.PortraitWidth + 10.0f;
            float statsY = 5.0f;

            // Character name
            new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX, statsY, "Name:");
            m_nameText =
                new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX + style.LabelWidth, statsY, "");

            // Character gender
            statsY += style.LabelHeight;
            new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX, statsY, "Gender:");
            m_genderText =
                new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX + style.LabelWidth, statsY, "");

            // Character archetype
            statsY += style.LabelHeight;
            new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX, statsY, "Archetype:");
            m_archetypeText =
                new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX + style.LabelWidth, statsY, "");

            // Level
            statsY += style.LabelHeight;
            new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX, statsY, "Level:");
            m_levelText =
                new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX + style.LabelWidth, statsY, "");

            // Game
            statsY += style.LabelHeight;
            new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX, statsY, "Game:");
            m_gameText =
                new LabelWidget(m_characterDataGroup, style.LabelWidth, style.LabelHeight, statsX + style.LabelWidth, statsY, "");
        }

        // By default this isn't visible
        HideCharacterData();
    }
Exemple #34
0
 public void Init(GUIHost host)
 {
     Sprite.texture_height_pixels = 1024;
     Sprite.texture_width_pixels  = 1024;
     Sprite.pixel_perfect         = true;
     Init(host, "guicontrols", 896f, 384f, 1023f, 511f, 64, 32, 64, 16, 16, 64);
     WrapOnNegativeY = false;
     X_Text          = new ImageWidget(0);
     X_Text.SetPosition(6, 7);
     X_Text.SetSize(56, 56);
     X_Text.Init(host, "guicontrols", 64f, 192f, 119f, 247f, 64f, 192f, 119f, 247f, 64f, 192f, 119f, 247f);
     X_Text.Text = "";
     AddChildElement(X_Text);
     Y_Text = new ImageWidget(0);
     Y_Text.SetPosition(6, 63);
     Y_Text.SetSize(56, 56);
     Y_Text.Init(host, "guicontrols", 192f, 192f, 247f, 247f, 192f, 192f, 247f, 247f, 192f, 192f, 247f, 247f);
     Y_Text.Text = "";
     AddChildElement(Y_Text);
     Z_Text = new ImageWidget(0);
     Z_Text.SetPosition(6, 119);
     Z_Text.SetSize(56, 56);
     Z_Text.Init(host, "guicontrols", 320f, 192f, 375f, 247f, 320f, 192f, 375f, 247f, 320f, 192f, 375f, 247f);
     Z_Text.Text = "";
     AddChildElement(Z_Text);
     XPitch_Text = new ImageWidget(0);
     XPitch_Text.SetPosition(6, 7);
     XPitch_Text.SetSize(56, 56);
     XPitch_Text.Init(host, "guicontrols", 0.0f, 192f, 55f, 247f, 0.0f, 192f, 55f, 247f, 0.0f, 192f, 55f, 247f);
     XPitch_Text.Text    = "";
     XPitch_Text.Visible = true;
     AddChildElement(XPitch_Text);
     YRoll_Text = new ImageWidget(0);
     YRoll_Text.SetPosition(6, 63);
     YRoll_Text.SetSize(56, 56);
     YRoll_Text.Init(host, "guicontrols", 128f, 192f, 183f, 247f, 128f, 192f, 183f, 247f, 128f, 192f, 183f, 247f);
     YRoll_Text.Text    = "";
     YRoll_Text.Visible = true;
     AddChildElement(YRoll_Text);
     ZYaw_Text = new ImageWidget(0);
     ZYaw_Text.SetPosition(6, 119);
     ZYaw_Text.SetSize(56, 56);
     ZYaw_Text.Init(host, "guicontrols", 256f, 192f, 311f, 247f, 256f, 192f, 311f, 247f, 256f, 192f, 311f, 247f);
     ZYaw_Text.Text    = "";
     ZYaw_Text.Visible = true;
     AddChildElement(ZYaw_Text);
     X_Edit = new EditBoxWidget(8006);
     X_Edit.Init(host, "guicontrols", 384f, 192f, 447f, 247f);
     X_Edit.SetTextWindowBorders(6, 6, 19, 17);
     X_Edit.SetGrowableWidth(40, 16, 68);
     X_Edit.Size  = FontSize.Medium;
     X_Edit.Color = new Color4(0.51f, 0.51f, 0.51f, 1f);
     X_Edit.Hint  = "";
     X_Edit.Text  = "0.0";
     X_Edit.SetPosition(51, 7);
     X_Edit.SetSize(68, 56);
     X_Edit.tabIndex = 1;
     AddChildElement(X_Edit);
     Y_Edit = new EditBoxWidget(8007);
     Y_Edit.Init(host, "guicontrols", 384f, 192f, 447f, 247f);
     Y_Edit.SetTextWindowBorders(6, 6, 19, 17);
     Y_Edit.SetGrowableWidth(40, 16, 68);
     Y_Edit.Size  = FontSize.Medium;
     Y_Edit.Color = new Color4(0.51f, 0.51f, 0.51f, 1f);
     Y_Edit.Hint  = "";
     Y_Edit.Text  = "0.0";
     Y_Edit.SetPosition(51, 63);
     Y_Edit.SetSize(68, 56);
     Y_Edit.tabIndex = 2;
     AddChildElement(Y_Edit);
     Z_Edit = new EditBoxWidget(8008);
     Z_Edit.Init(host, "guicontrols", 384f, 192f, 447f, 247f);
     Z_Edit.SetTextWindowBorders(6, 6, 19, 17);
     Z_Edit.SetGrowableWidth(40, 16, 68);
     Z_Edit.Size  = FontSize.Medium;
     Z_Edit.Color = new Color4(0.51f, 0.51f, 0.51f, 1f);
     Z_Edit.Hint  = "";
     Z_Edit.Text  = "0.0";
     Z_Edit.SetPosition(51, 119);
     Z_Edit.SetSize(68, 56);
     Z_Edit.tabIndex = 3;
     AddChildElement(Z_Edit);
     Sprite.pixel_perfect = false;
     top_bracket_image    = new ImageWidget(0);
     top_bracket_image.Init(host, "extendedcontrols3", 0.0f, 0.0f, 22f, 31f, 0.0f, 0.0f, 22f, 31f, 0.0f, 0.0f, 22f, 31f);
     top_bracket_image.SetSize(22, 30);
     top_bracket_image.SetPosition(131, 33);
     top_bracket_image.Visible = true;
     AddChildElement(top_bracket_image);
     link_image = new ImageWidget(1);
     link_image.Init(host, "extendedcontrols3", 24f, 0.0f, 48f, 9f, 0.0f, 0.0f, 48f, 9f, 0.0f, 0.0f, 48f, 9f, 24f, 12f, 48f, 20f);
     link_image.SetSize(20, 10);
     link_image.SetPosition(124, 69);
     link_image.Visible = false;
     AddChildElement(link_image);
     linkScaling_button = new ButtonWidget(8015);
     linkScaling_button.Init(host, "guicontrols", 640f, 448f, 671f, 479f, 672f, 448f, 703f, 479f, 640f, 480f, 671f, 511f, 672f, 480f, 703f, 511f);
     linkScaling_button.Size = FontSize.Small;
     linkScaling_button.Text = "";
     linkScaling_button.SetGrowableWidth(5, 5, 16);
     linkScaling_button.SetGrowableHeight(5, 5, 16);
     linkScaling_button.SetSize(24, 24);
     linkScaling_button.SetPosition(122, 82);
     linkScaling_button.SetCallback(new ButtonCallback(MyButtonCallback));
     linkScaling_button.DontMove           = true;
     linkScaling_button.ClickType          = ButtonType.Checkable;
     linkScaling_button.CanClickOff        = true;
     linkScaling_button.Checked            = true;
     linkScaling_button.Visible            = false;
     linkScaling_button.ImageHasFocusColor = new Color4(100, 230, byte.MaxValue, byte.MaxValue);
     linkScaling_button.tabIndex           = 4;
     AddChildElement(linkScaling_button);
     middle_bracket_image = new ImageWidget(2);
     middle_bracket_image.Init(host, "extendedcontrols3", 5f, 0.0f, 22f, 5f, 0.0f, 0.0f, 22f, 31f, 0.0f, 0.0f, 22f, 31f);
     middle_bracket_image.SetSize(11, 5);
     middle_bracket_image.SetPosition(150, 88);
     middle_bracket_image.Visible = true;
     AddChildElement(middle_bracket_image);
     bottom_bracket_image = new ImageWidget(3);
     bottom_bracket_image.Init(host, "extendedcontrols3", 0.0f, 85f, 22f, 115f, 0.0f, 85f, 22f, 115f, 0.0f, 85f, 22f, 115f);
     bottom_bracket_image.SetSize(22, 35);
     bottom_bracket_image.SetPosition(131, 113);
     bottom_bracket_image.Visible = true;
     AddChildElement(bottom_bracket_image);
     X_Slider = new HorizontalSliderWidget(8009);
     X_Slider.InitTrack(host, "guicontrols", 809f, 72f, 831f, 95f, 4, 24);
     X_Slider.InitButton(host, "guicontrols", 808f, 0.0f, 831f, 23f, 808f, 24f, 831f, 47f, 808f, 48f, 831f, 71f, 4, 4, 24);
     X_Slider.InitMinus(host, "guicontrols", 736f, 0.0f, 759f, 23f, 760f, 0.0f, 783f, 23f, 784f, 0.0f, 808f, 23f);
     X_Slider.InitPlus(host, "guicontrols", 736f, 24f, 759f, 47f, 760f, 24f, 783f, 47f, 784f, 24f, 808f, 47f);
     X_Slider.SetButtonSize(24f);
     X_Slider.ShowPushButtons = true;
     X_Slider.SetSize(167, 24);
     X_Slider.SetPosition(155, 23);
     X_Slider.SetRange(-360f, 360f);
     X_Slider.PushButtonStep = 15f;
     X_Slider.SetTrackPosition(0.0f);
     AddChildElement(X_Slider);
     Y_Slider = new HorizontalSliderWidget(8010);
     Y_Slider.InitTrack(host, "guicontrols", 809f, 72f, 831f, 95f, 4, 24);
     Y_Slider.InitButton(host, "guicontrols", 904f, 0.0f, 927f, 23f, 904f, 24f, 927f, 47f, 904f, 48f, 927f, 71f, 4, 4, 24);
     Y_Slider.InitMinus(host, "guicontrols", 832f, 0.0f, 855f, 23f, 856f, 0.0f, 879f, 23f, 880f, 0.0f, 904f, 23f);
     Y_Slider.InitPlus(host, "guicontrols", 832f, 24f, 855f, 47f, 856f, 24f, 879f, 47f, 880f, 24f, 904f, 47f);
     Y_Slider.SetButtonSize(24f);
     Y_Slider.ShowPushButtons = true;
     Y_Slider.SetSize(167, 24);
     Y_Slider.SetPosition(155, 78);
     Y_Slider.SetRange(-360f, 360f);
     Y_Slider.PushButtonStep = 15f;
     Y_Slider.SetTrackPosition(0.0f);
     AddChildElement(Y_Slider);
     Z_Slider = new HorizontalSliderWidget(8011);
     Z_Slider.InitTrack(host, "guicontrols", 809f, 72f, 831f, 95f, 4, 24);
     Z_Slider.InitButton(host, "guicontrols", 1000f, 0.0f, 1023f, 23f, 1000f, 24f, 1023f, 47f, 1000f, 48f, 1023f, 71f, 4, 4, 24);
     Z_Slider.InitMinus(host, "guicontrols", 928f, 0.0f, 951f, 23f, 952f, 0.0f, 975f, 23f, 976f, 0.0f, 999f, 23f);
     Z_Slider.InitPlus(host, "guicontrols", 928f, 24f, 951f, 47f, 952f, 24f, 975f, 47f, 976f, 24f, 999f, 47f);
     Z_Slider.SetButtonSize(24f);
     Z_Slider.ShowPushButtons = true;
     Z_Slider.SetSize(167, 24);
     Z_Slider.SetPosition(155, 133);
     Z_Slider.SetRange(-360f, 360f);
     Z_Slider.PushButtonStep = 15f;
     Z_Slider.SetTrackPosition(0.0f);
     AddChildElement(Z_Slider);
     Sprite.pixel_perfect         = true;
     Sprite.texture_height_pixels = 1024;
     Sprite.texture_width_pixels  = 1024;
     Sprite.pixel_perfect         = false;
 }
Exemple #35
0
        public override void Init()
        {
            var frame       = new Frame(1);
            var color4_1    = new Color4(0.35f, 0.35f, 0.35f, 1f);
            var color4_2    = new Color4(1f, 1f, 1f, 1f);
            var color4_3    = new Color4(246, 246, 246, byte.MaxValue);
            var color4_4    = new Color4(220, 220, 220, byte.MaxValue);
            var textWidget1 = new TextWidget(0)
            {
                Color         = color4_1,
                Text          = "Set new 3D Ink information by cheat code:",
                RelativeWidth = 1f,
                Size          = FontSize.Medium,
                Alignment     = QFontAlignment.Centre
            };

            textWidget1.SetPosition(0, 40);
            AddChildElement(textWidget1);
            var imageWidget = new ImageWidget(0);

            imageWidget.Init(Host, "extendedcontrols", 0.0f, 256f, 290f, 381f, 0.0f, 256f, 448f, 511f, 0.0f, 256f, 448f, 511f);
            imageWidget.Width  = 290;
            imageWidget.Height = 125;
            imageWidget.X      = 100;
            imageWidget.Y      = 40;
            imageWidget.CenterHorizontallyInParent = true;
            frame.AddChildElement(imageWidget);
            var textWidget2 = new TextWidget(1)
            {
                Text = "Enter cheat code or filament type:"
            };

            textWidget2.SetSize(150, 100);
            textWidget2.SetPositionRelative(0.25f, 0.6f);
            textWidget2.Color = color4_1;
            frame.AddChildElement(textWidget2);
            CheatEdit = new MultiBoxEditBoxWidget(13, null);
            CheatEdit.Init(Host, 3, 1);
            CheatEdit.SetSize(150, 32);
            CheatEdit.SetPositionRelative(0.55f, 0.75f);
            CheatEdit.Color = color4_1;
            CheatEdit.SetCallbackEnterKey(new MultiBoxEditBoxWidget.EditBoxCallback(CheatCodeEnterCallBack));
            frame.AddChildElement(CheatEdit);
            var buttonWidget1 = new ButtonWidget(11);

            buttonWidget1.Init(Host, "guicontrols", 896f, 192f, 959f, byte.MaxValue, 896f, 256f, 959f, 319f, 896f, 320f, 959f, 383f, 960f, 128f, 1023f, 191f);
            buttonWidget1.Size = FontSize.Medium;
            buttonWidget1.Text = "Cancel";
            buttonWidget1.SetGrowableWidth(4, 4, 32);
            buttonWidget1.SetGrowableHeight(4, 4, 32);
            buttonWidget1.SetSize(110, 40);
            buttonWidget1.SetPosition(20, -50);
            buttonWidget1.SetPositionRelative(0.025f, -1000f);
            buttonWidget1.SetCallback(new ButtonCallback(((Manage3DInkChildWindow)this).MyButtonCallback));
            AddChildElement(buttonWidget1);
            var buttonWidget2 = new ButtonWidget(12);

            buttonWidget2.Init(Host, "guicontrols", 896f, 192f, 959f, byte.MaxValue, 896f, 256f, 959f, 319f, 896f, 320f, 959f, 383f, 960f, 128f, 1023f, 191f);
            buttonWidget2.Size = FontSize.Medium;
            buttonWidget2.Text = "Next";
            buttonWidget2.SetGrowableWidth(4, 4, 32);
            buttonWidget2.SetGrowableHeight(4, 4, 32);
            buttonWidget2.SetSize(100, 32);
            buttonWidget2.SetPosition(400, -50);
            buttonWidget2.SetPositionRelative(0.8f, -1000f);
            buttonWidget2.SetCallback(new ButtonCallback(((Manage3DInkChildWindow)this).MyButtonCallback));
            AddChildElement(buttonWidget2);
            frame.BGColor     = color4_3;
            frame.BorderColor = color4_4;
            frame.SetSizeRelative(1f, 0.6f);
            frame.SetPositionRelative(0.0f, 0.15f);
            BGColor = color4_2;
            SetSizeRelative(1f, 0.9f);
            SetPositionRelative(0.0f, 0.05f);
            AddChildElement(frame);
        }
        public void AddElements()
        {
            Title = LocalizedString.Get("Design Add-ons");

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.HAnchor = HAnchor.ParentLeftRight;
            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);
            {
                string     elementHeaderLabelBeg  = LocalizedString.Get("Select a Design Tool");
                string     elementHeaderLabelFull = string.Format("{0}:", elementHeaderLabelBeg);
                string     elementHeaderLabel     = elementHeaderLabelFull;
                TextWidget elementHeader          = new TextWidget(string.Format(elementHeaderLabel), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

            GuiWidget presetsFormContainer = new GuiWidget();
            {
                presetsFormContainer.HAnchor         = HAnchor.ParentLeftRight;
                presetsFormContainer.VAnchor         = VAnchor.ParentBottomTop;
                presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            pluginRowContainer.AnchorAll();
            presetsFormContainer.AddChild(pluginRowContainer);

            unlockButtonFactory.Margin = new BorderDouble(10, 0);
            if (ActiveTheme.Instance.IsDarkTheme)
            {
                unlockButtonFactory.normalFillColor   = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.hoverFillColor    = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.hoverBorderColor  = new RGBA_Bytes(0, 0, 0, 50);
            }
            else
            {
                unlockButtonFactory.normalFillColor   = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.hoverFillColor    = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.hoverBorderColor  = new RGBA_Bytes(0, 0, 0, 100);
            }

            foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
            {
                FlowLayoutWidget pluginListingContainer = new FlowLayoutWidget();
                pluginListingContainer.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                pluginListingContainer.BackgroundColor = RGBA_Bytes.White;
                pluginListingContainer.Padding         = new BorderDouble(0);
                pluginListingContainer.Margin          = new BorderDouble(6, 0, 6, 6);

                ClickWidget pluginRow = new ClickWidget();
                pluginRow.Margin  = new BorderDouble(6, 0, 6, 0);
                pluginRow.Height  = 38;
                pluginRow.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.AnchorAll();
                macroRow.BackgroundColor = RGBA_Bytes.White;

                if (creatorInfo.iconPath != "")
                {
                    ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
                    ImageWidget imageWidget = new ImageWidget(imageBuffer);
                    imageWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    macroRow.AddChild(imageWidget);
                }

                bool userHasPermission;
                if (!creatorInfo.paidAddOnFlag)
                {
                    userHasPermission = true;
                }
                else
                {
                    userHasPermission = creatorInfo.permissionFunction();
                }

                string addOnDescription;
                addOnDescription = creatorInfo.description;
                TextWidget buttonLabel = new TextWidget(addOnDescription, pointSize: 14);
                buttonLabel.Margin  = new BorderDouble(left: 10);
                buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                macroRow.AddChild(buttonLabel);

                if (!userHasPermission)
                {
                    TextWidget demoLabel = new TextWidget("(" + "demo".Localize() + ")", pointSize: 10);

                    demoLabel.Margin  = new BorderDouble(left: 4);
                    demoLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    macroRow.AddChild(demoLabel);
                }

                macroRow.AddChild(new HorizontalSpacer());

                CreatorInformation callCorrectFunctionHold = creatorInfo;
                pluginRow.Click += (sender, e) =>
                {
                    if (RegisteredCreators.Instance.Creators.Count > 0)
                    {
                        UiThread.RunOnIdle(CloseOnIdle, callCorrectFunctionHold);
                    }
                    else
                    {
                        UiThread.RunOnIdle(CloseOnIdle);
                    }
                };

                pluginRow.Cursor    = Cursors.Hand;
                macroRow.Selectable = false;
                pluginRow.AddChild(macroRow);

                pluginListingContainer.AddChild(pluginRow);

                if (!userHasPermission)
                {
                    Button unlockButton = unlockButtonFactory.Generate("Unlock".Localize());
                    unlockButton.Margin = new BorderDouble(0);
                    unlockButton.Cursor = Cursors.Hand;
                    unlockButton.Click += (sender, e) =>
                    {
                        callCorrectFunctionHold.unlockFunction();
                    };
                    pluginListingContainer.AddChild(unlockButton);
                }

                pluginRowContainer.AddChild(pluginListingContainer);
                if (callCorrectFunctionHold.unlockRegisterFunction != null)
                {
                    callCorrectFunctionHold.unlockRegisterFunction(TriggerReload, ref unregisterEvents);
                }
            }

            topToBottom.AddChild(presetsFormContainer);
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));

            cancelPresetsButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(CloseOnIdle);
            };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Padding = new BorderDouble(0, 3);

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
    public void Start()
    {
        SessionData sessionData = SessionData.GetInstance();

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, gamePanelStyle.Width, gamePanelStyle.Height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Background for the game info
        ImageWidget gamePanel =
            new ImageWidget(
                m_rootWidgetGroup,
                gamePanelStyle.Width,
                gamePanelStyle.Height,
                gamePanelStyle.Background,
                0.0f, 0.0f);

        float statsLabelWidth = (gamePanel.Width - 2 * BORDER_WIDTH) / 2 - 3;
        float statsX = 10;
        float statsY = 10;

        // Owner Name
        LabelWidget ownerNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Owner Name:");
        ownerNameLabel.Alignment = TextAnchor.UpperRight;
        m_ownerNameLabel =
            new LabelWidget(
                m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT,
                statsX + statsLabelWidth, statsY, sessionData.UserName);
        m_ownerNameLabel.Text = "";

        // Game name
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget gameNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Game Name:");
        gameNameLabel.Alignment = TextAnchor.UpperRight;
        m_gameNameTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX+statsLabelWidth, statsY, "");

        // IRC Server
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCServerLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Server:");
        IRCServerLabel.Alignment = TextAnchor.UpperRight;
        m_IRCServerTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX+statsLabelWidth, statsY, "");
        m_IRCServerTextField.Text = ServerConstants.DEFAULT_IRC_SERVER;

        // IRC Port
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCPortLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Port:");
        IRCPortLabel.Alignment = TextAnchor.UpperRight;
        m_IRCPortTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX + statsLabelWidth, statsY, "");
        m_IRCPortTextField.Restrict = @"[^0-9]";
        m_IRCPortTextField.MaxLength = 6;
        m_IRCPortTextField.Text = ServerConstants.DEFAULT_IRC_PORT.ToString();

        // IRC Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Enabled:");
        IRCEnabledLabel.Alignment = TextAnchor.UpperRight;
        m_IRCEnabledToggle = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEnabledToggle.Enabled = true;

        // IRC Encryption Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEncryptionEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Encryption Enabled:");
        IRCEncryptionEnabledLabel.Alignment = TextAnchor.UpperRight;
        m_IRCEncryptionEnabledToggle = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEncryptionEnabledToggle.Enabled = true;

        // Creation status
        m_statusLabel = new LabelWidget(m_rootWidgetGroup, gamePanel.Width, STATS_LABEL_HEIGHT, 0.0f, 0.0f, "");
        m_statusLabel.SetLocalPosition(0, gamePanel.Height - m_statusLabel.Height - BORDER_WIDTH);
        m_statusLabel.Alignment = TextAnchor.UpperCenter;

        // Create button
        m_createButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Create");
        m_createButton.SetLocalPosition(gamePanel.Width/3 - m_createButton.Width/2, m_statusLabel.LocalY - m_createButton.Height - 5);

        // Cancel button
        m_cancelButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Cancel");
        m_cancelButton.SetLocalPosition((2*gamePanel.Width)/3 - m_cancelButton.Width/2, m_statusLabel.LocalY - m_cancelButton.Height - 5);

        // Center the group info widgets
        m_rootWidgetGroup.SetLocalPosition(Screen.width / 2 - gamePanel.Width / 2, Screen.height / 2 - gamePanel.Height / 2);
    }