Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="System.Windows.MouseLeave"/> event.
        /// </summary>
        /// <param name="e">
        /// Contains the event data.
        /// </param>
        protected override void OnMouseMove(MouseEventArgs e)
#endif
        {
#if WPF
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                (this.Controller as GridColumnChooserController).Show((this.Controller as GridColumnChooserController).dataGrid.Columns.IndexOf(Column), e);
                VisualStateManager.GoToState(this, "Normal", true);
                return;
            }
            if (this.Controller.isDragState)
            {
                VisualStateManager.GoToState(this, "Normal", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "MouseOver", true);
            }
            base.OnMouseMove(e);
#else
            if (e.GetCurrentPoint(null).Properties.IsLeftButtonPressed)
            {
                (this.Controller as GridColumnChooserController).Show((this.Controller as GridColumnChooserController).dataGrid.Columns.IndexOf(Column), e);
                VisualStateManager.GoToState(this, "Normal", true);
                return;
            }
            VisualStateManager.GoToState(this, "PointerOver", true);
            base.OnPointerMoved(e);
#endif
        }
Exemplo n.º 2
0
 protected override void OnPointerMoved(MouseEventArgs e)
 {
     if (this.CanResizeHiddenColumn() && e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
     {
         this.TreeGrid.ColumnResizingController.DoActionOnMouseMove(e.GetCurrentPoint(this.TreeGrid.TreeGridPanel), this);
     }
     base.OnPointerMoved(e);
 }
Exemplo n.º 3
0
        private void GetBitmapSeriesCollection(FrameworkElement element, MouseEventArgs e)
#endif
        {
#if __IOS__ || __ANDROID__
            Image bitmapImage = (element as Border)?.Child as Image;
#else
            Image bitmapImage = element as Image;
#endif

            PointerPoint mousePoint = e.GetCurrentPoint(element);
            int          position   = ((bitmapImage.Source as WriteableBitmap).PixelWidth *
                                       (int)mousePoint.Position.Y + (int)mousePoint.Position.X) * 4;

            if (!ChartArea.isBitmapPixelsConverted)
            {
                ChartArea.ConvertBitmapPixels();
            }

            seriesCollection = (from series in ChartArea.Series
                                where (series.Pixels.Count > 0 && series.Pixels.Contains(position))
                                select series).ToList();

            if (seriesCollection.Count > 0)
            {
                foreach (ChartSeries series in seriesCollection)
                {
                    if (!series.IsLinear || EnableSeriesSelection)
                    {
                        ChangeSelectionCursor(true);
                    }
                }
            }
            else
            {
                ChangeSelectionCursor(false);
            }
        }
        /// <summary>
        /// Perfoms MouseUp operation on GridHeaderCellControl
        /// </summary>
        /// <param name="e">An <see cref="T:System.Windows.Input.MouseButtonEventArgs">MouseButtonEventArgs</see> that contains the event data.</param>
        /// <param name="headerCell"></param>
        /// <remarks></remarks>
        internal void DoActionOnMouseUp(MouseEventArgs e, GridHeaderCellControl headerCell)
        {
#if !WPF
            PointerPoint pp            = e.GetCurrentPoint(this.dataGrid.VisualContainer);
            double       hScrollChange = 0;

            for (int i = 0; i < this.dataGrid.VisualContainer.FrozenColumns; i++)
            {
                hScrollChange += this.dataGrid.VisualContainer.ColumnWidths[i];
            }
            var    pointerPoint = new Point(pp.Position.X - (dataGrid.VisualContainer.HScrollBar.Value - hScrollChange), pp.Position.Y - dataGrid.VisualContainer.VScrollBar.Value);
            double delta        = pointerPoint.X - dragLine.Corner;
#else
            Point  pp    = e.GetPosition(this.dataGrid.VisualContainer);
            double delta = pp.X - dragLine.Corner;
#endif
            var    columnIndex = this.dataGrid.ResolveToGridVisibleColumnIndex(dragLine.LineIndex);
            double width       = Math.Max(0, dragLine.Size + delta);
            if (!(columnIndex >= 0 && columnIndex < this.dataGrid.Columns.Count))
            {
                return;
            }
            width = ComputeResizingWidth(this.dataGrid.Columns[columnIndex], width);
            this.dataGrid.VisualContainer.ScrollColumns.ResetLineResize();
            var args = new ResizingColumnsEventArgs(this.dataGrid)
            {
                ColumnIndex = dragLine.LineIndex, Width = width
            };
            if (columnIndex >= 0 && !dataGrid.RaiseResizingColumnsEvent(args))
            {
                this.dataGrid.Columns[columnIndex].IsHidden = (args.Width == 0 || args.Width == 1);
                if ((args.Width == 0) || (args.Width == 1))
                {
                    this.dataGrid.Columns[columnIndex].Width = Math.Round(args.Width);
                    //Reset the extendedwidth when column is in Hidden because of Resizing.
                    this.dataGrid.Columns[columnIndex].ExtendedWidth = double.NaN;
                }
                else
                {
                    if (args.Width != this.dataGrid.Columns[columnIndex].ActualWidth && this.dataGrid.Columns[columnIndex].ExtendedWidth > 0)
                    {
                        var actualWidth               = this.dataGrid.Columns[columnIndex].ActualWidth;
                        var extendedWidth             = this.dataGrid.Columns[columnIndex].ExtendedWidth;
                        var differenceInExtendedWidth = ((args.Width - actualWidth) < extendedWidth) ? (args.Width - actualWidth) : 0;
                        this.dataGrid.Columns[columnIndex].ExtendedWidth = (differenceInExtendedWidth > 0) ? (extendedWidth - differenceInExtendedWidth) : double.NaN;
                    }
                    if ((this.dataGrid.ResolveToGridVisibleColumnIndex(this.dataGrid.VisualContainer.ScrollColumns.GetVisibleLines().Count) == 1) && this.dataGrid.Columns[columnIndex].Width == args.Width)
                    {
                        args.Width += 1;
                    }
                    this.dataGrid.Columns[columnIndex].Width = Math.Round(args.Width) == 0 ? 20 : Math.Round(args.Width);
                }
            }
            if ((args.Width == 0 || columnIndex >= 0 && dataGrid.Columns[columnIndex].IsHidden) && dataGrid.AllowResizingHiddenColumns && dataGrid.VisualContainer.ColumnCount == this.dataGrid.ResolveToGridVisibleColumnIndex(dragLine.LineIndex + 1))
            {
                var headerRow       = dataGrid.RowGenerator.Items.FirstOrDefault(row => row.RowIndex == dataGrid.GetHeaderIndex());
                var columnBase      = headerRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == dragLine.LineIndex + 1);
                var prevHiddenIndex = columnIndex - 1;
                while (prevHiddenIndex > 0 && dataGrid.Columns[prevHiddenIndex].IsHidden)
                {
                    prevHiddenIndex--;
                }
                if (columnBase != null)
                {
                    var prevColumnHeader = (columnBase.ColumnElement as GridHeaderCellControl);
                    if (prevHiddenIndex != columnIndex)
                    {
                        columnBase       = headerRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == prevHiddenIndex);
                        prevColumnHeader = columnBase.ColumnElement as GridHeaderCellControl;
                    }
                    dataGrid.VisualContainer.ColumnWidths.SetHidden(dragLine.LineIndex, dragLine.LineIndex, true);
                    dataGrid.Columns[dataGrid.ResolveToGridVisibleColumnIndex(dragLine.LineIndex)].IsHidden = true;
                    dataGrid.Columns[dataGrid.ResolveToGridVisibleColumnIndex(dragLine.LineIndex)].Width    = 0.0;
                }
            }
            if (dataGrid.SelectionController.CurrentCellManager.HasCurrentCell && dataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex == dragLine.LineIndex)
            {
#if !WPF
                dataGrid.Focus(FocusState.Programmatic);
#endif
            }
            dragLine = null;
#if !WPF
            headerCell.ReleasePointerCaptures();
            if (Window.Current.CoreWindow.PointerCursor.Type != CoreCursorType.Arrow)
            {
                Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 1);
            }
#else
            headerCell.isMouseLeftButtonPressed = false;
            headerCell.ReleaseMouseCapture();
            if (headerCell.Cursor != Cursors.Arrow)
            {
                SetPointerCursor(Cursors.Arrow, headerCell);
            }
            //WRT-4573 - While clicking on HeaderCell border on Resizing, the sorting operation is done in WinRT. Hence
            //the flag is skipped to set false which will be set on mouse move.
            this.isHovering = false;
#endif
        }