Exemple #1
0
 public void ShowShapes()
 {
     foreach (var sh in GetShapes())
     {
         sh.Show();
     }
     DocTools.UnfocusAll(GetShapes());
     _shapeVisibility = true;
 }
Exemple #2
0
        public bool InpDeviceDown(Point pos, TouchDevice touchDev)
        {
            DocTools.UnfocusAll(_doc.GetShapes().Where(sh => !sh.IsManipulated()));
            switch (_modeMgr.Mode)
            {
            case ShapeInputMode.CreationExpected:
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
                CreateManipulate(_palette.shapeType, pos.X, pos.Y);
                if (_palette != null)
                {
                    _palette.ResetOvers();
                }
                return(true);

            case ShapeInputMode.LinkedObj1Expected:
                GetLinkables(pos, touchDev);
                if (_linkCreation.end1 != null)
                {
                    ModeMgr.Mode = ShapeInputMode.LinkedObj2Expected;
                }
                return(true);

            case ShapeInputMode.LinkedObj2Expected:
                GetLinkables(pos, touchDev);
                if (_linkCreation.end1 != null && _linkCreation.end2 != null)
                {
                    _linkCreation.linkId = _doc.BeginCreateLink(_linkCreation.end1.GetId(), _linkCreation.end2.GetId(),
                                                                _linkCreation.headType);
                    _linkCreation.end1 = null;
                    _linkCreation.end2 = null;
                    ModeMgr.Mode       = ShapeInputMode.ManipulationExpected;

                    if (_palette != null)
                    {
                        _palette.ResetOvers();
                    }
                }
                return(true);

            case ShapeInputMode.ManipulationExpected:
                //no current touch points on shapes (maybe touch points over empty space)

                Shape resizeNode   = null;
                var   underContact = DocTools.DetectSelectedShape(_doc, pos, touchDev, out resizeNode) as IVdShape;
                if (underContact == null)
                {
                    return(false);
                }

                LockIfPossible(underContact, resizeNode, pos, touchDev);
                return(true);

            case ShapeInputMode.Manipulating:
                DocTools.UnfocusAll(_doc.GetShapes().Where(sh => !sh.IsManipulated()));
                StopManipulation(_doc.VolatileCtx.LocalCursor, true);
                return(true);

            case ShapeInputMode.CursorApprovalExpected:
                return(true);

            default:
                throw new NotSupportedException();
            }
        }
Exemple #3
0
        public void InpDeviceDown(Point pos, TouchDevice touchDev)
        {
            if (ShapeHitTester.IsPaletteHit(_doc, pos))
            {
                _palette.StartManip(pos, touchDev);
                return;
            }

            DocTools.UnfocusAll(_doc.GetShapes().Where(sh => !sh.IsManipulated()));
            switch (_modeMgr.Mode)
            {
            case ShapeInputMode.CreationExpected:
                _modeMgr.Mode = ShapeInputMode.ManipulationExpected;
                CreateManipulate(_palette.shapeType, pos.X, pos.Y);
                if (_palette != null)
                {
                    _palette.ResetOvers();
                }
                break;

            case ShapeInputMode.LinkedObj1Expected:
                GetLinkables(pos, touchDev);
                if (linkCreation.end1 != null)
                {
                    ModeMgr.Mode = ShapeInputMode.LinkedObj2Expected;
                }
                break;

            case ShapeInputMode.LinkedObj2Expected:
                GetLinkables(pos, touchDev);
                if (linkCreation.end1 != null && linkCreation.end2 != null)
                {
                    _doc.BeginCreateLink(linkCreation.end1.GetId(), linkCreation.end2.GetId(), linkCreation.linkHead);
                    linkCreation.end1 = null;
                    linkCreation.end2 = null;
                    ModeMgr.Mode      = ShapeInputMode.ManipulationExpected;

                    if (_palette != null)
                    {
                        _palette.ResetOvers();
                    }
                }
                break;

            case ShapeInputMode.ManipulationExpected:
                //no current touch points on shapes (maybe touch points over empty space)

                Shape resizeNode   = null;
                var   underContact = DocTools.DetectSelectedShape(_doc, pos, touchDev, out resizeNode) as IVdShape;
                if (underContact == null)
                {
                    return;
                }

                var shapeFree       = underContact.GetCursor() == null;
                var shapeLockedByUs = false;
                if (!shapeFree)
                {
                    shapeLockedByUs = underContact.GetCursor().OwnerId == _palette.GetOwnerId();
                }

                //this shape free and we don't have cursors
                if (shapeFree && _doc.VolatileCtx.LocalCursor == null)
                {
                    //shape free, try lock it and schedule cursor approval continuation
                    {
                        cursorApproval.resizeNode = resizeNode;
                        cursorApproval.pos        = pos;
                        cursorApproval.td         = touchDev;
                        _modeMgr.Mode             = ShapeInputMode.CursorApprovalExpected;
                    }

                    //take new local cursor
                    _doc.VolatileCtx.BeginTakeShapeWithLocalCursor(underContact.Id());
                }
                else if (shapeLockedByUs)
                {
                    CaptureAndStartManip(underContact, pos, resizeNode, touchDev);
                }
                break;

            case ShapeInputMode.Manipulating:
                break;

            case ShapeInputMode.CursorApprovalExpected:
                break;

            default:
                throw new NotSupportedException();
            }
        }