private void CloseOnIdle(object state)
        {
            Close();

            CreatorInformation creatorInfo = state as CreatorInformation;

            if (creatorInfo != null)
            {
                UiThread.RunOnIdle(creatorInfo.Show);
            }
        }
        private void CloseOnIdle(object state)
        {
            Close();
            CreatorInformation callCorrectFunctionHold = state as CreatorInformation;

            if (callCorrectFunctionHold != null)
            {
                UiThread.RunOnIdle(() =>
                {
                    callCorrectFunctionHold.functionToLaunchCreator(null, null);
                });
            }
        }
		public override void Initialize(GuiWidget application)
		{
			CreatorInformation information = new CreatorInformation(LaunchNewBrailleBuilder, "259.png", "Braille Builder");
			RegisteredCreators.Instance.RegisterLaunchFunction(information);
			mainApplication = application;

			if (false)
			{
				UiThread.RunOnIdle(() =>
					{
						LaunchNewBrailleBuilder(null, null);
					}, .5);
			}
		}
 public override void Initialize(GuiWidget application)
 {
     CreatorInformation information = new CreatorInformation(LaunchNewTextCreator, "259.png", "Text Creator");
     RegisteredCreators.Instance.RegisterLaunchFunction(information);
     mainApplication = application;
 }
        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 RegisterLaunchFunction(CreatorInformation creatorInformation)
 {
     Creators.Add(creatorInformation);
 }
 public void RegisterLaunchFunction(CreatorInformation creatorInformation)
 {
     Creators.Add(creatorInformation);
 }