Пример #1
0
        public void ZoomAll()
        {
            var bounds = ChartCanvas.GetModelBounds();

            if (bounds == Rect.Empty)
            {
                return;
            }
            ChartCanvas.Viewport.ModelRectangle = bounds;
        }
Пример #2
0
        public void Zoom(Point mPos, int delta)
        {
            var factor = delta / 1200.0;

            var cx1 = factor * mPos.X;
            var cx2 = ChartCanvas.Viewport.HorizontalAxis.ClientEnd - factor * (ChartCanvas.ActualWidth - mPos.X);
            var cy1 = factor * mPos.Y;
            var cy2 = ChartCanvas.Viewport.VerticalAxis.ClientEnd - factor * (ChartCanvas.ActualHeight - mPos.Y);
            var mx1 = ChartCanvas.Viewport.HorizontalAxis.ClientToModel(cx1);
            var mx2 = ChartCanvas.Viewport.HorizontalAxis.ClientToModel(cx2);
            var my1 = ChartCanvas.Viewport.VerticalAxis.ClientToModel(cy1);
            var my2 = ChartCanvas.Viewport.VerticalAxis.ClientToModel(cy2);

            var modelRectangle = (_x && _y)
                ? new Rect(Math.Min(mx1, mx2), Math.Min(my1, my2), Math.Abs(mx2 - mx1), Math.Abs(my2 - my1))
                : (_x
                    ? new Rect(Math.Min(mx1, mx2), ChartCanvas.Viewport.VerticalAxis.ModelStart,
                               Math.Abs(mx2 - mx1), ChartCanvas.Viewport.VerticalAxis.Model.Delta())
                    : new Rect(ChartCanvas.Viewport.HorizontalAxis.ModelStart, Math.Min(my1, my2),
                               ChartCanvas.Viewport.HorizontalAxis.Model.Delta(), Math.Abs(my2 - my1)));

            if (!_zoomOutBorders)
            {
                var bounds = ChartCanvas.GetModelBounds();
                modelRectangle.Intersect(bounds);
            }

            if (Keyboard.IsKeyDown(Key.LeftShift))
            {
                modelRectangle = new Rect(modelRectangle.X, ChartCanvas.Viewport.ModelRectangle.Y, modelRectangle.Width,
                                          ChartCanvas.Viewport.ModelRectangle.Height);
            }
            else if (Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                modelRectangle = new Rect(ChartCanvas.Viewport.ModelRectangle.X, modelRectangle.Y,
                                          ChartCanvas.Viewport.ModelRectangle.Width, modelRectangle.Height);
            }

            if (modelRectangle == Rect.Empty)
            {
                return;
            }

            ChartCanvas.Viewport.ModelRectangle = modelRectangle;
        }
Пример #3
0
        public void Pan(Vector delta)
        {
            //var cx1 = delta.X;
            //var cy1 = delta.Y;
            var cx1 = ChartCanvas.Viewport.HorizontalAxis.ClientStart + delta.X;
            var cy1 = ChartCanvas.Viewport.VerticalAxis.ClientStart + delta.Y;
            var cx2 = ChartCanvas.Viewport.HorizontalAxis.ClientEnd + delta.X;
            var cy2 = ChartCanvas.Viewport.VerticalAxis.ClientEnd + delta.Y;

            var x1             = ChartCanvas.Viewport.HorizontalAxis.ClientToModel(cx1);
            var y1             = ChartCanvas.Viewport.VerticalAxis.ClientToModel(cy1);
            var x2             = ChartCanvas.Viewport.HorizontalAxis.ClientToModel(cx2);
            var y2             = ChartCanvas.Viewport.VerticalAxis.ClientToModel(cy2);
            var modelRectangle = new Rect(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1));

            if (!_y)
            {
                modelRectangle = new Rect(modelRectangle.X, ChartCanvas.Viewport.ModelRectangle.Y, modelRectangle.Width,
                                          ChartCanvas.Viewport.ModelRectangle.Height);
            }
            if (!_x)
            {
                modelRectangle = new Rect(ChartCanvas.Viewport.ModelRectangle.X, modelRectangle.Y,
                                          ChartCanvas.Viewport.ModelRectangle.Width, modelRectangle.Height);
            }

            var bounds = _getBoundsMethod.Invoke(ChartCanvas.GetModelBounds());

            if (_zoomOnBoundary)
            {
                modelRectangle.Intersect(bounds);
            }

            if (modelRectangle == Rect.Empty)
            {
                return;
            }

            ChartCanvas.Viewport.ModelRectangle = modelRectangle;
        }
Пример #4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 7 "..\..\..\Chart\ChartControl.xaml"
                ((Nordwest.Wpf.Controls.Chart.ChartControl)(target)).Loaded += new System.Windows.RoutedEventHandler(this.OnLoaded);

            #line default
            #line hidden
                return;

            case 2:
                this.grid = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.chartCanvas = ((Nordwest.Wpf.Controls.Chart.ChartCanvas)(target));
                return;

            case 4:
                this.leftAxis = ((Nordwest.Wpf.Controls.Chart.VerticalAxisControl)(target));
                return;

            case 5:
                this.rightAxis = ((Nordwest.Wpf.Controls.Chart.VerticalAxisControl)(target));
                return;

            case 6:
                this.topAxis = ((Nordwest.Wpf.Controls.Chart.HorizontalAxisControl)(target));
                return;

            case 7:
                this.bottomAxis = ((Nordwest.Wpf.Controls.Chart.HorizontalAxisControl)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #5
0
 protected override void RemoveHandlers(ChartCanvas chartCanvas)
 {
     chartCanvas.MouseDown -= chartCanvas_MouseDown;
     chartCanvas.MouseUp   -= chartCanvas_MouseUp;
     chartCanvas.MouseMove -= chartCanvas_MouseMove;
 }
Пример #6
0
 protected override void AddHandlers(ChartCanvas chartCanvas)
 {
     chartCanvas.MouseDown += chartCanvas_MouseDown;
     chartCanvas.MouseUp   += chartCanvas_MouseUp;
     chartCanvas.MouseMove += chartCanvas_MouseMove;
 }
Пример #7
0
 protected override void RemoveHandlers(ChartCanvas chartCanvas)
 {
     chartCanvas.MouseWheel       -= chartCanvas_MouseWheel;
     chartCanvas.MouseDoubleClick -= chartCanvas_MouseDoubleClick;
 }
Пример #8
0
 protected override void AddHandlers(ChartCanvas chartCanvas)
 {
     chartCanvas.MouseWheel       += chartCanvas_MouseWheel;
     chartCanvas.MouseDoubleClick += chartCanvas_MouseDoubleClick;
 }
Пример #9
0
 protected abstract void RemoveHandlers(ChartCanvas chartCanvas);
Пример #10
0
        //public ChartElement ChartElement { get; set; }

        protected abstract void AddHandlers(ChartCanvas chartCanvas);