private MenuItem BuildMenuItem(ButtonConfig button) { var header = new Grid(); if (button.Icon != null) { header.Children.Add(button.Icon); } if (button.Text != null) { header.Children.Add(new TextBlock { Text = button.Text, FontSize = 12 }); } var menuItem = new MenuItem { Header = header, Command = button.Command, ToolTip = button.Tooltip, HorizontalContentAlignment = HorizontalAlignment.Center, }; return(menuItem); }
private bool ButtonSetup() { //initialise button list and set as invisible BUTTONLIST = new PictureBox[CONFIG_FILE.numOfButtons]; for (int i = 0; i < BUTTONLIST.Length; i++) { BUTTONLIST[i] = new PictureBox { Name = "AppButton" + i, BackColor = Color.White, SizeMode = PictureBoxSizeMode.StretchImage }; BUTTONLIST[i].Click += ButtonClick; BUTTONLIST[i].Paint += ButtonText_Paint; HOMEFORM.Controls.Add(BUTTONLIST[i]); } //setup all app buttons Image image; for (int i = 0; i < CONFIG_FILE.numOfButtons; i++) { ButtonConfig temp = CONFIG_FILE.appButtonsConfig[i]; //get image from path try { image = Image.FromFile(Path.Combine(CONFIG_FILE.resourceFolder, temp.backgroundImageName)); } catch { image = null; } BUTTONLIST[i].Image = image; } //create home button from config try { OVERLAYFORM = new OverlayForm(HOMEFORM); } catch { return(true); } return(false); }
private void Awake() { instance = this; _isModEnabled = Main.Instance.Config.Bind <bool>(nameof(Eraser), "Enabled", false, "Globally enable or disable the prefab eraser."); _isModEnabled.SettingChanged += (sender, eventArgs) => { DestroyPanel(); if (_isModEnabled.Value && Hud.instance) { CreatePanel(Hud.instance); } }; _deleteObjectConfig = Main.Instance.Config.Bind <KeyCode>(nameof(Eraser), "KeyCode", KeyCode.KeypadMinus, "Key for the prefab eraser."); _deleteObjectButton = new ButtonConfig { Name = "DebugDeleteObject", Config = _deleteObjectConfig }; InputManager.Instance.AddButton(Main.ModGuid, _deleteObjectButton); Main.Harmony.PatchAll(typeof(Patches)); }
public static void Bind(CropReplant cr) { c_range = cr.Config.Bind("General", "MultipickRange", 2f, "Radius to pick crops in"); c_multipick = cr.Config.Bind("General", "MultipickEnable", true, "Enable picking crops in radius"); c_displayGrowth = cr.Config.Bind("General", "DisplayGrowth", true, "Enable growth % tooltip on plant."); c_useDurability = cr.Config.Bind("General", "UseDurability", true, "Enable cultivator durability depletion when replanting."); c_blockHarvestNoResources = cr.Config.Bind("General", "blockHarvestNoResources", false, "Block harvest if no resource to replant."); c_replantSame = cr.Config.Bind("General", "replantSame", false, "Replant same plant if cultivate is selected in cultivator menu."); c_customReplantables = cr.Config.Bind("General", "customReplantables", "", "Custom plants to replant in format 'SeedName : PlantName, SeedName : PlantName'"); customReplantables = ParseReplantables(c_customReplantables.Value); c_oldStyle = cr.Config.Bind("General", "oldStyle", false, "1.6 style replanting"); c_useCustomReplantKey = cr.Config.Bind("General", "UseCustomReplantKey", false, "Use a custom keybind instead of game's alternative attack bind."); c_customReplantKey = cr.Config.Bind("General", "customReplantKey", KeyCode.H, "Custom keybind to use instead of of game's alternative attack bind."); replantButton = new ButtonConfig { Name = "ReplantKey", Config = c_customReplantKey, HintToken = "Replant" }; replantHint = new KeyHintConfig { ButtonConfigs = new ButtonConfig[] { replantButton }, }; GUIManager.Instance.AddKeyHint(replantHint); InputManager.Instance.AddButton(CropReplant.PluginGUID, replantButton); }
private void Button_OnClick_ContentCallout(object sender, RoutedEventArgs e) { var okButtonConfig = new ButtonConfig("I Agree", () => { Debug.WriteLine("Agreed!"); }, isEnabled: false); var cancelButtonConfig = new ButtonConfig("I Decline", () => { Debug.WriteLine("Disagreed!"); }); var buttonConfigs = new[] { okButtonConfig, cancelButtonConfig }; var panel = new StackPanel(); panel.Children.Add(new TextBlock { Text = "This is a short message.", TextWrapping = TextWrapping.Wrap, }); var checkBox = new CheckBox { Content = "Agree" }; checkBox.Checked += (o, args) => { okButtonConfig.IsEnabled = true; }; checkBox.Unchecked += (o, args) => { okButtonConfig.IsEnabled = false; }; panel.Children.Add(checkBox); this.callout.Show( this.CaptionTextBox.Text, panel, buttonConfigs, this.FullScreenCheckBox.IsChecked.Value); }
private void OnDPadPress(object sender, GamepadDPadEventArgs args) { ButtonConfig currentButton = GetCurrentButton(args.Buttons); if (lastDPadButton == null) { if (currentButton != null) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } lastDPadButton = currentButton; } else { if (lastDPadButton != currentButton) { if (lastDPadButton != null) { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(lastDPadButton)); } if (currentButton != null) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } lastDPadButton = currentButton; } } }
public static MenuBlock createMenuBlock(ButtonConfig config, Transform parent) { var menuBlock = Instantiate(Resources.Load <GameObject>("Prefabs/MenuBlock"), parent, false).GetComponent <MenuBlock>(); menuBlock.initMenuBlock(config); return(menuBlock); }
private void UpdateButton(Button button, ButtonConfig buttonConfig) { button.gameObject.SetActive(true); button.onClick.AddListener(new UnityEngine.Events.UnityAction(buttonConfig.ButtonCommand)); Text textComponent = button.GetComponentInChildren <Text>(); textComponent.text = buttonConfig.ButtonText; }
/// <summary> /// Renders an Mvc Core Bootstrap button. /// </summary> /// <param name="htmlHelper">Html helper instance.</param> /// <param name="configAction">Action that implements button configuration.</param> /// <returns>Button html markup.</returns> public static IHtmlContent MvcCoreBootstrapButton(this IHtmlHelper htmlHelper, Action <MvcCoreBootstrapButtonBuilder> configAction) { ButtonConfig config = new ButtonConfig(); configAction(new MvcCoreBootstrapButtonBuilder(config)); return(new ButtonRenderer(new ModalRenderer(), new TooltipRenderer()).Render(config)); }
public static Button ToButton(this ButtonConfig button, IEnumerable <EntityVariant>?entityVariants, EntityVariant baseEntityVariant) { return(button switch { DefaultButtonConfig defaultButton => defaultButton.ToDefaultButton(entityVariants, baseEntityVariant), CustomButtonConfig customButton => customButton.ToCustomButton(), PaneButtonConfig paneButton => paneButton.ToPaneButton(baseEntityVariant), _ => throw new InvalidOperationException() });
private void ConfigureButton(int button, ButtonConfig buttonConfig) { System.Windows.Forms.Button Button = GetButton(button); if (Button != null) { Button.Text = buttonConfig.GetText(); Button.Enabled = (Button.Text != ""); } }
public void RegisterButton(string name, ButtonConfig button) { if (Buttons.ContainsKey(name)) { Debug.LogError("Cannot have duplicate button: " + name); return; } Buttons.Add(name, button); }
/// <summary> /// 获取渲染器 /// </summary> /// <param name="context">上下文</param> protected override IRender GetRender(Context context) { var config = new ButtonConfig(context); if (config.UseButtonRender()) { return(new ButtonRender(config)); } return(new ButtonWrapperRender(config)); }
void SetButton(string buttonTag, int buttonPressCount, Sprite btnSprite) { GameObject Button = GameObject.FindGameObjectWithTag(buttonTag); ButtonConfig BtnCfg = (ButtonConfig)Button.GetComponent(typeof(ButtonConfig)); BtnCfg.pressCount = buttonPressCount; BtnCfg.pressCountTxt.text = BtnCfg.pressCount.ToString(); BtnCfg.disabled = false; Button.GetComponent <SpriteRenderer>().sprite = btnSprite; }
/// <summary> /// 获取渲染器 /// </summary> /// <param name="context">上下文</param> protected override IRender GetRender(Context context) { var config = new ButtonConfig(context); if (config.Contains(MaterialConst.MenuId)) { return(new ButtonRender(config)); } return(new ButtonWrapperRender(config)); }
public IHtmlContent Render(ButtonConfig config, bool inGroup = false) { _config = config; _button = _config.Url != null || _config.Ajax != null ? new TagBuilder("a") : new TagBuilder("button"); Element = config.Dropdown != null ? new TagBuilder("div") : _button; //_builder.AppendHtml(Element); if (config.Dropdown != null) { Element.AddCssClass(inGroup || _config.Url != null || _config.Ajax != null ? "btn-group" : "dropdown"); } else { this.BaseConfig(config, config.Dropdown != null ? "btn-group" : "btn", "btn-"); } _button.AddCssClass("btn"); if (_config.Url == null) { this.AddAttribute("type", _config.Submit ? "submit" : "button", _button); } else { _button.Attributes.Add("role", "button"); } this.AddAttribute("href", config.Url, _button); this.AddAttribute("onclick", this.AddJavascriptFuncPars(config.Click, _config.Id, false), _button); if (!string.IsNullOrEmpty(config.Text)) { _button.InnerHtml.Append(config.Text); } this.AddElement(new TagBuilder("span"), new[] { "badge badge-light" }, _config.Badge); this.AddContextualState(_button, config.State, "btn-", _config.Outline ? "outline" : null); this.SetSize(); this.AddCssClass("btn-block", _config.Block); this.AddCssClass("active", _config.Active); if (_config.Disabled) { if (_config.Url == null) { _button.Attributes.Add("disabled", "disabled"); } else { _button.AddCssClass("disabled"); } } this.AddCssClasses(config.CssClasses, _button); this.Dropdown(); this.Ajax(_button, _config.Ajax); this.TriggerModal(_button, _config.Modal); _tooltipRenderer.Render(Element, _config.Tooltip); return(Element); }
/// <summary> /// Configures a button in the group. /// </summary> /// <param name="configAction">Configuration action</param> /// <returns>The group builder instance.</returns> public MvcCoreBootstrapButtonGroupBuilder Button(Action <MvcCoreBootstrapButtonBuilder> configAction) { ButtonConfig button = new ButtonConfig(); MvcCoreBootstrapButtonBuilder builder = new MvcCoreBootstrapButtonBuilder(button); this.CheckNullPar(configAction, () => nameof(configAction)); configAction(builder); _config.Buttons.Add(button); return(this); }
// Add custom key bindings private void AddInputs() { // Add key bindings backed by a config value escapeChallenge = new ButtonConfig { Name = "EscapeChallenge", Key = (KeyCode)Config["Client config", "EscapeChallenge"].BoxedValue, HintToken = "Terminate a challenge as a loss." }; InputManager.Instance.AddButton(PluginGUID, escapeChallenge); }
/// <summary> /// Add a custom button binding via config /// </summary> /// <param name="modguid"></param> /// <param name="button"></param> public void AddButton(string modguid, ButtonConfig button) { if (Buttons.ContainsKey(button.Name + "!" + modguid)) { Logger.LogError("Cannot have duplicate button: " + button.Name); return; } button.Name += "!" + modguid; Buttons.Add(button.Name, button); }
public ButtonSetup(ButtonConfig button, EntityVariantSetup?baseEntityVariant = default, IEnumerable <EntityVariantSetup>?entityVariants = default) { var def = (button as DefaultButtonConfig)?.ButtonType.GetCustomAttribute <DefaultIconLabelAttribute>(); Label = button.Label ?? def?.Label ?? "Button"; Icon = button.Icon ?? def?.Icon ?? ""; IsPrimary = button.IsPrimary; ButtonId = button.Id ?? throw new ArgumentNullException(nameof(button.Id)); EntityVariant = baseEntityVariant; if (button is DefaultButtonConfig defaultButton) { if (defaultButton.ButtonType == DefaultButtonType.OpenPane) { throw new InvalidOperationException($"An {DefaultButtonType.OpenPane} button is not allowed to be used by DefaultButton"); } DefaultButtonType = defaultButton.ButtonType; ButtonHandlerType = typeof(DefaultButtonActionHandler); Buttons = defaultButton.ButtonType == DefaultButtonType.New && entityVariants != null ? entityVariants.ToList(variant => new ButtonSetup( new DefaultButtonConfig { ButtonType = DefaultButtonType.New, Icon = variant.Icon, Id = $"{button.Id}-{variant.Alias}", IsPrimary = button.IsPrimary, Label = string.Format(button.Label ?? variant.Name, variant.Name) }, variant)) : EmptySubButtons; } else if (button is CustomButtonConfig customButton) { CustomType = customButton.CustomType; ButtonHandlerType = customButton.ActionHandler; } else if (button is PaneButtonConfig paneButton) { DefaultButtonType = DefaultButtonType.OpenPane; DefaultCrudType = paneButton.CrudType; ButtonHandlerType = typeof(OpenPaneButtonActionHandler <>).MakeGenericType(paneButton.PaneType); } else { throw new InvalidOperationException(); } }
private void ContentCalloutButton_Clicked(object sender, System.EventArgs e) { var callout = SimpleIoc.Default.GetInstance <ICallout>(); var okButtonConfig = new ButtonConfig("I Agree", () => { Debug.WriteLine("AGREED!"); }, isEnabled: false); var cancelButtonConfig = new ButtonConfig("I Decline"); var buttonConfigs = new[] { okButtonConfig, cancelButtonConfig }; var customCallout = SimpleIoc.Default.GetInstance <ICustomCallout>(); var customCalloutContent = customCallout.GetContent(okButtonConfig); callout.Show("Content Callout", customCalloutContent, buttonConfigs); }
private void OnButtonPress(object sender, GamepadButtonEventArgs args) { ButtonConfig currentButton = GetCurrentButton(args.Button); if (currentButton != null && args.IsPressed) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } else { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } }
private void OnTriggerPress(object sender, GamepadTriggerEventArgs args) { ButtonConfig currentButton = args.Trigger == GamepadTriggers.Left ? profile.LT : profile.RT; if (args.Value > 0) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } else { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } }
public void AddButtonToolbarOperateData(ButtonConfig btnConfig, params ButtonConfig[] tbButtons) { var tbButton = TempData.ContainsKey("Temp") ? (List <ButtonConfig>)TempData[StandardTempKey.OperateData] : new List <ButtonConfig>(); tbButton.Add(btnConfig); if (tbButtons != null) { tbButton.AddRange(tbButtons); } TempData[StandardTempKey.OperateData] = tbButton; }
public object GetContent(ButtonConfig okButtonConfig) { var inflatorservice = (LayoutInflater)Android.App.Application.Context.GetSystemService(Context.LayoutInflaterService); var containerView = inflatorservice.Inflate(Resource.Layout.customcallout, null, false); var @switch = (Switch)containerView.FindViewById(Resource.Id.switch1); @switch.CheckedChange += (sender, args) => { okButtonConfig.IsEnabled = args.IsChecked; }; return(containerView); }
public object GetContent(ButtonConfig okButtonConfig) { var stackpanel = new StackPanel(); ////var label = new TextBlock(); ////label.Text = "Do you agree?"; ////stackpanel.Children.Add(label); ////var checkBox = new CheckBox(); ////checkBox.Checked += (o, args) => { okButtonConfig.IsEnabled = checkBox.IsChecked.HasValue && checkBox.IsChecked.Value; }; ////stackpanel.Children.Add(checkBox); return(null); }
// Add custom key bindings private void AddInputs() { // Add key bindings on the fly InputManager.Instance.AddButton(PluginGUID, "JotunnModExample_Menu", KeyCode.Insert); // Add key bindings backed by a config value // Create a ButtonConfig to also add it as a custom key hint in AddClonedItems evilSwordSpecial = new ButtonConfig { Name = "EvilSwordSpecialAttack", Key = (KeyCode)Config["Client config", "EvilSwordSpecialAttack"].BoxedValue, HintToken = "$evilsword_beevil" }; InputManager.Instance.AddButton(PluginGUID, evilSwordSpecial); }
public BotService( ILogger <BotService> logger, IOptionsSnapshot <ButtonConfig> buttonConfig, IOptionsSnapshot <CommandConfig> commandConfig, IOptionsSnapshot <EventLogConfig> eventLogConfig, ITelegramBotClient botClient, CacheService cacheService ) { _logger = logger; _eventLogConfig = eventLogConfig.Value; _commandConfig = commandConfig.Value; _buttonConfig = buttonConfig.Value; _botClient = botClient; _cacheService = cacheService; }
private void initMenuBlock(ButtonConfig inConfig) { config = inConfig; transform.localPosition = new Vector3(config.x, config.y, -0.4f); GameObject ga = new GameObject(); _text = ga.AddComponent <TextMeshPro>(); _text.transform.parent = transform; _text.transform.transform.localEulerAngles = new Vector3(0, 0, 0); _text.text = config.text; _text.transform.localScale = Vector3.one; _text.fontSize = 2; _text.transform.localPosition = new Vector3(0, 0, -0.3f); _text.alignment = TextAlignmentOptions.Center; }
private void ButtonText_Paint(object sender, PaintEventArgs e) { int buttonNum = Convert.ToInt32((sender as PictureBox).Name.Substring(9)); StringFormat format = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center, Trimming = StringTrimming.Character }; ButtonConfig temp = CONFIG_FILE.appButtonsConfig[buttonNum]; using (Font myFont = new Font("Arial", temp.fontSize)) { e.Graphics.DrawString(temp.buttonText, myFont, new SolidBrush(Color.FromName(temp.textColor)), new Point(CONFIG_FILE.buttonWidth / 2, CONFIG_FILE.buttonHeight / 2), format); } }
public CustomMessageBoxWindow(string caption, object content, ButtonConfig[] buttonConfigs, bool isModal = false) { this.InitializeComponent(); this.Title = caption; var stringContent = content as string; if (stringContent != null) { this.ContentControl.Content = new TextAndImage( messageBoxText: stringContent, messageBoxImage: this.GetImageSource(MessageBoxImage.None)); } else { this.ContentControl.Content = content; } this.isModal = isModal; this.DisplayButtons(buttonConfigs); }
/// <inheritdoc /> public abstract void Show(string caption, object content, ButtonConfig[] buttonConfigs, bool isFullScreen = false);
private void DisplayButtons(ButtonConfig[] buttonConfigs) { this.ButtonConfigItems.ItemsSource = buttonConfigs; }
public void Show(string caption, object content, ButtonConfig[] buttonConfigs, bool isFullScreen = false) { throw new NotImplementedInReferenceAssemblyException(); }