示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OutlookGridDefaultGroup"/> class.
 /// </summary>
 public OutlookGridDefaultGroup()
 {
     val    = null;
     column = null;
     if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
     {
         height = StaticValues._2013GroupRowHeight; // special height for office 2013
     }
     else
     {
         height = StaticValues._defaultGroupRowHeight; // default height
     }
     rows                   = new List <OutlookGridRow>();
     children               = new OutlookGridGroupCollection();
     formatStyle            = "";
     oneItemText            = LangManager.Instance.GetString("OneItem");
     XXXItemsText           = LangManager.Instance.GetString("XXXItems");
     allowHiddenWhenGrouped = true;
     sortBySummaryCount     = false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OutlookGridDefaultGroup"/> class.
 /// </summary>
 public OutlookGridDefaultGroup()
 {
     val = null;
     column = null;
     if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
         height = StaticValues._2013GroupRowHeight; // special height for office 2013
     else
         height = StaticValues._defaultGroupRowHeight; // default height
     rows = new List<OutlookGridRow>();
     children = new OutlookGridGroupCollection();
     formatStyle = "";
     oneItemText = LangManager.Instance.GetString("OneItem");
     XXXItemsText = LangManager.Instance.GetString("XXXItems");
     allowHiddenWhenGrouped = true;
     sortBySummaryCount = false;
 }
        /// <summary>
        /// Sort recursively the OutlookGridRows within groups
        /// </summary>
        /// <param name="groupCollection">The OutlookGridGroupCollection.</param>
        /// <param name="sortList">The list of sorted columns</param>
        private void RecursiveSort(OutlookGridGroupCollection groupCollection, List<Tuple<int, SortOrder, IComparer>> sortList)
        {
            //We sort the groups
            if (groupCollection.Count > 0)
            {
                if (groupCollection[0].Column.GroupingType.SortBySummaryCount)
                    groupCollection.Sort(new OutlookGridGroupCountComparer());
                else
                    groupCollection.Sort();
            }

            //Sort the rows inside each group
            for (int i = 0; i < groupCollection.Count; i++)
            {
                //If there is no child group then we have only rows...
                if ((groupCollection[i].Children.Count == 0) && sortList.Count > 0)
                {
                    //We sort the rows according to the sorted only columns
                    groupCollection[i].Rows.Sort(new OutlookGridRowComparer2(sortList));
                }
                //else
                //{
                //    Console.WriteLine("groupCollection[i].Rows" + groupCollection[i].Rows.Count.ToString());
                //    //We sort the rows according to the group sort (useful for alphbetics for example)
                //    groupCollection[i].Rows.Sort(new OutlookGridRowComparer(groupCollection[i].Column.DataGridViewColumn.Index, internalColumns[groupCollection[i].Column.DataGridViewColumn.Name].SortDirection));
                //}

                //Recursive call for children
                RecursiveSort(groupCollection[i].Children, sortList);
            }
        }
 private void RecursiveSetGroupCollapse(string c, OutlookGridGroupCollection col, bool collapsed)
 {
     for (int i = 0; i < col.Count; i++)
     {
         if (col[i].Column.Name == c)
             col[i].Collapsed = collapsed;
         RecursiveSetGroupCollapse(c, col[i].Children, collapsed);
     }
 }
 private void RecursiveSetGroupCollapse(OutlookGridGroupCollection col, bool collapsed)
 {
     for (int i = 0; i < col.Count; i++)
     {
         col[i].Collapsed = collapsed;
         RecursiveSetGroupCollapse(col[i].Children, collapsed);
     }
 }
        /// <summary>
        /// Transform a group in a list of OutlookGridRows. Recursive call
        /// </summary>
        /// <param name="l">The OutlookGridGroupCollection that contains the groups and associated rows.</param>
        /// <param name="tmp">A List of OutlookGridRow</param>
        private void RecursiveFillOutlookGridRows(OutlookGridGroupCollection l, List<OutlookGridRow> tmp)
        {
            OutlookGridRow grRow;
            IOutlookGridGroup gr;

            //for each group
            for (int i = 0; i < l.List.Count; i++)
            {
                gr = l.List[i];

                //Create the group row
                grRow = (OutlookGridRow)RowTemplate.Clone();
                grRow.Group = gr;
                grRow.IsGroupRow = true;
                grRow.Height = gr.Height;
                grRow.MinimumHeight = grRow.Height; //To handle auto resize rows correctly on high dpi
                grRow.CreateCells(this, gr.Value);
                tmp.Add(grRow);

                //Recusive call
                if (gr.Children.Count > 0)
                {
                    RecursiveFillOutlookGridRows(gr.Children, tmp);
                }

                //We add the rows associated with the current group
                if (_fillMode == FillMode.GroupsOnly)
                {
                    tmp.AddRange(gr.Rows);
                }
                else
                {
                    NonGroupedRecursiveFillOutlookGridRows(gr.Rows, tmp);
                }

            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public KryptonOutlookGrid()
        {
            InitializeComponent();

            // very important, this indicates that a new default row class is going to be used to fill the grid
            // in this case our custom OutlookGridRow class
            base.RowTemplate = new OutlookGridRow();
            groupCollection = new OutlookGridGroupCollection(null);
            internalRows = new List<OutlookGridRow>();
            internalColumns = new OutlookGridColumnCollection();

            // Cache the current global palette setting
            _palette = KryptonManager.CurrentGlobalPalette;

            // Hook into palette events
            if (_palette != null)
                _palette.PalettePaint += new EventHandler<PaletteLayoutEventArgs>(OnPalettePaint);

            // (4) We want to be notified whenever the global palette changes
            KryptonManager.GlobalPaletteChanged += new EventHandler(OnGlobalPaletteChanged);

            // Create redirection object to the base palette
            _paletteRedirect = new PaletteRedirect(_palette);

            // Create accessor objects for the back, border and content
            _paletteBack = new PaletteBackInheritRedirect(_paletteRedirect);
            _paletteBorder = new PaletteBorderInheritRedirect(_paletteRedirect);
            //_paletteContent = new PaletteContentInheritRedirect(_paletteRedirect);

            AllowUserToOrderColumns = false;  //we will handle it ourselves
            _hideColumnOnGrouping = false;
            formatConditions = new List<ConditionalFormatting>();

            using (Graphics g = CreateGraphics())
            {
                factorX = g.DpiX > 96 ? (1f * g.DpiX / 96) : 1f;
                factorY = g.DpiY > 96 ? (1f * g.DpiY / 96) : 1f;
            }

            //Update StaticValues
            //ColumnHeadersHeight = (int)(ColumnHeadersHeight * factorY); //No need already done in KryptonDataGridView
            StaticValues._defaultGroupRowHeight = (int)(StaticValues._defaultGroupRowHeight * factorY);
            StaticValues._2013GroupRowHeight = (int)(StaticValues._2013GroupRowHeight * factorY);
            StaticValues._defaultOffsetHeight = (int)(StaticValues._defaultOffsetHeight * factorY);
            StaticValues._2013OffsetHeight = (int)(StaticValues._defaultOffsetHeight * factorY);
            StaticValues._ImageOffsetwidth = (int)(StaticValues._ImageOffsetwidth * factorX);
            StaticValues._groupLevelMultiplier = (int)(StaticValues._groupLevelMultiplier * factorX);
            StaticValues._groupImageSide = (int)(StaticValues._groupImageSide * factorX);
        }