public void DumpGridColumnStylesCollection (GridColumnStylesCollection ts)
		{
			Console.WriteLine ("IsSynchronized {0} ", ts.IsSynchronized);
			Console.WriteLine ("SyncRoot {0} ", ts.SyncRoot);
			//Console.WriteLine ("IsFixedSize {0} ", ts.IsFixedSize);
			Console.WriteLine ("IsReadOnly {0} ", ts.IsReadOnly);
		}
        internal protected override int MinimumRowHeight(GridColumnStylesCollection cols) {
            /*
            if (DataGrid != null && DataGrid.LinkFontHeight + this.dgTable.relationshipSpacing != relationshipHeight) {
                relationshipRect = Rectangle.Empty;
                relationshipHeight = DataGrid.LinkFontHeight + this.dgTable.relationshipSpacing;
            }
            */

            return base.MinimumRowHeight(cols) + (this.expanded ? GetRelationshipRect().Height : 0);
        }
 public void PushState(System.Windows.Forms.DataGrid dataGrid)
 {
     this.DataSource = dataGrid.DataSource;
     this.DataMember = dataGrid.DataMember;
     this.DataGrid = dataGrid;
     this.DataGridRows = dataGrid.DataGridRows;
     this.DataGridRowsLength = dataGrid.DataGridRowsLength;
     this.FirstVisibleRow = dataGrid.firstVisibleRow;
     this.FirstVisibleCol = dataGrid.firstVisibleCol;
     this.CurrentRow = dataGrid.currentRow;
     this.GridColumnStyles = new GridColumnStylesCollection(dataGrid.myGridTable);
     this.GridColumnStyles.Clear();
     foreach (DataGridColumnStyle style in dataGrid.myGridTable.GridColumnStyles)
     {
         this.GridColumnStyles.Add(style);
     }
     this.ListManager = dataGrid.ListManager;
     this.ListManager.ItemChanged += new ItemChangedEventHandler(this.DataSource_Changed);
     this.ListManager.MetaDataChanged += new EventHandler(this.DataSource_MetaDataChanged);
     this.CurrentCol = dataGrid.currentCol;
 }
        /// <summary>
        /// Initiates a recalculation of the needed filter GUI elements and their positions.
        /// </summary>
        private void RecreateGridFilters()
        {
            //first clean up what has beed done before

            foreach (DataGridColumnStyle columnStyle in _columnStyleToGridFilterHash.Keys)
            {
                IGridFilter gridFilter = _columnStyleToGridFilterHash[columnStyle] as IGridFilter;
                gridFilter.Changed -= new EventHandler(OnFilterChanged);
                gridFilter.FilterControl.KeyPress -= new KeyPressEventHandler(OnFilterControlKeyPress);
                gridFilter.FilterControl.Leave -= new EventHandler(OnFilterControlLeave);
                columnStyle.WidthChanged -= new EventHandler(OnColumnStyleWidthChanged);
                if (this.Controls.Contains(gridFilter.FilterControl))
                {
                    this.Controls.Remove(gridFilter.FilterControl);
                    gridFilter.FilterControl.Dispose();
                }
            }
            _columnStyleToGridFilterHash.Clear();

            if (_currentTableStyle != null)
            {
                _currentTableStyle.RowHeaderWidthChanged -= new EventHandler(OnCurrentTableStyleRowHeaderWidthChanged);
                _currentTableStyle.RowHeadersVisibleChanged -= new EventHandler(OnCurrentTableStyleRowHeadersVisibleChanged);
                _currentColumnStyleCollection.CollectionChanged -= new CollectionChangeEventHandler(OnGridColumnStylesCollectionChanged);
                _currentTableStyle = null;
                _currentColumnStyleCollection = null;
            }

            //adjust the position for the filter GUI
            this.Height = _refBox.Height;

            if (_gridExtension == null)
                return;

            _lblFilter.Width = _grid.RowHeaderWidth;

            if (_gridExtension.CurrentView == null)
            {
                //provide a dummy represantation when nothing is set
                //this allows better desing time support
                _refBox.Visible = true;
                _refBox.Left = _grid.RowHeaderWidth + 1;
                _refBox.Width = this.Width - _grid.RowHeaderWidth - 1;
                return;
            }
            _refBox.Visible = false;

            if (_grid.TableStyles.Contains(_gridExtension.CurrentView.Table.TableName))
            {
                //get the appropriate table style
                _currentTableStyle = _grid.TableStyles[_gridExtension.CurrentView.Table.TableName];
                _currentTableStyle.RowHeaderWidthChanged += new EventHandler(OnCurrentTableStyleRowHeaderWidthChanged);
                _currentTableStyle.RowHeadersVisibleChanged += new EventHandler(OnCurrentTableStyleRowHeadersVisibleChanged);

                _currentColumnStyleCollection = _currentTableStyle.GridColumnStyles;
                _currentColumnStyleCollection.CollectionChanged += new CollectionChangeEventHandler(OnGridColumnStylesCollectionChanged);

                _filterFactory.BeginGridFilterCreation();
                try
                {
                    foreach (DataGridColumnStyle columnStyle in _currentColumnStyleCollection)
                    {
                        //we need notification when the width of the column changes
                        columnStyle.WidthChanged += new EventHandler(OnColumnStyleWidthChanged);
                        //get the datatype
                        Type dataType = _gridExtension.CurrentView.Table.Columns[columnStyle.MappingName].DataType;
                        //create a filter
                        IGridFilter gridFilter = _filterFactory.CreateGridFilter(_gridExtension.CurrentView.Table.Columns[columnStyle.MappingName], columnStyle);
                        if (!gridFilter.UseCustomFilterPlacement)
                        {
                            //adjust the vertical positions
                            gridFilter.FilterControl.Top = 0;
                            gridFilter.FilterControl.Height = this.Height;
                            gridFilter.FilterControl.Visible = false;
                            //add the GUI element to our controls collection
                            this.Controls.Add(gridFilter.FilterControl);
                            gridFilter.FilterControl.BringToFront();
                        }
                        //notification needed when the filter settings are changed
                        gridFilter.Changed += new EventHandler(OnFilterChanged);
                        gridFilter.FilterControl.KeyPress += new KeyPressEventHandler(OnFilterControlKeyPress);
                        gridFilter.FilterControl.Leave += new EventHandler(OnFilterControlLeave);
                        //added to hash to provider fast access
                        _columnStyleToGridFilterHash.Add(columnStyle, gridFilter);
                    }
                }
                finally
                {
                    _filterFactory.EndGridFilterCreation();
                }
                if (_keepFilters && _keepFiltersHash.ContainsKey(_gridExtension.CurrentView.Table.TableName))
                    SetFilters((string[])_keepFiltersHash[_gridExtension.CurrentView.Table.TableName]);
            }

            RepositionGridFilters();
        }
Example #5
0
		public DataGridTableStyle (bool isDefaultTableStyle)
		{
			is_default = isDefaultTableStyle;
			allow_sorting = true;
			datagrid = null;
			header_forecolor = def_header_forecolor;
			mapping_name = string.Empty;
			table_relations = new ArrayList ();
			column_styles = new GridColumnStylesCollection (this);

			alternating_backcolor = def_alternating_backcolor;
			columnheaders_visible = true;
			gridline_color = def_gridline_color;
			gridline_style = DataGridLineStyle.Solid;
			header_backcolor = def_header_backcolor;
			header_font = null;
			link_color = def_link_color;
			link_hovercolor = def_link_hovercolor;
			preferredcolumn_width = ThemeEngine.Current.DataGridPreferredColumnWidth;
			preferredrow_height = ThemeEngine.Current.DefaultFont.Height + 3;
			_readonly = false;
			rowheaders_visible = true;
			selection_backcolor = def_selection_backcolor;
			selection_forecolor = def_selection_forecolor;
			rowheaders_width = 35;
			backcolor = def_backcolor;
			forecolor = def_forecolor;
		}
Example #6
0
        /// <summary>
        /// Get Header Title and Index of table of DataGridTableStyle
        /// </summary>
        /// <param name="view"></param>
        /// <param name="cols"></param>
        /// <param name="headers"></param>
        /// <param name="indexes"></param>
        /// <remarks>
        /// Author:			PhatLT. FPTSS.
        /// Created date:	14/02/2011
        /// </remarks>
        public void GetExportInfo(DataView view, GridColumnStylesCollection cols, ref string[]headers, ref int [] indexes)
        {
            int count = cols.Count;
            headers = new string[count];
            indexes = new int[count];
            DataTable dt = view.Table;

            for(int i = 0; i < count; i ++)
            {
                headers[i] = cols[i].HeaderText;
                indexes[i] = GetColumnIndex(dt, cols[i].MappingName);
            }
        }
 protected internal override int MinimumRowHeight(GridColumnStylesCollection cols)
 {
     return (base.MinimumRowHeight(cols) + (this.expanded ? this.GetRelationshipRect().Height : 0));
 }
Example #8
0
        internal protected virtual int MinimumRowHeight(GridColumnStylesCollection columns) {
            int h = dgTable.IsDefault ? this.DataGrid.PreferredRowHeight : dgTable.PreferredRowHeight;

            try {
                if (this.dgTable.DataGrid.DataSource != null) {
                    int nCols = columns.Count;
                    for (int i = 0; i < nCols; ++i) {
                        // if (columns[i].Visible && columns[i].PropertyDescriptor != null)
                        if (columns[i].PropertyDescriptor != null)
                            h = Math.Max(h, columns[i].GetMinimumHeight());
                    }
                }
            }
            catch {
            }
            return h;
        }
 protected internal virtual int MinimumRowHeight(GridColumnStylesCollection columns)
 {
     int num = this.dgTable.IsDefault ? this.DataGrid.PreferredRowHeight : this.dgTable.PreferredRowHeight;
     try
     {
         if (this.dgTable.DataGrid.DataSource == null)
         {
             return num;
         }
         int count = columns.Count;
         for (int i = 0; i < count; i++)
         {
             if (columns[i].PropertyDescriptor != null)
             {
                 num = Math.Max(num, columns[i].GetMinimumHeight());
             }
         }
     }
     catch
     {
     }
     return num;
 }
 /// <include file='doc\DataGridTable.uex' path='docs/doc[@for="DataGridTableStyle.DataGridTableStyle"]/*' />
 /// <internalonly/>
 /// <devdoc>
 /// <para>Initializes a new instance of the <see cref='System.Windows.Forms.DataGridTableStyle'/> class.</para>
 /// </devdoc>
 public DataGridTableStyle(bool isDefaultTableStyle) {
     gridColumns = new GridColumnStylesCollection(this, isDefaultTableStyle);
     gridColumns.CollectionChanged += new CollectionChangeEventHandler(this.OnColumnCollectionChanged);
     this.isDefaultTableStyle = isDefaultTableStyle;
 }
 public DataGridTableStyle(bool isDefaultTableStyle)
 {
     this.relationshipRect = Rectangle.Empty;
     this.focusedRelation = -1;
     this.relationsList = new ArrayList(2);
     this.mappingName = "";
     this.allowSorting = true;
     this.alternatingBackBrush = DefaultAlternatingBackBrush;
     this.backBrush = DefaultBackBrush;
     this.foreBrush = DefaultForeBrush;
     this.gridLineBrush = DefaultGridLineBrush;
     this.gridLineStyle = DataGridLineStyle.Solid;
     this.headerBackBrush = DefaultHeaderBackBrush;
     this.headerForeBrush = DefaultHeaderForeBrush;
     this.headerForePen = DefaultHeaderForePen;
     this.linkBrush = DefaultLinkBrush;
     this.preferredColumnWidth = 0x4b;
     this.prefferedRowHeight = defaultFontHeight + 3;
     this.selectionBackBrush = DefaultSelectionBackBrush;
     this.selectionForeBrush = DefaultSelectionForeBrush;
     this.rowHeaderWidth = 0x23;
     this.rowHeadersVisible = true;
     this.columnHeadersVisible = true;
     this.gridColumns = new GridColumnStylesCollection(this, isDefaultTableStyle);
     this.gridColumns.CollectionChanged += new CollectionChangeEventHandler(this.OnColumnCollectionChanged);
     this.isDefaultTableStyle = isDefaultTableStyle;
 }
 private int MoveLeftRight(GridColumnStylesCollection cols, int startCol, bool goRight)
 {
     int num;
     if (goRight)
     {
         num = startCol + 1;
         while (num < cols.Count)
         {
             if (cols[num].PropertyDescriptor != null)
             {
                 return num;
             }
             num++;
         }
         return num;
     }
     num = startCol - 1;
     while (num >= 0)
     {
         if (cols[num].PropertyDescriptor != null)
         {
             return num;
         }
         num--;
     }
     return num;
 }