Beispiel #1
0
        protected override void OnParentMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            _startPoint = e.GetPosition(this);
            _lastPoint  = _startPoint;

            if (!BlockConverter.CanConvert(PointOutBlock))
            {
                return;
            }

            _canMove = PointOutBlock != null && !BlockConverter.GetLocked(PointOutBlock);

            if (_canMove)
            {
                StartMouseMovementTracking();
                var date    = AxisXConverter.ScreenToData(0);
                var newDate = date.Add(StepMin);
                _stepMinDistance = AxisXConverter.DataToScreen(newDate);
            }
        }
Beispiel #2
0
        public override void Initialize()
        {
            base.Initialize();
            _startTime        = AxisXConverter.ScreenToData(Math.Min(0, -AxisPanel.HorizontalOffset));//AxisXConverter.ViewportToData(0);
            _enquiryStartTime = _startTime.AddDays(Global.HeadDayAmount);

            base.OnLoaded();
        }
Beispiel #3
0
        protected override double GetCellInterval()
        {
            var dateTime  = AxisXConverter.ScreenToData(0);
            var hourWidth = AxisXConverter.DataToScreen(dateTime.AddHours(1));

            //每个小时的长度除以PerHourCount;
            return(hourWidth / PerHourCount);
        }
Beispiel #4
0
        protected override int GetStartIndex(double xTransform)
        {
            //得到相对于大容器的位置
            //var startTime = AxisXConverter.ScreenToData(-AxisPanel.HorizontalOffset);//AxisXConverter.ViewportToScreen(0)
            //var screenTime = AxisXConverter.ScreenToData(xTransform);
            // index = screenTime.Subtract(startTime).TotalHours * PerHourCount;
            var screenStartTime = AxisXConverter.ScreenToData(0);

            return((int)(screenStartTime.Subtract(_enquiryStartTime).TotalMinutes / 15));

            //return (int)index;)
            return(0);
        }
Beispiel #5
0
        protected void MouseMoving(Point point)
        {
            //if(_startPoint == null || _lastPoint == null)
            //{
            //    return;
            //}


            var distance = point.X - (_startPoint == null ? 0 : _startPoint.Value.X);

            _lastPoint = new Point(point.X - distance % _stepMinDistance, point.Y); // do not modify 每格移动,减去不到标准距离的值

            //Henry modified
            MoveSpan        = AxisXConverter.ScreenToData(GetMoveOffSet()).Subtract(AxisXConverter.ScreenToData(0)); // was => NotifyBlocknewPositionInfoList();
            DropedPlacement = new TimeRange(PointOutBlock.Start.Add(MoveSpan).AddSeconds(0.1), PointOutBlock.End.Add(MoveSpan).AddSeconds(0.1));
            _isMoving       = true;
        }
Beispiel #6
0
        protected override void OnParentDragOver(DragEventArgs e)
        {
            _isDragLeave = false;

            var point = e.GetPosition(this);

            if (_startPoint == null || _startPoint.Value.X < 0)
            {
                var date    = AxisXConverter.ScreenToData(0);
                var newDate = date.Add(StepMin);
                _stepMinDistance = AxisXConverter.DataToScreen(newDate);

                var pointTime = AxisXConverter.ScreenToData(point.X - point.X % _stepMinDistance).ConvertToMultiplesOfFive();
                System.Diagnostics.Debug.Print(pointTime.ToString());
                var arg = default(DragingRoutedEventArgs);

                var data = e.Data.GetData("Castle.Proxies.TermStyleProxy");

                if (data != null)
                {
                    arg = new DragingRoutedEventArgs(pointTime, data, DraggingEvent, this);
                    RaiseEvent(arg);
                }

                if (arg != null && arg.Target != null)
                {
                    _startPoint = point;
                    _lastPoint  = _startPoint;
                }
                else
                {
                    _startPoint = null;
                    _lastPoint  = null;
                }

                PointOutBlock = arg == null ? null : arg.Target;
            }

            _canMove = PointOutBlock != null;

            if (_canMove)
            {
                MouseMoving(point);
                InvalidateVisual();
            }
        }
Beispiel #7
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (AxisPanel == null)
            {
                return;
            }


            var point = e.GetPosition(this);

            WatchTime = AxisXConverter.ScreenToData(point.X);

            if (_popup == null)
            {
                return;
            }
            _popup.HorizontalOffset = point.X + HorizontalOffset;
            _popup.VerticalOffset   = point.Y - RenderSize.Height + VerticalOffset;
        }
        protected override void OnParentMouseDown(object sender, MouseButtonEventArgs e)
        {
            //xif (LayerContainer.TryPrevent()) return;
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            _startPoint = e.GetPosition(this);
            _lastPoint  = _startPoint;
            FlagAdd(MouseState.MouseDown);
            var date    = AxisXConverter.ScreenToData(0);
            var newDate = date.Add(StepMin);

            _stepMinDistance = AxisXConverter.DataToScreen(newDate);

            if (FlagExist(MouseState.LeftDirection) || FlagExist(MouseState.RightDirection))
            {
                e.Handled        = true;
                InvalidPlacement = true; // 注意 首次按下鼠标时先设定没任何拖动之前都不是有效的位置改变

                StartMouseMovementTracking();
            }
        }
        private object PointoutBlock(Point e)
        {
            var y = e.Y; //- GetHeaderHeight();

            //var y1 = AxisYConverter.ScreenToData(y);
            //var y2 = (int)(y / Interval) + AxisYConverter.ScreenToData(0);

            //if (y1 != y2)
            //    Debug.Print(string.Format("-------- ViewportToDataY called : y1 = {0}  y2 = {1}", y1, y2));

            // BMK Ambiguous getRowIndex
            PointOutDataRowIndex = AxisYConverter.ScreenToData(y);

            object fountBlock = null;

            if (ItemsSource != null && 0 <= PointOutDataRowIndex && PointOutDataRowIndex < ItemsSource.Count)
            {
                var dateTime  = AxisXConverter.ScreenToData(e.X); // current mouse moved postion
                var positionY = y % Interval;                     // for Top useage


                if (CellMode)
                {
                    var date = dateTime.Date;
                    ItemsSource[PointOutDataRowIndex].SaftyInvoke <IEnumerable>(
                        o =>
                    {
                        fountBlock = o.OfType <ITerm>().FirstOrDefault(t =>
                        {
                            //using HrDate
                            var blockStart = BlockConverter.GetStart(t);
                            return((date == blockStart) && !TryPrevent(t));
                        });
                    });

                    if (RecursivelyPointout)
                    {
                        ItemsSource[PointOutDataRowIndex].SaftyInvoke <IDateIndexer <DateTerm> >(o => o[date].SaftyInvoke(b => fountBlock = b));
                    }
                }
                else
                {
                    ItemsSource[PointOutDataRowIndex].SaftyInvoke <IEnumerable>(
                        o =>
                    {
                        fountBlock = o.OfType <ITerm>().LastOrDefault(block =>
                        {
                            var blockStart = BlockConverter.GetStart(block);
                            var blockTop   = BlockConverter.GetTop(block);
                            return((blockStart <= dateTime && dateTime < block.End &&
                                    blockTop <= positionY && (BlockConverter.GetHeight(block) + blockTop) >= positionY) && !TryPrevent(block));
                        });
                    });
                }
            }

            if (fountBlock != null)
            {
                PointOutDataRowTop = (e.Y - e.Y % Interval) + BlockConverter.GetTop(fountBlock);
            }

            return(fountBlock);
        }
        protected override void OnParentMouseMove(object sender, MouseEventArgs e)
        {
            //xif (LayerContainer.TryPrevent()) return;

            var point = e.GetPosition(this);

            if (!FlagExist(MouseState.MouseDown))
            {
                MoveStateCheck(point); // 尝试变更鼠标样式
            }
            else
            {
                var moveDirection = MouseState.MouseOver;
                if (FlagExist(MouseState.LeftDirection))
                {
                    moveDirection = MouseState.LeftDirection;
                }
                if (FlagExist(MouseState.RightDirection))
                {
                    moveDirection = MouseState.RightDirection;
                }

                //未发现任何左右拉动现象
                if (moveDirection == MouseState.MouseOver)
                {
                    return;
                }

                //var step = AxisXConverter.ScreenToData(distance) - AxisPanel.ScreenStart;
                //if (!(PointOutBlock.End >= PointOutBlock.Start.AddMinutes(step.TotalMinutes))
                //    || !(PointOutBlock.End.AddMinutes(step.TotalMinutes) >= PointOutBlock.Start))
                //    return;

                var distance = point.X - _startPoint.X;
                _lastPoint = new Point(point.X - distance % _stepMinDistance, point.Y); // 刻度式移动,根据 stepMinDistance(通常为5)步进

                var moveSpan = AxisXConverter.ScreenToData(GetMoveOffSet()).Subtract(AxisXConverter.ScreenToData(0));

                var draggingPlacement = default(TimeRange);


                switch (moveDirection)
                {
                case MouseState.LeftDirection:
                    draggingPlacement = PointOutBlock == null ? default(TimeRange) : new TimeRange(PointOutBlock.Start.Add(moveSpan).AddSeconds(0.1), PointOutBlock.End);
                    break;

                case MouseState.RightDirection:
                    draggingPlacement = PointOutBlock == null ? default(TimeRange) : new TimeRange(PointOutBlock.Start, PointOutBlock.End.Add(moveSpan).AddSeconds(0.1));
                    break;
                }

                InvalidPlacement = draggingPlacement == default(TimeRange) || draggingPlacement.Invalid; // 检查Start, End数据正确性(通常Start不能大于End)

                if (InvalidPlacement)
                {
                    DropedPlacement = null;
                    return;
                }

                DropedPlacement = draggingPlacement;
                e.Handled       = true;
                InvalidateVisual();
            }
        }