当前位置: 首页>>代码示例>>C#>>正文


C# List.TrimExcess方法代码示例

本文整理汇总了C#中System.Windows.Documents.List.TrimExcess方法的典型用法代码示例。如果您正苦于以下问题:C# List.TrimExcess方法的具体用法?C# List.TrimExcess怎么用?C# List.TrimExcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.List的用法示例。


在下文中一共展示了List.TrimExcess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetImagePaths

        List<string> GetImagePaths(string folder)
        {
            List<string> filePaths = new List<string>();

            try
            {
                files = Directory.GetFiles(folder);
            }
            catch (DirectoryNotFoundException ex)
            {
            }

            foreach(string file in files)
            {
                if (file.ToUpper().EndsWith(".JPG") ||
                    file.ToUpper().EndsWith(".PNG") ||
                    file.ToUpper().EndsWith(".GIF") ||
                    file.ToUpper().EndsWith(".TIF"))
                {
                    filePaths.Add(file);
                }
            }

            filePaths.TrimExcess();

            return filePaths;
        }
开发者ID:pjmodi,项目名称:projects,代码行数:27,代码来源:Welcome.xaml.cs

示例2: UpdateChildren

    private void UpdateChildren( DataGridContext dataGridContext, TableViewColumnVirtualizationManager columnVirtualizationManager, VirtualizingCellCollection parentRowCells )
    {
      //Prevent reentrance
      if( m_parentRowCells.AlreadyUpdating )
        return;

      m_parentRowCells.AlreadyUpdating = true;

      if( dataGridContext == null )
        throw new DataGridInternalException( "DataGridContext is null for FixedCellPanel" );

      if( columnVirtualizationManager == null )
        throw new DataGridInternalException( "ColumnVirtualizationManager is null for FixedCellPanel" );

      if( parentRowCells == null )
        return;

      this.ClearPermanentScrollingFieldNames();

      List<string> currentFieldsName = new List<string>();
      currentFieldsName.AddRange( columnVirtualizationManager.FixedFieldNames );
      currentFieldsName.AddRange( columnVirtualizationManager.ScrollingFieldNames );

      HashSet<Cell> unusedCells = new HashSet<Cell>( parentRowCells.BindedCells );

      //Idenfity the binded cells that aren't needed anymore.
      foreach( string fieldName in currentFieldsName )
      {
        ColumnBase column = dataGridContext.Columns[ fieldName ];
        Cell cell;

        if( parentRowCells.TryGetCell( column, out cell ) )
        {
          //Certain non recyclable cells like StatCells need their content binding to be updated when they become (or stay) in view.
          cell.AddContentBinding();
          unusedCells.Remove( cell );
        }
      }
      currentFieldsName.Clear();
      currentFieldsName.TrimExcess();

      //Release the unused binded cells now in order to minimize the number of cell's creation.
      foreach( Cell cell in unusedCells )
      {
        bool release = this.CanReleaseCell( cell );

        //We move the unused cell into the scrolling panel since there is more chance it will be reused there in the future.
        this.MoveCellToScrollingPanel( cell, release );

        if( release )
        {
          parentRowCells.Release( cell );
        }
        //Since the cell cannot be released, it will not be collapsed. We must keep the field name in order to let the scrolling sub-panel measure and arrange the cell out of view.
        else
        {
          //Certain non recyclable cells like StatCells needs their content binding to be removed when they become out of view.
          cell.RemoveContentBinding();
          this.AddPermanentScrollingFieldNames( cell.FieldName );
        }
      }
      unusedCells.Clear();
      unusedCells.TrimExcess();

      //Add the missing cells to the fixed region.
      foreach( string fieldName in columnVirtualizationManager.FixedFieldNames )
      {
        //The cell is created if it is missing.
        Cell cell = parentRowCells[ fieldName ];

        //Make sure the cell is in the appropriate panel.
        this.MoveCellToFixedPanel( cell );
      }

      //Add the missing cells to the scrolling region.
      foreach( string fieldName in columnVirtualizationManager.ScrollingFieldNames )
      {
        //The cell is created if it is missing.
        Cell cell = parentRowCells[ fieldName ];

        //Make sure the cell is in the appropriate panel.
        this.MoveCellToScrollingPanel( cell );
      }

      if( m_clearUnusedCellsDispatcherOperation == null )
      {
        m_clearUnusedCellsDispatcherOperation = this.Dispatcher.BeginInvoke( new Action( this.ClearUnusedCells ), DispatcherPriority.ApplicationIdle );
      }

      m_fixedPanel.InvalidateMeasure();
      m_scrollingCellsDecorator.InvalidateMeasure();
      m_scrollingPanel.InvalidateMeasure();

      m_parentRowCells.AlreadyUpdating = false;
    }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:95,代码来源:FixedCellPanel.cs


注:本文中的System.Windows.Documents.List.TrimExcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。