Example #1
0
        private void ComponentMouseDownHandler(Event e)
        {
            Debug.Log(string.Format("ComponentMouseDownHandler [{0}, {1}]", e.Phase, e.CurrentTarget));

            if (!Enabled)
                return;

            if (AutoBringToFront)
                _component.BringToFront();

            MouseEvent me = (MouseEvent) e;

            //var container = _component.Parent as Container; // 20121125 (because dragging didn't work well when parent scrolled)
            //_startCoordinates = null != container ?
            //    container.GlobalToContent(_component.Transform.GlobalPosition) : // GlobalToContent no more - TODO
            //    _component.Parent.GlobalToLocal(_component.Transform.GlobalPosition);

            _clickCoordinates = me.GlobalPosition;

            if (_constraintMode)
            {
                _constrainedRect = _constraintMetrics.GetConstrainedRectangle(_component.Transform.LocalBounds);

                if (!_constrainedRect.Contains(me.LocalPosition))
                    return;
            }

            e.CancelAndStopPropagation();

            DragManager.IsDragging = true;

            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_MOVE, MouseMoveHandler);
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);

            if (-1 == _cursorId)
            {
                _cursorId = CursorManager.Instance.SetCursor(CursorType.Move, CursorPriority.High);
            }
        }
Example #2
0
        private static Color _transparent = new Color(1, 1, 1, 0); // transparent

        private void DrawPixels(Rectangle fillRect, int yMax, int yMin, int xMin, int xMax, bool hasStroke, Color[] pixels, int count)
        {
            //if (null == Fill)
            //    Fill = new Fill(new Color(1, 1, 1, 0)); // transparent

            for (int y = yMax; y > yMin; y--)
            {
                for (int x = xMin; x < xMax; x++)
                {
                    _isFill = false;
                    _isStroke = false;

                    _point.X = x; 
                    _point.Y = y;

                    _isFill = fillRect.Contains(_point);

                    if (hasStroke && !_isFill)
                        _isStroke = Bounds.Contains(_point);

                    _color = _transparent; // new Color(1, 1, 1, 0); // transparent

                    if (_isFill && null != Fill) {
                        _color = CalculatePixelColor(Fill, y, x);
                    }
                    else if (_isStroke && null != Stroke) {
                        _color = CalculatePixelColor(Stroke, x, y);
                    }

                    pixels[count] = _color;

                    count++;
                }
            }
        }
Example #3
0
        /// <summary>
        /// We should listen the mouse move events over the component
        /// If mouse moved over the event, we should check border and draw overlay
        /// </summary>
        /// <param name="e"></param>
        private void ComponentMouseMoveHandler(Event e)
        {
            if (!Enabled)
                return;

            Debug.Log(string.Format("ComponentMouseMoveHandler [{0}, {1}]", e.Phase, e.CurrentTarget));

            if (!(e.Target is DisplayListMember))
                return;

            DisplayListMember dlm = (DisplayListMember)e.Target;

            MouseEvent me = (MouseEvent)e;

            //Container container = _component as Container;

            //Point coordsInComponentSpace = null != container ? 
            //      container.GlobalToContent(dlm.LocalToGlobal(me.LocalPosition)) : 
            //      _component.GlobalToLocal(dlm.LocalToGlobal(me.LocalPosition));

            Point coordsInComponentSpace = _component.GlobalToLocal(dlm.LocalToGlobal(me.LocalPosition));

            // if some component is already being dragged/resized, do not draw borders on hover
            if (DragManager.IsDragging)
                return;

            if (_constraintMode)
            {
                _constrainedRect = _constraintMetrics.GetConstrainedRectangle(_component.Transform.LocalBounds);
                DoRenderOverlay = _constrainedRect.Contains(coordsInComponentSpace);
            }
            else
            {
                DoRenderOverlay = true;
            }

            if (DoRenderOverlay)
            {
                e.Cancel();
            }
        }