public String ButtonLabelForType (ButtonType type)
		{
			switch (type) {
			case ButtonType.Free:
				return "Free()";

			case ButtonType.Release:
				return "[Release]";

			case ButtonType.AutoRelease:
				return "[AutoRelease]";

			case ButtonType.DeAlloc:
				return "[DeAlloc]";

			case ButtonType.GC:
				return "Garbage Collection";

			case ButtonType.ARC:
				return "ARC!";
			default:
				break;

			}
			return null;
		}
Exemplo n.º 2
0
 public void SetButton(ButtonType btn, bool value)
 {
     if( value )
         buttons = buttons | btn; // set on
     else
         buttons = buttons & ~btn; // set off
 }
 public static void TypeButtonPressed(object sender, ButtonType button)
 {
     if (TypeButtonChanged != null)
     {
         TypeButtonChanged(sender, new TypeButtonEventArgs(button));
     }
 }
Exemplo n.º 4
0
    private void SendDownEvent( ButtonType button )
    {
        //Debug.Log( "Button: " + button );

        if( OnButtonDown != null )
            OnButtonDown( button );
    }
Exemplo n.º 5
0
 public ButtonCell(ButtonCell bc)
     : base(bc)
 {
     this.m_bColor = SystemColors.ControlDark;
     this.m_pForeColor = SystemColors.HighlightText;
     this.m_pBgColor = SystemColors.ControlDark;
     this.m_pBorderColor = SystemColors.ControlDarkDark;
     this.m_text = "";
     this.m_DetachImageList = new EventHandler(this.OnDetachImageList);
     this.m_buttonStyle = bc.m_buttonStyle;
     this.m_font = new Font(bc.m_font.Name, bc.m_font.Size, bc.m_font.Style);
     this.m_text = bc.m_text;
     this.m_textAlignment = bc.m_textAlignment;
     this.m_textPosition = bc.m_textPosition;
     this.m_imageAlignment = bc.m_imageAlignment;
     this.m_imagePosition = bc.m_imagePosition;
     this.m_autoResizeImage = bc.m_autoResizeImage;
     this.m_ia = new ImageAttributes();
     this.m_bColor = bc.m_bColor;
     this.m_pBgColor = bc.m_pBgColor;
     this.m_pBorderColor = bc.m_pBorderColor;
     this.m_pForeColor = bc.m_pForeColor;
     this.m_transparentColor = bc.m_transparentColor;
     this.m_bAutoTransparent = bc.m_bAutoTransparent;
     this.m_touchMargin = bc.m_touchMargin;
     this.m_bPressed = bc.m_bPressed;
     this.m_defaultImage = bc.m_defaultImage;
     this.m_defaultImageVGA = bc.m_defaultImageVGA;
     this.m_pressedImage = bc.m_pressedImage;
     this.m_pressedImageVGA = bc.m_pressedImageVGA;
     base.Selectable = bc.Selectable;
 }
Exemplo n.º 6
0
		public ButtonCell()
		{
			title = "Button";
			buttonType = ButtonType.MomentaryLight;
			bezelStyle = BezelStyle.Rounded;
			buttonState = ButtonState.Unchecked;
		}
		public static IDataControlButton CreateButton (ButtonType type, Control container, string text, string image, string command, string commandArg, bool allowCallback)
		{
			IDataControlButton btn;

			switch (type) {
			case ButtonType.Link:
				btn = new DataControlLinkButton ();
				break;
			case ButtonType.Image:
				btn = new DataControlImageButton ();
				btn.ImageUrl = image;
				break;
			default:
				btn = new DataControlButton ();
				break;
			}

			btn.Container = container;
			btn.CommandName = command;
			btn.CommandArgument = commandArg;
			btn.Text = text;
			btn.CausesValidation = false;
			btn.AllowCallback = allowCallback;

			return btn;
		}
Exemplo n.º 8
0
    private void OnButtonClick(ButtonType type)
    {
        string account = accountInput.text;
		string password = passwordInput.text;
		Debug.Log("---"+account+"---" + password);
        if(account.Equals(""))
        {
            ShowErrorMsg("账号不能为空");
            return;
        }
		if (password.Equals("")) 
		{
			ShowErrorMsg ("密码不能为空");
			return;
		}

        if(type == ButtonType.LOGIN)
        {
			AccountController.Instance.SendLoginRequest(account, password);
        }
        else if(type == ButtonType.REGIST)
        {
			AccountController.Instance.SendRegistRequest(account, password);
        }
    }
Exemplo n.º 9
0
 void OnClick()
 {
     switch (type)
     {
         case ButtonType.Play:
             GameDirector.gameInstance.ResetGame();
             break;
         case ButtonType.Credits:
             break;
         case ButtonType.Pause:
             GameDirector.gameInstance.PauseGame();
             GUIManager.guiInstance.ShowGamePausedPanel();
     //                type = ButtonType.Resume;
             break;
         case ButtonType.Resume:
             GameDirector.gameInstance.ResumeGame();
             GUIManager.guiInstance.ShowInGamePanel();
     //                type = ButtonType.Pause;
             break;
         case ButtonType.Share:
             FacebookManager.facebookInstance.PostOnFacebook();
             type = ButtonType.Share;
             break;
         case ButtonType.GoHome:
             GUIManager.guiInstance.ShowStartPanel();
             break;
         case ButtonType.Leaderboard:
             GUIManager.guiInstance.ShowLeaderboardPanel();
             break;
     }
 }
Exemplo n.º 10
0
    public bool GetButtonDown(ButtonType buttonType)
    {
        if( currentState.GetButton(buttonType) && !lastState.GetButton(buttonType))
            return true;

        return false;
    }
Exemplo n.º 11
0
    public bool GetButtonUp(ButtonType buttonType)
    {
        if( !currentState.GetButton(buttonType) && lastState.GetButton(buttonType))
            return true;

        return false;
    }
    public TypeButton(ButtonType type, Rect menuArea)
    {
        m_ButtonType = type;

        CalculateSize (menuArea);

        //Create Style

        if (m_ButtonType == ButtonType.Building){

            m_ButtonStyle = GUIStyles.CreateTypeButtonStyleB();
            Debug.Log (m_ButtonType);
        }

        if (m_ButtonType == ButtonType.Ship){

            m_ButtonStyle = GUIStyles.CreateTypeButtonStyleSh();
            Debug.Log (m_ButtonType);

        }

        if (m_ButtonType == ButtonType.Science){

            m_ButtonStyle = GUIStyles.CreateTypeButtonStyleSc();
            Debug.Log (m_ButtonType);
        }

        //Attach to events
        GUIEvents.TypeButtonChanged += ButtonPressedEvent;
    }
Exemplo n.º 13
0
 public MessageForm(string info,string title,ButtonType buttonType)
 {
     this.info=info;
     this.title=title;
     this.buttonType=buttonType;
     InitializeComponent();
     this.BackgroundImage=new Bitmap(GetType(),"images.message.jpg");
 }
Exemplo n.º 14
0
 /// <summary>
 /// 根据按钮类型实例化按钮
 /// </summary>
 public ControlButton(ButtonType buttonType)
 {
     this.Type = buttonType;
     StateLast = ButtonState.Released;
     StateNow = ButtonState.Released;
     //将按钮添加到按钮列表
     buttonList.Add(this);
 }
    public override void OnButtonClick(ButtonType button)
    {
        if( ButtonType.ButtonWinGame == button )
            gameManager.NewGameState(gameManager.stateGameWon);

        if( ButtonType.ButtonLoseGame == button )
            gameManager.NewGameState(gameManager.stateGameLost);
    }
Exemplo n.º 16
0
 public string GetButton(ButtonType buttonType)
 {
     foreach(ButtonMapping mapping in buttonMappings)
     {
         if( mapping.target == buttonType )
             return mapping.button;
     }
     return "";
 }
Exemplo n.º 17
0
	/*
		Constructor must specify both Controller and Button Type
	*/
	public Button(ControlType control,ButtonType button) {
		_controlType = control;
		_buttonType = button;
		_virtualName = "joystick";
		if (_controlType != ControlType.Any) {
			_virtualName += " " + ((int)(_controlType));	
		}
		_virtualName += " button " + ((int)(_buttonType));
	}
Exemplo n.º 18
0
 // ajouter un bouton dans le panel
 public void AddButton(ButtonType type)
 {
     string name = type.Value;
     GameObject btn = Resources.Load("Prefabs/OptionButton/" + name) as GameObject;
     if (btn != null)
         instanciateButton(btn);
     else
         Debug.LogError("Prefab : \"Prefabs/OptionButton/" + name + "\" introuvable");
 }
Exemplo n.º 19
0
        public Button(ButtonType buttonType, Vector2 position)
        {
            if (buttonType == ButtonType.SHOOT)
                sources = shootSources;
            else if (buttonType == ButtonType.BOMB)
                sources = bombSources;

            this.Position = position;
        }
Exemplo n.º 20
0
        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            string name = null,
            string value = null,
            ButtonType? type = null,
            Disabled? disabled = null,
            string id = null,
            string @class = null,
            string style = null,
            string title = null,
            LangCode lang = null,
            string xmllang = null,
            Dir? dir = null,
            string onclick = null,
            string ondblclick = null,
            string onmousedown = null,
            string onmouseup = null,
            string onmouseover = null,
            string onmousemove = null,
            string onmouseout = null,
            string onkeypress = null,
            string onkeydown = null,
            string onkeyup = null,
            char? accesskey = null,
            int? tabindex = null,
            string onfocus = null,
            string onblur = null
        )
        {
            Name = name;
            Value = value;
            Type = type;
            Disabled = disabled;
            Id = id;
            Class = @class;
            Style = style;
            Title = title;
            Lang = lang;
            XmlLang = xmllang;
            Dir = dir;
            OnClick = onclick;
            OnDblClick = ondblclick;
            OnMouseDown = onmousedown;
            OnMouseUp = onmouseup;
            OnMouseOver = onmouseover;
            OnMouseMove = onmousemove;
            OnMouseOut = onmouseout;
            OnKeyPress = onkeypress;
            OnKeyDown = onkeydown;
            OnKeyUp = onkeyup;
            AccessKey = accesskey;
            TabIndex = tabindex;
            OnFocus = onfocus;
            OnBlur = onblur;

            return this;
        }
        /// <summary>
        /// Bootstraps the button.
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="id">The id.</param>
        /// <param name="text">The text.</param>
        /// <param name="buttonType">Type of the button.</param>
        /// <param name="buttonSize">Size of the button.</param>
        /// <param name="disabled">if set to <c>true</c> [disabled].</param>
        /// <param name="icon">The icon.</param>
        /// <param name="inverted">if set to <c>true</c> [icon is inverted].</param>
        /// <param name="isSubmit">if set to <c>true</c> [is submit].</param>
        /// <returns>
        /// An MvcHtmlString
        /// </returns>
        public static MvcHtmlString BootstrapButton(this HtmlHelper htmlHelper, string id, string text, ButtonType buttonType = ButtonType.@default, ButtonSize buttonSize = ButtonSize.@default, bool disabled = false, Icon icon = Icon.@default, bool inverted = false, bool isSubmit = false)
        {
            var tag = new TagBuilder("button");
            if (isSubmit)
            {
                tag.Attributes.Add("type", "submit");
            }

            return ButtonBuilder(htmlHelper, id, text, string.Empty, tag, buttonType, buttonSize, disabled, icon, inverted);
        }
Exemplo n.º 22
0
 public Button(ButtonType buttonType, Id id, Vector2 position)
 {
     this.ButtonType = buttonType;
     this.Id = id;
     this.Position = position;
     if (this.ButtonType != mtg_lifecounter.ButtonType.Menu)
         this.Rotation = Id == mtg_lifecounter.Id.One ? FPI / 2 : 3 * FPI / 2;
     else
         this.Rotation = 0;
 }
 /// <summary>
 /// Creates a Zurb Foundation button
 /// </summary>
 /// <param name="html">The current HtmlHelper instance</param>
 /// <param name="value">The button text</param>
 /// <param name="id">The button id</param>
 /// <param name="type"> The type of button to create </param>
 /// <param name="size"> The button size </param>
 /// <param name="color">The button color</param>
 /// <param name="style">The button style</param>
 /// <param name="cssClass">Any additional css classes</param>
 public static MvcHtmlString ZurbButton(this HtmlHelper html, string value, string id, ButtonType type, ZurbSize size, ZurbColor color, ButtonStyle style, string cssClass)
 {
     return new MvcHtmlString(String.Format("<input type=\"{0}\" value=\"{1}\" class=\"{2} {3} {4} {5} button\" id=\"{6}\" />",
                               type.GetStringValue(),
                               value,
                               size.GetStringValue(),
                               color.GetStringValue(),
                               style.GetStringValue(),
                               cssClass,
                               id));
 }
Exemplo n.º 24
0
        public Button(Puzzle owner)
            : base(owner)
        {
            defaultRight = Direction.X;

            Type = TypeName;
            deletable = true;
            Wall = Direction.NegZ;
            ButtonType = ButtonType.Standard;

            ConnectionSender = new ConnectionLogicSender(this);
        }
        /// <summary>
        /// Get button of following type.
        /// </summary>
        /// <param name="btnType">The button type you want to get</param>
        /// <returns>The button or null if no button was found</returns>
        public Button GetButton(ButtonType btnType)
        {
            for (int i = 0; i < _buttons.Count; ++i)
            {
                if (_buttons[i].btnType == btnType)
                {
                    return _buttons[i];
                }
            }

            return null;
        }
Exemplo n.º 26
0
		public override void Wrap (object obj, bool initialized)
		{
			base.Wrap (obj, initialized);
			Gtk.ToolButton toolbutton = (Gtk.ToolButton)Wrapped;

			if (toolbutton.StockId != null) {
				stockId = toolbutton.StockId;
				type = ButtonType.StockItem;
			} else {
				type = ButtonType.TextAndIcon;
			}
		}
Exemplo n.º 27
0
        internal static MenuButton CreateKeyMenu(ButtonType buttonType, string name, string key)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, "name", null);
            TkDebug.AssertArgumentNullOrEmpty(key, "key", null);

            MenuButton menu = new MenuButton
            {
                Type = buttonType,
                Name = name,
                Key = key
            };
            return menu;
        }
Exemplo n.º 28
0
		public virtual void SetButtonType (ButtonType type) {
			switch (type) {
			case ButtonType.Normal:
				Button.Style = null;
				break;

			case ButtonType.DropDown:
				Button.Style = (Style) ButtonResources ["NormalDropDown"];
				break;
			}

			Button.InvalidateMeasure ();
		}
Exemplo n.º 29
0
        private void Initialize(ButtonType buttonType, string iconFilePath, string buttonTitle, string buttonColour, string brushMouseEnterHexCode, string brushMouseLeaveHexCode, string brushMouseDownHexCode, string brushMouseUpHexCode)
        {
            BrushConverter bc = new BrushConverter();
            _brushMouseEnter = (Brush)bc.ConvertFromString(brushMouseEnterHexCode);
            _brushMouseLeave = (Brush)bc.ConvertFromString(brushMouseLeaveHexCode);
            _brushMouseDown = (Brush)bc.ConvertFromString(brushMouseDownHexCode);
            _brushMouseUp = brushMouseUpHexCode == null ? Brushes.Transparent : (Brush)bc.ConvertFromString(brushMouseUpHexCode);

            TextBlockTitle.Background = (Brush)bc.ConvertFromString(buttonColour);
            TextBlockTitle.Text = buttonTitle;
            ImageIcon.Source = PlusPlayTools.ImageEditing.GenerateImage_FileStream(iconFilePath);

            _buttonType = buttonType;
        }
Exemplo n.º 30
0
		public override void SetButtonType (ButtonType type)
		{
			switch (type) {
			case ButtonType.Normal:
				DropDownButton.Style = null;
				break;

			case ButtonType.DropDown:
				DropDownButton.Style = (Style) ButtonResources["MenuDropDown"];
				break;
			}

			DropDownButton.InvalidateMeasure();
		}
Exemplo n.º 31
0
 public static string GetClassForButtonType(ButtonType buttonType)
 {
     return(_htmlButtonType[buttonType]);
 }
Exemplo n.º 32
0
        public static MvcHtmlString Button(this HtmlHelper helper, string id = "", string cssClass = "", ButtonType type = ButtonType.button, string text = "")
        {
            //TagBuilder metotlarla daha pratik ve efektif kod yazmamıza imkan sağlar.
            TagBuilder tag = new TagBuilder("button");

            tag.AddCssClass(cssClass);
            tag.GenerateId(id);
            tag.Attributes.Add(new KeyValuePair <string, string>("type", type.ToString()));
            tag.Attributes.Add(new KeyValuePair <string, string>("name", id));
            tag.SetInnerText(text);
            return(MvcHtmlString.Create(tag.ToString()));
        }
Exemplo n.º 33
0
 private void ButtonPressed(ButtonType button, float value)
 {
     keyPressedText.text = string.Format("{0} was pressed", button.ToString());
 }
Exemplo n.º 34
0
        // Buttons

        public static ComponentBuilder <TConfig, InputButton> InputButton <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string value = null, string label = null, ButtonType buttonType = ButtonType.Button)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <InputButton>
        {
            return(new ComponentBuilder <TConfig, InputButton>(helper.Config, new InputButton(helper, buttonType))
                   .SetValue(value)
                   .SetControlLabel(label));
        }
Exemplo n.º 35
0
 public static ComponentBuilder <TConfig, FormButton> FormButton <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string text = null, string label = null, object value = null, ButtonType buttonType = ButtonType.Button)
     where TConfig : BootstrapConfig
     where TComponent : Component, ICanCreate <FormButton>
 {
     return(new ComponentBuilder <TConfig, FormButton>(helper.Config, new FormButton(helper, buttonType))
            .SetText(text)
            .SetControlLabel(label)
            .SetValue(value));
 }
Exemplo n.º 36
0
 public IWriter2 <Button, AnyContent> Button(ButtonType type, params object[] contents)
 {
     return(Context.CreateWriter <Button, AnyContent>().Type(type).Content(contents));
 }
Exemplo n.º 37
0
        public void SetButtonType(ButtonType type)
        {
            Button b = (Button)Frontend;

            SetContent(b.Label, WidgetRegistry.GetBackend(b.Image), b.ImagePosition);
        }
Exemplo n.º 38
0
 /// <summary>
 /// Create ButtonItem
 /// </summary>
 /// <param name="label"></param>
 /// <param name="type"></param>
 public Item(string label, ButtonType type)
 {
     buttonType = type;
     this.label = label;
     this.type  = ItemType.Button;
 }
Exemplo n.º 39
0
    private void Update()
    {
        time += Time.deltaTime;

        Input.simulateMouseWithTouches = true;

        if (Input.GetMouseButtonDown(0))
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out RaycastHit hit))
            {
                if (hit.transform.CompareTag("Selectable"))
                {
                    Flame.Play();
                }
            }
        }


        if (time >= 0.85f && Clicked != ButtonType.Completed)
        {
            switch (Clicked)
            {
            case ButtonType.Copper:
                SetFlame(new Color(0, 1, 0, 1));

                goto default;

            case ButtonType.Ba:
                SetFlame(new Color(1, 1, 0, 1));

                goto default;

            case ButtonType.Pottasium:
                SetFlame(new Color(1f, 0f, 0.399f, 1));

                goto default;

            case ButtonType.Na:

                SetFlame(
                    new Color(1f, 0.9559f, 0f, 1),
                    new Gradient
                {
                    colorKeys = new GradientColorKey[]
                    {
                        new GradientColorKey(new Color(0, 0.1769555f, 0.7169812f), 0f),
                        new GradientColorKey(new Color(0.5471698f, 0f, 0.08362977f), 0.412f)
                    },
                    alphaKeys = new GradientAlphaKey[]
                    {
                        new GradientAlphaKey(1.0f, 0.0f),
                        new GradientAlphaKey(1.0f, 0.0f)
                    }
                });

                goto default;

            default:
                Clicked = ButtonType.Completed;
                break;
            }
        }
    }
    internal void OnButtonInteraction(ButtonType type, bool down)
    {
        switch (type)
        {
        case ButtonType.CIRCLE:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.CIRCLE].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.CIRCLE].upValue, false);
            }
            break;

        case ButtonType.CROSS:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.CROSS].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.CROSS].upValue, false);
            }
            break;

        case ButtonType.TRIANGLE:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.TRIANGLE].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.TRIANGLE].upValue, false);
            }
            break;

        case ButtonType.SQUARE:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.SQUARE].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.SQUARE].upValue, false);
            }
            break;

        case ButtonType.LEFT:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.LEFT].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.LEFT].upValue, false);
            }
            break;

        case ButtonType.RIGHT:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.RIGHT].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.RIGHT].upValue, false);
            }
            break;

        case ButtonType.TOP:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.TOP].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.TOP].upValue, false);
            }
            break;

        case ButtonType.DOWN:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.DOWN].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.DOWN].upValue, false);
            }
            break;

        case ButtonType.L1:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.L1].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.L1].upValue, false);
            }
            break;

        case ButtonType.R1:
            if (down)
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.R1].downValue, true);
            }
            else
            {
                SendCharacter(fragReference.controllerValues.btnValues[(int)ButtonType.R1].upValue, false);
            }
            break;
        }
    }
Exemplo n.º 41
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="x">X</param>
 /// <param name="y">Y</param>
 /// <param name="angle">回転角</param>
 /// <param name="time">時間</param>
 /// <param name="buttontype">ボタンタイプ</param>
 /// <param name="id">ID</param>
 public MarkData(float x, float y, float angle, float time, ButtonType buttontype, uint id)
     : base(x, y, angle, time, buttontype, id)
 {
 }
Exemplo n.º 42
0
        public async static Task <IHtmlContent> ButtonAsync(this IHtmlHelper htmlHelper, string id, string value, string cssClass, ButtonType buttonType)
        {
            try
            {
                var buttonModel = new ButtonModel()
                {
                    Id           = id,
                    Value        = value,
                    CssClassName = cssClass,
                    Type         = buttonType
                };

                return(await htmlHelper.PartialAsync("~/Views/Shared/_Button.PartialView.cshtml", buttonModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 43
0
    private void HandleButton(ButtonType buttonType, PointerEventData.FramePressState buttonState, CustomEventData eventData, bool allowDragging)
    {
        GameObject currentOverGo = activeGameObject;

        // PointerDown notification
        if (buttonState == PointerEventData.FramePressState.Pressed || buttonState == PointerEventData.FramePressState.PressedAndReleased)
        {
            eventData.eligibleForClick    = true;
            eventData.delta               = Vector2.zero;
            eventData.dragging            = false;
            eventData.useDragThreshold    = true;
            eventData.pressPosition       = eventData.position;
            eventData.pointerPressRaycast = eventData.pointerCurrentRaycast;

            DeselectIfSelectionChanged(currentOverGo, eventData);

            // search for the control that will receive the press
            // if we can't find a press handler set the press
            // handler to be what would receive a click.
            var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.pointerDownHandler);

            // didnt find a press handler... search for a click handler
            if (newPressed == null)
            {
                newPressed = ExecuteEvents.GetEventHandler <IPointerClickHandler>(currentOverGo);
            }

            // Debug.Log("Pressed: " + newPressed);

            float time = Time.unscaledTime;

            if (newPressed == eventData.lastPress)
            {
                var diffTime = time - eventData.clickTime;
                if (diffTime < 0.3f)
                {
                    ++eventData.clickCount;
                }
                else
                {
                    eventData.clickCount = 1;
                }

                eventData.clickTime = time;
            }
            else
            {
                eventData.clickCount = 1;
            }

            eventData.pointerPress    = newPressed;
            eventData.rawPointerPress = currentOverGo;

            eventData.clickTime = time;

            // Save the drag handler as well
            eventData.pointerDrag = ExecuteEvents.GetEventHandler <IDragHandler>(currentOverGo);

            if (eventData.pointerDrag != null)
            {
                ExecuteEvents.Execute(eventData.pointerDrag, eventData, ExecuteEvents.initializePotentialDrag);
            }
        }

        // PointerUp notification
        if (buttonState == PointerEventData.FramePressState.Released || buttonState == PointerEventData.FramePressState.PressedAndReleased)
        {
            // Debug.Log("Executing pressup on: " + pointer.pointerPress);
            ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerUpHandler);

            // Debug.Log("KeyCode: " + pointer.eventData.keyCode);

            // see if we mouse up on the same element that we clicked on...
            var pointerUpHandler = ExecuteEvents.GetEventHandler <IPointerClickHandler>(currentOverGo);

            // PointerClick and Drop events
            if (eventData.pointerPress == pointerUpHandler && eventData.eligibleForClick)
            {
                ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerClickHandler);
            }
            else if (eventData.pointerDrag != null && eventData.dragging)
            {
                ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
            }

            eventData.eligibleForClick = false;
            eventData.pointerPress     = null;
            eventData.rawPointerPress  = null;

            if (eventData.pointerDrag != null && eventData.dragging)
            {
                ExecuteEvents.Execute(eventData.pointerDrag, eventData, ExecuteEvents.endDragHandler);
            }

            eventData.dragging    = false;
            eventData.pointerDrag = null;

            // redo pointer enter / exit to refresh state
            // so that if we moused over somethign that ignored it before
            // due to having pressed on something else
            // it now gets it.
            if (currentOverGo != eventData.pointerEnter)
            {
                HandlePointerExitAndEnter(eventData, null);
                HandlePointerExitAndEnter(eventData, currentOverGo);
            }
        }
    }
Exemplo n.º 44
0
 protected abstract Image GetActionButtonImage(ButtonType buttonType);
Exemplo n.º 45
0
 public IWriter2 <Button, AnyContent> Button(ButtonType type, IconType iconType, object content)
 {
     return(Context.CreateWriter <Button, AnyContent>().Type(type).Content(Context.CreateWriter <Icon>().Type(iconType), content));
 }
Exemplo n.º 46
0
 public static IWriter2 <T, AnyContent> Type <T>(this IWriter2 <T, AnyContent> target, ButtonType value) where T : Button
 {
     target.Item.TypeValue = value;
     return(target);
 }
Exemplo n.º 47
0
 public ButtonData(ButtonType eType, string sPath, string sLabel)
 {
     _eType  = eType;
     _sPath  = sPath;
     _sLabel = sLabel;
 }
Exemplo n.º 48
0
 public static IWriter2 <Button, AnyContent> Button(this IAnyContentMarker contentHelper, ButtonType type, object content)
 {
     return(contentHelper.Context.CreateWriter <Button, AnyContent>().Type(type).Content(content));
 }
Exemplo n.º 49
0
 public static MvcHtmlString SubmitButton(this AjaxHelper ajaxHelper, ButtonType buttonType = ButtonType.Image, ButtonIcon buttonIcon = ButtonIcon.Ok)
 {
     return(SubmitButton(ajaxHelper, buttonType, "", buttonIcon));
 }
Exemplo n.º 50
0
 public Button(int id, Color4 backgroundColor, Color4 highlightBackgroundColor) : base(id)
 {
     Type = ButtonType.ColoredBackground;
     AddAppearenceColored(backgroundColor, highlightBackgroundColor);
 }
Exemplo n.º 51
0
 public Button(int id, string backgroundImagePath, string highlightBackgroundImagePath) : base(id)
 {
     Type = ButtonType.Image;
     AddAppearenceImage(backgroundImagePath, highlightBackgroundImagePath);
 }
Exemplo n.º 52
0
 public TypeButtonEventArgs(ButtonType button)
 {
     ButtonClicked = button;
 }
Exemplo n.º 53
0
 public static MvcHtmlString Button(this HtmlHelper helper, ButtonType type, string value, object attributes)
 {
     return(Button(helper, type.ToString(), value, attributes));
 }
Exemplo n.º 54
0
 public override int GetPressingFrame(ButtonType buttonType)
 {
     return(pressingFrame);
 }
Exemplo n.º 55
0
 private RenderFragment CreateButtonRenderer(DialogOption option, string text, MessageBoxResult result, ButtonType type)
 {
     return(builder =>
     {
         builder.OpenComponent <BButton>(0);
         builder.AddAttribute(1, "Click", new Func <MouseEventArgs, Task>((MouseEventArgs e) =>
         {
             return option.Instance.CloseDialogAsync(option, new DialogResult()
             {
                 Result = result
             });
         }));
         builder.AddAttribute(2, "Type", type);
         builder.AddAttribute(3, "ChildContent", new RenderFragment(__builder2 => __builder2.AddMarkupContent(4, text)));
         builder.AddAttribute(4, "Size", ButtonSize.Small);
         builder.CloseComponent();
     });
 }
Exemplo n.º 56
0
 public override bool IsPressed(ButtonType buttonType)
 {
     return(this.buttonType == buttonType && isPressed);
 }
Exemplo n.º 57
0
        public static MvcHtmlString Button(this HtmlHelper helper, string id, ButtonType type, string text)
        {
            string html = string.Format("<button id='{0}' name='{0}' type='{1}'>{2}</button>", id, type.ToString(), text);

            return(MvcHtmlString.Create(html));
        }
Exemplo n.º 58
0
 public bool WasButtonPressed(int playerIndex, ButtonType button)
 {
     return(gamePadHandler.WasButtonPressed(playerIndex, button));
 }
Exemplo n.º 59
0
 public Button(string text = "", ButtonType buttonType = ButtonType.Button) : this(text, BootTheme.Default, buttonType)
 {
 }
Exemplo n.º 60
0
    public KeyCode GetKeyFromButtonType(ButtonType b)
    {
        switch (b)
        {
        case ButtonType.A:
            return(KeyCode.A);

        case ButtonType.C:
            return(KeyCode.C);

        case ButtonType.D:
            return(KeyCode.D);

        case ButtonType.E:
            return(KeyCode.E);

        case ButtonType.F:
            return(KeyCode.F);

        case ButtonType.LeftControl:
            return(KeyCode.LeftControl);

        case ButtonType.LeftShift:
            return(KeyCode.LeftShift);

        case ButtonType.Q:
            return(KeyCode.Q);

        case ButtonType.R:
            return(KeyCode.R);

        case ButtonType.S:
            return(KeyCode.S);

        case ButtonType.RightControl:
            return(KeyCode.RightControl);

        case ButtonType.RightShift:
            return(KeyCode.RightShift);

        case ButtonType.SpaceBar:
            return(KeyCode.Space);

        case ButtonType.V:
            return(KeyCode.V);

        case ButtonType.W:
            return(KeyCode.W);

        case ButtonType.X:
            return(KeyCode.X);

        case ButtonType.Z:
            return(KeyCode.Z);

        case ButtonType.None:
            return(KeyCode.Joystick5Button13);    // uhhh needed a key that is super unlikely to be pressed
        }

        return(KeyCode.Asterisk);
    }