protected override IScriptCommand executeInner(ParameterDic pm, UIElement sender, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            Point position = input.Position;

            //Console.WriteLine(input.IsDragging.ToString() +  position.ToString());
            switch (PositionRelativeTo)
            {
            case PositionRelativeToType.Sender:
                position = input.PositionRelativeTo(sender);
                break;

            case PositionRelativeToType.Scp:
                var scp = ControlUtils.GetScrollContentPresenter(sender is Control ? (Control)sender : UITools.FindAncestor <Control>(sender));
                position = input.PositionRelativeTo(scp);
                break;

            case PositionRelativeToType.Panel:
                var parentPanel = UITools.FindAncestor <Panel>(sender);
                position = input.PositionRelativeTo(parentPanel);
                break;

            case PositionRelativeToType.Window:
                var parentWindow = Window.GetWindow(sender);
                position = input.PositionRelativeTo(parentWindow);
                break;
            }

            //Console.WriteLine(position);
            return(ScriptCommands.Assign(DestinationKey, position, SkipIfExists, NextCommand));
        }
        protected override IScriptCommand executeInner(ParameterDic pm, ItemsControl ic, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var scp = ControlUtils.GetScrollContentPresenter(ic);

            if (!ic.IsKeyboardFocusWithin)
            {
                var itemUnderMouse = UITools.GetItemUnderMouse(ic, input.PositionRelativeTo(scp));

                if ((itemUnderMouse is ListBoxItem && (itemUnderMouse as ListBoxItem).IsSelected) ||
                    (itemUnderMouse is TreeViewItem && (itemUnderMouse as TreeViewItem).IsSelected))
                {
                    ic.Focus();
                    evnt.Handled = true;
                    logger.Debug("Set");
                }
            }

            return(NextCommand);
        }
Пример #3
0
        protected override IScriptCommand executeInner(ParameterDic pm, FrameworkElement ele,
                                                       RoutedEventArgs eventArgs, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var scp            = ControlUtils.GetScrollContentPresenter(ele is Control ? (Control)ele : UITools.FindAncestor <Control>(ele));
            var scpRelativePos = scp == null ? new Point(0, 0) : scp.TranslatePoint(new Point(0, 0), ele);
            var gvhrp          = UITools.FindVisualChild <GridViewHeaderRowPresenter>(ele);

            DragInputProcessor dragInpProc = inpProcs.Where(p => p is DragInputProcessor).Cast <DragInputProcessor>().First();

            var startPos            = AdjustHeaderPosition(dragInpProc.StartInput.Position, pm, scpRelativePos, -1);
            var startScrollbarPos   = dragInpProc.StartInput.ScrollBarPosition;
            var currentPos          = AdjustHeaderPosition(input.Position, pm, scpRelativePos, -1);
            var currentRelativePos  = input.PositionRelativeTo(scp);
            var currentScrollbarPos = input.ScrollBarPosition;
            var startAdjustedPos    = add(startPos, startScrollbarPos);
            var currentAdjustedPos  = add(currentPos, currentScrollbarPos);

            //var startVisualPos = AdjustScrollBarPosition(startPos, //for used in visual only.
            //    startScrollbarPos, currentScrollbarPos);

            pm.SetValue(StartPositionKey, startPos);
            pm.SetValue(StartScrollbarPositionKey, startScrollbarPos);
            pm.SetValue(StartPositionAdjustedKey, startAdjustedPos);

            pm.SetValue(CurrentPositionKey, currentPos);
            pm.SetValue(CurrentScrollbarPositionKey, currentPos);
            pm.SetValue(CurrentRelativePositionKey, currentRelativePos);
            pm.SetValue(CurrentPositionAdjustedKey, currentAdjustedPos);

            pm.SetValue(SelectionBoundKey, new Rect(startPos, currentPos));
            pm.SetValue(SelectionBoundAdjustedKey, new Rect(startAdjustedPos,
                                                            currentAdjustedPos));

            logger.Debug(String.Format("{0}", new Rect(startPos, currentPos)));

            return(_nextCommand);
        }
Пример #4
0
 /// <summary>
 /// Cursor position relative to inputElement.
 /// </summary>
 /// <param name="inputElement"></param>
 /// <returns></returns>
 public static Point PositionRelativeTo(this IUIInput input, IInputElement inputElement,
                                        Func <Point, Point> adjustFunc)
 {
     return(adjustFunc(input.PositionRelativeTo(inputElement)));
 }