Exemplo n.º 1
0
 public void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (child is LayoutGroupPanel)
     {
         RootGroupPanel = child as LayoutGroupPanel;
     }
 }
Exemplo n.º 2
0
 public override void AttachChild(IDockView child, AttachMode mode, int index)
 {
     //后面的2是border Thickness
     _widthEceeed  += Constants.DocumentWindowPadding * 2 + 2;
     _heightEceeed += Constants.DocumentWindowPadding * 2 + Constants.FloatWindowHeaderHeight + 2;
     base.AttachChild(child, mode, index);
 }
Exemplo n.º 3
0
 internal AttachObject(LayoutGroup relativeObj, INotifyDisposable parent, int index, AttachMode mode = AttachMode.None)
 {
     _relativeObj      = relativeObj;
     _parent           = parent;
     _index            = index;
     _mode             = mode;
     _parent.Disposed += OnDisposed;
 }
Exemplo n.º 4
0
 public virtual void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (Content != child)
     {
         Content = child;
         DockManager.AddFloatWindow(this);
         Height = (child as ILayoutSize).DesiredHeight + _heightEceeed;
         Width  = (child as ILayoutSize).DesiredWidth + _widthEceeed;
     }
 }
Exemplo n.º 5
0
 internal override bool _AssertMode(AttachMode mode)
 {
     return(mode == AttachMode.Left ||
            mode == AttachMode.Top ||
            mode == AttachMode.Right ||
            mode == AttachMode.Bottom ||
            mode == AttachMode.Left_WithSplit ||
            mode == AttachMode.Top_WithSplit ||
            mode == AttachMode.Right_WithSplit ||
            mode == AttachMode.Bottom_WithSplit);
 }
Exemplo n.º 6
0
 public override void AttachChild(IDockView child, AttachMode mode, int index)
 {
     if (child is ILayoutPanel)
     {
         _heightEceeed += Constants.FloatWindowHeaderHeight;
     }
     Owner = DockManager.MainWindow;
     base.AttachChild(child, mode, index);
     if (child is BaseGroupControl)
     {
         (((child as BaseGroupControl).Model as BaseLayoutGroup).Children as ObservableCollection <IDockElement>).CollectionChanged += OnCollectionChanged;
     }
 }
Exemplo n.º 7
0
        public void AttachWith(IDockView source, AttachMode mode = AttachMode.Center)
        {
            switch (mode)
            {
            case AttachMode.Left:
                _dropMode = DropMode.Left;
                break;

            case AttachMode.Top:
                _dropMode = DropMode.Top;
                break;

            case AttachMode.Right:
                _dropMode = DropMode.Right;
                break;

            case AttachMode.Bottom:
                _dropMode = DropMode.Bottom;
                break;

            case AttachMode.Left_WithSplit:
                _dropMode = DropMode.Left_WithSplit;
                break;

            case AttachMode.Top_WithSplit:
                _dropMode = DropMode.Top_WithSplit;
                break;

            case AttachMode.Right_WithSplit:
                _dropMode = DropMode.Right_WithSplit;
                break;

            case AttachMode.Bottom_WithSplit:
                _dropMode = DropMode.Bottom_WithSplit;
                break;

            case AttachMode.Center:
                _dropMode = DropMode.Center;
                break;

            default:
                _dropMode = DropMode.None;
                break;
            }
            DragItem item = new DragItem(source, DockMode.Normal, DragMode.None, new Point(), Rect.Empty, Size.Empty);

            OnDrop(item);
            _dropMode = DropMode.None;
        }
Exemplo n.º 8
0
        private void _AttachWithSplit(IDockView child, AttachMode mode, int index)
        {
            if (child is LayoutDocumentGroupControl)
            {
                if (Direction == Direction.None)
                {
                    Direction = (mode == AttachMode.Left_WithSplit || mode == AttachMode.Right_WithSplit) ? Direction.LeftToRight : Direction.UpToDown;
                }
                _AttachChild(child, index);

                if (DockViewParent != null)
                {
                    DockManager.Root.DocumentModels.Add(child.Model as BaseLayoutGroup);
                }
            }

            if (child is AnchorSideGroupControl)
            {
                var model     = (child as AnchorSideGroupControl).Model as LayoutGroup;
                var _children = new List <IDockElement>(model.Children);
                model.Dispose();
                var group = new LayoutDocumentGroup(DockViewParent == null ? DockMode.Float : DockMode.Normal, DockManager);
                foreach (var _child in _children)
                {
                    group.Attach(_child);
                }
                var ctrl = new LayoutDocumentGroupControl(group);
                _AttachChild(ctrl, index);
                (child as IDisposable).Dispose();
            }

            if (child is LayoutGroupDocumentPanel ||
                child is LayoutGroupPanel)
            {
                var _children = new List <IDockView>((child as LayoutGroupPanel).Children.OfType <IDockView>());
                _children.Reverse();
                (child as LayoutGroupPanel).Children.Clear();
                foreach (var _child in _children)
                {
                    _AttachWithSplit(_child as IDockView, mode, index);
                }
                (child as IDisposable).Dispose();
            }

            //if (child is IDisposable)
            //    (child as IDisposable).Dispose();
        }
Exemplo n.º 9
0
 /// <summary>
 /// attach source to target by <see cref="AttachMode"/>
 /// </summary>
 /// <param name="source">源</param>
 /// <param name="target">目标</param>
 /// <param name="mode">附加模式</param>
 public void AttachTo(IDockControl source, IDockControl target, AttachMode mode)
 {
     if (target.Container.View == null)
     {
         throw new InvalidOperationException("target must be visible!");
     }
     if (target.IsDisposed)
     {
         throw new InvalidOperationException("target is disposed!");
     }
     if (source == target)
     {
         throw new InvalidOperationException("source can not be target!");
     }
     if (source == null || target == null)
     {
         throw new ArgumentNullException("source or target is null!");
     }
     if (source.Container.View != target.Container.View && source.CanSelect)
     {
         source.SetActive();
     }
     else if (source.Container != null)
     {
         source.Container.Detach(source.ProtoType);
         BaseLayoutGroup  group;
         BaseGroupControl ctrl;
         if (source.IsDocument)
         {
             group = new LayoutDocumentGroup(DockMode.Normal, this);
             ctrl  = new LayoutDocumentGroupControl(group, (target.Container.View as ILayoutViewWithSize).DesiredWidth, (target.Container.View as ILayoutViewWithSize).DesiredHeight);
         }
         else
         {
             group = new LayoutGroup(source.Side, DockMode.Normal, this);
             ctrl  = new AnchorSideGroupControl(group, (target.Container.View as ILayoutViewWithSize).DesiredWidth, (target.Container.View as ILayoutViewWithSize).DesiredHeight);
         }
         group.Attach(source.ProtoType);
         var _atsource = target.ProtoType.Container.View as IAttcah;
         _atsource.AttachWith(ctrl, mode);
         source.SetActive();
     }
     else
     {
         throw new ArgumentNullException("the container of source is null!");
     }
 }
Exemplo n.º 10
0
            public void Attach(Task task, AttachMode attachMode)
            {
                switch (attachMode)
                {
                case AttachMode.ContinueWith:
                    task.ContinueWith(Continue);
                    break;

                case AttachMode.ContinueWithExecSync:
                    task.ContinueWith(Continue, TaskContinuationOptions.ExecuteSynchronously);
                    break;

                case AttachMode.Await:
                    DoAwait(task);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(attachMode));
                }
            }
Exemplo n.º 11
0
 // Token: 0x06005533 RID: 21811 RVA: 0x001D5A2C File Offset: 0x001D3E2C
 public void SetTargetObject(Transform targetObject, AttachMode attachMode, Vector3 tetherPos, Vector3 labelPos, bool isFloatingLabel)
 {
     this._tetherLength      = (labelPos - tetherPos).magnitude;
     base.transform.position = tetherPos;
     if (!isFloatingLabel)
     {
         base.transform.LookAt(labelPos, Vector3.up);
     }
     this.UpdateScale();
     if (!isFloatingLabel)
     {
         AttachToTransform component = base.GetComponent <AttachToTransform>();
         if (component != null)
         {
             component.Parent         = targetObject;
             component.FollowPosition = true;
             component.FollowRotation = (attachMode == AttachMode.PositionAndRotation);
             component.ResetLocalTransform();
         }
     }
     this.SetAlpha(0f);
 }
Exemplo n.º 12
0
        public void TestContinuationHijacking(SourceOrign origin, AttachMode attachMode, bool expectHijack)
        {
            TaskCompletionSource <int> source = Create <int>(origin);

            int settingThread = Environment.CurrentManagedThreadId;
            var state         = new AwaitState();

            state.Attach(source.Task, attachMode);
            source.TrySetResult(123);
            state.Wait(); // waits for the continuation to run
            int from = state.Thread;

            Assert.NotEqual(-1, from); // not set
            if (expectHijack)
            {
                Assert.True(settingThread == from, "expected hijack; didn't happen");
            }
            else
            {
                Assert.False(settingThread == from, "setter was hijacked");
            }
        }
Exemplo n.º 13
0
    // Token: 0x06005577 RID: 21879 RVA: 0x001D7BF8 File Offset: 0x001D5FF8
    private bool ActivateLabel(Transform targetObj, string id, TutorialLabelType type, ControllerHand hand, ControllerInputUI controllerPart, string text, ControllerActionUI action, string textSecondary, ControllerActionUI actionSecondary, float duration, int priority, Vector3?tetherPos, Vector3?labelPos, AttachMode attachMode, bool showOffscreen, float scale)
    {
        if (!this.AreLabelsEnabled)
        {
            return(false);
        }
        if (this.TutorialLabelPrefab == null)
        {
            return(false);
        }
        bool flag = targetObj == null || type == TutorialLabelType.Popup || type == TutorialLabelType.PopupAttached;

        if (targetObj == null)
        {
            targetObj = this.FloatingLabelTransform;
        }
        TutorialManager.ActiveLabel activeLabel = this.FindActiveLabel(targetObj.GetInstanceID());
        if (activeLabel == null)
        {
            if (flag)
            {
                Vector3 value = TutorialLabel.CalculateFloatingLabelPosition();
                tetherPos = new Vector3?(value);
                labelPos  = new Vector3?(value);
            }
            else if (tetherPos == null || labelPos == null)
            {
                Vector3 value2;
                Vector3 value3;
                TutorialLabel.FindLabelAttachPoints(targetObj, out value2, out value3);
                if (tetherPos == null)
                {
                    tetherPos = new Vector3?(value2);
                }
                if (labelPos == null)
                {
                    labelPos = new Vector3?(value3);
                }
            }
            if (!showOffscreen && !VRCTrackingManager.IsPointWithinHMDView(labelPos.Value))
            {
                return(false);
            }
            activeLabel = new TutorialManager.ActiveLabel();
            activeLabel.TargetObject = targetObj;
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.TutorialLabelPrefab);
            activeLabel.Label = gameObject.GetComponent <TutorialLabel>();
            activeLabel.Label.Init();
            this._activeLabels.Add(activeLabel.TargetObject.GetInstanceID(), activeLabel);
            activeLabel.Label.SetTargetObject(targetObj, attachMode, tetherPos.Value, labelPos.Value, flag);
        }
        else if (activeLabel.Label.IsActive && activeLabel.Priority > priority)
        {
            VRC.Core.Logger.LogOnceEvery(10f, this, string.Concat(new object[]
            {
                "TutorialManager: Existing label (",
                activeLabel.ID,
                ", ",
                activeLabel.TargetObject.name,
                ") \"",
                activeLabel.Label.TextString,
                "\" has higher priority ",
                activeLabel.Priority,
                " > ",
                priority,
                ", discarding new one"
            }));
            return(false);
        }
        activeLabel.ID   = id;
        activeLabel.Type = type;
        activeLabel.SetController(hand, controllerPart);
        activeLabel.ShowOffscreen = showOffscreen;
        activeLabel.Priority      = priority;
        activeLabel.Label.SetText(text, textSecondary);
        activeLabel.Label.SetIcon(action, actionSecondary);
        activeLabel.Label.SetTextScaleOverride(scale);
        bool invertLabelAlignment = type == TutorialLabelType.Controller && hand == ControllerHand.Right && VRCInputManager.LastInputMethod == VRCInputManager.InputMethod.Oculus;

        activeLabel.Label.IsFloatingLabel      = flag;
        activeLabel.Label.InvertLabelAlignment = invertLabelAlignment;
        activeLabel.Label.IsAttachedToView     = (type == TutorialLabelType.PopupAttached);
        activeLabel.Label.RefreshComponentPositions();
        activeLabel.TimeToLive = duration;
        activeLabel.Label.Activate();
        return(true);
    }
Exemplo n.º 14
0
    // Token: 0x0600556E RID: 21870 RVA: 0x001D794C File Offset: 0x001D5D4C
    public void ActivateObjectLabel(Transform targetObject, string id, TutorialLabelType type, ControllerHand hand, string text, ControllerActionUI action, string textSecondary, ControllerActionUI actionSecondary, float duration = 0.1f, int priority = 0, AttachMode attachMode = AttachMode.PositionOnly, bool showOffscreen = false)
    {
        float scale = (type != TutorialLabelType.AreaMarker) ? 1f : 2f;

        this.ActivateLabel(targetObject, id, type, hand, ControllerInputUI.None, text, action, textSecondary, actionSecondary, duration, priority, null, null, attachMode, showOffscreen, scale);
    }
Exemplo n.º 15
0
 // Token: 0x0600556D RID: 21869 RVA: 0x001D7920 File Offset: 0x001D5D20
 public void ActivateObjectLabel(Transform targetObject, TutorialLabelType type, ControllerHand hand, string text, ControllerActionUI action, string textSecondary, ControllerActionUI actionSecondary, float duration = 0.1f, int priority = 0, AttachMode attachMode = AttachMode.PositionOnly, bool showOffscreen = false)
 {
     this.ActivateObjectLabel(targetObject, "<no id>", type, hand, text, action, textSecondary, actionSecondary, duration, priority, attachMode, showOffscreen);
 }
Exemplo n.º 16
0
 // Token: 0x06005543 RID: 21827 RVA: 0x001D67D8 File Offset: 0x001D4BD8
 public static void VRC_Tutorial_ActivateObjectLabel(Transform targetObject, TutorialLabelType type, ControllerHand hand, string text, ControllerActionUI action, string textSecondary, ControllerActionUI actionSecondary, float duration, int priority, AttachMode attachMode, bool showOffscreen)
 {
     if (TutorialManager.Instance != null)
     {
         TutorialManager.Instance.ActivateObjectLabel(targetObject, type, hand, text, action, textSecondary, actionSecondary, duration, priority, attachMode, showOffscreen);
     }
 }
Exemplo n.º 17
0
 public void ActivateObjectLabel(Transform targetObject, TutorialLabelType type, ControllerHand hand, string text, float duration = 0.1f, int priority = 0, AttachMode attachMode = AttachMode.PositionOnly, bool showOffscreen = false)
 {
     Tutorial.ActivateObjectLabel(targetObject, type, hand, text, ControllerActionUI.None, string.Empty, ControllerActionUI.None, duration, priority, attachMode, showOffscreen);
 }
Exemplo n.º 18
0
        public override void AttachChild(IDockView child, AttachMode mode, int index)
        {
            if (index < 0 || index > Count)
            {
                throw new ArgumentOutOfRangeException("index out of range!");
            }
            if (!_AssertMode(mode))
            {
                throw new ArgumentException("mode is illegal!");
            }

            if (Count == 1 && ActualWidth > 0 && ActualHeight > 0)
            {
                ILayoutSize size = Children[0] as ILayoutSize;
                size.DesiredWidth  = ActualWidth;
                size.DesiredHeight = ActualHeight;
            }

            if (child is LayoutDocumentGroupControl ||
                child is LayoutGroupDocumentPanel ||
                mode == AttachMode.Left_WithSplit ||
                mode == AttachMode.Top_WithSplit ||
                mode == AttachMode.Right_WithSplit ||
                mode == AttachMode.Bottom_WithSplit)
            {
                _AttachWithSplit(child, mode, index);
            }
            else
            {
                if (IsRootPanel)
                {
                    AttachToRootPanel(child, mode);
                }
                else
                {
                    var parent = Parent as LayoutGroupPanel;
                    switch (parent.Direction)
                    {
                    case Direction.LeftToRight:
                        if (mode == AttachMode.Left || mode == AttachMode.Right)
                        {
                            if (child is LayoutGroupPanel)
                            {
                                _AttachSubPanel((child as LayoutGroupPanel), index);
                            }
                            else
                            {
                                _AttachChild(child, index);
                            }
                        }
                        else
                        {
                            int _index = parent.IndexOf(this);
                            parent._DetachChild(this);
                            var pparent = new LayoutGroupPanel()
                            {
                                Direction = Direction.UpToDown
                            };
                            parent._AttachChild(pparent, _index);
                            pparent._AttachChild(this, 0);
                            pparent._AttachChild(child, mode == AttachMode.Top ? 0 : 1);
                        }
                        break;

                    case Direction.UpToDown:
                        if (mode == AttachMode.Top || mode == AttachMode.Bottom)
                        {
                            if (child is LayoutGroupPanel)
                            {
                                _AttachSubPanel((child as LayoutGroupPanel), index);
                            }
                            else
                            {
                                _AttachChild(child, index);
                            }
                        }
                        else
                        {
                            int _index = parent.IndexOf(this);
                            parent._DetachChild(this);
                            var pparent = new LayoutGroupPanel()
                            {
                                Direction = Direction.LeftToRight
                            };
                            parent._AttachChild(pparent, _index);
                            pparent._AttachChild(this, 0);
                            pparent._AttachChild(child, mode == AttachMode.Left ? 0 : 1);
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// attach source to target by <see cref="AttachMode"/>
        /// </summary>
        /// <param name="source">源</param>
        /// <param name="target">目标</param>
        /// <param name="mode">附加模式</param>
        public void AttachTo(IDockControl source, IDockControl target, AttachMode mode, double ratio = -1)
        {
            if (target.Container.View == null)
            {
                throw new InvalidOperationException("target must be visible!");
            }
            if (target.IsDisposed)
            {
                throw new InvalidOperationException("target is disposed!");
            }
            if (source == target)
            {
                throw new InvalidOperationException("source can not be target!");
            }
            if (source == null || target == null)
            {
                throw new ArgumentNullException("source or target is null!");
            }
            if (target.Mode == DockMode.DockBar)
            {
                throw new ArgumentNullException("target is DockBar Mode!");
            }
            if (source.Container != null)
            {
                //DockBar模式下无法合并,故先转换为Normal模式
                //if (target.Mode == DockMode.DockBar)
                //    target.ToDock();

                source.Container.Detach(source.ProtoType);


                double width = (target.Container.View as ILayoutViewWithSize).DesiredWidth
                , height     = (target.Container.View as ILayoutViewWithSize).DesiredHeight;

                if (ratio > 0)
                {
                    if (mode == AttachMode.Right ||
                        mode == AttachMode.Left ||
                        mode == AttachMode.Left_WithSplit ||
                        mode == AttachMode.Right_WithSplit)
                    {
                        width = (target.Container.View as ILayoutViewWithSize).DesiredWidth * ratio;
                    }

                    if (mode == AttachMode.Top ||
                        mode == AttachMode.Bottom ||
                        mode == AttachMode.Top_WithSplit ||
                        mode == AttachMode.Bottom_WithSplit)
                    {
                        height = (target.Container.View as ILayoutViewWithSize).DesiredHeight * ratio;
                    }
                }

                BaseLayoutGroup  group;
                BaseGroupControl ctrl;
                if (source.IsDocument)
                {
                    group = new LayoutDocumentGroup(DockMode.Normal, this);
                    ctrl  = new LayoutDocumentGroupControl(group, ratio > 0 ? width : source.DesiredWidth, ratio > 0 ? height : source.DesiredHeight);
                }
                else
                {
                    group = new LayoutGroup(source.Side, DockMode.Normal, this);
                    ctrl  = new AnchorSideGroupControl(group, ratio > 0 ? width : source.DesiredWidth, ratio > 0 ? height : source.DesiredHeight);
                }
                group.Attach(source.ProtoType);
                var _atsource = target.ProtoType.Container.View as IAttcah;
                _atsource.AttachWith(ctrl, mode);
                source.SetActive();
            }
            else
            {
                throw new ArgumentNullException("the container of source is null!");
            }
        }
Exemplo n.º 20
0
 void SwitchAttachMode(AttachMode value)
 {
     attachTo = value;
     AttachToTarget();
 }
Exemplo n.º 21
0
 public void ActivateObjectLabel(Transform targetObject, TutorialLabelType type, ControllerHand hand, string text, ControllerActionUI action, string textSecondary, ControllerActionUI actionSecondary, float duration, int priority, AttachMode attachMode, bool showOffscreen)
 {
     Tutorial.ActivateObjectLabel(targetObject, type, hand, text, action, textSecondary, actionSecondary, duration, priority, attachMode, showOffscreen);
 }