コード例 #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
ファイル: ImageButton.cs プロジェクト: lulzzz/infonetpos_ui
 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
ファイル: ImageButton.cs プロジェクト: lulzzz/infonetpos_ui
 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);
        }
コード例 #8
0
 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
ファイル: ImageButton.cs プロジェクト: yukiyuki/MyToolkit
        public ImageButton()
        {
            DefaultStyleKey = typeof(ImageButton);

            State = ImageButtonState.Normal;

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

            //Tapped += OnTapped; 
        }
コード例 #11
0
ファイル: ImageButton.cs プロジェクト: lulzzz/infonetpos_ui
        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
ファイル: ImageButton.cs プロジェクト: lulzzz/infonetpos_ui
 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
ファイル: ImageButton.cs プロジェクト: yukiyuki/MyToolkit
 private void SetStandardContent()
 {
     State = ImageButtonState.Normal;
     content.Content = Content;
 }
コード例 #27
0
ファイル: ImageButton.cs プロジェクト: yukiyuki/MyToolkit
 private void SetOverContent()
 {
     State = ImageButtonState.Over;
     if (OverContent != null)
         content.Content = OverContent;
 }
コード例 #28
0
ファイル: ImageButton.cs プロジェクト: yukiyuki/MyToolkit
 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);
        }