Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (StartTime == (DateTime)StartTimeProperty.DefaultMetadata.DefaultValue || EndTime == (DateTime)EndTimeProperty.DefaultMetadata.DefaultValue || AxisPanel == null)
            {
                return;
            }

            var left  = AxisXConverter.DataToScreen(StartTime);
            var right = Math.Min(AxisXConverter.DataToScreen(EndTime), RenderSize.Width);
            var width = right - left;

            var rect = new Rect(Math.Max(0, left), RenderSize.Height - 14, Math.Min(right >= 0 ? right : 0, width > 0 ? width : 0), 14);//14 is Line Height

            drawingContext.DrawRectangle(ColorRender, null, rect);
            if (Text == null)
            {
                return;
            }
            Text.ToFormattedText(Foreground).Self(fTxt =>
            {
                if (AxisXConverter.DataToScreen(EndTime) - Text.GetTtextSize().Width < 0 || RenderSize.Width < left)
                {
                    return;
                }
                var topMargin = 0;
                drawingContext.DrawText(fTxt, new Point(left >= 0?left:0, topMargin));
            });
        }
Exemplo n.º 3
0
        protected override double GetCellInterval()
        {
            var dateTime  = AxisXConverter.ScreenToData(0);
            var hourWidth = AxisXConverter.DataToScreen(dateTime.AddHours(1));

            //每个小时的长度除以PerHourCount;
            return(hourWidth / PerHourCount);
        }
Exemplo n.º 4
0
        private void ChangeBlockEdgeCursor(Point point)
        {
            var left  = AxisXConverter.DataToScreen(PointOutBlock.Start);
            var right = AxisXConverter.DataToScreen(PointOutBlock.End);

            //如果在边上,鼠标形状就发生变化
            if ((point.X - left) < ApprochDistance)
            {
                LayerContainer.ChangeCursor(Cursors.SizeWE);
                FlagAdd(MouseState.LeftDirection);
            }
            else if ((right - point.X) < ApprochDistance)
            {
                LayerContainer.ChangeCursor(Cursors.SizeWE);
                FlagAdd(MouseState.RightDirection);
            }
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
        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();
            }
        }