예제 #1
0
        private static void OnParentGridControlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RowSelector     rowSelector = ( RowSelector )sender;
            DataGridControl newGrid     = e.NewValue as DataGridControl;

            if (newGrid != null)
            {
                rowSelector.PrepareDefaultStyleKey(newGrid.GetView());
            }
        }
예제 #2
0
        private Size PrepareAvailableSizeForRowSelector(RowSelector rowSelector, Size availableSize)
        {
            Rect containerRect = rowSelector.ContainerRect;
            Size returnSize;

            if (this.Orientation == Orientation.Vertical)
            {
                returnSize = new Size(availableSize.Width, containerRect.Height);
            }
            else
            {
                returnSize = new Size(containerRect.Width, availableSize.Height);
            }

            return(returnSize);
        }
예제 #3
0
        internal void FreeRowSelector(DependencyObject container)
        {
            RowSelector rowSelector = null;

            //Check if a RowSelector is already assigned to the container passed.
            if (m_visibleSelectors.TryGetValue(container, out rowSelector) == true)
            {
                //Remove from Visible list, add to pending cleanup list
                m_visibleSelectors.Remove(container);
                m_pendingCleanup.Add(rowSelector);

                //clear data context (container) from the RowSelector.
                rowSelector.DataContext = null;
                DataGridControl.ClearContainer(rowSelector);

                //Invalidate Measure since the list of VisibleSelector + PendingCleanup changed
                this.InvalidateMeasure();
            }
            //If there are no RowSelector for container, then do nothing.
        }
예제 #4
0
        internal void SetRowSelectorPosition(DependencyObject container, Rect containerRect, FrameworkElement referenceElement)
        {
            Debug.Assert(( Visibility )this.GetValue(RowSelectorPane.VisibilityProperty) == Visibility.Visible, "We should not be creating RowSelectors if we are not Visible.");

            RowSelector rowSelector = null;

            //Check if a RowSelector is already assigned to the container passed.
            if (m_visibleSelectors.TryGetValue(container, out rowSelector) == false)
            {
                //If no RowSelector exists for this container, try to recycle one.
                if (m_recycleQueue.Count > 0)
                {
                    //get next recyclable RowSelector.
                    rowSelector = m_recycleQueue.Dequeue();
                }
                else
                {
                    //Recycling pool empty, create a new RowSelector and place it in the visual tree right away.
                    rowSelector = new RowSelector();
                    this.InternalChildren.Add(rowSelector);
                }

                //Since there was no RowSelector for the container, map the container to this RowSelector
                rowSelector.DataContext = container;
                DataGridControl.SetContainer(rowSelector, container);
                rowSelector.ReferenceElement = referenceElement;
                m_visibleSelectors.Add(container, rowSelector);
            }

            //At this stage, it is not normal that no RowSelector instance is available.
            Debug.Assert(rowSelector != null);

            if (rowSelector == null)
            {
                throw new InvalidOperationException("An attempt was made to set the position of a row selector that does not exist.");
            }

            rowSelector.ContainerRect = containerRect;

            this.InvalidateMeasure();
        }
예제 #5
0
        private static void OnRowSelectorStyleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RowSelector rowSelector = sender as RowSelector;

            //Here, since the property is an Attached propety, the type of sender can be anything, but in this particular case, I want
            //to filter out everything but RowSelector since this is my queue to set a local style on the RowSelector ( or clear the local
            //value).
            if (rowSelector == null)
            {
                return;
            }

            if (e.NewValue == null)
            {
                rowSelector.ClearValue(RowSelector.StyleProperty);
            }
            else
            {
                rowSelector.SetValue(RowSelector.StyleProperty, e.NewValue);
            }
        }
예제 #6
0
        private Rect PrepareArrangeRectForRowSelector(Size finalSize, RowSelector visibleRowSelector)
        {
            Rect returnRect;

            FrameworkElement container = visibleRowSelector.DataContext as FrameworkElement;

            Debug.Assert(container != null);

            GeneralTransform coordinatesTransform = container.TransformToVisual(this);
            Point            origin = coordinatesTransform.Transform(OriginPoint);

            if (this.Orientation == Orientation.Vertical)
            {
                returnRect = new Rect(0, origin.Y, finalSize.Width, container.ActualHeight);
            }
            else
            {
                returnRect = new Rect(origin.X, 0, container.ActualWidth, finalSize.Height);
            }

            return(returnRect);
        }
예제 #7
0
        private Geometry PrepareClipForRowSelector(RowSelector rowSelector, Rect arrangeRect, FrameworkElement referenceElement)
        {
            if (referenceElement == null)
            {
                return(null);
            }

            GeneralTransform referenceElementToRowSelectorPaneTransform = referenceElement.TransformToVisual(this);

            Rect referenceElementRegion = referenceElementToRowSelectorPaneTransform.TransformBounds(new Rect(0, 0, referenceElement.ActualWidth, referenceElement.ActualHeight));

            RectangleGeometry clipRegion = null;

            if (this.Orientation == Orientation.Vertical)
            {
                UIElement container = rowSelector.DataContext as UIElement;

                if ((container != null) && (container.Clip != null))
                {
                    Rect containerClipBounds = container.Clip.Bounds;

                    // In this case, we will use the container's clip properties (Top and Bottom).
                    clipRegion = new RectangleGeometry(new Rect(0d, containerClipBounds.Y, arrangeRect.Width, containerClipBounds.Height));
                }
                else if ((arrangeRect.Top < referenceElementRegion.Top) || (arrangeRect.Bottom > referenceElementRegion.Bottom))
                {
                    double x = 0d;
                    double y = Math.Max(referenceElementRegion.Top - arrangeRect.Top, 0);

                    double width  = arrangeRect.Width;
                    double height = Math.Max(0, arrangeRect.Height - y - Math.Max(0, arrangeRect.Bottom - referenceElementRegion.Bottom));


                    clipRegion = new RectangleGeometry(new Rect(x, y, width, height));
                }
            }
            else
            {
                UIElement container = rowSelector.DataContext as UIElement;

                if ((container != null) && (container.Clip != null))
                {
                    Rect containerClipBounds = container.Clip.Bounds;

                    // In this case, we will use the container's clip properties (Left and Right).
                    clipRegion = new RectangleGeometry(new Rect(containerClipBounds.X, 0d, containerClipBounds.Width, arrangeRect.Height));
                }
                else if ((arrangeRect.Left < referenceElementRegion.Left) || (arrangeRect.Right > referenceElementRegion.Right))
                {
                    double x = Math.Max(referenceElementRegion.Left - arrangeRect.Left, 0);
                    double y = 0d;

                    double width  = arrangeRect.Width - x - Math.Max(0, arrangeRect.Right - referenceElementRegion.Right);
                    double height = arrangeRect.Height;

                    clipRegion = new RectangleGeometry(new Rect(x, y, width, height));
                }
            }

            return(clipRegion);
        }
예제 #8
0
    internal void SetRowSelectorPosition( DependencyObject container, Rect containerRect, FrameworkElement referenceElement )
    {
      Debug.Assert( ( Visibility )this.GetValue( RowSelectorPane.VisibilityProperty ) == Visibility.Visible, "We should not be creating RowSelectors if we are not Visible." );

      RowSelector rowSelector = null;

      //Check if a RowSelector is already assigned to the container passed.
      if( m_visibleSelectors.TryGetValue( container, out rowSelector ) == false )
      {
        //If no RowSelector exists for this container, try to recycle one.
        if( m_recycleQueue.Count > 0 )
        {
          //get next recyclable RowSelector.
          rowSelector = m_recycleQueue.Dequeue();
        }
        else
        {
          //Recycling pool empty, create a new RowSelector and place it in the visual tree right away.
          rowSelector = new RowSelector();
          this.InternalChildren.Add( rowSelector );
        }

        //Since there was no RowSelector for the container, map the container to this RowSelector
        rowSelector.DataContext = container;
        DataGridControl.SetContainer( rowSelector, container );
        rowSelector.ReferenceElement = referenceElement;
        m_visibleSelectors.Add( container, rowSelector );
      }

      //At this stage, it is not normal that no RowSelector instance is available.
      Debug.Assert( rowSelector != null );

      if( rowSelector == null )
        throw new InvalidOperationException( "An attempt was made to set the position of a row selector that does not exist." );

      rowSelector.ContainerRect = containerRect;

      this.InvalidateMeasure();
    }
예제 #9
0
    private Geometry PrepareClipForRowSelector( RowSelector rowSelector, Rect arrangeRect, FrameworkElement referenceElement )
    {
      if( referenceElement == null )
        return null;

      GeneralTransform referenceElementToRowSelectorPaneTransform = referenceElement.TransformToVisual( this );

      Rect referenceElementRegion = referenceElementToRowSelectorPaneTransform.TransformBounds( new Rect( 0, 0, referenceElement.ActualWidth, referenceElement.ActualHeight ) );

      RectangleGeometry clipRegion = null;

      if( this.Orientation == Orientation.Vertical )
      {
        UIElement container = rowSelector.DataContext as UIElement;

        if( ( container != null ) && ( container.Clip != null ) )
        {
          Rect containerClipBounds = container.Clip.Bounds;

          // In this case, we will use the container's clip properties (Top and Bottom).
          clipRegion = new RectangleGeometry( new Rect( 0d, containerClipBounds.Y, arrangeRect.Width, containerClipBounds.Height ) );
        }
        else if( ( arrangeRect.Top < referenceElementRegion.Top ) || ( arrangeRect.Bottom > referenceElementRegion.Bottom ) )
        {
          double x = 0d;
          double y = Math.Max( referenceElementRegion.Top - arrangeRect.Top, 0 );

          double width = arrangeRect.Width;
          double height = Math.Max( 0, arrangeRect.Height - y - Math.Max( 0, arrangeRect.Bottom - referenceElementRegion.Bottom ) );


          clipRegion = new RectangleGeometry( new Rect( x, y, width, height ) );
        }
      }
      else
      {
        UIElement container = rowSelector.DataContext as UIElement;

        if( ( container != null ) && ( container.Clip != null ) )
        {
          Rect containerClipBounds = container.Clip.Bounds;

          // In this case, we will use the container's clip properties (Left and Right).
          clipRegion = new RectangleGeometry( new Rect( containerClipBounds.X, 0d, containerClipBounds.Width, arrangeRect.Height ) );
        }
        else if( ( arrangeRect.Left < referenceElementRegion.Left ) || ( arrangeRect.Right > referenceElementRegion.Right ) )
        {
          double x = Math.Max( referenceElementRegion.Left - arrangeRect.Left, 0 );
          double y = 0d;

          double width = arrangeRect.Width - x - Math.Max( 0, arrangeRect.Right - referenceElementRegion.Right );
          double height = arrangeRect.Height;

          clipRegion = new RectangleGeometry( new Rect( x, y, width, height ) );
        }
      }

      return clipRegion;
    }
예제 #10
0
    private Size PrepareAvailableSizeForRowSelector( RowSelector rowSelector, Size availableSize )
    {
      Rect containerRect = rowSelector.ContainerRect;
      Size returnSize;

      if( this.Orientation == Orientation.Vertical )
      {
        returnSize = new Size( availableSize.Width, containerRect.Height );
      }
      else
      {
        returnSize = new Size( containerRect.Width, availableSize.Height );
      }

      return returnSize;
    }
예제 #11
0
    private Rect PrepareArrangeRectForRowSelector( Size finalSize, RowSelector visibleRowSelector )
    {
      Rect returnRect;

      FrameworkElement container = visibleRowSelector.DataContext as FrameworkElement;
      Debug.Assert( container != null );

      GeneralTransform coordinatesTransform = container.TransformToVisual( this );
      Point origin = coordinatesTransform.Transform( OriginPoint );

      if( this.Orientation == Orientation.Vertical )
      {
        returnRect = new Rect( 0, origin.Y, finalSize.Width, container.ActualHeight );
      }
      else
      {
        returnRect = new Rect( origin.X, 0, container.ActualWidth, finalSize.Height );
      }

      return returnRect;
    }