Exemplo n.º 1
0
        /// <summary>
        /// Handles the GroupIntervalClick event
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A EventArgs that contains the event data.</param>
        private void OnGroupIntervalClick(object sender, EventArgs e)
        {
            KryptonContextMenuItem    item     = (KryptonContextMenuItem)sender;
            OutlookGridGroupBoxColumn col      = columnsList[indexselected];
            OutlookGridColumn         colEvent = new OutlookGridColumn(col.ColumnName, null, null, SortOrder.None, -1, -1);

            colEvent.GroupingType = new OutlookGridDateTimeGroup(null)
            {
                Interval = ((OutlookGridDateTimeGroup.DateInterval)Enum.Parse(typeof(OutlookGridDateTimeGroup.DateInterval), item.Tag.ToString()))
            };
            col.GroupInterval = ((OutlookGridDateTimeGroup)colEvent.GroupingType).Interval.ToString();
            //Raise event
            OnGroupIntervalClick(new OutlookGridColumnEventArgs(colEvent));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the OnSortBySummaryCount event
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A EventArgs that contains the event data.</param>
        private void OnSortBySummaryCount(object sender, EventArgs e)
        {
            KryptonContextMenuItem    item     = (KryptonContextMenuItem)sender;
            OutlookGridGroupBoxColumn col      = columnsList[indexselected];
            OutlookGridColumn         colEvent = new OutlookGridColumn(col.ColumnName, null, null, SortOrder.None, -1, -1);

            colEvent.GroupingType = new OutlookGridDefaultGroup(null)
            {
                SortBySummaryCount = item.Checked
            };
            col.SortBySummaryCount = item.Checked;
            //Raise event
            OnSortBySummaryCount(new OutlookGridColumnEventArgs(colEvent));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Group a column
 /// </summary>
 /// <param name="col">The name of the column.</param>
 /// <param name="sortDirection">The sort direction of the group./</param>
 /// <param name="gr">The IOutlookGridGroup object.</param>
 public void GroupColumn(OutlookGridColumn col, SortOrder sortDirection, IOutlookGridGroup gr)
 {
     if (!col.IsGrouped)
     {
         col.GroupIndex = ++internalColumns.MaxGroupIndex;
         if (col.SortIndex > -1)
             internalColumns.RemoveSortIndex(col);
         col.SortDirection = sortDirection;
         col.DataGridViewColumn.HeaderCell.SortGlyphDirection = sortDirection;
         if (gr != null)
             col.GroupingType = gr;
         if (_hideColumnOnGrouping && col.GroupingType.AllowHiddenWhenGrouped)
             col.DataGridViewColumn.Visible = false;
     }
     #if DEBUG
     internalColumns.DebugOutput();
     #endif
 }
 /// <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;
 }
Exemplo n.º 5
0
 /// <summary>
 /// UnSort the column. Call Fill after to make the changes
 /// </summary>
 /// <param name="col">The outlookGridColumn.</param>
 public void UnSortColum(OutlookGridColumn col)
 {
     //Remove the SortIndex and rearrange the SortIndexes only if the column is not grouped
     if (!col.IsGrouped)
     {
         internalColumns.RemoveSortIndex(col);
         col.SortDirection = System.Windows.Forms.SortOrder.None;
         col.DataGridViewColumn.HeaderCell.SortGlyphDirection = System.Windows.Forms.SortOrder.None;
     }
     #if DEBUG
     internalColumns.DebugOutput();
     #endif
 }
Exemplo n.º 6
0
 /// <summary>
 /// Add a column for internal uses of the OutlookGrid. The column must already exists in the datagridview. Do this *BEFORE* using the grid (sorting and grouping, filling,...)
 /// </summary>
 /// <param name="col">The configured OutlookGridColumn.</param>
 public void AddInternalColumn(OutlookGridColumn col)
 {
     Debug.Assert(col != null);
     if (col != null)
     {
         internalColumns.Add(col);
         //Already reflect the SortOrder on the column
         col.DataGridViewColumn.HeaderCell.SortGlyphDirection = col.SortDirection;
         if (_hideColumnOnGrouping && col.GroupIndex > -1 && col.GroupingType.AllowHiddenWhenGrouped)
             col.DataGridViewColumn.Visible = false;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Sort the column. Call Fill after to make the changes
 /// </summary>
 /// <param name="col">The outlookGridColumn</param>
 /// <param name="sort">The new SortOrder.</param>
 public void SortColumn(OutlookGridColumn col, SortOrder sort)
 {
     //Change the SortIndex and MaxSortIndex only if it is not a grouped column
     if (!col.IsGrouped && col.SortIndex == -1)
         col.SortIndex = ++internalColumns.MaxSortIndex;
     //Change the order in all cases
     col.SortDirection = sort;
     col.DataGridViewColumn.HeaderCell.SortGlyphDirection = sort;
     #if DEBUG
     internalColumns.DebugOutput();
     #endif
 }
Exemplo n.º 8
0
 /// <summary>
 /// Ungroup a column
 /// </summary>
 /// <param name="col">The OutlookGridColumn.</param>
 public void UnGroupColumn(OutlookGridColumn col)
 {
     if (col.IsGrouped)
     {
         internalColumns.RemoveGroupIndex(col);
         col.SortDirection = SortOrder.None;
         col.DataGridViewColumn.HeaderCell.SortGlyphDirection = SortOrder.None;
         col.GroupingType.Collapsed = false;
         if (_hideColumnOnGrouping && col.GroupingType.AllowHiddenWhenGrouped)
             col.DataGridViewColumn.Visible = true;
     }
     #if DEBUG
     internalColumns.DebugOutput();
     #endif
 }
        /// <summary>
        /// Loads the configuration from file.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="Grid">The grid.</param>
        private void LoadConfigFromFile(string file, JDHSoftware.Krypton.Toolkit.KryptonOutlookGrid.KryptonOutlookGrid Grid)
        {
            if (string.IsNullOrEmpty(file))
                throw new Exception("Grid config file is missing !");

            XDocument doc = XDocument.Load(file);
            int versionGrid = -1;
            int.TryParse(doc.Element("OutlookGrid").Attribute("V").Value, out versionGrid);

            //Upgrade if necessary the config file
            CheckAndUpgradeConfigFile(versionGrid, doc, Grid, LoadState.After);
            Grid.ClearEverything();
            Grid.GroupBox.Visible = CommonHelper.StringToBool(doc.XPathSelectElement("OutlookGrid/GroupBox").Value);
            Grid.HideColumnOnGrouping = CommonHelper.StringToBool(doc.XPathSelectElement("OutlookGrid/HideColumnOnGrouping").Value);

            //Initialize
            int NbColsInFile = doc.XPathSelectElements("//Column").Count();
            DataGridViewColumn[] columnsToAdd = new DataGridViewColumn[NbColsInFile];
            SandBoxGridColumn[] enumCols = new SandBoxGridColumn[NbColsInFile];
            OutlookGridColumn[] OutlookColumnsToAdd = new OutlookGridColumn[columnsToAdd.Length];
            SortedList<int, int> hash = new SortedList<int, int>();// (DisplayIndex , Index)

            int i = 0;
            IOutlookGridGroup group;
            XElement node2;

            foreach (XElement node in doc.XPathSelectElement("OutlookGrid/Columns").Nodes())
            {
                //Create the columns and restore the saved properties
                //As the OutlookGrid receives constructed DataGridViewColumns, only the parent application can recreate them (dgvcolumn not serializable)
                enumCols[i] = (SandBoxGridColumn)Enum.Parse(typeof(SandBoxGridColumn), node.Element("Name").Value);
                columnsToAdd[i] = SetupColumn(enumCols[i]);
                columnsToAdd[i].Width = int.Parse(node.Element("Width").Value);
                columnsToAdd[i].Visible = CommonHelper.StringToBool(node.Element("Visible").Value);
                hash.Add(int.Parse(node.Element("DisplayIndex").Value), i);
                //Reinit the group if it has been set previously
                group = null;
                if (!node.Element("GroupingType").IsEmpty && node.Element("GroupingType").HasElements)
                {
                    node2 = node.Element("GroupingType");
                    group = (IOutlookGridGroup)Activator.CreateInstance(Type.GetType(TypeConverter.ProcessType(node2.Element("Name").Value), true));
                    group.OneItemText = node2.Element("OneItemText").Value;
                    group.XXXItemsText = node2.Element("XXXItemsText").Value;
                    group.SortBySummaryCount = CommonHelper.StringToBool(node2.Element("SortBySummaryCount").Value);
                    if (!string.IsNullOrEmpty((node2.Element("ItemsComparer").Value)))
                    {
                        Object comparer = Activator.CreateInstance(Type.GetType(TypeConverter.ProcessType(node2.Element("ItemsComparer").Value), true));
                        group.ItemsComparer = (IComparer)comparer;
                    }
                    if (node2.Element("Name").Value.Contains("OutlookGridDateTimeGroup"))
                    {
                        ((OutlookGridDateTimeGroup)group).Interval = (OutlookGridDateTimeGroup.DateInterval)Enum.Parse(typeof(OutlookGridDateTimeGroup.DateInterval), node2.Element("GroupDateInterval").Value);
                    }
                }
                OutlookColumnsToAdd[i] = new OutlookGridColumn(columnsToAdd[i], group, (SortOrder)Enum.Parse(typeof(SortOrder), node.Element("SortDirection").Value), int.Parse(node.Element("GroupIndex").Value), int.Parse(node.Element("SortIndex").Value));

                i += 1;
            }
            //First add the underlying DataGridViewColumns to the grid
            Grid.Columns.AddRange(columnsToAdd);
            //And then the outlookgrid columns
            Grid.AddRangeInternalColumns(OutlookColumnsToAdd);

            //Add conditionnal formatting to the grid
            EnumConditionalFormatType conditionFormatType = default(EnumConditionalFormatType);
            IFormatParams conditionFormatParams = default(IFormatParams);
            foreach (XElement node in doc.XPathSelectElement("OutlookGrid/ConditionalFormatting").Nodes())
            {
                conditionFormatType = (EnumConditionalFormatType)Enum.Parse(typeof(EnumConditionalFormatType), node.Element("FormatType").Value);
                XElement nodeParams = node.Element("FormatParams");
                switch (conditionFormatType)
                {
                    case EnumConditionalFormatType.Bar:
                        conditionFormatParams = new BarParams(Color.FromArgb(int.Parse(nodeParams.Element("BarColor").Value)), CommonHelper.StringToBool(nodeParams.Element("GradientFill").Value));
                        break;
                    case EnumConditionalFormatType.ThreeColorsRange:
                        conditionFormatParams = new ThreeColorsParams(Color.FromArgb(int.Parse(nodeParams.Element("MinimumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MediumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MaximumColor").Value)));
                        break;
                    case EnumConditionalFormatType.TwoColorsRange:
                        conditionFormatParams = new TwoColorsParams(Color.FromArgb(int.Parse(nodeParams.Element("MinimumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MaximumColor").Value)));
                        break;
                    default:
                        conditionFormatParams = null;
                        //will never happened but who knows ? throw exception ?
                        break;
                }
                Grid.ConditionalFormatting.Add(new ConditionalFormatting(node.Element("ColumnName").Value, conditionFormatType, conditionFormatParams));
            }

            //We need to loop through the columns in the order of the display order, starting at zero; otherwise the columns will fall out of order as the loop progresses.
            foreach (KeyValuePair<int, int> kvp in hash)
            {
                columnsToAdd[kvp.Value].DisplayIndex = kvp.Key;
            }

            activeColumns = enumCols;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Loads the configuration from file.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="Grid">The grid.</param>
        private void LoadConfigFromFile(string file, KryptonOutlookGrid.Classes.KryptonOutlookGrid Grid)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new Exception("Grid config file is missing !");
            }

            XDocument doc         = XDocument.Load(file);
            int       versionGrid = -1;

            int.TryParse(doc.Element("OutlookGrid").Attribute("V").Value, out versionGrid);

            //Upgrade if necessary the config file
            CheckAndUpgradeConfigFile(versionGrid, doc, Grid, LoadState.Before);
            Grid.ClearEverything();
            Grid.GroupBox.Visible     = CommonHelper.StringToBool(doc.XPathSelectElement("OutlookGrid/GroupBox").Value);
            Grid.HideColumnOnGrouping = CommonHelper.StringToBool(doc.XPathSelectElement("OutlookGrid/HideColumnOnGrouping").Value);

            //Initialize
            int NbColsInFile = doc.XPathSelectElements("//Column").Count();

            DataGridViewColumn[]  columnsToAdd        = new DataGridViewColumn[NbColsInFile];
            VaultGridColumn[]     enumCols            = new VaultGridColumn[NbColsInFile];
            OutlookGridColumn[]   OutlookColumnsToAdd = new OutlookGridColumn[columnsToAdd.Length];
            SortedList <int, int> hash = new SortedList <int, int>();// (DisplayIndex , Index)


            int i = 0;
            IOutlookGridGroup group;
            XElement          node2;

            foreach (XElement node in doc.XPathSelectElement("OutlookGrid/Columns").Nodes())
            {
                //Create the columns and restore the saved properties
                //As the OutlookGrid receives constructed DataGridViewColumns, only the parent application can recreate them (dgvcolumn not serializable)
                enumCols[i]             = (VaultGridColumn)Enum.Parse(typeof(VaultGridColumn), node.Element("Name").Value);
                columnsToAdd[i]         = SetupColumn(enumCols[i]);
                columnsToAdd[i].Width   = int.Parse(node.Element("Width").Value);
                columnsToAdd[i].Visible = CommonHelper.StringToBool(node.Element("Visible").Value);
                hash.Add(int.Parse(node.Element("DisplayIndex").Value), i);
                //Reinit the group if it has been set previously
                group = null;
                if (!node.Element("GroupingType").IsEmpty&& node.Element("GroupingType").HasElements)
                {
                    node2                    = node.Element("GroupingType");
                    group                    = (IOutlookGridGroup)Activator.CreateInstance(Type.GetType(TypeConverter.ProcessType(node2.Element("Name").Value), true));
                    group.OneItemText        = node2.Element("OneItemText").Value;
                    group.XXXItemsText       = node2.Element("XXXItemsText").Value;
                    group.SortBySummaryCount = CommonHelper.StringToBool(node2.Element("SortBySummaryCount").Value);
                    if (!string.IsNullOrEmpty((node2.Element("ItemsComparer").Value)))
                    {
                        Object comparer = Activator.CreateInstance(Type.GetType(TypeConverter.ProcessType(node2.Element("ItemsComparer").Value), true));
                        group.ItemsComparer = (IComparer)comparer;
                    }
                    if (node2.Element("Name").Value.Contains("OutlookGridDateTimeGroup"))
                    {
                        ((OutlookGridDateTimeGroup)group).Interval = (OutlookGridDateTimeGroup.DateInterval)Enum.Parse(typeof(OutlookGridDateTimeGroup.DateInterval), node2.Element("GroupDateInterval").Value);
                    }
                }
                OutlookColumnsToAdd[i] = new OutlookGridColumn(columnsToAdd[i], group, (SortOrder)Enum.Parse(typeof(SortOrder), node.Element("SortDirection").Value), int.Parse(node.Element("GroupIndex").Value), int.Parse(node.Element("SortIndex").Value));

                i += 1;
            }
            //First add the underlying DataGridViewColumns to the grid
            Grid.Columns.AddRange(columnsToAdd);
            //And then the outlookgrid columns
            Grid.AddRangeInternalColumns(OutlookColumnsToAdd);

            //Add conditionnal formatting to the grid
            EnumConditionalFormatType conditionFormatType   = default(EnumConditionalFormatType);
            IFormatParams             conditionFormatParams = default(IFormatParams);

            foreach (XElement node in doc.XPathSelectElement("OutlookGrid/ConditionalFormatting").Nodes())
            {
                conditionFormatType = (EnumConditionalFormatType)Enum.Parse(typeof(EnumConditionalFormatType), node.Element("FormatType").Value);
                XElement nodeParams = node.Element("FormatParams");
                switch (conditionFormatType)
                {
                case EnumConditionalFormatType.BAR:
                    conditionFormatParams = new BarParams(Color.FromArgb(int.Parse(nodeParams.Element("BarColor").Value)), CommonHelper.StringToBool(nodeParams.Element("GradientFill").Value));
                    break;

                case EnumConditionalFormatType.THREECOLOURSRANGE:
                    conditionFormatParams = new ThreeColoursParams(Color.FromArgb(int.Parse(nodeParams.Element("MinimumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MediumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MaximumColor").Value)));
                    break;

                case EnumConditionalFormatType.TWOCOLOURSRANGE:
                    conditionFormatParams = new TwoColoursParams(Color.FromArgb(int.Parse(nodeParams.Element("MinimumColor").Value)), Color.FromArgb(int.Parse(nodeParams.Element("MaximumColor").Value)));
                    break;

                default:
                    conditionFormatParams = null;
                    //will never happened but who knows ? throw exception ?
                    break;
                }
                Grid.ConditionalFormatting.Add(new ConditionalFormatting(node.Element("ColumnName").Value, conditionFormatType, conditionFormatParams));
            }



            //We need to loop through the columns in the order of the display order, starting at zero; otherwise the columns will fall out of order as the loop progresses.
            foreach (KeyValuePair <int, int> kvp in hash)
            {
                columnsToAdd[kvp.Value].DisplayIndex = kvp.Key;
            }

            activeColumns = enumCols;
        }
 /// <summary>
 /// Handles the OnSortBySummaryCount event
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">A EventArgs that contains the event data.</param>
 private void OnSortBySummaryCount(object sender, EventArgs e)
 {
     KryptonContextMenuItem item = (KryptonContextMenuItem)sender;
     OutlookGridGroupBoxColumn col = columnsList[indexselected];
     OutlookGridColumn colEvent = new OutlookGridColumn(col.ColumnName, null, null, SortOrder.None, -1, -1);
     colEvent.GroupingType = new OutlookGridDefaultGroup(null) { SortBySummaryCount = item.Checked };
     col.SortBySummaryCount = item.Checked;
     //Raise event
     OnSortBySummaryCount(new OutlookGridColumnEventArgs(colEvent));
 }
 /// <summary>
 /// Handles the GroupIntervalClick event
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">A EventArgs that contains the event data.</param>
 private void OnGroupIntervalClick(object sender, EventArgs e)
 {
     KryptonContextMenuItem item = (KryptonContextMenuItem)sender;
     OutlookGridGroupBoxColumn col = columnsList[indexselected];
     OutlookGridColumn colEvent = new OutlookGridColumn(col.ColumnName, null, null, SortOrder.None, -1, -1);
     colEvent.GroupingType = new OutlookGridDateTimeGroup(null) { Interval = ((OutlookGridDateTimeGroup.DateInterval)Enum.Parse(typeof(OutlookGridDateTimeGroup.DateInterval), item.Tag.ToString())) };
     col.GroupInterval = ((OutlookGridDateTimeGroup)colEvent.GroupingType).Interval.ToString();
     //Raise event
     OnGroupIntervalClick(new OutlookGridColumnEventArgs(colEvent));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="col">The OutlookGridColumn.</param>
 public OutlookGridColumnEventArgs(OutlookGridColumn col)
 {
     this.column = col;
 }