示例#1
0
 private void Start()
 {
     _levelName.text    = Toolbox.Instance.LevelNames[Level];
     _levelName.enabled = false;
     _namePanel.GetComponent <Image>().enabled = false;
     _state = BtnState.Unclicked;
 }
示例#2
0
    static void CommonUpdate()
    {
        // If we can't see the world, we'll draw a floor!
        if (StereoKitApp.System.displayType == Display.Opaque)
        {
            Renderer.Add(floorMesh, floorTr, Color.White);
        }

        // Skip selection window if we're in test mode
        if (Demos.TestMode)
        {
            return;
        }

        // Make a window for demo selection
        UI.WindowBegin("Demos", ref demoSelectPose, new Vec2(50 * Units.cm2m, 0));
        for (int i = 0; i < Demos.Count; i++)
        {
            string name = Demos.GetName(i);

            // No Doc demos
            if (name.StartsWith("Doc"))
            {
                continue;
            }

            // Chop off the "Demo" part of any demo name that has it
            if (name.StartsWith("Demo"))
            {
                name = name.Substring("Demo".Length);
            }

            if (UI.Button(name))
            {
                Demos.SetActive(i);
            }
            UI.SameLine();
        }
        UI.WindowEnd();

        RulerWindow();
        /// :CodeSample: Log.Subscribe Log
        /// And in your Update loop, you can draw the window.
        LogWindow();
        /// And that's it!
        /// :End:

        // Take a screenshot on the first frame both hands are gripped
        bool valid =
            Input.Hand(Handed.Left).IsTracked&&
            Input.Hand(Handed.Right).IsTracked;
        BtnState right = Input.Hand(Handed.Right).grip;
        BtnState left  = Input.Hand(Handed.Left).grip;

        if (valid && left.IsActive() && right.IsActive() && (left.IsJustActive() || right.IsJustActive()))
        {
            Renderer.Screenshot(Input.Head.position, Input.Head.Forward, 1920 * 2, 1080 * 2, "Screenshot" + screenshotId + ".jpg");
            screenshotId += 1;
        }
    }
示例#3
0
 protected void RemoveState(BtnState state)
 {
     if (IsState(state))
     {
         _state ^= state;
     }
 }
示例#4
0
        /// <summary>
        /// Like an Update-Methode but this returns if clicked
        /// </summary>
        /// <param name="mouseState">MouseState of the used Mouse</param>
        /// <returns>If Button was klicked on</returns>
        public bool Check(MouseState mouseState)
        {
            if (!visibility)
            {
                return(false);
            }
            if (mouseState.X + 16 >= position.X && mouseState.X + 16 <= (position.X + active.Width) && mouseState.Y >= position.Y && mouseState.Y <= (position.Y + active.Height))
            {
                drawToolTip = true;
                if (current != BtnState.active && current != BtnState.hover)
                {
                    return(false);
                }
                current = BtnState.hover;

                if (mouseState.LeftButton == ButtonState.Pressed && visibility)
                {
                    return(true);
                }
            }
            else
            {
                if (current == BtnState.hover)
                {
                    current = BtnState.active;
                }
                drawToolTip = false;
            }
            return(false);
        }
示例#5
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            bool clicked    = _State == BtnState.Pushed;
            bool clickedBT1 = _StateBT1 == BtnState.Pushed;
            bool clickedBT2 = _StateBT2 == BtnState.Pushed;

            if (clicked)
            {
                _Timer.Enabled = false;
                _State         = BtnState.MouseOver;
                _StateBT1      = clickedBT1 ? BtnState.MouseOver : _StateBT1; // BtnState.Normal;
                _StateBT2      = clickedBT2 || (_StateBT2 == BtnState.MouseOver) ? BtnState.MouseOver : BtnState.Normal;

                Invalidate();
            }

            EventHandler ev = _AllAsOneBt && clicked ? Click : clickedBT1 ? TxClick : clickedBT2 ? RxShortClick : null;

            if (ev != null)
            {
                ev(this, EventArgs.Empty);
            }
        }
示例#6
0
        private void CalculateBlend(BtnState st)
        {
            Color bColor = GetBackColor(st);

            if (st == BtnState.Pushed)
            {
                _Blends[(int)st].Colors = new Color[] {
                    Blend(bColor, Color.White, 80),
                    Blend(bColor, Color.White, 40),
                    Blend(bColor, Color.Black, 0),
                    Blend(bColor, Color.Black, 0),
                    Blend(bColor, Color.White, 40),
                    Blend(bColor, Color.White, 80),
                };
                _Blends[(int)st].Positions = new float[] { 0.0f, .05f, .40f, .60f, .95f, 1.0f };
            }
            else
            {
                _Blends[(int)st].Colors = new Color[] {
                    Blend(bColor, Color.White, 70),
                    Blend(bColor, Color.White, 50),
                    Blend(bColor, Color.White, 30),
                    Blend(bColor, Color.White, 00),
                    Blend(bColor, Color.Gray, 20),
                    Blend(bColor, Color.Gray, 40),
                };
                _Blends[(int)st].Positions = new float[] { 0.0f, .15f, .40f, .65f, .80f, 1.0f };
            }
        }
示例#7
0
        /// <summary>
        /// returns true if the mouse is being clicked and changes what sprite it's using
        /// </summary>
        /// <param name="ms">the current mouse state</param>
        /// <returns></returns>
        public Boolean Update(MouseState ms)
        {
            //don't worry about this it just works
            if (state != BtnState.Selected)                          //if the button is not selected
            {
                if (location.Contains(ms.Position))                  //if the button is being hovered over
                {
                    state = BtnState.Hovered;                        //change it to be hovered over
                    if (Config.SingleMouseClick(ms, prevMouseState)) //if it is being clicked on select it
                    {
                        state          = BtnState.Selected;
                        prevMouseState = ms;

                        return(true);
                    }
                }
                else
                {
                    //if it is not being hovered over draw it as it's default
                    state          = BtnState.Default;
                    prevMouseState = ms;

                    return(false);
                }
            }

            prevMouseState = ms;
            return(false);
        }
示例#8
0
        public static void DrawString(Graphics g, Rectangle rect, Color backColor, BtnState btnState,
                                      string text, Font font, ContentAlignment textAlign, Color foreColor)
        {
            if (!string.IsNullOrEmpty(text))
            {
                using (StringFormat sf = StringFormatAlignment(textAlign))
                {
                    Rectangle rr = new Rectangle(rect.X + 3, rect.Y + 6, rect.Width - 7, rect.Height - 13);

                    if (btnState == BtnState.Inactive)
                    {
                        g.DrawString(text, font, Brushes.White, new Rectangle(rr.X + 1, rr.Y + 1, rr.Width, rr.Height), sf);
                        using (Brush brush = new SolidBrush(ControlPaint.Dark(backColor)))
                        {
                            g.DrawString(text, font, brush, rr, sf);
                        }
                    }
                    else
                    {
                        if (btnState == BtnState.Pushed)
                        {
                            rr.Offset(2, 2);
                        }

                        using (Brush brush = new SolidBrush(foreColor))
                        {
                            g.DrawString(text, font, brush, rr, sf);
                        }
                    }
                }
            }
        }
示例#9
0
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            bool clicked = _State == BtnState.Pushed;

            _State = BtnState.Normal;

            if (_AllAsOneBt)
            {
                _StateBT1 = BtnState.Normal;
                _StateBT2 = BtnState.Normal;

                if (clicked)
                {
                    Invalidate();
                }
            }
            else if (_StateBT1 != BtnState.Normal && _StateBT1 != BtnState.Inactive)
            {
                _StateBT1 = BtnState.Normal;
                Invalidate(_TxBtnInfo.Rect);
            }
            else if (_StateBT2 != BtnState.Normal)
            {
                _Timer.Enabled = false;
                _StateBT2      = BtnState.Normal;
                Invalidate(_RxBtnInfo.Rect);
            }
        }
示例#10
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_BtnState != BtnState.Inactive)
            {
                base.OnMouseMove(e);

                if (_BtnState == BtnState.Pushed)
                {
                    if (!ClientRectangle.Contains(e.Location))
                    {
                        _Timer.Enabled = false;
                        base.OnMouseUp(e);

                        _BtnState = BtnState.Normal;
                        Capture   = false;

                        Invalidate();
                    }
                }
                else if (_BtnState != BtnState.MouseOver)
                {
                    _BtnState = BtnState.MouseOver;
                    Invalidate();
                }
            }
        }
示例#11
0
 public void Deselect()
 {
     if (state == BtnState.Selected)
     {
         state = BtnState.Default;
     }
 }
示例#12
0
        public void Reset(string frecuency, string alias, bool drawX, bool allAsOneBt, int rtxGroup, Image ptt, Image squelch, Image audio, Color title, Color tx, Color rx, Color txForeColor, Color rxForeColor, Color titleForeColor, bool degradedState = false)
        {
            _Frecuency    = frecuency;
            _Alias        = alias.Length > 11 ? (alias.Substring(0, 8) + "...") : alias;
            _RtxGroup     = rtxGroup;
            _PttImage     = ptt;
            _SquelchImage = squelch;

            ForeColor = titleForeColor;
            //            BackColor = titleForeColor;
            _CurrentBackColor = degradedState ? Color.OrangeRed : VisualStyle.ButtonColor;
            // El amarillo (formacion de retransmision) y rojo (para las falsas maniobras) tienen preferencia sobre el color de fondo.
            _BtnInfo.SetBackColor(BtnState.Normal, (title == VisualStyle.Colors.Yellow || title == VisualStyle.Colors.Red ||
                                                    title == HMI.Presentation.AUrr.UI.VisualStyle.Colors.DarkGreen ||
                                                    title == HMI.Presentation.AUrr.UI.VisualStyle.Colors.HeaderBlueA1) ? title : _CurrentBackColor);
            _TxBtnInfo.SetBackColor(BtnState.Normal, tx);
            _TxBtnInfo.SetForeColor(BtnState.Normal, txForeColor);
            _RxBtnInfo.SetBackColor(BtnState.Normal, rx);
            _RxBtnInfo.SetForeColor(BtnState.Normal, rxForeColor);
            _RxBtnInfo.SetImage(BtnState.Normal, audio);
            _RxBtnInfo.Text = audio == null ? "" : "";

            _DrawX = drawX;

            if (allAsOneBt != _AllAsOneBt)
            {
                _Timer.Enabled = false;
                _State         = BtnState.Normal;
                _StateBT1      = BtnState.Normal;
                _StateBT2      = BtnState.Normal;
                _AllAsOneBt    = allAsOneBt;
            }

            Invalidate();
        }
示例#13
0
        public Color GetBackColor(BtnState st)
        {
            Color backColor;

            switch (st)
            {
            case BtnState.Inactive:
                if (_BackColors[(int)st] != null)
                {
                    backColor = _BackColors[(int)st].Value;
                }
                else if ((_BackColors[(int)BtnState.Normal] != null) && (_BackColors[(int)BtnState.Normal] != VisualStyle.ButtonColor))
                {
                    backColor = _BackColors[(int)BtnState.Normal].Value;
                }
                else
                {
                    backColor = VisualStyle.ButtonColorDisabled;
                }
                //backColor = _BackColors[(int)st] ?? VisualStyle.ButtonColorDisabled;
                break;

            case BtnState.MouseOver:
            case BtnState.Pushed:
                backColor = _BackColors[(int)st] ?? GetBackColor(BtnState.Normal);
                break;

            default:
                backColor = _BackColors[(int)st] ?? VisualStyle.ButtonColor;
                break;
            }

            return(backColor);
        }
示例#14
0
        private ColorBlend GetBlend(BtnState st)
        {
            ColorBlend blend;

            switch (st)
            {
            case BtnState.Inactive:
                if ((_BackColors[(int)st] != null) || (_BackColors[(int)BtnState.Normal] == null) ||
                    (_BackColors[(int)BtnState.Normal] == VisualStyle.ButtonColor))
                {
                    blend = _Blends[(int)st];
                }
                else
                {
                    blend = _Blends[(int)BtnState.Normal];
                }
                break;

            case BtnState.MouseOver:
            case BtnState.Pushed:
                blend = _BackColors[(int)st] != null ? _Blends[(int)st] : _Blends[(int)BtnState.Normal];
                break;

            default:
                blend = _Blends[(int)st];
                break;
            }

            return(blend);
        }
示例#15
0
 /// <summary>
 /// Mouse Move Event:
 /// If CapturingMouse = true and mouse coordinates are within button region,
 /// set BtnState to Pushed, otherwise set BtnState to Normal.
 /// If CapturingMouse = false, then set BtnState to MouseOver
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (CapturingMouse)
     {
         Rectangle rect     = new Rectangle(0, 0, this.Width, this.Height);
         BtnState  oldState = btnState;
         btnState = BtnState.Normal;
         if ((e.X >= rect.Left) && (e.X <= rect.Right))
         {
             if ((e.Y >= rect.Top) && (e.Y <= rect.Bottom))
             {
                 btnState = BtnState.Pushed;
             }
         }
         this.Capture = true;
         if (btnState != oldState)
         {
             this.Invalidate();
         }
     }
     else
     {
         //if(!this.Focused)
         {
             if (btnState != BtnState.MouseOver && btnState != BtnState.Inactive)
             {
                 btnState = BtnState.MouseOver;
                 //	this.Invalidate();
             }
         }
     }
 }
示例#16
0
        public Color GetInnerBorderColor(BtnState st)
        {
            Color innerBorderColor;

            switch (st)
            {
            case BtnState.Inactive:
                innerBorderColor = _InnerBorderColors[(int)st] ?? VisualStyle.InnerBorderColorDisabled;
                break;

            case BtnState.MouseOver:
                innerBorderColor = _InnerBorderColors[(int)st] ?? VisualStyle.InnerBorderColorMouseOver;
                break;

            case BtnState.Pushed:
                innerBorderColor = _InnerBorderColors[(int)st] ?? VisualStyle.InnerBorderColorPushed;
                break;

            default:
                innerBorderColor = _InnerBorderColors[(int)st] ?? VisualStyle.InnerBorderColorNormal;
                break;
            }

            return(innerBorderColor);
        }
示例#17
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (_UpBtnInfo.Rect.Contains(e.Location))
            {
                if ((_UpBtnState != BtnState.MouseOver) && (_UpBtnState != BtnState.Pushed))
                {
                    _UpBtnState = BtnState.MouseOver;
                    Invalidate(_UpBtnInfo.Rect);
                }
            }
            else if ((_UpBtnState == BtnState.MouseOver) || (_UpBtnState == BtnState.Pushed))
            {
                _UpBtnState = BtnState.Normal;
                Invalidate(_UpBtnInfo.Rect);
            }

            if (_DownBtnInfo.Rect.Contains(e.Location))
            {
                if ((_DownBtnState != BtnState.MouseOver) && (_DownBtnState != BtnState.Pushed))
                {
                    _DownBtnState = BtnState.MouseOver;
                    Invalidate(_DownBtnInfo.Rect);
                }
            }
            else if ((_DownBtnState == BtnState.MouseOver) || (_DownBtnState == BtnState.Pushed))
            {
                _DownBtnState = BtnState.Normal;
                Invalidate(_DownBtnInfo.Rect);
            }
        }
示例#18
0
 /// <summary>
 /// Mouse Move Event:
 /// If CapturingMouse = true and mouse coordinates are within button region,
 /// set BtnState to Pushed, otherwise set BtnState to Normal.
 /// If CapturingMouse = false, then set BtnState to MouseOver
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (CapturingMouse)
     {
         System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, this.Width, this.Height);
         btnState = BtnState.Normal;
         if ((e.X >= rect.Left) && (e.X <= rect.Right))
         {
             if ((e.Y >= rect.Top) && (e.Y <= rect.Bottom))
             {
                 btnState = BtnState.Pushed;
             }
         }
         this.Capture = true;
         this.Invalidate();
     }
     else
     {
         //if(!this.Focused)
         {
             if (btnState != BtnState.MouseOver)
             {
                 btnState = BtnState.MouseOver;
                 this.Invalidate();
             }
         }
     }
 }
示例#19
0
        public void EnableTx(bool enable)
        {
            _StateBT1 = enable ? BtnState.Normal : BtnState.Inactive;
            _TxBtnInfo.SetBackColor(BtnState.Inactive, _TxBtnInfo.GetBackColor(BtnState.Inactive));
            _TxBtnInfo.SetForeColor(BtnState.Inactive, _TxBtnInfo.GetForeColor(BtnState.Inactive));

            Invalidate();
        }
示例#20
0
        public static void FireEvent(InputSource eventSource, BtnState eventTypes, Pointer pointer)
        {
            IntPtr arg = Marshal.AllocCoTaskMem(Marshal.SizeOf <Pointer>());

            Marshal.StructureToPtr(pointer, arg, false);
            NativeAPI.input_fire_event(eventSource, eventTypes, arg);
            Marshal.FreeCoTaskMem(arg);
        }
示例#21
0
 /// <summary>
 /// Mouse Down Event:
 /// set BtnState to Pushed and Capturing mouse to true
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     this.Capture        = true;
     this.CapturingMouse = true;
     btnState            = BtnState.Pushed;
     this.Invalidate();
 }
示例#22
0
 /// <summary>
 /// Lose Focus Event:
 /// set btnState to Normal
 /// </summary>
 /// <param name="e"></param>
 protected override void OnLostFocus(EventArgs e)
 {
     base.OnLostFocus(e);
     if (this.Enabled)
     {
         this.btnState = BtnState.Normal;
     }
     this.Invalidate();
 }
示例#23
0
        public void SetBackColor(BtnState st, Color color)
        {
            _BackColors[(int)st] = color;

            if (_Style != BtnStyle.Fixed3D)
            {
                CalculateBlend(st);
            }
        }
示例#24
0
    /// <summary>
    /// 누르고 있는 상태로 전환합니다.
    /// </summary>
    public void onPressButton()
    {
        if (pressImage != null)
        {
            image.sprite = pressImage;
        }

        _btnState = BtnState.PRESS;
    }
示例#25
0
 /// <summary>
 /// Mouse Up Event:
 /// Set BtnState to Normal and set CapturingMouse to false
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     btnState = BtnState.Normal;
     this.Invalidate();
     this.CapturingMouse = false;
     this.Capture        = false;
     this.Invalidate();
 }
示例#26
0
 /// <summary>
 /// Mouse Leave Event:
 /// Set BtnState to normal if we CapturingMouse = true
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     if (!CapturingMouse)
     {
         btnState = BtnState.Normal;
         this.Invalidate();
     }
 }
示例#27
0
        public void Reset(string frecuency, string alias, bool drawX, bool allAsOneBt, int rtxGroup, Image ptt, Image squelch, Image audio, Color title, Color tx, Color rx, Color txForeColor,
                          Color rxForeColor, Color titleForeColor, FrequencyState state = FrequencyState.Available)
        {
            _Frecuency    = frecuency;
            _Alias        = alias.Length > 11 ? (alias.Substring(0, 8) + "...") : alias;
            _RtxGroup     = rtxGroup;
            _PttImage     = ptt;
            _SquelchImage = squelch;

            ForeColor = titleForeColor;
//            BackColor = titleForeColor;
            if (drawX)
            {
                _CurrentBackColor = VisualStyle.ButtonColor;
            }
            else
            {
                if ((title == VisualStyle.Colors.Yellow) || (title == VisualStyle.Colors.Red))
                {
                    _CurrentBackColor = title; //error cases and rtx formation with priority over other colors
                }
                else if (state == FrequencyState.Degraded)
                {
                    _CurrentBackColor = Color.OrangeRed;
                }
                else if (state == FrequencyState.Available)
                {
                    _CurrentBackColor = VisualStyle.ButtonColor;
                }
                else //FrequencyState.NotAvailable
                {
                    _CurrentBackColor = title;
                }
            }

            _BtnInfo.SetBackColor(BtnState.Normal, _CurrentBackColor);
            _TxBtnInfo.SetBackColor(BtnState.Normal, tx);
            _TxBtnInfo.SetForeColor(BtnState.Normal, txForeColor);
            _RxBtnInfo.SetBackColor(BtnState.Normal, rx);
            _RxBtnInfo.SetForeColor(BtnState.Normal, rxForeColor);
            _RxBtnInfo.SetImage(BtnState.Normal, audio);
            _RxBtnInfo.Text = audio == null ? "Rx" : "";

            _DrawX = drawX;

            if (allAsOneBt != _AllAsOneBt)
            {
                _Timer.Enabled = false;
                _State         = BtnState.Normal;
                _StateBT1      = BtnState.Normal;
                _StateBT2      = BtnState.Normal;
                _AllAsOneBt    = allAsOneBt;
            }

            Invalidate();
        }
示例#28
0
        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            if ((_BtnState != BtnState.Inactive) && (_BtnState != BtnState.Normal))
            {
                _BtnState = BtnState.Normal;
                Invalidate();
            }
        }
示例#29
0
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            if ((_BtnState != BtnState.Normal) && (_BtnState != BtnState.Inactive))
            {
                _BtnState = BtnState.Normal;
                Invalidate();
            }
        }
示例#30
0
 /// <summary>
 /// Mouse Leave Event:
 /// Set BtnState to normal if we CapturingMouse = true
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     if (!CapturingMouse && btnState != BtnState.Inactive)
     {
         btnState = BtnState.Normal;
         this.Invalidate();
     }
     tooltip.Hide(this);
 }
示例#31
0
 public void changeState(BtnState state)
 {
     _curState = state;
     switch (_curState) {
     case BtnState.UP:
         ((SpriteRenderer)renderer).sprite = upSprite;
         break;
     case BtnState.OVER:
         ((SpriteRenderer)renderer).sprite = overSprite;
         break;
     case BtnState.DOWN:
         ((SpriteRenderer)renderer).sprite = downSprite;
         break;
     }
 }
示例#32
0
		/// <summary>
		/// Mouse Up Event:
		/// Set BtnState to Normal and set CapturingMouse to false
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseUp(MouseEventArgs e)
		{
			base.OnMouseUp (e);
			State = BtnState.Normal;
			this.Invalidate();
			this.CapturingMouse = false;
			this.Capture = false;
			this.Invalidate();
		}
示例#33
0
 /// <summary>
 /// Enable/Disable Event:
 /// If button became enabled, set BtnState to Normal
 /// else set BtnState to Inactive
 /// </summary>
 /// <param name="e"></param>
 protected override void OnEnabledChanged(EventArgs e)
 {
     base.OnEnabledChanged(e);
     if (this.Enabled)
     {
         this.btnState = BtnState.Normal;
         this.CapturingMouse = false;
         this.Capture = false;
     }
     else
     {
         this.btnState = BtnState.Inactive;
     }
     this.Invalidate();
 }
示例#34
0
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     if (!this.CapturingMouse)
     {
         if (base.Enabled)
         {
             this.btnState = BtnState.Normal;
         }
         else
         {
             this.btnState = BtnState.Inactive;
         }
         base.Invalidate();
     }
 }
示例#35
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (this.CapturingMouse)
     {
         Rectangle rectangle = new Rectangle(0, 0, base.Width, base.Height);
         this.btnState = BtnState.Normal;
         if (((e.X >= rectangle.Left) && (e.X <= rectangle.Right)) && ((e.Y >= rectangle.Top) && (e.Y <= rectangle.Bottom)))
         {
             this.btnState = BtnState.Pushed;
         }
         base.Capture = true;
         base.Invalidate();
     }
     else if (this.btnState != BtnState.MouseOver)
     {
         this.btnState = BtnState.MouseOver;
         base.Invalidate();
     }
 }
示例#36
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (base.Enabled)
     {
         this.btnState = BtnState.Normal;
     }
     else
     {
         this.btnState = BtnState.Inactive;
     }
     base.Invalidate();
     this.CapturingMouse = false;
     base.Capture = false;
     base.Invalidate();
 }
示例#37
0
        private System.Drawing.Image GetCurrentImage(BtnState btnState)
        {
            System.Drawing.Image imageNormal = this.ImageNormal;
            switch (btnState)
            {
                case BtnState.Inactive:
                    if (this.ImageInactive == null)
                    {
                        if (imageNormal != null)
                        {
                            this.ImageInactive = this.ConvertToGrayscale(new Bitmap(this.ImageNormal));
                        }
                        return this.ImageNormal;
                    }
                    return this.ImageInactive;

                case BtnState.Normal:
                    if (this.Focused && (this.ImageFocused != null))
                    {
                        imageNormal = this.ImageFocused;
                    }
                    return imageNormal;

                case BtnState.MouseOver:
                    if (this.ImageMouseOver != null)
                    {
                        imageNormal = this.ImageMouseOver;
                    }
                    return imageNormal;

                case BtnState.Pushed:
                    if (this.ImagePressed != null)
                    {
                        imageNormal = this.ImagePressed;
                    }
                    return imageNormal;
            }
            return imageNormal;
        }
示例#38
0
 // Use this for initialization
 void Start()
 {
     _curState = BtnState.UP;
 }
示例#39
0
    // Use this for initialization
    void Start()
    {
        bclose = false;
        btnstate = BtnState.none;
        /*stream = new SerialPort(COMPort, 58400);
        stream.Open();
        stream.ReadTimeout = 1;
        //stream.ReadTimeout = 10;*/
        /*try
        {
            stream.Open(); //Open the Serial Stream.
            stream.DataReceived += DataReceivedHandler;
            stream.ErrorReceived += DataErrorReceivedHandler;
        }
        catch (Exception e) {
            Debug.Log("Could not open serial port: " + e.Message);
        }*/

        myThread = new Thread(new ThreadStart(GetArduino));
        myThread.Start();
        DontDestroyOnLoad(gameObject);
        byell = false;
    }
示例#40
0
    // Update is called once per frame
    void Update()
    {
        /*if (ftemp < fupdatetime) {
            ftemp+=Time.deltaTime;
        }
        else{
            nothread();
            ftemp = 0;
        }*/
        //nothread();
        if (fx_axis >= 600f && fy_axis >= 600f)
            btnstate = BtnState.UR;
        else if (fx_axis >= 600f && fy_axis <= 400f)
            btnstate = BtnState.UL;
        else if (fx_axis <= 400f && fy_axis <= 400f)
            btnstate = BtnState.DL;
        else if (fx_axis <= 400f && fy_axis >= 600f)
            btnstate = BtnState.DR;
        else if (fx_axis >= 600f)
            btnstate = BtnState.up;
        else if (fx_axis <= 400f && fx_axis != 0)
            btnstate = BtnState.down;
        else if (fy_axis >= 600f)
            btnstate = BtnState.right;
        else if (fy_axis <= 400f)
            btnstate = BtnState.left;
        else
            btnstate = BtnState.none;
        //判斷聲音

        if (fsound >= ftempsound+4f)
            byell = true;
        else
            byell = false;

        if (fbtn == 1)
            bclick = true;
        else
            bclick = false;
        //Debug.Log(fsound+" "+ftempsound);
    }
示例#41
0
 /// <summary>
 /// Mouse Move Event:
 /// If CapturingMouse = true and mouse coordinates are within button region, 
 /// set BtnState to Pushed, otherwise set BtnState to Normal.
 /// If CapturingMouse = false, then set BtnState to MouseOver
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (CapturingMouse)
     {
         Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
         BtnState oldState = btnState;
         btnState = BtnState.Normal;
         if ((e.X >= rect.Left) && (e.X <= rect.Right))
         {
             if ((e.Y >= rect.Top) && (e.Y <= rect.Bottom))
             {
                 btnState = BtnState.Pushed;
             }
         }
         this.Capture = true;
         if (btnState != oldState)
             this.Invalidate();
     }
     else
     {
         //if(!this.Focused)
         {
             if (btnState != BtnState.MouseOver && btnState != BtnState.Inactive)
             {
                 btnState = BtnState.MouseOver;
                 //	this.Invalidate();
             }
         }
     }
 }
        /// <summary>
        /// This method paints the button in its entirety.
        /// </summary>
        /// <param name="e">paint arguments use to paint the button</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if(!this.Enabled)
                btnState = BtnState.Inactive;

            CreateRegion(0);
            paint_Background(e);
            paint_Text(e);
            paint_Image(e);
            paint_Border(e);
            paint_InnerBorder(e);
            paint_FocusBorder(e);
        }
示例#43
0
 public void setState(BtnState state)
 {
     State = state;
 }
示例#44
0
		/// <summary>
		/// Mouse Move Event:
		/// If CapturingMouse = true and mouse coordinates are within button region,
		/// set BtnState to Pushed, otherwise set BtnState to Normal.
		/// If CapturingMouse = false, then set BtnState to MouseOver
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove (e);
			if(CapturingMouse)
			{
				System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0,0,this.Width,this.Height);
				State = BtnState.Normal;
				if( (e.X >= rect.Left) && (e.X <= rect.Right) )
				{
					if( (e.Y >= rect.Top) && (e.Y <= rect.Bottom) )
					{
						State = BtnState.Pushed;
					}
				}
				this.Capture = true;
				this.Invalidate();
			}
			else
			{
				//if(!this.Focused)
				{
					if(State != BtnState.MouseOver)
					{
						State = BtnState.MouseOver;
						this.Invalidate();
					}
				}
			}
		}
示例#45
0
		/// <summary>
		/// Lose Focus Event:
		/// set btnState to Normal
		/// </summary>
		/// <param name="e"></param>
		protected override void OnLostFocus(EventArgs e)
		{
			base.OnLostFocus (e);
			if(this.Enabled)
			{
				this.State = BtnState.Normal;
			}
			this.Invalidate();
		}
示例#46
0
		/// <summary>
		/// Mouse Down Event:
		/// set BtnState to Pushed and Capturing mouse to true
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown (e);
			this.Capture = true;
			this.CapturingMouse = true;
			State = BtnState.Pushed;
			this.Invalidate();
		}
示例#47
0
 /// <summary>
 /// Mouse Leave Event:
 /// Set BtnState to normal if we CapturingMouse = true
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     if (!CapturingMouse && btnState != BtnState.Inactive)
     {
         btnState = BtnState.Normal;
         this.Invalidate();
     }
     tooltip.Hide(this);
 }
示例#48
0
		/// <summary>
		/// Mouse Leave Event:
		/// Set BtnState to normal if we CapturingMouse = true
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseLeave(EventArgs e)
		{
			base.OnMouseLeave (e);
			if(!CapturingMouse)
			{
				State = BtnState.Normal;
				this.Invalidate();
			}
		}
示例#49
0
 public void setActive()
 {
     State = BtnState.Active;
 }
示例#50
0
		/// <summary>
		/// Enable/Disable Event:
		/// If button became enabled, set BtnState to Normal
		/// else set BtnState to Inactive
		/// </summary>
		/// <param name="e"></param>
		protected override void OnEnabledChanged(EventArgs e)
		{
			base.OnEnabledChanged (e);
			if(this.Enabled)
			{
				this.State = BtnState.Normal;
			}
			else
			{
				this.State = BtnState.Inactive;
			}
			this.Invalidate();
		}
示例#51
0
 public void setNormal()
 {
     State = BtnState.Normal;
 }
示例#52
0
		/// <summary>
		/// This method is used to retrieve the image used by the button for the given state.
		/// </summary>
		/// <param name="btnState">holds the state of the button</param>
		/// <returns>returns the button Image</returns>
		private System.Drawing.Image GetCurrentImage(BtnState btnState)
		{
			System.Drawing.Image image = ImageNormal;
			switch(btnState)
			{
				case BtnState.Normal:
					if(this.Focused)
					{
						if(this.ImageFocused != null)
							image = this.ImageFocused;
					}
					if (!this.Enabled && ImageInactive != null)
						image = ImageInactive;
					break;
				case BtnState.MouseOver:
					if(ImageMouseOver != null)
						image = ImageMouseOver;
					break;
				case BtnState.Pushed:
					if(ImagePressed != null)
						image = ImagePressed;
					break;
				case BtnState.Inactive:
					if(ImageInactive != null)
						image = ImageInactive;
					else
					{
						if(image != null)
						{
							using(var tempNormalImage = new Bitmap(ImageNormal))
							{
								ImageInactive = ConvertToGrayscale(tempNormalImage);
							}
						}
						image = ImageNormal;
					}
					break;
			}
			return(image);
		}
示例#53
0
 public void setOver()
 {
     State = BtnState.Over;
 }