Exemplo n.º 1
0
        SlideWidget getItemActionButtons()
        {
            int buttonWidth;

            if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
            {
                buttonWidth = 120;
            }
            else
            {
                buttonWidth = 80;
            }

            SlideWidget buttonContainer = new SlideWidget();

            buttonContainer.VAnchor = VAnchor.ParentBottomTop;

            FlowLayoutWidget buttonFlowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonFlowContainer.VAnchor = VAnchor.ParentBottomTop;

            ClickWidget removeButton = new ClickWidget();

            removeButton.VAnchor         = VAnchor.ParentBottomTop;
            removeButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
            removeButton.Width           = buttonWidth;

            TextWidget printLabel = new TextWidget("Remove".Localize());

            printLabel.TextColor = RGBA_Bytes.White;
            printLabel.VAnchor   = VAnchor.ParentCenter;
            printLabel.HAnchor   = HAnchor.ParentCenter;

            removeButton.AddChild(printLabel);
            removeButton.Click += RemoveConnectionLink_Click;

            ClickWidget editButton = new ClickWidget();

            editButton.VAnchor         = VAnchor.ParentBottomTop;
            editButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            editButton.Width           = buttonWidth;

            TextWidget editLabel = new TextWidget("Edit".Localize());

            editLabel.TextColor = RGBA_Bytes.White;
            editLabel.VAnchor   = VAnchor.ParentCenter;
            editLabel.HAnchor   = HAnchor.ParentCenter;

            editButton.AddChild(editLabel);
            editButton.Click += EditConnectionLink_Click;

            buttonFlowContainer.AddChild(editButton);
            buttonFlowContainer.AddChild(removeButton);

            buttonContainer.AddChild(buttonFlowContainer);
            buttonContainer.Width = buttonWidth * 2;

            return(buttonContainer);
        }
Exemplo n.º 2
0
        SlideWidget getItemActionButtons()
        {
            SlideWidget buttonContainer = new SlideWidget();

            buttonContainer.VAnchor = VAnchor.ParentBottomTop;

            FlowLayoutWidget buttonFlowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonFlowContainer.VAnchor = VAnchor.ParentBottomTop;

            ClickWidget printButton = new ClickWidget();

            printButton.VAnchor         = VAnchor.ParentBottomTop;
            printButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
            printButton.Width           = 100;

            TextWidget printLabel = new TextWidget("Print".Localize());

            printLabel.TextColor = RGBA_Bytes.White;
            printLabel.VAnchor   = VAnchor.ParentCenter;
            printLabel.HAnchor   = HAnchor.ParentCenter;

            printButton.AddChild(printLabel);
            printButton.Click += (sender, e) =>
            {
                QueueData.Instance.AddItem(this.printItemWrapper, 0);
                if (!PrinterCommunication.PrinterConnectionAndCommunication.Instance.PrintIsActive)
                {
                    QueueData.Instance.SelectedIndex = 0;
                    PrinterCommunication.PrinterConnectionAndCommunication.Instance.PrintActivePartIfPossible();
                }

                this.Invalidate();
            };;

            ClickWidget editButton = new ClickWidget();

            editButton.VAnchor         = VAnchor.ParentBottomTop;
            editButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            editButton.Width           = 100;

            TextWidget editLabel = new TextWidget("View".Localize());

            editLabel.TextColor = RGBA_Bytes.White;
            editLabel.VAnchor   = VAnchor.ParentCenter;
            editLabel.HAnchor   = HAnchor.ParentCenter;

            editButton.AddChild(editLabel);
            editButton.Click += onViewPartClick;

            buttonFlowContainer.AddChild(editButton);
            buttonFlowContainer.AddChild(printButton);

            buttonContainer.AddChild(buttonFlowContainer);
            buttonContainer.Width = 200;

            return(buttonContainer);
        }
Exemplo n.º 3
0
        SlideWidget getItemActionButtons()
        {
            SlideWidget buttonContainer = new SlideWidget();

            buttonContainer.VAnchor = VAnchor.ParentBottomTop;
            buttonContainer.HAnchor = HAnchor.ParentRight;

            FlowLayoutWidget buttonFlowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonFlowContainer.VAnchor = VAnchor.ParentBottomTop;

            ClickWidget printButton = new ClickWidget();

            printButton.VAnchor         = VAnchor.ParentBottomTop;
            printButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
            printButton.Width           = 100;

            TextWidget printLabel = new TextWidget("Remove".Localize());

            printLabel.TextColor = RGBA_Bytes.White;
            printLabel.VAnchor   = VAnchor.ParentCenter;
            printLabel.HAnchor   = HAnchor.ParentCenter;

            printButton.AddChild(printLabel);
            printButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(DeletePartFromQueue);
            };;

            ClickWidget viewButton = new ClickWidget();

            viewButton.VAnchor         = VAnchor.ParentBottomTop;
            viewButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            viewButton.Width           = 100;

            TextWidget editLabel = new TextWidget("View".Localize());

            editLabel.TextColor = RGBA_Bytes.White;
            editLabel.VAnchor   = VAnchor.ParentCenter;
            editLabel.HAnchor   = HAnchor.ParentCenter;

            viewButton.AddChild(editLabel);
            viewButton.Click += onViewPartClick;

            //buttonFlowContainer.AddChild(viewButton);
            buttonFlowContainer.AddChild(printButton);

            buttonContainer.AddChild(buttonFlowContainer);
            //buttonContainer.Width = 200;
            buttonContainer.Width = 100;

            return(buttonContainer);
        }
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
		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)", pointSize: 10);

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

				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)
					{
						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");
					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);
		}
Exemplo n.º 8
0
        void AddChildElements()
        {
            GuiWidget mainContainer = new GuiWidget();

            mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            mainContainer.VAnchor = VAnchor.ParentBottomTop;

            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
            {
                GuiWidget indicator = new GuiWidget();
                indicator.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
                indicator.Width   = 15;
                if (printTask.PrintComplete)
                {
                    indicator.BackgroundColor = new RGBA_Bytes(38, 147, 51, 180);
                }
                else
                {
                    indicator.BackgroundColor = new RGBA_Bytes(252, 209, 22, 180);
                }

                FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                middleColumn.Padding = new BorderDouble(6, 3);
                {
                    FlowLayoutWidget labelContainer = new FlowLayoutWidget();
                    labelContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                    string labelName = textInfo.ToTitleCase(printTask.PrintName);
                    labelName           = labelName.Replace('_', ' ');
                    partLabel           = new TextWidget(labelName, pointSize: 15);
                    partLabel.TextColor = WidgetTextColor;

                    labelContainer.AddChild(partLabel);


                    middleColumn.AddChild(labelContainer);
                }

                RGBA_Bytes timeTextColor = new RGBA_Bytes(34, 34, 34);

                FlowLayoutWidget buttonContainer = new FlowLayoutWidget();
                buttonContainer.Margin  = new BorderDouble(0);
                buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                {
                    TextWidget statusIndicator = new TextWidget("Status: Completed".Localize(), pointSize: 8);
                    statusIndicator.Margin = new BorderDouble(right: 3);
                    //buttonContainer.AddChild(statusIndicator);

                    string     printTimeLabel     = "Time".Localize().ToUpper();
                    string     printTimeLabelFull = string.Format("{0}: ", printTimeLabel);
                    TextWidget timeLabel          = new TextWidget(printTimeLabelFull, pointSize: 8);
                    timeLabel.TextColor = timeTextColor;

                    TextWidget timeIndicator;
                    int        minutes = printTask.PrintTimeMinutes;
                    if (minutes < 0)
                    {
                        timeIndicator = new TextWidget("Unknown".Localize());
                    }
                    else if (minutes > 60)
                    {
                        timeIndicator = new TextWidget("{0}hrs {1}min".FormatWith(printTask.PrintTimeMinutes / 60, printTask.PrintTimeMinutes % 60), pointSize: 12);
                    }
                    else
                    {
                        timeIndicator = new TextWidget(string.Format("{0}min", printTask.PrintTimeMinutes), pointSize: 12);
                    }

                    timeIndicator.Margin    = new BorderDouble(right: 6);
                    timeIndicator.TextColor = timeTextColor;

                    buttonContainer.AddChild(timeLabel);
                    buttonContainer.AddChild(timeIndicator);
                    buttonContainer.AddChild(new HorizontalSpacer());
                    middleColumn.AddChild(buttonContainer);
                }

                GuiWidget primaryContainer = new GuiWidget();
                primaryContainer.HAnchor = HAnchor.ParentLeftRight;
                primaryContainer.VAnchor = VAnchor.ParentBottomTop;


                FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight);
                primaryFlow.HAnchor = HAnchor.ParentLeftRight;
                primaryFlow.VAnchor = VAnchor.ParentBottomTop;

                primaryFlow.AddChild(indicator);
                primaryFlow.AddChild(middleColumn);

                primaryContainer.AddChild(primaryFlow);

                rightButtonOverlay         = new SlideWidget();
                rightButtonOverlay.VAnchor = VAnchor.ParentBottomTop;
                rightButtonOverlay.HAnchor = Agg.UI.HAnchor.ParentRight;
                rightButtonOverlay.Width   = 200;
                rightButtonOverlay.Visible = false;

                FlowLayoutWidget rightMiddleColumnContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
                rightMiddleColumnContainer.VAnchor = VAnchor.ParentBottomTop;
                {
                    ClickWidget viewButton = new ClickWidget();
                    viewButton.VAnchor         = VAnchor.ParentBottomTop;
                    viewButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
                    viewButton.Width           = 100;

                    TextWidget viewLabel = new TextWidget("View".Localize());
                    viewLabel.TextColor = RGBA_Bytes.White;
                    viewLabel.VAnchor   = VAnchor.ParentCenter;
                    viewLabel.HAnchor   = HAnchor.ParentCenter;

                    viewButton.AddChild(viewLabel);
                    viewButton.Click += ViewButton_Click;
                    rightMiddleColumnContainer.AddChild(viewButton);

                    ClickWidget printButton = new ClickWidget();
                    printButton.VAnchor         = VAnchor.ParentBottomTop;
                    printButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
                    printButton.Width           = 100;

                    TextWidget printLabel = new TextWidget("Print".Localize());
                    printLabel.TextColor = RGBA_Bytes.White;
                    printLabel.VAnchor   = VAnchor.ParentCenter;
                    printLabel.HAnchor   = HAnchor.ParentCenter;

                    printButton.AddChild(printLabel);
                    printButton.Click += (sender, e) =>
                    {
                        QueueData.Instance.AddItem(new PrintItemWrapper(printTask.PrintItemId), 0);
                        if (!PrinterCommunication.PrinterConnectionAndCommunication.Instance.PrintIsActive)
                        {
                            QueueData.Instance.SelectedIndex = 0;
                            PrinterCommunication.PrinterConnectionAndCommunication.Instance.PrintActivePartIfPossible();
                        }
                    };
                    rightMiddleColumnContainer.AddChild(printButton);
                }
                rightButtonOverlay.AddChild(rightMiddleColumnContainer);

                if (showTimestamp)
                {
                    FlowLayoutWidget timestampColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    timestampColumn.VAnchor         = Agg.UI.VAnchor.ParentBottomTop;
                    timestampColumn.BackgroundColor = RGBA_Bytes.LightGray;
                    timestampColumn.Padding         = new BorderDouble(6, 0);

                    FlowLayoutWidget startTimeContainer = new FlowLayoutWidget();
                    startTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                    startTimeContainer.Padding = new BorderDouble(0, 3);

                    string     startLabelFull = "{0}:".FormatWith("Start".Localize().ToUpper());
                    TextWidget startLabel     = new TextWidget(startLabelFull, pointSize: 8);
                    startLabel.TextColor = timeTextColor;

                    string     startTimeString = printTask.PrintStart.ToString("MMM d yyyy h:mm ") + printTask.PrintStart.ToString("tt").ToLower();
                    TextWidget startDate       = new TextWidget(startTimeString, pointSize: 12);
                    startDate.TextColor = timeTextColor;

                    startTimeContainer.AddChild(startLabel);
                    startTimeContainer.AddChild(new HorizontalSpacer());
                    startTimeContainer.AddChild(startDate);


                    FlowLayoutWidget endTimeContainer = new FlowLayoutWidget();
                    endTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                    endTimeContainer.Padding = new BorderDouble(0, 3);

                    string     endLabelFull = "{0}:".FormatWith("End".Localize().ToUpper());
                    TextWidget endLabel     = new TextWidget(endLabelFull, pointSize: 8);
                    endLabel.TextColor = timeTextColor;

                    string endTimeString;
                    if (printTask.PrintEnd != DateTime.MinValue)
                    {
                        endTimeString = printTask.PrintEnd.ToString("MMM d yyyy h:mm ") + printTask.PrintEnd.ToString("tt").ToLower();
                    }
                    else
                    {
                        endTimeString = "Unknown".Localize();
                    }

                    TextWidget endDate = new TextWidget(endTimeString, pointSize: 12);
                    endDate.TextColor = timeTextColor;

                    endTimeContainer.AddChild(endLabel);
                    endTimeContainer.AddChild(new HorizontalSpacer());
                    endTimeContainer.AddChild(endDate);

                    HorizontalLine horizontalLine = new HorizontalLine();
                    horizontalLine.BackgroundColor = RGBA_Bytes.Gray;

                    timestampColumn.AddChild(endTimeContainer);
                    timestampColumn.AddChild(horizontalLine);
                    timestampColumn.AddChild(startTimeContainer);

                    timestampColumn.Width = 200;

                    primaryFlow.AddChild(timestampColumn);
                }

                mainContainer.AddChild(primaryContainer);
                mainContainer.AddChild(rightButtonOverlay);

                this.AddChild(mainContainer);
            }
        }