Exemplo n.º 1
0
 private void HookupItemsControlKeyboardEvent(TreeGridColumnHeader header)
 {
     if (this._itemsControl != null)
     {
         this._itemsControl.KeyDown += new KeyEventHandler(header.OnColumnHeaderKeyDown);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 为指定列生成 header 并添加到 InternalChildren 的索引 index 处。
        /// </summary>
        /// <param name="column"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private TreeGridColumnHeader CreateAndInsertHeader(TreeGridColumn column, int index)
        {
            object header = column.Header;
            var    gridViewColumnHeader = header as TreeGridColumnHeader;

            if (header != null)
            {
                var dependencyObject = header as DependencyObject;
                if (dependencyObject != null)
                {
                    var visual = dependencyObject as Visual;
                    if (visual != null)
                    {
                        var visual2 = VisualTreeHelper.GetParent(visual) as Visual;
                        if (visual2 != null)
                        {
                            if (gridViewColumnHeader != null)
                            {
                                var gridViewHeaderRowPresenter = visual2 as TreeGridHeaderRowPresenter;
                                if (gridViewHeaderRowPresenter != null)
                                {
                                    MSInternal.RemoveNoVerify(gridViewHeaderRowPresenter.UIChildren, gridViewColumnHeader);
                                }
                            }
                            else
                            {
                                var gridViewColumnHeader2 = visual2 as TreeGridColumnHeader;
                                if (gridViewColumnHeader2 != null)
                                {
                                    gridViewColumnHeader2.ClearValue(ContentControl.ContentProperty);
                                }
                            }
                        }
                    }
                    var parent = LogicalTreeHelper.GetParent(dependencyObject);
                    if (parent != null)
                    {
                        MSInternal.RemoveLogicalChild(parent, header);
                    }
                }
            }

            if (gridViewColumnHeader == null)
            {
                gridViewColumnHeader = new TreeGridColumnHeader();
                gridViewColumnHeader.IsInternalGenerated = true;
            }

            gridViewColumnHeader.SetValue(TreeGridColumnHeader.ColumnPropertyKey, column);

            this.HookupItemsControlKeyboardEvent(gridViewColumnHeader);

            base.UIChildren.Insert(index, gridViewColumnHeader);

            this.UpdateHeader(gridViewColumnHeader);

            this._gvHeadersValid = false;

            return(gridViewColumnHeader);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新指定 Header 的指定依赖属性。
        /// </summary>
        /// <param name="header"></param>
        /// <param name="targetDP"></param>
        /// <param name="columnDP"></param>
        /// <param name="gvDP"></param>
        private void UpdateHeaderProperty(TreeGridColumnHeader header, DependencyProperty targetDP, DependencyProperty columnDP, DependencyProperty gvDP)
        {
            if (gvDP == TreeGridHeaderRowPresenter.ColumnHeaderContainerStyleProperty && header.Role == TreeGridColumnHeaderRole.Padding)
            {
                Style columnHeaderContainerStyle = this.ColumnHeaderContainerStyle;
                if (columnHeaderContainerStyle != null && !columnHeaderContainerStyle.TargetType.IsAssignableFrom(typeof(TreeGridColumnHeader)))
                {
                    header.Style = null;
                    return;
                }
            }

            object value = null;

            var column = header.Column;

            if (column != null && columnDP != null)
            {
                value = column.GetValue(columnDP);
            }

            if (value == null)
            {
                value = base.GetValue(gvDP);
            }

            header.UpdateProperty(targetDP, value);
        }
Exemplo n.º 4
0
        private TreeGridColumnHeader FindHeaderByColumn(TreeGridColumn column)
        {
            var columns = base.Columns;
            UIElementCollection internalChildren = base.UIChildren;

            if (internalChildren.Count > columns.Count)
            {
                int num = columns.IndexOf(column);
                if (num != -1)
                {
                    int visualIndex = this.GetVisualIndex(num);
                    TreeGridColumnHeader gridViewColumnHeader = internalChildren[visualIndex] as TreeGridColumnHeader;
                    if (gridViewColumnHeader.Column == column)
                    {
                        return(gridViewColumnHeader);
                    }
                    for (int i = 1; i < internalChildren.Count; i++)
                    {
                        gridViewColumnHeader = (internalChildren[i] as TreeGridColumnHeader);
                        if (gridViewColumnHeader != null && gridViewColumnHeader.Column == column)
                        {
                            return(gridViewColumnHeader);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        private void UpdateFloatingHeader(TreeGridColumnHeader srcHeader)
        {
            this._floatingHeader.Style             = srcHeader.Style;
            this._floatingHeader.FloatSourceHeader = srcHeader;
            this._floatingHeader.Width             = srcHeader.ActualWidth;
            this._floatingHeader.Height            = srcHeader.ActualHeight;
            this._floatingHeader.SetValue(TreeGridColumnHeader.ColumnPropertyKey, srcHeader.Column);
            this._floatingHeader.Visibility = Visibility.Hidden;
            this._floatingHeader.MinWidth   = srcHeader.MinWidth;
            this._floatingHeader.MinHeight  = srcHeader.MinHeight;
            object obj = srcHeader.ReadLocalValue(ContentControl.ContentTemplateProperty);

            if (obj != DependencyProperty.UnsetValue && obj != null)
            {
                this._floatingHeader.ContentTemplate = srcHeader.ContentTemplate;
            }
            object obj2 = srcHeader.ReadLocalValue(ContentControl.ContentTemplateSelectorProperty);

            if (obj2 != DependencyProperty.UnsetValue && obj2 != null)
            {
                this._floatingHeader.ContentTemplateSelector = srcHeader.ContentTemplateSelector;
            }
            if (!(srcHeader.Content is Visual))
            {
                this._floatingHeader.Content = srcHeader.Content;
            }
        }
Exemplo n.º 6
0
        internal void UpdateHeaderProperty(TreeGridColumnHeader header, DependencyProperty property)
        {
            DependencyProperty gvDP;
            DependencyProperty columnDP;
            DependencyProperty targetDP;

            GetMatchingDPs(property, out gvDP, out columnDP, out targetDP);
            this.UpdateHeaderProperty(header, targetDP, columnDP, gvDP);
        }
Exemplo n.º 7
0
        private void OnHeaderLabelChanged(DependencyPropertyChangedEventArgs e)
        {
            var value = (string)e.NewValue;

            _header = new TreeGridColumnHeader
            {
                Content = value
            };
            this.Header = _header;
        }
Exemplo n.º 8
0
        private void UpdateHeader(TreeGridColumnHeader header)
        {
            this.UpdateHeaderContent(header);
            int i   = 0;
            int num = s_DPList[0].Length;

            while (i < num)
            {
                this.UpdateHeaderProperty(header, s_DPList[2][i], s_DPList[1][i], s_DPList[0][i]);
                i++;
            }
        }
Exemplo n.º 9
0
 private void RemoveHeader(TreeGridColumnHeader header, int index)
 {
     this._gvHeadersValid = false;
     if (header != null)
     {
         base.UIChildren.Remove(header);
     }
     else
     {
         header = (TreeGridColumnHeader)base.UIChildren[index];
         base.UIChildren.RemoveAt(index);
     }
     this.UnhookItemsControlKeyboardEvent(header);
 }
Exemplo n.º 10
0
        private void BuildHeaderLinks()
        {
            TreeGridColumnHeader previousVisualHeader = null;

            for (int i = 0; i < base.Columns.Count; i++)
            {
                TreeGridColumnHeader gridViewColumnHeader = (TreeGridColumnHeader)base.UIChildren[this.GetVisualIndex(i)];
                gridViewColumnHeader.PreviousVisualHeader = previousVisualHeader;
                previousVisualHeader = gridViewColumnHeader;
            }
            if (this._paddingHeader != null)
            {
                this._paddingHeader.PreviousVisualHeader = previousVisualHeader;
            }
        }
Exemplo n.º 11
0
 private void PrepareHeaderDrag(TreeGridColumnHeader header, Point pos, Point relativePos, bool cancelInvoke)
 {
     if (header.Role == TreeGridColumnHeaderRole.Normal)
     {
         this._prepareDragging   = true;
         this._isHeaderDragging  = false;
         this._draggingSrcHeader = header;
         this._startPos          = pos;
         this._relativeStartPos  = relativePos;
         if (!cancelInvoke)
         {
             this._startColumnIndex = this.FindIndexByPosition(this._startPos, false);
         }
     }
 }
Exemplo n.º 12
0
 private void UpdateHeaderContent(TreeGridColumnHeader header)
 {
     if (header != null && header.IsInternalGenerated)
     {
         TreeGridColumn column = header.Column;
         if (column != null)
         {
             if (column.Header == null)
             {
                 header.ClearValue(ContentControl.ContentProperty);
                 return;
             }
             header.Content = column.Header;
         }
     }
 }
Exemplo n.º 13
0
        private void AddPaddingColumnHeader()
        {
            var header = new TreeGridColumnHeader();

            header.IsInternalGenerated = true;
            header.SetValue(TreeGridColumnHeader.RolePropertyKey, TreeGridColumnHeaderRole.Padding);
            header.Content                 = null;
            header.ContentTemplate         = null;
            header.ContentTemplateSelector = null;
            header.MinWidth                = 0.0;
            header.Padding                 = new Thickness(0.0);
            header.Width = double.NaN;
            header.HorizontalAlignment = HorizontalAlignment.Stretch;

            base.UIChildren.Add(header);

            this._paddingHeader = header;
        }
Exemplo n.º 14
0
        private void AddFloatingHeader(TreeGridColumnHeader srcHeader)
        {
            Type type = srcHeader != null?srcHeader.GetType() : typeof(TreeGridColumnHeader);

            TreeGridColumnHeader header;

            try
            {
                header = Activator.CreateInstance(type) as TreeGridColumnHeader;
            }
            catch (MissingMethodException innerException)
            {
                throw new ArgumentException("ListView_MissingParameterlessConstructor", innerException);
            }
            header.IsInternalGenerated = true;
            header.SetValue(TreeGridColumnHeader.RolePropertyKey, TreeGridColumnHeaderRole.Floating);
            header.Visibility = Visibility.Hidden;

            base.UIChildren.Add(header);

            this._floatingHeader = header;
        }
Exemplo n.º 15
0
 private void UpdateHeaderContent(TreeGridColumnHeader header)
 {
     if (header != null && header.IsInternalGenerated)
     {
         TreeGridColumn column = header.Column;
         if (column != null)
         {
             if (column.Header == null)
             {
                 header.ClearValue(ContentControl.ContentProperty);
                 return;
             }
             header.Content = column.Header;
         }
     }
 }
Exemplo n.º 16
0
 internal void UpdateHeaderProperty(TreeGridColumnHeader header, DependencyProperty property)
 {
     DependencyProperty gvDP;
     DependencyProperty columnDP;
     DependencyProperty targetDP;
     GetMatchingDPs(property, out gvDP, out columnDP, out targetDP);
     this.UpdateHeaderProperty(header, targetDP, columnDP, gvDP);
 }
Exemplo n.º 17
0
        /// <summary>
        /// 更新指定 Header 的指定依赖属性。
        /// </summary>
        /// <param name="header"></param>
        /// <param name="targetDP"></param>
        /// <param name="columnDP"></param>
        /// <param name="gvDP"></param>
        private void UpdateHeaderProperty(TreeGridColumnHeader header, DependencyProperty targetDP, DependencyProperty columnDP, DependencyProperty gvDP)
        {
            if (gvDP == TreeGridHeaderRowPresenter.ColumnHeaderContainerStyleProperty && header.Role == TreeGridColumnHeaderRole.Padding)
            {
                Style columnHeaderContainerStyle = this.ColumnHeaderContainerStyle;
                if (columnHeaderContainerStyle != null && !columnHeaderContainerStyle.TargetType.IsAssignableFrom(typeof(TreeGridColumnHeader)))
                {
                    header.Style = null;
                    return;
                }
            }

            object value = null;

            var column = header.Column;
            if (column != null && columnDP != null)
            {
                value = column.GetValue(columnDP);
            }

            if (value == null)
            {
                value = base.GetValue(gvDP);
            }

            header.UpdateProperty(targetDP, value);
        }
Exemplo n.º 18
0
        private void AddPaddingColumnHeader()
        {
            var header = new TreeGridColumnHeader();
            header.IsInternalGenerated = true;
            header.SetValue(TreeGridColumnHeader.RolePropertyKey, TreeGridColumnHeaderRole.Padding);
            header.Content = null;
            header.ContentTemplate = null;
            header.ContentTemplateSelector = null;
            header.MinWidth = 0.0;
            header.Padding = new Thickness(0.0);
            header.Width = double.NaN;
            header.HorizontalAlignment = HorizontalAlignment.Stretch;

            base.UIChildren.Add(header);

            this._paddingHeader = header;
        }
Exemplo n.º 19
0
        private void AddFloatingHeader(TreeGridColumnHeader srcHeader)
        {
            Type type = srcHeader != null ? srcHeader.GetType() : typeof(TreeGridColumnHeader);
            TreeGridColumnHeader header;
            try
            {
                header = Activator.CreateInstance(type) as TreeGridColumnHeader;
            }
            catch (MissingMethodException innerException)
            {
                throw new ArgumentException("ListView_MissingParameterlessConstructor", innerException);
            }
            header.IsInternalGenerated = true;
            header.SetValue(TreeGridColumnHeader.RolePropertyKey, TreeGridColumnHeaderRole.Floating);
            header.Visibility = Visibility.Hidden;

            base.UIChildren.Add(header);

            this._floatingHeader = header;
        }
Exemplo n.º 20
0
        /// <summary>
        /// 为指定列生成 header 并添加到 InternalChildren 的索引 index 处。
        /// </summary>
        /// <param name="column"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private TreeGridColumnHeader CreateAndInsertHeader(TreeGridColumn column, int index)
        {
            object header = column.Header;
            var gridViewColumnHeader = header as TreeGridColumnHeader;
            if (header != null)
            {
                var dependencyObject = header as DependencyObject;
                if (dependencyObject != null)
                {
                    var visual = dependencyObject as Visual;
                    if (visual != null)
                    {
                        var visual2 = VisualTreeHelper.GetParent(visual) as Visual;
                        if (visual2 != null)
                        {
                            if (gridViewColumnHeader != null)
                            {
                                var gridViewHeaderRowPresenter = visual2 as TreeGridHeaderRowPresenter;
                                if (gridViewHeaderRowPresenter != null)
                                {
                                    MSInternal.RemoveNoVerify(gridViewHeaderRowPresenter.UIChildren, gridViewColumnHeader);
                                }
                            }
                            else
                            {
                                var gridViewColumnHeader2 = visual2 as TreeGridColumnHeader;
                                if (gridViewColumnHeader2 != null)
                                {
                                    gridViewColumnHeader2.ClearValue(ContentControl.ContentProperty);
                                }
                            }
                        }
                    }
                    var parent = LogicalTreeHelper.GetParent(dependencyObject);
                    if (parent != null)
                    {
                        MSInternal.RemoveLogicalChild(parent, header);
                    }
                }
            }

            if (gridViewColumnHeader == null)
            {
                gridViewColumnHeader = new TreeGridColumnHeader();
                gridViewColumnHeader.IsInternalGenerated = true;
            }

            gridViewColumnHeader.SetValue(TreeGridColumnHeader.ColumnPropertyKey, column);

            this.HookupItemsControlKeyboardEvent(gridViewColumnHeader);

            base.UIChildren.Insert(index, gridViewColumnHeader);

            this.UpdateHeader(gridViewColumnHeader);

            this._gvHeadersValid = false;

            return gridViewColumnHeader;
        }
Exemplo n.º 21
0
 private void HookupItemsControlKeyboardEvent(TreeGridColumnHeader header)
 {
     if (this._itemsControl != null)
     {
         this._itemsControl.KeyDown += new KeyEventHandler(header.OnColumnHeaderKeyDown);
     }
 }
Exemplo n.º 22
0
 private void PrepareHeaderDrag(TreeGridColumnHeader header, Point pos, Point relativePos, bool cancelInvoke)
 {
     if (header.Role == TreeGridColumnHeaderRole.Normal)
     {
         this._prepareDragging = true;
         this._isHeaderDragging = false;
         this._draggingSrcHeader = header;
         this._startPos = pos;
         this._relativeStartPos = relativePos;
         if (!cancelInvoke)
         {
             this._startColumnIndex = this.FindIndexByPosition(this._startPos, false);
         }
     }
 }
Exemplo n.º 23
0
 private void RemoveHeader(TreeGridColumnHeader header, int index)
 {
     this._gvHeadersValid = false;
     if (header != null)
     {
         base.UIChildren.Remove(header);
     }
     else
     {
         header = (TreeGridColumnHeader)base.UIChildren[index];
         base.UIChildren.RemoveAt(index);
     }
     this.UnhookItemsControlKeyboardEvent(header);
 }
Exemplo n.º 24
0
 private void UpdateHeader(TreeGridColumnHeader header)
 {
     this.UpdateHeaderContent(header);
     int i = 0;
     int num = s_DPList[0].Length;
     while (i < num)
     {
         this.UpdateHeaderProperty(header, s_DPList[2][i], s_DPList[1][i], s_DPList[0][i]);
         i++;
     }
 }
Exemplo n.º 25
0
 private void OnHeaderLabelChanged(DependencyPropertyChangedEventArgs e)
 {
     var value = (string)e.NewValue;
     _header = new TreeGridColumnHeader
     {
         Content = value
     };
     this.Header = _header;
 }
Exemplo n.º 26
0
 private void UpdateFloatingHeader(TreeGridColumnHeader srcHeader)
 {
     this._floatingHeader.Style = srcHeader.Style;
     this._floatingHeader.FloatSourceHeader = srcHeader;
     this._floatingHeader.Width = srcHeader.ActualWidth;
     this._floatingHeader.Height = srcHeader.ActualHeight;
     this._floatingHeader.SetValue(TreeGridColumnHeader.ColumnPropertyKey, srcHeader.Column);
     this._floatingHeader.Visibility = Visibility.Hidden;
     this._floatingHeader.MinWidth = srcHeader.MinWidth;
     this._floatingHeader.MinHeight = srcHeader.MinHeight;
     object obj = srcHeader.ReadLocalValue(ContentControl.ContentTemplateProperty);
     if (obj != DependencyProperty.UnsetValue && obj != null)
     {
         this._floatingHeader.ContentTemplate = srcHeader.ContentTemplate;
     }
     object obj2 = srcHeader.ReadLocalValue(ContentControl.ContentTemplateSelectorProperty);
     if (obj2 != DependencyProperty.UnsetValue && obj2 != null)
     {
         this._floatingHeader.ContentTemplateSelector = srcHeader.ContentTemplateSelector;
     }
     if (!(srcHeader.Content is Visual))
     {
         this._floatingHeader.Content = srcHeader.Content;
     }
 }