コード例 #1
0
        public bool MouseMove(MouseEventArgs e)
        {
            Control controlBase = this.ControlBase;

            if (!this.m_DragActive && this.MouseDownControl != null)
            {
                if (controlBase != null)
                {
                    controlBase.Cursor = this.MouseDownControl.GetMouseCursor(e);
                }
                this.MouseDownControl.MouseMove(e);
                this.ControlBase.UIInvalidate(this);
            }
            else
            {
                IUIInput uIInputControl = this.GetUIInputControl(e);
                if (uIInputControl != null)
                {
                    if (controlBase != null)
                    {
                        controlBase.Cursor = uIInputControl.GetMouseCursor(e);
                    }
                    uIInputControl.MouseMove(e);
                    return(true);
                }
                controlBase.Cursor = Cursors.Default;
            }
            return(false);
        }
コード例 #2
0
        private IUIInput GetUIInputControl(MouseEventArgs e)
        {
            IUIInput iUIInput  = null;
            IUIInput iUIInput2 = null;
            int      num       = 2147483647;

            for (int i = 0; i < this.Count; i++)
            {
                IUIInput iUIInput3 = this[i];
                if (iUIInput3 != null && iUIInput3.Enabled && iUIInput3.HitVisible && iUIInput3.HitTest(e))
                {
                    int num2 = iUIInput3.Bounds.Width * iUIInput3.Bounds.Height;
                    if (num2 < num)
                    {
                        if (iUIInput3.GetType() == this.NoHitDefaultType)
                        {
                            iUIInput2 = iUIInput3;
                        }
                        else
                        {
                            num      = num2;
                            iUIInput = iUIInput3;
                        }
                    }
                }
            }
            if (iUIInput == null)
            {
                iUIInput = iUIInput2;
            }
            return(iUIInput);
        }
コード例 #3
0
        public override void CreateUIElement()
        {
            XamTabControl tab = new XamTabControl();

            tab.MinHeight = Convert.ToDouble(Input.GetInput("MinHeight", 100));
            tab.MinWidth  = Convert.ToDouble(Input.GetInput("MinWidth", 400));
            tab.MaxHeight = Convert.ToDouble(Input.GetInput("MaxHeight", 500));
            tab.MaxWidth  = Convert.ToDouble(Input.GetInput("MaxWidth", 1000));

            int n = GetControlCount();

            for (int i = 0; i < n; i++)
            {
                //Get the control
                IUIControl control = GetControl(i);
                IUIInput   param   = control.Input;

                //Create the tab item
                TabItemEx item         = new TabItemEx();
                string    defaultTitle = (string)param.GetInput("Description", "Item-" + (i + 1).ToString());
                item.Header  = (string)param.GetInput("title", defaultTitle);
                item.Content = control.GetUIElement();

                //Add the tab item to the tab control
                tab.Items.Add(item);
            }

            UtilityMethods.SetPanelResources(tab);
            UIElement = tab;
        }
コード例 #4
0
        public void SetFocus(IUIInput value)
        {
            if (this.FocusControl != null && this.FocusControl != value)
            {
                LostFocusEventArgs lostFocusEventArgs = new LostFocusEventArgs(value);
                if (this.Focused)
                {
                    this.FocusControl.LostFocus(lostFocusEventArgs);
                }
                if (!lostFocusEventArgs.Cancel)
                {
                    this.FocusControl.IsMouseDown   = false;
                    this.FocusControl.IsMouseActive = false;
                    this.FocusControl.IsKeyDown     = false;
                    this.FocusControl.IsKeyActive   = false;
                    goto IL_0065;
                }
                return;
            }
            goto IL_0065;
IL_0065:
            this.m_FocusControl = value;
            if (!this.ControlBase.Focused)
            {
                this.Focus();
            }
            else
            {
                this.FocusControl.GotFocus(EventArgs.Empty);
                this.ControlBase.UIInvalidate(this);
            }
        }
コード例 #5
0
        public override void SetInput(IUIInput input)
        {
            base.SetInput(input);

            localChange = false;

            sliderType = (string)Input.GetInput("sliderType", "float");

            min = Input.HasParameter("min") ? Convert.ToSingle(Input.GetInput("min")) : 0f;

            max = Input.HasParameter("max") ? Convert.ToSingle(Input.GetInput("max")) : 100f;

            labels = (Hashtable)Input.GetInput("labelTable", new Hashtable());

            if (Input.HasParameter("leftLabel") && Input.HasParameter("rightLabel"))
            {
                labels.Add(0, (string)Input.GetInput("leftLabel"));
                labels.Add(100, (string)Input.GetInput("rightLabel"));
            }

            allowText = (bool)Input.GetInput("allowTextBox", false);

            float defaultWidth = allowText ? 2 : 3;

            width = Input.HasParameter("width") ? Convert.ToSingle(Input.GetInput("width")) : defaultWidth;

            tickSpace = (int)Input.GetInput("tickSpace", 25);

            adjustMinMax = (bool)Input.GetInput("adjustMinMax", false);

            showAbsolute = (bool)Input.GetInput("showAbsolute", true);
        }
コード例 #6
0
        private bool dragStart(ParameterDic pm, IUIInput input, string mode)
        {
            ISupportDrag isd = pm.GetValue <ISupportDrag>(DragSourceKey);

            if (pm.GetValue <string>(DragDropModeKey) == null && isd != null)
            {
                var         draggables = isd.GetDraggables();
                IDataObject dataObj    = isd is ISupportShellDrag ?
                                         (isd as ISupportShellDrag).GetDataObject(draggables) : null;
                DragDropEffectsEx effect = isd.QueryDrag(draggables);

                pm.SetValue(DragDropModeKey, mode);
                pm.SetValue(DragDropDeviceKey, input.InputType);
                pm.SetValue(DragDropDraggingItemsKey, draggables);
                pm.SetValue(DragDropEffectsKey, effect);
                pm.SetValue(DragDropDragSourceKey, isd);
                pm.SetValue(ParameterDic.CombineVariable(DragDropDragSourceKey, ".IsDraggingFrom", false), true);
                pm.SetValue(DragDropStartPositionKey, pm.GetValue <Point>(CurrentPositionAdjustedKey));
                pm.SetValue(InputKey, new DragInput(input, dataObj, DragDropEffectsEx.Copy, (eff) => { }));

                return(true);
            }

            return(false);
        }
コード例 #7
0
        public void BindInputController(IUIInput controller)
        {
            m_UserInput.Shoot.DownTrigger
            .OnPointerDownAsObservable()
            .Subscribe(_ => m_Shoot.Value = true);
            m_UserInput.Shoot.UpTrigger
            .OnPointerUpAsObservable()
            .Subscribe(_ => m_Shoot.Value = false);
            m_UserInput.Left.DownTrigger
            .OnPointerDownAsObservable()
            .Subscribe(_ => m_Move.Value = -1f);
            m_UserInput.Left.UpTrigger
            .OnPointerUpAsObservable()
            .Where(_ => m_Move.Value == -1f)
            .Subscribe(_ => m_Move.Value = 0f);
            m_UserInput.Right.DownTrigger
            .OnPointerDownAsObservable()
            .Subscribe(_ => m_Move.Value = 1f);
            m_UserInput.Right.UpTrigger
            .OnPointerUpAsObservable()
            .Where(_ => m_Move.Value == 1f)
            .Subscribe(_ => m_Move.Value = 0f);

            controller.SetUIMovementProperty(m_Move);
            controller.SetUIShootProperty(m_Shoot);
        }
コード例 #8
0
        /// <summary>
        /// Initializes the ControlList with the value of "controls" parameter in the Input.
        /// </summary>
        /// <param name="input"></param>
        public override void SetInput(IUIInput input)
        {
            base.SetInput(input);

            if (Input.HasParameter("controls"))
            {
                ControlList = new List <object>();

                IList <object> list = Input.GetInput("controls") as IList <object>;

                foreach (object control in list)
                {
                    if (control is IDictionary)
                    {
                        ControlList.Add(OmegaFactory.CreateControl(control as IDictionary <string, object>));
                    }
                    else if (control is IUIControl)
                    {
                        ControlList.Add(control);
                    }
                    else
                    {
                        throw new Exception(control + "is not a control");
                    }
                }
            }
        }
コード例 #9
0
        public void UpdateInputPosition(IUIInput input)
        {
            if (_dragState == DragState.Touched && input.EventArgs is TouchEventArgs)
            {
                if (DateTime.UtcNow.Subtract(_touchTime).TotalMilliseconds >= Defaults.MaximumTouchHoldInterval)
                {
                    var rect = (input.EventArgs as TouchEventArgs).GetTouchPoint(null).Size;
                    if ((input as TouchInput).IsDragThresholdReached(_startTouchInput as TouchInput))
                    {
                        StartInput = _startTouchInput;
                        _dragState = DragState.Pressed;
                        //_touchTime = DateTime.MinValue;
                        //_isDragging = true;
                        //DragStartedFunc(input);
                    }
                    else
                    {
                        _touchTime = DateTime.MinValue;
                        _dragState = DragState.Normal;
                    }
                }
            }



            //Console.WriteLine(String.Format("UpdateInputPosition - {0}", _dragState));
            if (_dragState == DragState.Pressed && input.IsDragThresholdReached(_startInput))
            {
                _dragState  = DragState.Dragging;
                _isDragging = true;
                DragStartedFunc(input);
            }
        }
コード例 #10
0
 public override void Update(ref IUIInput input)
 {
     if (input.EventArgs is MouseButtonEventArgs)
     {
         input.ClickCount = (input.EventArgs as MouseButtonEventArgs).ClickCount;
     }
     else
     if (input.InputType == UIInputType.Touch && input.InputState == UIInputState.Pressed)
     {
         //touchPts.First().Action == TouchAction.
         if (DateTime.UtcNow.Subtract(_lastClickTime).TotalMilliseconds <
             Defaults.MaximumClickInterval &&
             input.IsWithin(_startInput, Defaults.MaximumTouchClickDragDistance.X,
                            Defaults.MaximumTouchClickDragDistance.Y))
         {
             _clickCount     += 1;
             input.ClickCount = _clickCount;
         }
         else
         {
             _startInput = input;
             _clickCount = 1;
         }
         _lastClickTime = DateTime.UtcNow;
     }
     //else _clickCount = 0;
 }
コード例 #11
0
 public bool GetIsFocused(IUIInput value)
 {
     if (!this.Focused)
     {
         return(false);
     }
     return(value == this.FocusControl);
 }
コード例 #12
0
        public DragInput(IUIInput sourceInput)
        {
            _sourceInput = sourceInput;
            var eventArgs = sourceInput.EventArgs as DragEventArgs;

            _relPositionFunc = relTo => eventArgs.GetPosition(relTo);
            _position        = _relPositionFunc(sourceInput.Sender as IInputElement);
            init(eventArgs.Data, (DragDropEffectsEx)eventArgs.AllowedEffects, (eff) => { eventArgs.Effects = (DragDropEffects)eff; });
        }
コード例 #13
0
 public int Add(IUIInput value)
 {
     value.UICollection  = this;
     value.IsMouseDown   = false;
     value.IsMouseActive = false;
     value.IsKeyDown     = false;
     value.IsKeyActive   = false;
     return(this.m_List.Add(value));
 }
コード例 #14
0
 public void Clear()
 {
     foreach (IUIInput item in this.m_List)
     {
         item.UICollection = null;
     }
     this.m_List.Clear();
     this.m_FocusControl = null;
 }
コード例 #15
0
        public override void Update(ref IUIInput input)
        {
            if (input.InputType == UIInputType.Touch && input.InputState != UIInputState.NotApplied)
            {
                _touchState = input.InputState;
            }

            input.Touch = _touchState;
        }
コード例 #16
0
 public void Update(ref IUIInput input)
 {
     foreach (var p in Processors)
     {
         if (p.ProcessAllEvents || p.ProcessEvents.Contains(input.EventArgs.RoutedEvent))
         {
             p.Update(ref input);
         }
     }
 }
コード例 #17
0
    // Use this for initialization
    public DebugInputSystem()
    {
        Debug.Log("<b><color=red>------------ DEBUG INPUT ENABLED ---------------</color></b>");

        inputCentre = Vector2.zero;
        inputRadius = 75f;

        trickQueue = new TrickQueue(90);
        ui         = new UIDebugInput();
    }
コード例 #18
0
    // Use this for initialization
    public MobileInputSystem()
    {
        //parsedInput = new Queue<int>();
        //for (int i = 0; i < 90; i++) parsedInput.Enqueue(0); // fill queue with 0
        inputCentre = Vector2.zero;
        inputRadius = 75f;

        trickQueue = new TrickQueue(90);
        ui         = new UIMobileInput();
    }
コード例 #19
0
 public static void Update(this IEnumerable <IUIInputProcessor> processors, ref IUIInput input)
 {
     foreach (var p in processors)
     {
         if (p.ProcessAllEvents || p.ProcessEvents.Contains(input.EventArgs.RoutedEvent))
         {
             p.Update(ref input);
         }
     }
 }
コード例 #20
0
 public static TouchGesture GetTouchGesture(this IUIInput input)
 {
     if (input.InputType == UIInputType.Touch)
     {
         return(new TouchGesture(input.InputState, input.TouchGesture));
     }
     else
     {
         return(new TouchGesture(UIInputState.NotApplied, UITouchGesture.NotApplied));
     }
 }
コード例 #21
0
        public override void Update(ref IUIInput input)
        {
            var touchEventArgs = input.EventArgs as TouchEventArgs;

            if (touchEventArgs != null)
            {
                var touchPts   = touchEventArgs.GetIntermediateTouchPoints(input.Sender as IInputElement);
                var touchInput = String.Join("", touchPts.Select(tp => tp.Action.ToString()[0]));
                //Console.WriteLine(touchInput);
            }
        }
コード例 #22
0
        public static bool IsWithin(this IUIInput input, IUIInput input2, double x, double y)
        {
            return
                (input.IsSameSource(input2) && input.IsValidPositionForLisView(true) &&

                 (
                     Math.Abs(input.Position.X - input2.Position.X) < x &&
                     Math.Abs(input.Position.Y - input2.Position.Y) < y
                 )
                );
        }
コード例 #23
0
        public static bool IsDragThresholdReached(this IUIInput input, IUIInput input2)
        {
            var minDragDist = getMiniumDragDistance(input.InputType);

            return
                (input.IsSameSource(input2) && input.IsValidPositionForLisView(true) &&
                 (
                     Math.Abs(input.Position.X - input2.Position.X) > minDragDist.Width ||
                     Math.Abs(input.Position.Y - input2.Position.Y) > minDragDist.Height
                 ));
        }
コード例 #24
0
 /// <summary>
 /// Set the parameters of the UIElement
 /// </summary>
 /// <param name="valuePairs"></param>
 public override void SetInput(IUIInput input) // IUIInput
 {
     base.SetInput(input);
     if (Input.HasParameter("min"))
     {
         min = float.Parse(input.GetInput("min").ToString());
     }
     if (Input.HasParameter("max"))
     {
         max = float.Parse(input.GetInput("max").ToString());
     }
 }
コード例 #25
0
        protected override IScriptCommand executeInner(ParameterDic pm, ItemsControl ic,
                                                       RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            Point         posRelToScp    = pm.GetValue <Point>(CurrentRelativePositionKey);
            var           startSelected  = UIEventHubProperties.GetStartSelectedItem(ic);
            List <object> selectedList   = new List <object>();
            List <int>    selectedIdList = new List <int>();
            var           scp            = ControlUtils.GetScrollContentPresenter(ic);

            var currentSelected = UITools.GetSelectedListBoxItem(scp, posRelToScp);

            if (startSelected != null && currentSelected != null)
            {
                int startIdx = ic.ItemContainerGenerator.IndexFromContainer(startSelected);
                int endIdx   = ic.ItemContainerGenerator.IndexFromContainer(currentSelected);

                for (int i = Math.Min(startIdx, endIdx); i <= Math.Max(startIdx, endIdx); i++)
                {
                    selectedList.Add(ic.Items[i]);
                    selectedIdList.Add(i);
                }
            }

            //UpdateStartSelectedItems, or clear it if no longer selecting.
            if (UIEventHubProperties.GetIsSelecting(ic))
            {
                if (UIEventHubProperties.GetStartSelectedItem(ic) == null)
                {
                    var itemUnderMouse = UITools.GetSelectedListBoxItem(scp, posRelToScp);
                    UIEventHubProperties.SetStartSelectedItem(ic, itemUnderMouse);
                }
            }
            else
            {
                UIEventHubProperties.SetStartSelectedItem(ic, null);
            }

            if (UIEventHubProperties.GetIsSelecting(ic))
            {
                if (UIEventHubProperties.GetStartSelectedItem(ic) == null)
                {
                    UITools.SetItemUnderMouseToAttachedProperty(ic, posRelToScp,
                                                                UIEventHubProperties.StartSelectedItemProperty);
                }
            }

            pm.SetValue(SelectedListKey, selectedList);
            pm.SetValue(SelectedIdListKey, selectedIdList);
            logger.Debug(String.Format("Selected = {0}", selectedIdList.Count()));
            return(NextCommand);
        }
コード例 #26
0
        public void UpdatInputReleased(IUIInput input)
        {
            //Console.WriteLine("UpdatInputReleased -" + input.ToString());
            if (input.IsSameSource(_startInput))
            {
                if (_isDragging && _dragState == DragState.Dragging)
                {
                    DragStoppedFunc(input);
                }
                _isDragging = false;
                _dragState  = DragState.Released;
            }

            //Console.WriteLine(String.Format("UpdatInputReleased - {0}", _dragState));
        }
コード例 #27
0
        public void MouseRight(MouseEventArgs e)
        {
            this.Focus();
            IUIInput uIInputControl = this.GetUIInputControl(e);

            if (uIInputControl != null)
            {
                uIInputControl.IsMouseDown   = false;
                uIInputControl.IsMouseActive = false;
                uIInputControl.IsKeyDown     = false;
                uIInputControl.IsKeyActive   = false;
                uIInputControl.MouseRight(e);
            }
            this.ControlBase.UIInvalidate(this);
        }
コード例 #28
0
        public static bool IsValidPositionForLisView(this IUIInput input, bool validIfNotListView = false)
        {
            var sender = input.Sender as ListView;

            if (sender == null)
            {
                return(validIfNotListView);
            }
            var originalSource = input.EventArgs.OriginalSource as DependencyObject;

            if (sender == null)
            {
                return(false);
            }
            var scp = ControlUtils.GetScrollContentPresenter(sender);

            var lvo  = UITools.FindAncestor <ListView>(originalSource);
            var scpo = originalSource == sender ? scp :
                       UITools.FindAncestor <ScrollContentPresenter>(originalSource);

            //Make sure return false for ContextMenu items
            if (lvo == null)
            {
                return(false);
            }

            //This is for handling user click in empty area of a panel.
            bool isOverScrollViewer = (originalSource is ScrollViewer) && scpo == null && lvo == sender;

            if (scp == null ||
                //ListViewEx contains Top/RightContent, allow placing other controls in it, this is to avoid that)
                //scp of event listener (the main ListView) is not equals to scp of event source
                (!scp.Equals(scpo) && !isOverScrollViewer))
            {
                return(false);
            }


            bool isOverGridViewHeader = UITools.FindAncestor <GridViewColumnHeader>(originalSource) != null;
            bool isOverScrollBar      = UITools.FindAncestor <ScrollBar>(originalSource) != null;

            if (isOverGridViewHeader || isOverScrollBar)
            {
                return(false);
            }

            return(true);
        }
コード例 #29
0
        public void UpdateInputPressed(IUIInput input)
        {
            if (_dragState == DragState.Released)
            {
                StartInput = InvalidInput.Instance;
                _dragState = DragState.Normal;
            }

            if (!_isDragging && input.IsValidPositionForLisView(true))
            {
                if (input.ClickCount <= 1) //Touch/Stylus input 's ClickCount = 0
                {
                    //When touch and hold it raise a mouse right click command, skip it.
                    if (_dragState == DragState.Touched && input.InputType == UIInputType.MouseRight)
                    {
                        return;
                    }
                    //Console.WriteLine(input);
                    StartInput  = input;
                    _isDragging = false;
                    switch (input.InputType)
                    {
                    case UIInputType.Touch:
                        _startTouchInput = input;
                        _dragState       = DragState.Touched;
                        _touchTime       = DateTime.UtcNow;
                        //input.EventArgs.Handled = true;
                        break;

                    default:
                        switch (_dragState)
                        {
                        case DragState.Touched:
                            break;

                        case DragState.Normal:
                        case DragState.Released:
                            IsDragging = false;
                            _dragState = DragState.Pressed;
                            break;
                        }

                        break;
                    }
                }
            }
            //Console.WriteLine(String.Format("UpdateInputPressed - {0}", _dragState));
        }
コード例 #30
0
        public override Script.IScriptCommand Execute(ParameterDic pm)
        {
            IList <IUIInputProcessor> inpProcs = pm.GetValue <IList <IUIInputProcessor> >(InputProcessorsKey);
            var      processor = inpProcs.First(p => p is TouchDragMoveCountInputProcessor) as TouchDragMoveCountInputProcessor;
            IUIInput input     = pm.GetValue <IUIInput>(InputKey);

            if (input.InputType != Defines.UIInputType.Touch || processor.DragMoveCount % Divider == 0)
            {
                return(NextCommand);
            }

            else
            {
                return(OtherwiseCommand);
            }
        }