示例#1
0
        /// <summary>
        /// 사용자 컨트롤 마우스 DOWN시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.isClicked)
                {
                    return;
                }

                this.isClicked = true;

                this.buttonState = ImageButtonState.Pressed;

                if (this.buttonStyle != ImageButtonStyle.Flat)
                {
                    this.glowAlpha = 255;
                }

                this.fadeInTimer.Stop();

                this.fadeOutTimer.Stop();

                Invalidate();
            }
        }
示例#2
0
 private void SetPressedContent()
 {
     State = ImageButtonState.Pressed;
     if (PressedContent != null)
     {
         content.Content = PressedContent;
     }
 }
示例#3
0
        /// <summary>
        /// 사용자 컨트롤 마우스 진입시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_MouseEnter(object sender, EventArgs e)
        {
            this.buttonState = ImageButtonState.Hover;

            this.fadeOutTimer.Stop();

            this.fadeInTimer.Start();
        }
示例#4
0
 private void SetOverContent()
 {
     State = ImageButtonState.Over;
     if (OverContent != null)
     {
         content.Content = OverContent;
     }
 }
示例#5
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!Enabled)
                return;

            state = ImageButtonState.Active;
            Invalidate();
            base.OnMouseDown(e);
        }
示例#6
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         State = lastState;
         Invalidate();
     }
 }
示例#7
0
        protected ImageButtonStateTest()
        {
            _button       = new Button();
            _enableImage  = new Image();
            _disableImage = new Image();

            var genericType = typeof(T);

            _imageButtonState = (ImageButtonState)Activator.CreateInstance(genericType, _button, _enableImage, _disableImage);
        }
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         lastState = State;
         State = ImageButtonState.Click;
         Invalidate();
     }
 }
示例#9
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         lastState = State;
         State     = ImageButtonState.Click;
         Invalidate();
     }
 }
示例#10
0
        public ImageButton()
        {
            DefaultStyleKey = typeof(ImageButton);

            State = ImageButtonState.Normal;

            PointerPressed += OnPointerPressed;
            PointerReleased += OnPointerReleased;
            PointerExited += OnPointerExited;
            PointerEntered += OnPointerEntered;

            //Tapped += OnTapped; 
        }
示例#11
0
        public ImageButton()
        {
            DefaultStyleKey = typeof(ImageButton);

            State = ImageButtonState.Normal;

            PointerPressed  += OnPointerPressed;
            PointerReleased += OnPointerReleased;
            PointerExited   += OnPointerExited;
            PointerEntered  += OnPointerEntered;

            //Tapped += OnTapped;
        }
示例#12
0
        /// <summary>
        /// 사용자 컨트롤 마우스 이탈시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_MouseLeave(object sender, EventArgs e)
        {
            this.buttonState = ImageButtonState.None;

            if (this.buttonStyle == ImageButtonStyle.Flat)
            {
                this.glowAlpha = 0;
            }

            this.fadeInTimer.Stop();

            this.fadeOutTimer.Start();

            this.isClicked = false;
        }
示例#13
0
 /// <summary>
 /// Reset the button state to its original value and
 /// update the graphical view of the button appropriately
 /// </summary>
 public void resetToOriginalState()
 {
     lock (this.mutexObj)
     {
         this.buttonState = this.originalButtonState;
         if (this.buttonState == ImageButtonState.DISABLED)
         {
             this.buttonControl.Enabled = false;
         }
         else
         {
             this.buttonControl.Enabled = true;
             if (this.buttonState == ImageButtonState.DEPRESSED)
             {
                 this.buttonState = ImageButtonState.NORMAL;
             }
         }
         this.updateButton();
     }
 }
示例#14
0
        /// <summary>
        /// 사용자 컨트롤 마우스 UP시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.buttonState = ImageButtonState.Hover;

                this.fadeInTimer.Stop();

                this.fadeOutTimer.Stop();

                Invalidate();

                if (this.calledByKey == true)
                {
                    OnClick(EventArgs.Empty);

                    this.calledByKey = false;
                }

                this.isClicked = false;
            }
        }
示例#15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="btnCtrl">Button control</param>
 /// <param name="btnName">Button name context contained within the resource</param>
 /// <param name="startDisabled">Whether or not the button should be disabled</param>
 public ImageButtonController(DesktopSession desktopSession, Button btnCtrl, string btnName, bool startDisabled)
 {
     this.DesktopSession = desktopSession;
     this.initialized    = false;
     this.mutexObj       = null;
     if (btnCtrl == null || string.IsNullOrEmpty(btnName))
     {
         return;
     }
     this.mutexObj = new object();
     lock (this.mutexObj)
     {
         this.buttonControl = btnCtrl;
         this.buttonName    = btnName;
         this.buttonState   = (startDisabled) ? ImageButtonState.DISABLED : ImageButtonState.NORMAL;
         if (this.buttonState == ImageButtonState.DISABLED)
         {
             this.buttonControl.Enabled = false;
         }
         this.initialized         = true;
         this.originalButtonState = this.buttonState;
         this.updateButton();
     }
 }
示例#16
0
 protected override void OnMouseLeave(EventArgs e)
 {
     State = ImageButtonState.Default;
     base.OnMouseLeave(e);
     Invalidate();
 }
示例#17
0
 protected override void OnMouseEnter(EventArgs e)
 {
     State = ImageButtonState.Hover;
     base.OnMouseEnter(e);
     Invalidate();
 }
示例#18
0
 public ImageButton()
 {
     State = ImageButtonState.Default;
 }
示例#19
0
 protected override void OnMouseLeave(EventArgs e)
 {
     State = ImageButtonState.Default;
     base.OnMouseLeave(e);
     Invalidate();
 }
示例#20
0
 protected override void OnMouseEnter(EventArgs e)
 {
     State = ImageButtonState.Hover;
     base.OnMouseEnter(e);
     Invalidate();
 }
示例#21
0
 public StateImageButton()
 {
     State = ImageButtonState.Default;
 }
示例#22
0
 private object GetMemberValue(ImageButtonState imageButtonState, string name)
 {
     return(typeof(ImageButtonState).GetField(name, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(imageButtonState));
 }
示例#23
0
        protected override void OnMouseEnter(EventArgs e)
        {
            if (!Enabled)
                return;

            state = ImageButtonState.Hover;
            Invalidate();
            base.OnMouseEnter(e);
        }
示例#24
0
 private void SetStandardContent()
 {
     State           = ImageButtonState.Normal;
     content.Content = Content;
 }
示例#25
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         State = lastState;
         Invalidate();
     }
 }
示例#26
0
 private void SetStandardContent()
 {
     State = ImageButtonState.Normal;
     content.Content = Content;
 }
示例#27
0
 private void SetOverContent()
 {
     State = ImageButtonState.Over;
     if (OverContent != null)
         content.Content = OverContent;
 }
示例#28
0
 private void SetPressedContent()
 {
     State = ImageButtonState.Pressed;
     if (PressedContent != null)
         content.Content = PressedContent;
 }
示例#29
0
        protected Button GetButton(ImageButtonState imageButtonState)
        {
            var member = GetMemberValue(imageButtonState, "_button") as Button;

            return(member);
        }
示例#30
0
        protected Image GetDisableImage(ImageButtonState imageButtonState)
        {
            var member = GetMemberValue(imageButtonState, "_disabledImage") as Image;

            return(member);
        }
示例#31
0
        /// <summary>
        /// Compute the new button state based on the input action and the
        /// current button state
        /// </summary>
        /// <param name="action">Action to perform against the current button state</param>
        public void performAction(ImageButtonAction action)
        {
            if (!this.initialized || this.buttonState == ImageButtonState.DISABLED)
            {
                return;
            }

            //Lock the class as the asynchronous nature of the UI could
            //and will cause data race conditions otherwise
            lock (this.mutexObj)
            {
                //Perform the button state change based on previous button state
                //and the input button action
                switch (this.buttonState)
                {
                //Apply the action against the NORMAL button state
                case ImageButtonState.NORMAL:
                    if (action == ImageButtonAction.CLICK)
                    {
                        this.buttonState = ImageButtonState.DEPRESSED;
                    }
                    else if (action == ImageButtonAction.ENTER)
                    {
                        this.buttonState = ImageButtonState.HOVER;
                    }
                    else if (action == ImageButtonAction.HOVER)
                    {
                        this.buttonState = ImageButtonState.HOVER;
                    }
                    else if (action == ImageButtonAction.LEAVE)
                    {
                        this.buttonState = ImageButtonState.NORMAL;
                    }
                    break;

                //Apply the action against the HOVER button state
                case ImageButtonState.HOVER:
                    if (action == ImageButtonAction.CLICK)
                    {
                        this.buttonState = ImageButtonState.DEPRESSED;
                    }
                    else if (action == ImageButtonAction.ENTER)
                    {
                        this.buttonState = ImageButtonState.HOVER;
                    }
                    else if (action == ImageButtonAction.HOVER)
                    {
                        this.buttonState = ImageButtonState.HOVER;
                    }
                    else if (action == ImageButtonAction.LEAVE)
                    {
                        this.buttonState = ImageButtonState.NORMAL;
                    }
                    break;

                //Apply the action against the DEPRESSED button state
                case ImageButtonState.DEPRESSED:
                    if (action == ImageButtonAction.CLICK)
                    {
                        this.buttonState = ImageButtonState.HOVER;
                    }
                    else if (action == ImageButtonAction.ENTER)
                    {
                        this.buttonState = ImageButtonState.DEPRESSED;
                    }
                    else if (action == ImageButtonAction.HOVER)
                    {
                        this.buttonState = ImageButtonState.DEPRESSED;
                    }
                    else if (action == ImageButtonAction.LEAVE)
                    {
                        this.buttonState = ImageButtonState.DEPRESSED;
                    }
                    break;

                default:
                    break;
                }

                //Update button
                this.updateButton();
            }// End lock
        }
示例#32
0
        protected override void OnMouseLeave(EventArgs e)
        {
            if (!Enabled)
                return;

            state = ImageButtonState.Normal;
            Invalidate();
            base.OnMouseLeave(e);
        }