예제 #1
0
        protected bool TryDeferResort(DetailConfiguration detailConfiguration, out IDisposable defer)
        {
            defer = null;

            return((detailConfiguration != null) &&
                   (this.TryDeferResort(detailConfiguration.SortDescriptions, out defer)));
        }
        private static DataGridContext GetDataGridContextFromDetailConfiguration(
            DetailConfiguration configuration,
            DataGridContext parentDataGridContext)
        {
            if ((configuration == null) || (parentDataGridContext == null))
            {
                return(null);
            }

            if (parentDataGridContext.SourceDetailConfiguration == configuration)
            {
                return(parentDataGridContext);
            }

            foreach (DataGridContext childContext in parentDataGridContext.GetChildContexts())
            {
                DataGridContext foundContext =
                    HierarchicalGroupByControlNode.GetDataGridContextFromDetailConfiguration(configuration,
                                                                                             childContext);

                if (foundContext != null)
                {
                    return(foundContext);
                }
            }

            return(null);
        }
    internal DataGridContextAutomationPeer(
      DataGridControl dataGridControl,
      DataGridContext parentDataGridContext,
      object parentItem,
      DetailConfiguration detailConfiguration )
    {
      if( dataGridControl == null )
        throw new ArgumentNullException( "dataGridControl" );

      if( parentDataGridContext == null )
      {
        m_dataGridContext = dataGridControl.DataGridContext;
      }
      else
      {
        m_dataGridContext = parentDataGridContext.GetChildContext( parentItem, detailConfiguration );
      }

      if( m_dataGridContext != null )
        m_dataGridContext.Peer = this;

      m_dataGridControl = dataGridControl;
      m_parentDataGridContext = parentDataGridContext;
      m_parentItem = parentItem;
      m_detailConfiguration = detailConfiguration;

      m_dataChildren = new Hashtable( 0 );
      m_headerFooterChildren = new Hashtable( 0 );
    }
        internal DataGridContextAutomationPeer(
            DataGridControl dataGridControl,
            DataGridContext parentDataGridContext,
            object parentItem,
            DetailConfiguration detailConfiguration)
        {
            if (dataGridControl == null)
            {
                throw new ArgumentNullException("dataGridControl");
            }

            if (parentDataGridContext == null)
            {
                m_dataGridContext = dataGridControl.DataGridContext;
            }
            else
            {
                m_dataGridContext = parentDataGridContext.GetChildContext(parentItem, detailConfiguration);
            }

            if (m_dataGridContext != null)
            {
                m_dataGridContext.Peer = this;
            }

            m_dataGridControl       = dataGridControl;
            m_parentDataGridContext = parentDataGridContext;
            m_parentItem            = parentItem;
            m_detailConfiguration   = detailConfiguration;

            m_dataChildren         = new Hashtable(0);
            m_headerFooterChildren = new Hashtable(0);
        }
예제 #5
0
        /// <summary>
        /// Builds collectionSource DetailDescriptions.ItemProperties and collection of detail columns.
        /// </summary>
        /// <param name="collectionSource"></param>
        /// <param name="xceedControl"></param>
        /// <param name="detail"></param>
        public void  BuildDetailStructure(DataGridCollectionViewSource collectionSource, DataGridControl xceedGrid,
                                          DetailConfiguration detail)
        {
            Debug.Assert(null != collectionSource.DetailDescriptions);
            Debug.Assert(1 == collectionSource.DetailDescriptions.Count);

            _BuildCollectionSource(collectionSource.DetailDescriptions[0].ItemProperties);
            _BuildColumnsCollection(detail.Columns);

            // Add stops as detail of route.
            xceedGrid.DetailConfigurations.Clear();
            xceedGrid.DetailConfigurations.Add(detail);

            // NOTE: Set this property so that columns with custom order properties from default
            // settings were not added to grid automatically.
            xceedGrid.DetailConfigurations[0].AutoCreateColumns = false;

            // Collapse all detail and reexpand it.
            List <DataGridContext> dataGridContexts = new List <DataGridContext>(xceedGrid.GetChildContexts());

            foreach (DataGridContext dataGridContext in dataGridContexts)
            {
                dataGridContext.ParentDataGridContext.CollapseDetails(dataGridContext.ParentItem);
                dataGridContext.ParentDataGridContext.ExpandDetails(dataGridContext.ParentItem);
            }
        }
예제 #6
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool             allowColumnReorder = true;
            ColumnManagerRow parentRow          = this.ParentRow as ColumnManagerRow;

            if (parentRow != null)
            {
                allowColumnReorder = parentRow.AllowColumnReorder;
            }

            DataGridContext sourceDetailContext = this.DataGridContext;

            Debug.Assert(sourceDetailContext != null);
            DetailConfiguration sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null;

            DataGridContext draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement);

            Debug.Assert(draggedDetailContext != null);
            DetailConfiguration draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null;


            return((sourceDetailConfig == draggedDetailConfig) &&
                   (sourceDetailContext != null) &&
                   (draggedDetailContext != null) &&
                   (sourceDetailContext.GroupLevelDescriptions == draggedDetailContext.GroupLevelDescriptions) &&
                   (allowColumnReorder) &&
                   (draggedElement is ColumnManagerCell) &&
                   (draggedElement != this));
        }
예제 #7
0
        protected override void StopListening(object source)
        {
            DataGridContext context = source as DataGridContext;

            if (context != null)
            {
                context.GroupConfigurationSelectorChanged -= new EventHandler(this.OnGroupConfigurationSelectorChanged);
                return;
            }

            DataGridControl dataGridControl = source as DataGridControl;

            if (dataGridControl != null)
            {
                dataGridControl.GroupConfigurationSelectorChanged -= new EventHandler(this.OnGroupConfigurationSelectorChanged);
                return;
            }

            DetailConfiguration detailConfig = source as DetailConfiguration;

            if (detailConfig != null)
            {
                detailConfig.GroupConfigurationSelectorChanged -= new EventHandler(this.OnGroupConfigurationSelectorChanged);
                return;
            }

            throw new InvalidOperationException("An attempt was made to unregister an item other than a DataGridContext, DataGridControl, or DetailConfiguration from the GroupConfigurationSelectorChangedEventManager.");
        }
        internal void Clear(DetailConfiguration detailConfiguration)
        {
            m_containersRemoved = m_containersRemoved ?? new List <DependencyObject>();

            var key = CustomItemContainerGeneratorRecyclingPools.GetKey(detailConfiguration);

            var itemContainerPool = default(ItemContainerRecyclingPool);

            if (m_itemContainerPools.TryGetValue(key, out itemContainerPool))
            {
                m_itemContainerPools.Remove(key);

                this.ClearPool(itemContainerPool, m_containersRemoved, pool => pool.Clear());
            }

            var headerFooterItemContainerPool = default(HeaderFooterItemContainerRecyclingPool);

            if (m_headerFooterItemContainerPools.TryGetValue(key, out headerFooterItemContainerPool))
            {
                m_headerFooterItemContainerPools.Remove(key);

                this.ClearPool(headerFooterItemContainerPool, m_containersRemoved, pool => pool.Clear());
            }

            var groupHeaderFooterItemContainerPool = default(GroupHeaderFooterItemContainerRecyclingPool);

            if (m_groupHeaderFooterItemContainerPools.TryGetValue(key, out groupHeaderFooterItemContainerPool))
            {
                m_groupHeaderFooterItemContainerPools.Remove(key);

                this.ClearPool(groupHeaderFooterItemContainerPool, m_containersRemoved, pool => pool.Clear());
            }

            this.OnContainersRemoved();
        }
        private T GetPool <T>(Dictionary <object, T> pools, DetailConfiguration detailConfiguration, bool create) where T : class, new()
        {
            if (pools == null)
            {
                throw new ArgumentNullException("pools");
            }

            var key  = CustomItemContainerGeneratorRecyclingPools.GetKey(detailConfiguration);
            var pool = default(T);

            if (!pools.TryGetValue(key, out pool))
            {
                if (create)
                {
                    pool = new T();
                    pools.Add(key, pool);
                }
                else
                {
                    pool = null;
                }
            }

            return(pool);
        }
예제 #10
0
        private static bool HasGroup(DetailConfigurationCollection configurations)
        {
            bool returnValue = false;

            int detailConfigurationCount = configurations.Count;

            for (int i = 0; i < detailConfigurationCount; i++)
            {
                DetailConfiguration detailConfiguration = configurations[i];

                if (detailConfiguration.DetailConfigurations != null)
                {
                    returnValue = GroupingHelper.HasGroup(detailConfiguration.DetailConfigurations);
                }

                if (returnValue)
                {
                    break;
                }

                returnValue = (detailConfiguration.GroupLevelDescriptions.Count > 0);

                if (returnValue)
                {
                    break;
                }
            }

            return(returnValue);
        }
        internal DataGridContextAutomationPeer GetDetailPeer(object parentItem, DetailConfiguration detailConfig)
        {
            DataGridItemAutomationPeer itemAutomationPeer = m_dataChildren[parentItem] as DataGridItemAutomationPeer;

            if (itemAutomationPeer == null)
            {
                return(null);
            }

            return(itemAutomationPeer.GetDetailPeer(detailConfig));
        }
        internal void AddDefaultHeadersFooters()
        {
            if (m_defaultHeadersFootersAdded)
            {
                return;
            }

            m_defaultHeadersFootersAdded = true;

            DetailConfiguration.AddDefaultHeadersFooters(this.Headers, this.Footers);
        }
예제 #13
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool           allowGroupingModification = true;
            GroupByControl parentGBC = this.GetParentGroupByControl();

            if (parentGBC != null)
            {
                allowGroupingModification = parentGBC.IsGroupingModificationAllowed;
            }

            // We don't accept any ColumnManagerCell from Details
            DataGridContext context = DataGridControl.GetDataGridContext(draggedElement);

            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            bool isAlreadyGroupedBy = false;

            if (cell != null)
            {
                isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell);
                ColumnBase parentColumn = cell.ParentColumn;

                if ((parentColumn == null) || (!parentColumn.AllowGroup))
                {
                    return(false);
                }
            }

            DataGridContext sourceDetailContext = DataGridControl.GetDataGridContext(this);

            Debug.Assert(sourceDetailContext != null);
            DetailConfiguration sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null;

            DataGridContext draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement);

            Debug.Assert(draggedDetailContext != null);
            DetailConfiguration draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null;


            bool canDrop = (sourceDetailConfig == draggedDetailConfig) &&
                           (allowGroupingModification) &&
                           ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) &&
                           (draggedElement != this) &&
                           (isAlreadyGroupedBy == false);

            if (canDrop && (cell != null))
            {
                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedDetailContext);
            }

            return(canDrop);
        }
예제 #14
0
        private void InitializeDetail(DetailConfiguration detail)
        {
            var childTable = CremaDataTableItemControl.GetReference(detail) as CremaDataTable;
            var diffState  = DiffUtility.GetDiffState(childTable);

            detail.Title = new DetailsDescriptor()
            {
                Title = childTable.TableName, DiffState = diffState,
            };
            detail.TitleTemplate = this.FindResource("Diff_DetailConfiguration_Title_Template") as DataTemplate;

            foreach (var item in detail.Columns)
            {
                item.PropertyChanged += Column_PropertyChanged;
            }
        }
예제 #15
0
        protected override void StopListening(object source)
        {
            DetailConfiguration detailConfig = source as DetailConfiguration;

            if (detailConfig != null)
            {
                detailConfig.VisibilityChanged -= new EventHandler(this.OnVisibilityChanged);
                return;
            }

            DetailConfigurationCollection detailConfigCollection = source as DetailConfigurationCollection;

            if (detailConfigCollection != null)
            {
                detailConfigCollection.DetailVisibilityChanged -= new EventHandler(this.OnVisibilityChanged);
            }
        }
예제 #16
0
        private static TreeViewItem GetTreeViewItemFromGroupLevelDescription(TreeViewItem rootItem, GroupLevelDescription groupLevelDescription)
        {
            TreeViewItem returned = null;

            Debug.Assert(rootItem != null);
            Debug.Assert(groupLevelDescription != null);

            if (rootItem == null)
            {
                throw new DataGridInternalException("rootItem is null.");
            }

            foreach (object item in rootItem.Items)
            {
                TreeViewItem child = rootItem.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;

                Debug.Assert(child != null);
                if (child == null)
                {
                    throw new DataGridInternalException("An item does not contain a valid item.");
                }

                DetailConfiguration detailConfiguration = child.Header as DetailConfiguration;

                if (detailConfiguration == null)
                {
                    throw new DataGridInternalException("An item's DataContext must be a DetailConfiguration except for the top-most HierarchicalGroupByControl, which contains a DataGridContext.");
                }

                if (detailConfiguration.GroupLevelDescriptions.Contains(groupLevelDescription))
                {
                    returned = child;
                    break;
                }

                returned = HierarchicalGroupByControl.GetTreeViewItemFromGroupLevelDescription(child, groupLevelDescription);

                if (returned != null)
                {
                    break;
                }
            }

            return(returned);
        }
        private static TreeViewItem GetTreeViewItemFromGroupLevelDescriptionCollection(TreeViewItem rootItem, GroupLevelDescriptionCollection groupLevelDescriptions)
        {
            TreeViewItem returned = null;

            Debug.Assert(rootItem != null);
            Debug.Assert(groupLevelDescriptions != null);

            if (rootItem == null)
            {
                throw new DataGridInternalException();
            }

            foreach (object item in rootItem.Items)
            {
                TreeViewItem child = rootItem.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;

                // It may not be visible
                if (child == null)
                {
                    continue;
                }

                DetailConfiguration detailConfiguration = child.Header as DetailConfiguration;

                if (detailConfiguration == null)
                {
                    throw new DataGridInternalException("The item's DataContext must be a DetailConfiguration except for the top-most HierarchicalGroupByControl, which contains a DataGridContext.");
                }

                if (groupLevelDescriptions == detailConfiguration.GroupLevelDescriptions)
                {
                    returned = child;
                    break;
                }

                returned = HierarchicalGroupByControl.GetTreeViewItemFromGroupLevelDescriptionCollection(child, groupLevelDescriptions);

                if (returned != null)
                {
                    break;
                }
            }

            return(returned);
        }
예제 #18
0
        private void FillColumns(DetailConfiguration detail, CremaDataTable table)
        {
            try
            {
                detail.Columns.Add(new Column()
                {
                    FieldName = CremaSchema.Index, ReadOnly = true, Width = 50, Title = nameof(CremaSchema.Index)
                });
#if DEBUG
                detail.Columns.Add(new Column()
                {
                    FieldName = CremaSchema.__ParentID__, ReadOnly = true,
                });
#endif
                detail.Columns.Add(this.FindResource("tagColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("enableColumn") as ColumnBase);

                foreach (var item in table.Columns)
                {
                    var column = new Column()
                    {
                        FieldName = item.ColumnName,
                    };
                    this.InitializeColumn(item, column);
                    detail.Columns.Add(column);
                }

                detail.Columns.Add(this.FindResource("modifierColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("modifiedDateTimeColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("creatorColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("createdDateTimeColumn") as ColumnBase);

                var firstPrimaryKeyColumnIndex = FirstPrimaryKeyColumnIndex(detail.VisibleColumns, table.PrimaryKey);
                if (firstPrimaryKeyColumnIndex >= 0)
                {
                    detail.SetValue(TableView.FixedColumnCountProperty, firstPrimaryKeyColumnIndex + 1);
                }
            }
            catch
            {
                throw new InvalidOperationException();
            }
        }
예제 #19
0
            internal SynchronizationKey(
                ColumnBase masterColumn,
                ColumnBase detailColumn,
                DetailConfiguration detailConfig)
            {
                if (detailColumn == null)
                {
                    throw new ArgumentNullException("detailColumn");
                }

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

                m_masterColumn        = masterColumn;
                m_detailColumn        = detailColumn;
                m_detailConfiguration = detailConfig;
            }
예제 #20
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool isAlreadyGroupedBy = false;

            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            if (cell != null)
            {
                isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell);
                ColumnBase parentColumn = cell.ParentColumn;

                if ((parentColumn == null) || (!parentColumn.AllowGroup))
                {
                    return(false);
                }
            }

            DataGridContext sourceDetailContext = DataGridControl.GetDataGridContext(this);

            Debug.Assert(sourceDetailContext != null);
            DetailConfiguration sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null;

            DataGridContext draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement);

            Debug.Assert(draggedDetailContext != null);
            DetailConfiguration draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null;


            bool canDrop = (sourceDetailConfig == draggedDetailConfig) &&
                           (sourceDetailContext != null) &&
                           (draggedDetailContext != null) &&
                           (sourceDetailContext.GroupLevelDescriptions == draggedDetailContext.GroupLevelDescriptions) &&
                           (this.IsGroupingModificationAllowed) &&
                           ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) &&
                           (!isAlreadyGroupedBy);

            if (canDrop && (cell != null))
            {
                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedDetailContext);
            }

            return(canDrop);
        }
예제 #21
0
        protected override void StopListening(object source)
        {
            DataGridControl dataGridControl = source as DataGridControl;

            if (dataGridControl != null)
            {
                dataGridControl.MaxGroupLevelsChanged -= new EventHandler(this.OnMaxGroupLevelsChanged);
                return;
            }

            DetailConfiguration detailConfiguration = source as DetailConfiguration;

            if (detailConfiguration != null)
            {
                detailConfiguration.MaxGroupLevelsChanged -= new EventHandler(this.OnMaxGroupLevelsChanged);
                return;
            }

            throw new ArgumentException("The specified source must be a DataGridControl or a DetailConfiguration.", "source");
        }
        internal ColumnSynchronizationManager(DetailConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            m_detailConfiguration = configuration;
            m_itemPropertyMap     = configuration.ItemPropertyMap;

            PropertyChangedEventManager.AddListener(configuration, this, string.Empty);
            MappingChangedEventManager.AddListener(m_itemPropertyMap, this);

            using (this.DeferSynchronization())
            {
                this.DataGridControl     = configuration.DataGridControl;
                this.DetailColumnManager = configuration.ColumnManager;

                Debug.Assert(m_detailColumnManager != null);
            }
        }
예제 #23
0
        private void FillColumns(DetailConfiguration detail, CremaDataTable table)
        {
            try
            {
#if DEBUG
                detail.Columns.Add(new Column()
                {
                    FieldName = CremaSchema.Index, ReadOnly = true
                });
                detail.Columns.Add(new Column()
                {
                    FieldName = CremaSchema.__ParentID__, ReadOnly = true,
                });
#endif
                detail.Columns.Add(this.FindResource("tagColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("enableColumn") as ColumnBase);

                foreach (var item in table.Columns)
                {
                    var column = new Column()
                    {
                        FieldName = item.ColumnName,
                    };
                    this.InitializeColumn(item, column);
                    detail.Columns.Add(column);
                }

                detail.Columns.Add(this.FindResource("modifierColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("modifiedDateTimeColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("creatorColumn") as ColumnBase);
                detail.Columns.Add(this.FindResource("createdDateTimeColumn") as ColumnBase);

                detail.SetValue(TableView.FixedColumnCountProperty, 2 + table.PrimaryKey.Length);
            }
            catch
            {
                throw new InvalidOperationException();
            }
        }
예제 #24
0
        internal ColumnSynchronizationManager(DetailConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            m_detailConfiguration = configuration;
            m_itemPropertyMap     = configuration.ItemPropertyMap;

            PropertyChangedEventManager.AddListener(configuration, this, ColumnSynchronizationManager.DetailConfigurationDataGridControlPropertyName);
            PropertyChangedEventManager.AddListener(configuration, this, ColumnSynchronizationManager.DetailConfigurationIsAttachedToDetailDescriptionPropertyName);
            CollectionChangedEventManager.AddListener(( INotifyCollectionChanged )m_itemPropertyMap, this);

            using (this.DeferSynchronization())
            {
                this.DataGridControl = configuration.DataGridControl;
                this.DetailColumns   = configuration.Columns;

                Debug.Assert(this.DetailColumns != null);
            }
        }
예제 #25
0
 public static void RemoveListener(DetailConfiguration source, IWeakEventListener listener)
 {
     CurrentManager.ProtectedRemoveListener(source, listener);
 }
 internal ColumnCollection(DataGridControl dataGridControl, DetailConfiguration parentDetailConfiguration)
     : base()
 {
     this.DataGridControl           = dataGridControl;
     this.ParentDetailConfiguration = parentDetailConfiguration;
 }
예제 #27
0
 public static void SetReference(DetailConfiguration obj, object value)
 {
     obj.SetValue(ReferenceProperty, value);
 }
 internal DataGridContextAutomationPeer GetDetailPeer( DetailConfiguration detailConfig )
 {
   return m_dataChildren[ detailConfig ] as DataGridContextAutomationPeer;
 }
예제 #29
0
        protected override void StopListening(object source)
        {
            DetailConfiguration detailConfig = ( DetailConfiguration )source;

            detailConfig.CurrentColumnChanged -= new EventHandler(this.OnCurrentColumnChanged);
        }
 internal DataGridContextAutomationPeer GetDetailPeer(DetailConfiguration detailConfig)
 {
     return(m_dataChildren[detailConfig] as DataGridContextAutomationPeer);
 }
 internal static void AddListener(DetailConfiguration source, IWeakEventListener listener)
 {
     CurrentManager.ProtectedAddListener(source, listener);
 }
예제 #32
0
 public static object GetReference(DetailConfiguration obj)
 {
     return((object)obj.GetValue(ReferenceProperty));
 }
    internal DataGridContextAutomationPeer GetDetailPeer( object parentItem, DetailConfiguration detailConfig )
    {
      DataGridItemAutomationPeer itemAutomationPeer = m_dataChildren[ parentItem ] as DataGridItemAutomationPeer;

      if( itemAutomationPeer == null )
        return null;

      return itemAutomationPeer.GetDetailPeer( detailConfig );
    }