Esempio n. 1
0
 // Checks if the reference name has been overriden and appends menu action to reset it, if so
 internal void UpdateRightClickMenu()
 {
     if (string.IsNullOrEmpty(m_Input.overrideReferenceName))
     {
         this.RemoveManipulator(m_RightClickMenuManipulator);
         m_RightClickMenuManipulator = null;
     }
     else if (m_RightClickMenuManipulator == null)
     {
         m_RightClickMenuManipulator = (IManipulator)Activator.CreateInstance(s_ContextualMenuManipulatorType, (Action <ContextualMenuPopulateEvent>)BuildContextualMenu);
         this.AddManipulator(m_RightClickMenuManipulator);
     }
 }
Esempio n. 2
0
 void UpdateReferenceNameResetMenu()
 {
     if (string.IsNullOrEmpty(m_Input.overrideReferenceName))
     {
         this.RemoveManipulator(m_ResetReferenceMenu);
         m_ResetReferenceMenu = null;
     }
     else
     {
         m_ResetReferenceMenu = (IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action <ContextualMenuPopulateEvent>)BuildContextualMenu);
         this.AddManipulator(m_ResetReferenceMenu);
     }
 }
        void RenderSceneNode(bool isSubScene)
        {
            AddToClassList(UssClasses.EntityHierarchyWindow.Item.SceneNode);
            m_Icon.AddToClassList(UssClasses.EntityHierarchyWindow.Item.IconScene);
            m_NameLabel.AddToClassList(UssClasses.EntityHierarchyWindow.Item.NameScene);
            m_NameLabel.text = m_Item.CachedName;

            if (isSubScene)
            {
                m_ContextMenuManipulator = new ContextualMenuManipulator(null);
                this.AddManipulator(m_ContextMenuManipulator);
                RegisterCallback <ContextualMenuPopulateEvent>(OnSceneContextMenu);
            }
        }
        protected ObservableMap(string name, IManipulator <TIn, TOut, TKey> manipulator = null, object meta = null)
        {
            Data = new Map <TKey, IObservableValue <TIn> >();

            HasMap = new Map <TKey, IObservableValue <bool> >();

            Name = name ?? $"ObservableMap@{States.NextId}";

            Manipulator = manipulator ?? Manipulator <TIn, TOut, TKey> .For();

            KeysAtom = new Atom($"{Name}.keys()");

            Meta = meta;
        }
        public void Release()
        {
            if (m_ContextMenuManipulator != null)
            {
                this.RemoveManipulator(m_ContextMenuManipulator);
                UnregisterCallback <ContextualMenuPopulateEvent>(OnSceneContextMenu);
                m_ContextMenuManipulator = null;
            }

            m_Item          = null;
            m_OriginatingId = null;

            Pool.Release(this);
        }
Esempio n. 6
0
 public void AddObject(Object el)
 {
     if (el != null)
     {
         SelectedObjects.Insert(0, el);;
         UpdateManipulator();
     }
     else if (_manipulator != null)
     {
         _manipulator.Deactivate();
         _manipulator = null;
     }
     RaiseSelectionChanged(el);
 }
Esempio n. 7
0
        /// <summary>
        /// Does the command</summary>
        /// <param name="commandTag">Command to be done</param>
        public void DoCommand(object commandTag)
        {
            ISnapSettings snapSettings = (ISnapSettings)m_designView;
            IManipulator  manip        = commandTag as IManipulator;

            if (manip != null)
            {
                m_designView.Manipulator = manip;
            }
            else if (commandTag is Command)
            {
                switch ((Command)commandTag)
                {
                case Command.Select:
                    m_designView.Manipulator = null;
                    break;

                case Command.SnapToVertex:
                    snapSettings.SnapVertex = !snapSettings.SnapVertex;
                    break;

                case Command.RotateOnSnap:
                    snapSettings.RotateOnSnap = !snapSettings.RotateOnSnap;
                    break;

                case Command.AlignToTerrainUp:
                    if (snapSettings.TerrainAlignment == TerrainAlignmentMode.TerrainUp)
                    {
                        snapSettings.TerrainAlignment = TerrainAlignmentMode.None;
                    }
                    else
                    {
                        snapSettings.TerrainAlignment = TerrainAlignmentMode.TerrainUp;
                    }
                    break;

                case Command.AlignToWorldUp:
                    if (snapSettings.TerrainAlignment == TerrainAlignmentMode.WorldUp)
                    {
                        snapSettings.TerrainAlignment = TerrainAlignmentMode.None;
                    }
                    else
                    {
                        snapSettings.TerrainAlignment = TerrainAlignmentMode.WorldUp;
                    }
                    break;
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        ///     Disassociates a manipulator with a UIElement. This will remove it from
        ///     an active manipulation, possibly completing it.
        /// </summary>
        /// <param name="element">The element that the manipulator used to be associated with.</param>
        /// <param name="manipulator">The manipulator, such as a TouchDevice.</param>
        public static void RemoveManipulator(UIElement element, IManipulator manipulator)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (manipulator == null)
            {
                throw new ArgumentNullException("manipulator");
            }

            if (!TryRemoveManipulator(element, manipulator))
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotActive));
            }
        }
Esempio n. 9
0
        internal void AddManipulator(IManipulator manipulator)
        {
            Debug.Assert(manipulator != null);
            VerifyAccess();
            _manipulationEnded = false;

            if (_manipulators == null)
            {
                _manipulators = new List <IManipulator>(2);
            }

            _manipulators.Add(manipulator);
            manipulator.Updated += OnManipulatorUpdated;

            // Adding a manipulator counts as an update
            OnManipulatorUpdated(manipulator, EventArgs.Empty);
        }
Esempio n. 10
0
        private void UpdateMutators()
        {
            IManipulator oldMutator = MutatorParameter.Value;

            MutatorParameter.ValidValues.Clear();
            foreach (IManipulator mutator in Problem.Operators.OfType <IManipulator>().OrderBy(x => x.Name))
            {
                MutatorParameter.ValidValues.Add(mutator);
            }
            if (oldMutator != null)
            {
                IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
                if (mutator != null)
                {
                    MutatorParameter.Value = mutator;
                }
            }
        }
        void IPoolable.Reset()
        {
            Owner = null;
            if (m_ContextMenuManipulator != null)
            {
                this.RemoveManipulator(m_ContextMenuManipulator);
                UnregisterCallback <ContextualMenuPopulateEvent>(OnSceneContextMenu);
                m_ContextMenuManipulator = null;
            }

            m_Item          = null;
            m_OriginatingId = null;

            // These are overwritten by ListView in a way that conflicts with the TreeView representation
            // NOTE: Adding those to "ClearDynamicStyles()" messes-up the rendering of the ListView
            style.top      = 0.0f;
            style.bottom   = Constants.EntityHierarchy.ItemHeight;
            style.position = Position.Relative;
        }
Esempio n. 12
0
        /// <summary>
        ///     Associates a manipulator with a UIElement. This will either will start an
        ///     active manipulation or add to an existing one.
        /// </summary>
        /// <param name="element">The element with which to associate the manipulator.</param>
        /// <param name="manipulator">The manipulator, such as a TouchDevice.</param>
        public static void AddManipulator(UIElement element, IManipulator manipulator)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (manipulator == null)
            {
                throw new ArgumentNullException("manipulator");
            }
            if (!element.IsManipulationEnabled)
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotEnabled));
            }

            ManipulationDevice device = ManipulationDevice.AddManipulationDevice(element);

            device.AddManipulator(manipulator);
        }
Esempio n. 13
0
 public void UpdateManipulator()
 {
     if (_manipulator != null)
     {
         _manipulator.Deactivate();
     }
     if (SelectedObjects.Count > 0)
     {
         _manipulator = (IManipulator)Activator.CreateInstance(
             _view.ActiveTool.GetToolManipulator(),
             new object[] { _view, SelectedObjects.Cast <FrameworkElement>().FirstOrDefault() });
         if (_manipulator.IsApplicable())
         {
             _manipulator.Activate();
         }
         else
         {
             _manipulator = null;
         }
     }
     AdornerLayer.GetAdornerLayer(_view.MainPanel).Update();
 }
        public BuilderInspectorHeader(BuilderInspector inspector)
        {
            m_Inspector       = inspector;
            m_Selection       = inspector.selection;
            m_Header          = m_Inspector.Q <VisualElement>("header-container");
            m_StatusIndicator = m_Header.Q <FieldStatusIndicator>("header-field-status-indicator");
            m_StatusIndicator.populateMenuItems = (menu) =>
            {
                BuildNameFieldContextualMenu(menu, m_TextField);
            };

            m_InnerHeader = m_Inspector.Q <VisualElement>("header-container-minor");
            m_Icon        = m_Inspector.Q <VisualElement>("header-icon");

            m_Pill = m_Inspector.Q <Label>("header-selected-pill");
            m_Pill.AddToClassList("unity-builder-tag-pill");

            m_TextField             = m_Inspector.Q <TextField>("header-selected-text-field");
            m_TextField.isDelayed   = true;
            m_TextField.tooltip     = "name";
            m_TextField.bindingPath = "name";

            m_EditorWarningHelpBox      = m_Inspector.Q <UnityEngine.UIElements.HelpBox>("header-editor-warning-help-box");
            m_EditorWarningHelpBox.text = BuilderConstants.HeaderSectionHelpBoxMessage;
            m_ErrorIcon = m_Inspector.Q <VisualElement>("header-error-icon");

            // Warning must be hidden at first
            m_ErrorIcon.style.backgroundImage = EditorGUIUtility.LoadIcon("console.erroricon");
            AdjustBottomPadding(false);

            // Store callbacks to reduce delegate allocations
            m_ElementNameChangeCallback    = new EventCallback <ChangeEvent <string> >(OnNameAttributeChange);
            m_SelectorNameChangeCallback   = new EventCallback <ChangeEvent <string> >(OnStyleSelectorNameChange);
            m_SelectorEnterKeyDownCallback = new EventCallback <KeyDownEvent>(OnEnterStyleSelectorNameChange);

            m_TextField.RegisterValueChangedCallback(m_ElementNameChangeCallback);
            m_RightClickManipulator = new ContextualMenuManipulator(BuildNameFieldContextualMenu);
        }
Esempio n. 15
0
        /// <summary>
        /// Performs a picking test to see if any manipulator is visible on the screen at the given coordinates</summary>
        /// <param name="x">X-coordinate in screen coordinates (like from MouseEventArgs)</param>
        /// <param name="y">Y-coordinate in screen coordinates (like from MouseEventArgs)</param>
        /// <param name="hits">Resulting HitRecord(s) if there was a manipulator found</param>
        /// <returns>The found manipulator or null if none found</returns>
        protected IManipulator TestForManipulator(int x, int y, out HitRecord[] hits)
        {
            IManipulator manipulator = null;

            m_pickAction.TypeFilter = typeof(IManipulator);

            SetCurrentContext();
            m_pickAction.Set(m_renderAction);
            m_pickAction.Init(Camera, x, y, x, y, true, false);
            Render(m_pickAction, true, true);
            hits = m_pickAction.GetHits();
            m_pickAction.TypeFilter = null;

            // Analyze hits
            if (hits.Length > 0)
            {
                manipulator = hits[0].RenderObject as IManipulator;
            }

            m_pickAction.Clear();

            return(manipulator);
        }
Esempio n. 16
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="manipulator">Manipulator for event</param>
 public ManipulatorEventArgs(IManipulator manipulator) 
 {
     Manipulator = manipulator;
 }
Esempio n. 17
0
        internal static bool TryRemoveManipulator(UIElement element, IManipulator manipulator)
        { 
            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);
            if (device != null)
            {
                device.RemoveManipulator(manipulator); 
                return true;
            } 
 
            return false;
        } 
Esempio n. 18
0
        internal void RemoveManipulator(IManipulator manipulator)
        {
            Debug.Assert(manipulator != null);
            VerifyAccess();

            manipulator.Updated -= OnManipulatorUpdated;
            if (_manipulators != null)
            {
                _manipulators.Remove(manipulator);
            }

            // Removing a manipulator counts as an update
            OnManipulatorUpdated(manipulator, EventArgs.Empty);
            if (!_manipulationEnded)
            {
                if (_manipulators == null || _manipulators.Count == 0)
                {
                    // cache the last removed manipulator
                    _removedManipulator = manipulator;
                }
                // Call ReportFrame so that ManipulationInertiaStarting / ManipulationCompleted 
                // gets called synchronously if needed
                ReportFrame();
                _removedManipulator = null;
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Sets the game audio source
 /// </summary>
 /// <param name="source">Scene object instance</param>
 public void SetSource <T>(SceneObject <T> source)
 {
     this.source = source?.Transform;
 }
Esempio n. 20
0
 private void SetManipulator(IManipulator manipulator, HitRecord[] hits)
 {
     s_isManipulating        = true;
     m_manipulatorHitRecords = hits;
 }
Esempio n. 21
0
        public EventPropagation DispatchEvent(Event e, BaseVisualElementPanel panel)
        {
            EventPropagation result;

            if (e.type == EventType.Repaint)
            {
                Debug.Log("Repaint should be handled by Panel before Dispatcher");
                result = EventPropagation.Continue;
            }
            else
            {
                bool flag = false;
                if (panel.panelDebug != null && panel.panelDebug.enabled && panel.panelDebug.interceptEvents != null && panel.panelDebug.interceptEvents(e))
                {
                    result = EventPropagation.Stop;
                }
                else
                {
                    if (this.capture != null && this.capture.panel == null)
                    {
                        Debug.Log(string.Format("Capture has no panel, forcing removal (capture={0} eventType={1})", this.capture, e.type));
                        this.RemoveCapture();
                    }
                    if (this.capture != null)
                    {
                        if (this.capture.panel.contextType != panel.contextType)
                        {
                            result = EventPropagation.Continue;
                            return(result);
                        }
                        VisualElement visualElement = this.capture as VisualElement;
                        if (visualElement != null)
                        {
                            e.mousePosition = visualElement.GlobalToBound(e.mousePosition);
                        }
                        else
                        {
                            IManipulator manipulator = this.capture as IManipulator;
                            if (manipulator != null)
                            {
                                e.mousePosition = manipulator.target.GlobalToBound(e.mousePosition);
                            }
                        }
                        flag = true;
                        if (this.capture.HandleEvent(e, this.capture as VisualElement) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    if (e.isKey)
                    {
                        flag = true;
                        if (panel.focusedElement != null)
                        {
                            if (this.PropagateEvent(panel.focusedElement, e) == EventPropagation.Stop)
                            {
                                result = EventPropagation.Stop;
                                return(result);
                            }
                        }
                        else if (this.SendEventToIMGUIContainers(panel.visualTree, e, panel.focusedElement) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    else if (e.isMouse || e.isScrollWheel || e.type == EventType.DragUpdated || e.type == EventType.DragPerform || e.type == EventType.DragExited)
                    {
                        if (e.type == EventType.MouseLeaveWindow)
                        {
                            this.elementUnderMouse = null;
                        }
                        else
                        {
                            this.elementUnderMouse = panel.Pick(e.mousePosition);
                        }
                        if (e.type == EventType.MouseDown && this.elementUnderMouse != null && this.elementUnderMouse.enabled)
                        {
                            this.SetFocusedElement(panel, this.elementUnderMouse);
                        }
                        if (this.elementUnderMouse != null)
                        {
                            flag = true;
                            if (this.PropagateEvent(this.elementUnderMouse, e) == EventPropagation.Stop)
                            {
                                result = EventPropagation.Stop;
                                return(result);
                            }
                        }
                        if (e.type == EventType.MouseEnterWindow || e.type == EventType.MouseLeaveWindow)
                        {
                            flag = true;
                            if (this.SendEventToIMGUIContainers(panel.visualTree, e, null) == EventPropagation.Stop)
                            {
                                result = EventPropagation.Stop;
                                return(result);
                            }
                        }
                    }
                    if (e.type == EventType.ExecuteCommand || e.type == EventType.ValidateCommand)
                    {
                        flag = true;
                        if (panel.focusedElement != null && this.PropagateEvent(panel.focusedElement, e) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                        if (this.SendEventToIMGUIContainers(panel.visualTree, e, panel.focusedElement) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    if (e.type == EventType.Used)
                    {
                        flag = true;
                        if (this.SendEventToIMGUIContainers(panel.visualTree, e, null) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    if (!flag)
                    {
                        if (this.SendEventToIMGUIContainers(panel.visualTree, e, null) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    result = EventPropagation.Continue;
                }
            }
            return(result);
        }
Esempio n. 22
0
 public IManipulatorObject(IManipulator IManipulatorinstance)
 {
     IManipulatorInstance = IManipulatorinstance;
 }
Esempio n. 23
0
 /// <summary>
 /// Sets the manipulator (same as the Manipulator property) and its corresponding SceneNode</summary>
 /// <param name="manipulator">Manipulator to set</param>
 /// <param name="manipulatorNode">SceneNode to set</param>
 /// <param name="parentToWorld">Transform of the manipulator's parent's coordinate system to the world coordinate system</param>
 public void SetManipulatorNode(IManipulator manipulator, SceneNode manipulatorNode, Matrix4F parentToWorld)
 {
     m_manipulator = manipulator;
     m_manipulatorNode = manipulatorNode;
     m_manipulatorParentToWorld = parentToWorld;
 }
Esempio n. 24
0
        public static IObservableList <TIn, TOut> FromIn(IEnumerable <TIn> values = null, string name = null, IManipulator <TIn, TOut> manipulator = null, object meta = null)
        {
            var list = new ObservableList <TIn, TOut>(name, manipulator, meta);

            if (values != null)
            {
                var previous = Actions.AllowStateChangesStart(true);

                list.SpliceWithIn(0, 0, values.ToArray());

                Actions.AllowStateChangesEnd(previous);
            }

            return(list);
        }
Esempio n. 25
0
 protected ObservableList(string name, IManipulator <T, T> manipulator = null) : base(name, manipulator)
 {
 }
Esempio n. 26
0
 public CommandManager(IGameCreator creator, IManipulator manipulator, ICommandHistory history)
 {
     _gameCreator = creator;
     _manipulator = manipulator;
     _history     = history;
 }
Esempio n. 27
0
        internal void AddManipulator(IManipulator manipulator)
        {
            Debug.Assert(manipulator != null);
            VerifyAccess();
            _manipulationEnded = false;

            if (_manipulators == null)
            {
                _manipulators = new List<IManipulator>(2);
            }

            _manipulators.Add(manipulator);
            manipulator.Updated += OnManipulatorUpdated;

            // Adding a manipulator counts as an update
            OnManipulatorUpdated(manipulator, EventArgs.Empty);
        }
Esempio n. 28
0
 private void SetManipulator(IManipulator manipulator, HitRecord[] hits)
 {
     s_isManipulating = true;
     m_manipulatorHitRecords = hits;
 }
 public static void RemoveManipulator(System.Windows.UIElement element, IManipulator manipulator)
 {
 }
Esempio n. 30
0
        private EventPropagation PropagateEvent(VisualElement target, Event evt)
        {
            List <VisualElement> list      = this.BuildPropagationPath(target);
            Vector2          mousePosition = evt.mousePosition;
            EventPropagation result;

            for (int i = 0; i < list.Count; i++)
            {
                VisualElement visualElement = list[i];
                if (visualElement.enabled)
                {
                    evt.mousePosition = visualElement.GlobalToBound(mousePosition);
                    List <IManipulator> .Enumerator manipulatorsInternal = visualElement.GetManipulatorsInternal();
                    while (manipulatorsInternal.MoveNext())
                    {
                        IManipulator current = manipulatorsInternal.Current;
                        if (current.phaseInterest == EventPhase.Capture && current.HandleEvent(evt, target) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                    if (visualElement.phaseInterest != EventPhase.Capture || visualElement.HandleEvent(evt, target) != EventPropagation.Stop)
                    {
                        goto IL_A2;
                    }
                    result = EventPropagation.Stop;
                    return(result);
                }
                IL_A2 :;
            }
            if (target.enabled)
            {
                evt.mousePosition = target.GlobalToBound(mousePosition);
                List <IManipulator> .Enumerator manipulatorsInternal2 = target.GetManipulatorsInternal();
                while (manipulatorsInternal2.MoveNext())
                {
                    IManipulator current2 = manipulatorsInternal2.Current;
                    if (current2.phaseInterest == EventPhase.Capture && current2.HandleEvent(evt, target) == EventPropagation.Stop)
                    {
                        result = EventPropagation.Stop;
                        return(result);
                    }
                }
                if (target.HandleEvent(evt, target) == EventPropagation.Stop)
                {
                    result = EventPropagation.Stop;
                    return(result);
                }
                manipulatorsInternal2 = target.GetManipulatorsInternal();
                while (manipulatorsInternal2.MoveNext())
                {
                    IManipulator current3 = manipulatorsInternal2.Current;
                    if (current3.phaseInterest == EventPhase.BubbleUp && current3.HandleEvent(evt, target) == EventPropagation.Stop)
                    {
                        result = EventPropagation.Stop;
                        return(result);
                    }
                }
            }
            for (int j = list.Count - 1; j >= 0; j--)
            {
                VisualElement visualElement2 = list[j];
                if (visualElement2.enabled)
                {
                    evt.mousePosition = visualElement2.GlobalToBound(mousePosition);
                    if (visualElement2.phaseInterest == EventPhase.BubbleUp && visualElement2.HandleEvent(evt, target) == EventPropagation.Stop)
                    {
                        result = EventPropagation.Stop;
                        return(result);
                    }
                    List <IManipulator> .Enumerator manipulatorsInternal3 = visualElement2.GetManipulatorsInternal();
                    while (manipulatorsInternal3.MoveNext())
                    {
                        IManipulator current4 = manipulatorsInternal3.Current;
                        if (current4.phaseInterest == EventPhase.BubbleUp && current4.HandleEvent(evt, target) == EventPropagation.Stop)
                        {
                            result = EventPropagation.Stop;
                            return(result);
                        }
                    }
                }
            }
            result = EventPropagation.Continue;
            return(result);
        }
 public static void RemoveManipulator(System.Windows.UIElement element, IManipulator manipulator)
 {
 }
Esempio n. 32
0
 /// <summary>
 /// Sets the manipulator (same as the Manipulator property) and its corresponding SceneNode</summary>
 /// <param name="manipulator">Manipulator to set</param>
 /// <param name="manipulatorNode">SceneNode to set</param>
 /// <param name="parentToWorld">Transform of the manipulator's parent's coordinate system to the world coordinate system</param>
 public void SetManipulatorNode(IManipulator manipulator, SceneNode manipulatorNode, Matrix4F parentToWorld)
 {
     m_manipulator              = manipulator;
     m_manipulatorNode          = manipulatorNode;
     m_manipulatorParentToWorld = parentToWorld;
 }
Esempio n. 33
0
 public SMSCore(IManipulator manipulator)
 {
     _manipulator = manipulator;
 }
Esempio n. 34
0
        /// <summary>
        /// Raises the MouseMove event</summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (CanvasControl3D.ControlScheme.IsControllingCamera(ModifierKeys, e) == false &&
                m_manipulator != null)
            {
                // If we're actively dragging a manipulator, then handle that.
                if (m_manipulatorHitRecords != null)
                {
                    int   width  = base.Width;
                    int   height = base.Height;
                    float x      = (float)e.X / (float)width - 0.5f;
                    float y      = 1.0f - ((float)e.Y / (float)height) - 0.5f;

                    try
                    {
                        // Push render state
                        m_scene.StateStack.Push(m_renderState);
                        m_manipulator.OnDrag(m_manipulatorHitRecords, x, y, m_pickAction, m_renderAction, Camera, m_context);
                        m_scene.StateStack.Pop();

                        OnManipulatorUpdate(new ManipulatorEventArgs(m_manipulator));

                        // Redraw
                        Refresh();
                    }
                    catch (Exception ex)
                    {
                        Clear();
                        MessageBox.Show(this, ex.Message,
                                        "Error".Localize("title of a dialog box that displays information about an error that has occurred"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                //Otherwise, since we know a manipulator is active (m_manipulator is not null), see if
                // the user has moved the cursor over it.
                else
                {
                    HitRecord[] hits;

                    IManipulator manipulator = TestForManipulator(e.X, e.Y, out hits);
                    if (manipulator != null)
                    {
                        if (m_lastCursor == null)
                        {
                            m_lastCursor = Cursor;
                            Cursor       = Cursors.SizeAll;
                        }
                    }
                    else
                    {
                        if (m_lastCursor != null)
                        {
                            Cursor       = m_lastCursor;
                            m_lastCursor = null;
                        }
                    }
                    base.OnMouseMove(e);
                }
            }
            else
            {
                base.OnMouseMove(e);
            }
        }
Esempio n. 35
0
        /// <summary>
        ///     Associates a manipulator with a UIElement. This will either will start an 
        ///     active manipulation or add to an existing one. 
        /// </summary>
        /// <param name="element">The element with which to associate the manipulator.</param> 
        /// <param name="manipulator">The manipulator, such as a TouchDevice.</param>
        public static void AddManipulator(UIElement element, IManipulator manipulator)
        {
            if (element == null) 
            {
                throw new ArgumentNullException("element"); 
            } 
            if (manipulator == null)
            { 
                throw new ArgumentNullException("manipulator");
            }
            if (!element.IsManipulationEnabled)
            { 
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotEnabled));
            } 
 
            ManipulationDevice device = ManipulationDevice.AddManipulationDevice(element);
            device.AddManipulator(manipulator); 
        }
Esempio n. 36
0
 /// <summary>
 /// Sets the game audio source
 /// </summary>
 /// <param name="source">Manipulator instance</param>
 public void SetSource(IManipulator source)
 {
     this.source = source;
 }
Esempio n. 37
0
        /// <summary>
        ///     Disassociates a manipulator with a UIElement. This will remove it from 
        ///     an active manipulation, possibly completing it.
        /// </summary> 
        /// <param name="element">The element that the manipulator used to be associated with.</param> 
        /// <param name="manipulator">The manipulator, such as a TouchDevice.</param>
        public static void RemoveManipulator(UIElement element, IManipulator manipulator) 
        {
            if (element == null)
            {
                throw new ArgumentNullException("element"); 
            }
            if (manipulator == null) 
            { 
                throw new ArgumentNullException("manipulator");
            } 

            if (!TryRemoveManipulator(element, manipulator))
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotActive)); 
            }
        } 
Esempio n. 38
0
 public StartGameCommand(IGameCreator gameCreator, IManipulator manipulator, GameSettings gameSettings)
 {
     _gameCreator  = gameCreator;
     _manipulator  = manipulator;
     _gameSettings = gameSettings;
 }
Esempio n. 39
0
 public BoardWorker(IManipulator manipulator, ICommandHistory history)
 {
     _manipulator = manipulator;
     _history     = history;
 }