예제 #1
0
        public static IContainer BuildContainer()
        {
            var thisAssembly = typeof(Program).Assembly;
            var builder      = new ContainerBuilder();

            builder.RegisterModule <AttributedMetadataModule>();

            builder.RegisterType <MainForm>().AsSelf().SingleInstance();
            builder.RegisterAssemblyTypes(thisAssembly)
            .Where(t => t.IsAssignableTo <IMainFormComponent>())
            .AsSelf()
            .SingleInstance();

            builder.RegisterAssemblyTypes(thisAssembly)
            .Where(t => t.IsDefined(typeof(ToolBarButtonMetaData)))
            .AsImplementedInterfaces();

            builder.RegisterAdapter <Meta <IRequest>, ButtonConfiguration>((ctx, m) =>
            {
                var mediator = ctx.Resolve <IMediator>();
                var button   = new ButtonConfiguration
                {
                    Text  = (string)m.Metadata["Text"],
                    Order = (int)m.Metadata["Order"]
                };

                button.Click += (o, e) => { mediator.Send(m.Value); };

                return(button);
            });

            builder.RegisterAssemblyModules(thisAssembly);

            return(builder.Build());
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="buttonConfiguration"> The <see cref="ButtonConfiguration"/> of this button. </param>
        /// <param name="closeCallback"> The callback method used to close the dialog this button is being displayed in. </param>
        internal Button
        (
            ButtonConfiguration buttonConfiguration,
            Action <DialogResult> closeCallback
        )
        {
            // Save parameters.
            this.IsEnabled      = buttonConfiguration.IsEnabled;
            this.Caption        = buttonConfiguration.Caption;
            this.ButtonBehavior = buttonConfiguration.ButtonBehavior;

            // Initialize fields.
            this.Command = new CommandHandler
                           (
                async() =>
            {
                var dialogResult = await buttonConfiguration.Callback.Invoke();
                if (dialogResult != DialogResult.None)
                {
                    closeCallback?.Invoke(dialogResult);
                }
            },
                this.IsEnabled
                           );

            // Keep the enabled state up to date.
            buttonConfiguration.EnabledChanged += (sender, args) => this.IsEnabled = buttonConfiguration.IsEnabled;
        }
예제 #3
0
 private void PlayButtonConfig(ButtonConfiguration cfg, OutputProcessor pro, bool down)
 {
     if (cfg.Mode == ButtonConfiguration.eMode.SingleKey)
     {
         pro.PlayKey(cfg.Key, 10, down);
     }
     else if (down)
     {
         pro.PlayMacro(cfg.Macro);
     }
 }
    void Awake()
    {
        focusableButtonComponent = GetComponent <FocusableButton>();
        if (focusableButtonComponent != null)
        {
            focusableButtonComponent.OnPressed = KeyPressed;
        }

        buttonConfiguration = GetComponent <ButtonConfiguration>();
        keyboard            = transform.parent.GetComponent <Keyboard>();
    }
예제 #5
0
    /// <summary>
    /// Método que atualiza o botão que será liberado para o jogador
    /// </summary>
    /// <param name="newButtonConfiguration"></param>
    private void ChangeButton(ButtonConfiguration newButtonConfiguration)
    {
        if (_playerConfig.isLocalPlayer)
        {
            _actionButton.onClick.RemoveAllListeners();
            _actionButton.onClick = newButtonConfiguration.ButtonEvent;

            _actionButtonText.text = newButtonConfiguration.ButtonText;

            _actionButtonImage.sprite = newButtonConfiguration.ButtonSprite;

            _aimSign.SetActive(newButtonConfiguration.ShowAimSign);

            _actionButton.interactable = true;
        }
    }
        public static bool UpgradeButton(ButtonConfiguration buttonConfig, FileSystemInfo file)
        {
            LogMessage(MessageType.Info, "Checking Menu Versions");

            try
            {
                using (var client = GetPreconfiguredWebClient())
                {
                    if (string.IsNullOrEmpty(buttonConfig.versionUrl))
                    {
                        return false;
                    }

                    Stream myStream = client.OpenRead(buttonConfig.versionUrl);
                    if (myStream != null)
                    {
                        using (StreamReader sr = new StreamReader(myStream))
                        {
                            string latestVersion = sr.ReadToEnd();
                            if (latestVersion != buttonConfig.currentVersion)
                            {
                                // Download the latest version
                                DeployZippedButton(buttonConfig.sourceUrl, file.Name);
                                return true;
                            }
                        }
                    }
                }

                return false;
            }
            catch (Exception ex)
            {
                LogMessage(MessageType.Error, "Update check failed." + ex.Message);

                return false;

                // swallow the error.
            }
        }
        public static bool UpgradeButton(ButtonConfiguration buttonConfig, FileSystemInfo file)
        {
            LogMessage(MessageType.Info, "Checking Menu Versions");

            try
            {
                using (var client = GetPreconfiguredWebClient())
                {
                    if (string.IsNullOrEmpty(buttonConfig.versionUrl))
                    {
                        return(false);
                    }

                    Stream myStream = client.OpenRead(buttonConfig.versionUrl);
                    if (myStream != null)
                    {
                        using (StreamReader sr = new StreamReader(myStream))
                        {
                            string latestVersion = sr.ReadToEnd();
                            if (latestVersion != buttonConfig.currentVersion)
                            {
                                // Download the latest version
                                DeployZippedButton(buttonConfig.sourceUrl, file.Name);
                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                LogMessage(MessageType.Error, "Update check failed." + ex.Message);

                return(false);

                // swallow the error.
            }
        }