Example #1
0
 /// <summary>
 /// Occurs on a styles or mouse down event.
 /// </summary>
 public virtual void OnDown(PointEventArgs e)
 {
     if (enabled)
     {
         IsDown = true;
     }
 }
Example #2
0
 public override void OnMove(PointEventArgs p)
 {
     if (downControl != null)
     {
         downControl.OnMove(this.TranslatePoint(downControl, p));
     }
 }
Example #3
0
        private int IndexFromPoint(PointEventArgs e)
        {
            int index = 0;

            if (Text.Length > 0)
            {
                using (Graphics g = CreateGraphics())
                {
                    if (g != null)
                    {
                        Rectangle r = ClientRectangle;
                        r.Inflate(ScaleX(-3), 0);
                        int left = r.Left;
                        int x    = e.X;
                        for (int i = 1; i <= Text.Length; i++)
                        {
                            string s = Text.Substring(0, i);
                            int    w = (int)g.MeasureString(s, Font).Width;
                            if ((w + left) >= x)
                            {
                                break;
                            }
                            index++;
                        }
                    }
                }
            }
            index = EnsureStartSel(index);
            return(index);
        }
Example #4
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     //PointEventArgs e = new PointEventArgs(p.Gesture, p.X - c.Bounds.X, p.Y - c.Bounds.Y);
     return(p);
 }
Example #5
0
 public override void OnMove(PointEventArgs e)
 {
     if (!gestureCanceled && Enabled)
     {
         IsDown = ClientRectangle.Contains(e.X, e.Y);
     }
 }
Example #6
0
 public override void OnRelease(PointEventArgs p)
 {
     base.OnRelease(p);
     if (downControl != null)
     {
         downControl.OnRelease(TranslatePoint(downControl, p));
     }
 }
Example #7
0
 public override void OnUp(PointEventArgs p)
 {
     if (downControl != null)
     {
         downControl.OnUp(TranslatePoint(downControl, p));
     }
     downControl = null;
 }
Example #8
0
 public override bool OnClick(PointEventArgs p)
 {
     base.OnClick(p);
     if (downControl != null)
     {
         downControl.OnClick(TranslatePoint(downControl, p));
     }
     return(true);
 }
Example #9
0
 /// <summary>
 /// Occurs on a styles or mouse up event.
 /// </summary>
 public virtual void OnUp(PointEventArgs e)
 {
     canClick = IsDown;
     IsDown   = false;
     //if (Parent == null)
     //{
     //    if (isDown && !clicked) OnClick(e);
     //}
 }
Example #10
0
 /// <summary>
 /// Occurs when the control is clicked.
 /// </summary>
 public virtual bool OnClick(PointEventArgs e)
 {
     if (canClick && enabled)
     {
         if (ClientRectangle.Contains(e.X, e.Y))
         {
             IsDown = false;
             PerformClick();
         }
     }
     return(false);
 }
Example #11
0
 /// <summary>
 /// Scroll the container with finger, stylus or mouse.
 /// </summary>
 /// <param name="pressed">The position when the container was first touched.</param>
 /// <param name="moving">The position while moving.</param>
 protected virtual void Scroll(PointEventArgs pressed, Point moving)
 {
     if (CanShowScrollbar)
     {
         StopFadeTimer();
         ShowScrollBar = true;
         int deltaY = (int)((moving.Y - pressed.Y));
         int deltaX = (int)((moving.X - pressed.X));
         lastDeltaY = downTop - deltaY - TopOffset;
         int vt = downTop - (int)(deltaY / ScaleFactor.Height);
         SetTopOffset(vt);
     }
 }
Example #12
0
 public override bool OnClick(PointEventArgs p)
 {
     if (!Enabled)
     {
         return(false);
     }
     if (downControl != null)
     {
         return(downControl.OnClick(TranslatePoint(downControl, p)));
     }
     base.OnClick(p);
     return(false);
 }
Example #13
0
        public override void OnUp(PointEventArgs e)
        {
            base.OnUp(e);

            int tickDelta = Environment.TickCount - lastTick;

            IsMoving = false;

            EnsureValidPosition();
            if (IsDown)
            {
                OnClick(touchdPosition);
            }
            IsDown = false;
        }
Example #14
0
        public override void OnDown(PointEventArgs e)
        {
            base.OnDown(e);
            int index = IndexFromPoint(e);

            downIndex = index;
            if (index == startSel)
            {
                Select(0, Text.Length);
            }
            else
            {
                Select(index, 0);
            }
        }
Example #15
0
        public override void OnMove(PointEventArgs e)
        {
            base.OnMove(e);
            int index = IndexFromPoint(e);

            if (index != downIndex)
            {
                int idx0     = Math.Min(index, downIndex);
                int idx1     = Math.Max(index, downIndex);
                int selCount = idx1 - idx0;
                int startSel = idx0;
                if (this.selCount != selCount || this.startSel != startSel)
                {
                    Select(startSel, selCount);
                }
            }
        }
Example #16
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (control == null)
            {
                return;
            }
            lastTick    = startTick = Environment.TickCount;
            lastGesture = Gesture.None;
            Point p = new Point(e.X, e.Y);

            startPoint = lastGesturePoint = p;
            PointEventArgs pe = TranslatePoint(p.X, p.Y);

            IsDown = true;
            control.OnDown(pe);
            IsDown = false;
            keyInputHelperControl.Focus();
        }
Example #17
0
        public override void OnMove(PointEventArgs e)
        {
            SizeF factor = ScaleFactor;
            int   deltaY = e.Y - touchdPosition.Y;
            int   deltaX = e.X - touchdPosition.X;

            lastDeltaX = deltaX;
            lastTick   = Environment.TickCount;
            int threshold = (int)(ScrollContainer.MinMovePixelDistance * factor.Height);

            if ((isMoving || Math.Abs(deltaY) >= threshold) && CanScroll)
            {
                if (!isMoving)
                {
                    touchdPosition = e;
                }
                IsMoving = true;
                Scroll(touchdPosition, new Point(e.X, e.Y));
            }
        }
Example #18
0
        public override void OnDown(PointEventArgs p)
        {
            base.OnDown(p);
            FluidControl control = ControlFromPoint(p.X, p.Y);

            downControl = control;
            if (control != null)
            {
                PointEventArgs p2 = TranslatePoint(control, p);
                control.OnDown(p2);
            }
            if (control != null && control.Selectable)
            {
                selectedControl = control;
            }
            else if (control == null)
            {
                selectedControl = null;
            }
        }
Example #19
0
        public override void OnDown(PointEventArgs e)
        {
            ///stop the count down to hide the scrollbar, but do not necassarily show the scrollbar:
            StopFadeTimer();

            touchdPosition.X = e.X;
            touchdPosition.Y = e.Y;
            if (enableScroll)
            {
                pressedGesture = Gesture.None;
                bool isAutoScrolling = IsAutoScrolling;
                StopAutoScroll();
                lastDeltaY = 0;
                lastDeltaX = 0;
                lastTick   = Environment.TickCount;
                downTop    = TopOffset;

                CanScroll = true;
                IsMoving  = false;
                IsDown    = !isAutoScrolling;
            }
        }
Example #20
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (control == null)
            {
                return;
            }
            int            duration = Environment.TickCount - lastTick;
            PointEventArgs p        = TranslatePoint(e.X, e.Y);

            control.OnUp(p);
            // note that p might change it's value, therefore it is set again:
            p = TranslatePoint(e.X, e.Y);
            bool gestured = PerformUpGesture(e);

            if (!gestured)
            {
                if (duration < ClickThreshold)
                {
                    control.OnClick(p);
                }
            }
        }
Example #21
0
        public override void OnDown(PointEventArgs p)
        {
            if (!Enabled)
            {
                return;
            }
            base.OnDown(p);
            FluidControl control = ControlFromPoint(p.X, p.Y);

            if (control != null && !control.Active)
            {
                control = null;
            }
            downControl     = control;
            selectedControl = control;
            if (control != null)
            {
                PointEventArgs pointEventArgs = TranslatePoint(control, p);
                if (control.Active)
                {
                    control.OnDown(pointEventArgs);
                }
            }
        }
Example #22
0
 public override void OnRelease(PointEventArgs p)
 {
     base.OnRelease(p);
     if (downControl != null) downControl.OnRelease(this.TranslatePoint(downControl, p));
 }
Example #23
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     //PointEventArgs e = new PointEventArgs(p.Gesture, p.X - c.Bounds.X, p.Y - c.Bounds.Y);
     return p;
 }
Example #24
0
 public override void OnMove(PointEventArgs e)
 {
     if (!gestureCanceled && Enabled) IsDown = ClientRectangle.Contains(e.X, e.Y);
 }
Example #25
0
        public override void OnDown(PointEventArgs e)
        {
            canClick = !this.IsAutoScrolling;
            base.OnDown(e);
            if (!canClick) return;

            templateIndex = -1;
            downPoint.X = e.X;
            downPoint.Y = e.Y;

            int index = GetItemIndexUnderDisplayY(e.Y);
            if (index >= 0) OnTemplateEvent(index, e, TemplateEvent.Down);

            int selectedItemIndex = SelectedItemIndex;
            if (JogSelect)
            {
                selectedItemIndex = CheckJogSelect(e);
            }

            if (pressed) SelectedItemIndex = selectedItemIndex;
            else
            {
                int hoverIndex = index;

                if (hoverIndex == selectedItemIndex) Pressed = true; else HoveredItemIndex = hoverIndex;
            }
            downIndex = hoveredItemIndex;
            if (ItemSelect == SelectMode.Down && hoveredItemIndex >= 0) SelectedItemIndex = hoveredItemIndex;
        }
Example #26
0
 /// <summary>
 /// Occurs on stylus, mouse or finger move events.
 /// </summary>
 public virtual void OnMove(PointEventArgs e)
 {
 }
Example #27
0
 /// <summary>
 /// Occurs when the control is released to be in down mode but the mouse, style or finger still presses on the display.
 /// </summary>
 /// <param name="e"></param>
 public virtual void OnRelease(PointEventArgs e)
 {
     IsDown = false;
 }
Example #28
0
 public override void OnMove(PointEventArgs p)
 {
     if (downControl != null) downControl.OnMove(this.TranslatePoint(downControl, p));
 }
Example #29
0
 /// <summary>
 /// Occurs on stylus, mouse or finger move events.
 /// </summary>
 public virtual void OnMove(PointEventArgs e)
 {
 }
Example #30
0
 private PointEventArgs TranslatePoint(FluidTemplate c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     return p;
 }
Example #31
0
        public override void OnMove(PointEventArgs e)
        {
            base.OnMove(e);
            int index = IndexFromPoint(e);

            if (index != downIndex)
            {
                int idx0 = Math.Min(index, downIndex);
                int idx1 = Math.Max(index, downIndex);
                int selCount = idx1 - idx0;
                int startSel = idx0;
                if (this.selCount != selCount || this.startSel != startSel)
                {
                    Select(startSel, selCount);
                }
            }
        }
Example #32
0
        public override void OnUp(PointEventArgs e)
        {
            ScrollBarVisible = false;
            base.OnUp(e);
            if (templateIndex >= 0) OnTemplateEvent(templateIndex, e, TemplateEvent.Up);

            Pressed = false;
            HoveredItemIndex = -1;
        }
Example #33
0
        public override void OnRelease(PointEventArgs p)
        {
            if (templateIndex >= 0) OnTemplateEvent(templateIndex, p, TemplateEvent.Release);

            Pressed = false;
            HoveredItemIndex = -1;
        }
Example #34
0
 public override void OnMove(PointEventArgs e)
 {
     base.OnMove(e);
     if (templateIndex >= 0) OnTemplateEvent(templateIndex, e, TemplateEvent.Move);
 }
Example #35
0
        private int CheckJogSelect(PointEventArgs e)
        {
            const int fuzzyHeight = 18;
            int index = SelectedItemIndex;

            if (CanShowScrollbar)
            {
                if (index >= 0)
                {
                    Rectangle itemBounds = GetItemBounds(index);
                    int fuzzy = (int)(Math.Max(fuzzyHeight, itemHeight / 2) * ScaleFactor.Height);
                    int y = e.Y - fuzzy;
                    Rectangle pressedArea = new Rectangle(itemBounds.Left, y, itemBounds.Width, 2 * fuzzy);
                    Pressed = pressedArea.IntersectsWith(itemBounds);
                    if (Pressed)
                    {
                        index = GetItemIndexUnderDisplayY(e.Y);
                        if (index >= 0) SelectedItemIndex = index;
                    }
                }
                else Pressed = false;
            }
            else
            {
                index = GetItemIndexUnderDisplayY(e.Y);
                if (index >= 0) SelectedItemIndex = index;
                Pressed = true;
            }
            return index;
        }
Example #36
0
 /// <summary>
 /// Scroll the container with finger, stylus or mouse.
 /// </summary>
 /// <param name="pressed">The position when the container was first touched.</param>
 /// <param name="moving">The position while moving.</param>
 protected virtual void Scroll(PointEventArgs pressed, Point moving)
 {
     if (CanShowScrollbar)
     {
         StopFadeTimer();
         ShowScrollBar = true;
         int deltaY = (int)((moving.Y - pressed.Y));
         int deltaX = (int)((moving.X - pressed.X));
         lastDeltaY = downTop - deltaY - TopOffset;
         int vt = downTop - (int)(deltaY / ScaleFactor.Height);
         SetTopOffset(vt);
     }
 }
Example #37
0
 public override bool OnClick(PointEventArgs p)
 {
     base.OnClick(p);
     return(true);
 }
Example #38
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     return(p);
 }
Example #39
0
 /// <summary>
 /// Occurs when the control is released to be in down mode but the mouse, style or finger still presses on the display.
 /// </summary>
 /// <param name="e"></param>
 public virtual void OnRelease(PointEventArgs e)
 {
     IsDown = false;
 }
Example #40
0
        public override void OnUp(PointEventArgs e)
        {
            base.OnUp(e);

            int tickDelta = Environment.TickCount - lastTick;
            IsMoving = false;

            EnsureValidPosition();
            if (IsDown)
            {
                OnClick(touchdPosition);
            }
            IsDown = false;
        }
Example #41
0
 /// <summary>
 /// Occurs on a styles or mouse down event.
 /// </summary>
 public virtual void OnDown(PointEventArgs e)
 {
     if (enabled) IsDown = true;
 }
Example #42
0
 /// <summary>
 /// Occurs when the control is clicked.
 /// </summary>
 public virtual bool OnClick(PointEventArgs e)
 {
     if (canClick && enabled)
     {
         if (ClientRectangle.Contains(e.X, e.Y))
         {
             IsDown = false;
             PerformClick();
         }
     }
     return false;
 }
Example #43
0
 public override void OnDown(PointEventArgs p)
 {
     base.OnDown(p);
     Invalidate();
 }
Example #44
0
 public override bool OnClick(PointEventArgs p)
 {
     base.OnClick(p);
     if (downControl != null) downControl.OnClick(TranslatePoint(downControl, p));
     return true;
 }
Example #45
0
 public override bool OnClick(PointEventArgs e)
 {
     base.OnClick(e);
     return true;
 }
Example #46
0
        /// <summary>
        /// Occurs on a touch panel click.
        /// </summary>
        /// <param name="mousePosition"></param>
        public override bool OnClick(PointEventArgs p)
        {
            if (!canClick || !CanClick) return false;
            if (templateIndex >= 0)
            {
                if (OnTemplateEvent(templateIndex, p, TemplateEvent.Click)) return true;
            }

            bool result = false;
            //if (ItemSelect == SelectMode.Up)
            {
                if (downIndex >= 0) SelectedItemIndex = downIndex;
                bool criteria = !JogSelect;
                if (!criteria) criteria = Pressed && selectedItemIndex >= 0;
                if (criteria && SelectedItemIndex >= 0) OnItemClick(SelectedItemIndex);
                result = true;
            }
            base.OnClick(p);
            return result;
        }
Example #47
0
        public override void OnMove(PointEventArgs e)
        {
            SizeF factor = ScaleFactor;
            int deltaY = e.Y - touchdPosition.Y;
            int deltaX = e.X - touchdPosition.X;

            lastDeltaX = deltaX;
            lastTick = Environment.TickCount;
            int threshold = (int)(ScrollContainer.MinMovePixelDistance * factor.Height);

            if ((isMoving || Math.Abs(deltaY) >= threshold) && CanScroll)
            {
                if (!isMoving) touchdPosition = e;
                IsMoving = true;
                Scroll(touchdPosition, new Point(e.X, e.Y));
            }
        }
Example #48
0
        public override void OnDown(PointEventArgs e)
        {
            ///stop the count down to hide the scrollbar, but do not necassarily show the scrollbar:
            StopFadeTimer();

            touchdPosition.X = e.X;
            touchdPosition.Y = e.Y;
            if (enableScroll)
            {
                pressedGesture = Gesture.None;
                bool isAutoScrolling = IsAutoScrolling;
                StopAutoScroll();
                lastDeltaY = 0;
                lastDeltaX = 0;
                lastTick = Environment.TickCount;
                downTop = TopOffset;

                CanScroll = true;
                IsMoving = false;
                IsDown = !isAutoScrolling;
            }
        }
Example #49
0
 public override void OnDown(PointEventArgs p)
 {
     base.OnDown(p);
     FluidControl control = ControlFromPoint(p.X, p.Y);
     downControl = control;
     if (control != null)
     {
         PointEventArgs p2 = TranslatePoint(control, p);
         control.OnDown(p2);
     }
     if (control != null && control.Selectable)
     {
         selectedControl = control;
     }
     else if (control == null)
     {
         selectedControl = null;
     }
 }
Example #50
0
 public override void OnDown(PointEventArgs p)
 {
     base.OnDown(p);
     Invalidate();
 }
Example #51
0
 public override void OnUp(PointEventArgs p)
 {
     if (downControl != null) downControl.OnUp(TranslatePoint(downControl, p));
     downControl = null;
 }
Example #52
0
 /// <summary>
 /// Occurs on a styles or mouse up event.
 /// </summary>
 public virtual void OnUp(PointEventArgs e)
 {
     canClick = IsDown;
     IsDown = false;
     //if (Parent == null)
     //{
     //    if (isDown && !clicked) OnClick(e);
     //}
 }
Example #53
0
 public override void OnDown(PointEventArgs e)
 {
     base.OnDown(e);
     int index = IndexFromPoint(e);
     downIndex = index;
     if (index == startSel)
     {
         Select(0, Text.Length);
     }
     else
     {
         Select(index, 0);
     }
 }
Example #54
0
 protected override void Scroll(PointEventArgs p, Point moving)
 {
     //LeaveNestedControl(); <-- not necassary!
     if (pressed && JogSelect)
     {
         SelectInMove(moving);
     }
     else
     {
         base.Scroll(p, moving);
     }
 }
Example #55
0
 private int IndexFromPoint(PointEventArgs e)
 {
     int index = 0;
     if (Text.Length > 0)
     {
         using (Graphics g = CreateGraphics())
         {
             if (g != null)
             {
                 Rectangle r = ClientRectangle;
                 r.Inflate(ScaleX(-3), 0);
                 int left = r.Left;
                 int x = e.X;
                 for (int i = 1; i <= Text.Length; i++)
                 {
                     string s = Text.Substring(0, i);
                     int w = (int)g.MeasureString(s, Font).Width;
                     if ((w + left) >= x) break;
                     index++;
                 }
             }
         }
     }
     index = EnsureStartSel(index);
     return index;
 }
Example #56
0
 public override void OnDown(PointEventArgs p)
 {
     if (!Enabled) return;
     base.OnDown(p);
     FluidControl control = ControlFromPoint(p.X, p.Y);
     if (control != null && !control.Active) control = null;
     downControl = control;
     selectedControl = control;
     if (control != null)
     {
         PointEventArgs pointEventArgs = TranslatePoint(control, p);
         if (control.Active) control.OnDown(pointEventArgs);
     }
 }