internal static CustomItemContainerGenerator CreateGenerator( DataGridControl parentGridControl, CollectionView collectionView, DataGridContext dataGridContext )
    {
      CustomItemContainerGenerator newGenerator = new CustomItemContainerGenerator( collectionView, dataGridContext, parentGridControl );
      dataGridContext.SetGenerator( newGenerator );

      return newGenerator;
    }
 public void RemoveRef(CustomItemContainerGenerator reference)
 {
     if (m_refList.Contains(reference) == true)
     {
         m_refList.Remove(reference);
     }
 }
        public GeneratorNode CreateItemsGeneratorNode(
            IList collection,
            GeneratorNode parent,
            GeneratorNode previous,
            GeneratorNode next,
            CustomItemContainerGenerator generator)
        {
            Debug.Assert(collection != null, "collection cannot be null for CreateItemsGeneratorNode()");
            Debug.Assert(generator != null);

            INotifyCollectionChanged notifyCollection = collection as INotifyCollectionChanged;

            Debug.Assert(notifyCollection != null, "collection must be a INotifyCollectionChanged for CreateItemsGeneratorNode()");

            ItemCollection itemCollection = collection as ItemCollection;

            if (itemCollection != null)
            {
                DataGridCollectionView dgcv = itemCollection.SourceCollection as DataGridCollectionView;
                if (dgcv != null)
                {
                    collection = dgcv;
                }
            }

            ItemsGeneratorNode node = new ItemsGeneratorNode(collection, parent);

            this.SetupCollectionGeneratorNode(node, parent, previous, next);


            node.AdjustLeafCount(node.Items.Count);

            return(node);
        }
 public void AddRef(CustomItemContainerGenerator reference)
 {
     if (m_refList.Contains(reference) == false)
     {
         m_refList.Add(reference);
     }
 }
Exemple #5
0
        public void AddRef(CustomItemContainerGenerator reference)
        {
            Debug.Assert(reference != null);

            if (m_generators.Contains(reference))
            {
                return;
            }

            m_generators.Add(reference);
        }
    public DetailGeneratorNode( DataGridContext context, CustomItemContainerGenerator generator )
      : base( null )
    {
      if( generator == null )
        throw new ArgumentNullException( "generator" );

      if( context == null )
        throw new ArgumentNullException( "context" );

      m_generator = generator;
      m_context = context;
      m_itemCount = generator.ItemCount;
    }
Exemple #7
0
        public DetailGeneratorNode(DataGridContext context, CustomItemContainerGenerator generator)
            : base(null)
        {
            if (generator == null)
            {
                throw new ArgumentNullException("generator");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            m_generator = generator;
            m_context   = context;
            m_itemCount = generator.ItemCount;
        }
    private void InitializeGenerator()
    {
      DataGridControl dataGridControl = this.ParentDataGridControl;

      if( dataGridControl == null )
        throw new DataGridInternalException( "No DataGridContext set on the DataGridItemsHost while trying to initalize the ItemContainerGenerator" );

      if( m_generator == null )
      {
        m_generator = dataGridControl.CustomItemContainerGenerator;
      }

      Debug.Assert( m_generator != null );

      m_generator.ItemsChanged += this.HandleGeneratorItemsChanged;
      m_generator.ContainersRemoved += this.HandleGeneratorContainersRemoved;

      m_generatorInitialized = true;
    }
Exemple #9
0
    protected override void StopListening( object source )
    {
      DataGridControl dataGridControl = source as DataGridControl;
      if( dataGridControl != null )
      {
        dataGridControl.DetailsChanged -= this.OnDetailsChanged;
        return;
      }
      else
      {
        CustomItemContainerGenerator generator = source as CustomItemContainerGenerator;
        if( generator != null )
        {
          generator.DetailsChanged -= this.OnDetailsChanged;
          return;
        }
      }

      throw new InvalidOperationException( "An attempt was made to use a source other than a DataGridControl or CustomItemContainerGenerator." );
    }
        private void InitializeGenerator()
        {
            DataGridControl dataGridControl = this.ParentDataGridControl;

            if (dataGridControl == null)
            {
                throw new DataGridInternalException("No DataGridContext set on the DataGridItemsHost while trying to initalize the ItemContainerGenerator");
            }

            if (m_generator == null)
            {
                m_generator = dataGridControl.CustomItemContainerGenerator;
            }

            Debug.Assert(m_generator != null);

            m_generator.ItemsChanged      += this.HandleGeneratorItemsChanged;
            m_generator.ContainersRemoved += this.HandleGeneratorContainersRemoved;

            m_generatorInitialized = true;
        }
Exemple #11
0
        public GeneratorNode CreateItemsGeneratorNode(
            IList collection,
            GeneratorNode parent,
            GeneratorNode previous,
            GeneratorNode next,
            CustomItemContainerGenerator generator)
        {
            Debug.Assert(collection != null, "collection cannot be null for CreateItemsGeneratorNode()");
            Debug.Assert(generator != null);

            INotifyCollectionChanged notifyCollection = collection as INotifyCollectionChanged;

            Debug.Assert(notifyCollection != null, "collection must be a INotifyCollectionChanged for CreateItemsGeneratorNode()");

            //case 113904: If the item source for the ItemsGeneratorNode is an ItemCollection, then
            //check if the underlying SourceCollection is a DataGridCollectionView.
            //This particular exception case is there to handle messaging quirks in the case
            //of Master Detail edition. Refer to case for more details.
            ItemCollection itemCollection = collection as ItemCollection;

            if (itemCollection != null)
            {
                DataGridCollectionView dgcv = itemCollection.SourceCollection as DataGridCollectionView;
                if (dgcv != null)
                {
                    collection = dgcv;
                }
            }

            ItemsGeneratorNode node = new ItemsGeneratorNode(collection, parent);

            this.SetupCollectionGeneratorNode(node, parent, previous, next);


            node.AdjustLeafCount(node.Items.Count);

            return(node);
        }
      public DeferContainersRemovedDisposable( CustomItemContainerGenerator generator )
      {
        if( generator == null )
          throw new ArgumentNullException( "generator" );

        m_generator = generator;

        Debug.Assert( ( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 ), "( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 )" );
#if LOG
        Log.Assert( this, ( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 ), "( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 )" );
#endif

        m_generator.m_containersRemovedDeferCount++;
      }
      public GenPostoIndexInhibitionDisposable( CustomItemContainerGenerator generator )
      {
        if( generator == null )
          throw new ArgumentNullException( "generator" );

        m_generator = generator;

        m_generator.m_genPosToIndexUpdateInhibitCount++;

        if( m_generator.m_genPosToIndexInhibiter != null )
        {
          m_nestedDisposable = m_generator.m_genPosToIndexInhibiter.InhibitGenPosToIndexUpdates();
        }
      }
 public void RemoveRef( CustomItemContainerGenerator reference )
 {
   if( m_refList.Contains( reference ) == true )
   {
     m_refList.Remove( reference );
   }
 }
 public void AddRef( CustomItemContainerGenerator reference )
 {
   if( m_refList.Contains( reference ) == false )
   {
     m_refList.Add( reference );
   }
 }
    private DetailGeneratorNode FindDetailGeneratorNodeForGenerator( CustomItemContainerGenerator detailGenerator, out object masterItem )
    {
      foreach( KeyValuePair<object, List<DetailGeneratorNode>> detailsForItem in m_masterToDetails )
      {
        foreach( DetailGeneratorNode detailNode in detailsForItem.Value )
        {
          if( detailNode.DetailGenerator == detailGenerator )
          {
            masterItem = detailsForItem.Key;
            return detailNode;
          }
        }
      }

      masterItem = null;
      return null;
    }
      public CustomItemContainerGeneratorDisposableDisposer( CustomItemContainerGenerator generator, GeneratorPosition startGenPos, GeneratorDirection direction )
      {
        if( generator == null )
        {
          throw new ArgumentNullException( "generator" );
        }

        m_generator = generator;

        m_generator.StartGenerator( startGenPos, direction );
      }
    public GeneratorNode CreateItemsGeneratorNode(
      IList collection,
      GeneratorNode parent,
      GeneratorNode previous,
      GeneratorNode next,
      CustomItemContainerGenerator generator )
    {
      Debug.Assert( collection != null, "collection cannot be null for CreateItemsGeneratorNode()" );
      Debug.Assert( generator != null );

      INotifyCollectionChanged notifyCollection = collection as INotifyCollectionChanged;

      Debug.Assert( notifyCollection != null, "collection must be a INotifyCollectionChanged for CreateItemsGeneratorNode()" );

      ItemCollection itemCollection = collection as ItemCollection;
      if( itemCollection != null )
      {
        DataGridCollectionView dgcv = itemCollection.SourceCollection as DataGridCollectionView;
        if( dgcv != null )
        {
          collection = dgcv;
        }
      }

      ItemsGeneratorNode node = new ItemsGeneratorNode( collection, parent );

      this.SetupCollectionGeneratorNode( node, parent, previous, next );


      node.AdjustLeafCount( node.Items.Count );

      return node;
    }
      public DeferDetailsRemapDisposable( CustomItemContainerGenerator generator )
      {
        if( generator == null )
          throw new ArgumentNullException( "generator" );

        m_generator = generator;

        m_generator.m_remapDeferCount++;
      }
Exemple #20
0
        public void RemoveRef(CustomItemContainerGenerator reference)
        {
            Debug.Assert(reference != null);

            m_generators.Remove(reference);
        }
      public ProcessingGlobalItemsResetOrRemovingAllGeneratedItemsDisposable( CustomItemContainerGenerator generator )
      {
        if( generator == null )
          throw new ArgumentNullException( "generator" );

        m_generator = generator;

        Debug.Assert( ( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 ), "( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 )" );
#if LOG
        Log.Assert( this, ( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 ), "( m_generator.m_containersRemovedDeferCount != 0 ) || ( m_generator.m_deferredContainersRemoved.Count == 0 )" );
#endif

        m_generator.m_isProcessingGlobalResetOrRemovingAllGeneratedItemsDisposableCount++;
      }
    public GeneratorNode CreateItemsGeneratorNode(
      IList collection,
      GeneratorNode parent,
      GeneratorNode previous,
      GeneratorNode next,
      CustomItemContainerGenerator generator )
    {
      Debug.Assert( collection != null, "collection cannot be null for CreateItemsGeneratorNode()" );
      Debug.Assert( generator != null );

      INotifyCollectionChanged notifyCollection = collection as INotifyCollectionChanged;

      Debug.Assert( notifyCollection != null, "collection must be a INotifyCollectionChanged for CreateItemsGeneratorNode()" );

      //case 113904: If the item source for the ItemsGeneratorNode is an ItemCollection, then
      //check if the underlying SourceCollection is a DataGridCollectionView.
      //This particular exception case is there to handle messaging quirks in the case 
      //of Master Detail edition. Refer to case for more details.
      ItemCollection itemCollection = collection as ItemCollection;
      if( itemCollection != null )
      {
        DataGridCollectionView dgcv = itemCollection.SourceCollection as DataGridCollectionView;
        if( dgcv != null )
        {
          collection = dgcv;
        }
      }

      ItemsGeneratorNode node = new ItemsGeneratorNode( collection, parent );

      this.SetupCollectionGeneratorNode( node, parent, previous, next );


      node.AdjustLeafCount( node.Items.Count );

      return node;
    }