diff --git a/App.config b/App.config new file mode 100644 index 0000000..451442d --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Classes/OutlookGrid.cs b/Classes/OutlookGrid.cs new file mode 100644 index 0000000..3a6c6fe --- /dev/null +++ b/Classes/OutlookGrid.cs @@ -0,0 +1,2972 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using System.Xml; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Controls; +using KryptonOutlookGrid.CustomColumns; +using KryptonOutlookGrid.Formatting; +using KryptonOutlookGrid.Formatting.Params; +using KryptonOutlookGrid.Interfaces; +using KryptonOutlookGrid.Utilities.Language; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Krypton DataGridView allowing nested grouping and unlimited sorting + /// + /// + public partial class KryptonOutlookGrid : KryptonDataGridView + { + private KryptonOutlookGridGroupBox groupBox; + //Krypton + private IPalette _palette; + private PaletteRedirect _paletteRedirect; + private PaletteBackInheritRedirect _paletteBack; + private PaletteBorderInheritRedirect _paletteBorder; + //private PaletteContentInheritRedirect _paletteContent; + private IDisposable _mementoBack; + + private OutlookGridGroupCollection groupCollection; // List of Groups (of rows) + private List internalRows; // List of Rows in order to keep them as is (without grouping,...) + private OutlookGridColumnCollection internalColumns; // List of columns in order to know if sorted, Grouped, types,... + private int _previousGroupRowSelected = -1; //Useful to allow the selection of a group row or not when on mouse down + + //Krypton ContextMenu for the columns header + private bool _allowdefaultcontextmenu = true; + private KryptonContextMenu KCtxMenu; + private KryptonContextMenuItems _menuItems; + private KryptonContextMenuItem _menuSortAscending; + private KryptonContextMenuItem _menuSortDescending; + private KryptonContextMenuItem _menuClearSorting; + private KryptonContextMenuSeparator _menuSeparator1; + private KryptonContextMenuItem _menuGroupByThisColumn; + private KryptonContextMenuItem _menuUngroupByThisColumn; + private KryptonContextMenuItem _menuShowGroupBox; + private KryptonContextMenuItem _menuHideGroupBox; + private KryptonContextMenuSeparator _menuSeparator2; + private KryptonContextMenuItem _menuBestFitColumn; + private KryptonContextMenuItem _menuBestFitAllColumns; + private KryptonContextMenuSeparator _menuSeparator3; + private KryptonContextMenuItem _menuVisibleColumns; + private KryptonContextMenuItem _menuGroupInterval; + private KryptonContextMenuItem _menuSortBySummary; + private KryptonContextMenuItem _menuExpand; + private KryptonContextMenuItem _menuCollapse; + private KryptonContextMenuSeparator _menuSeparator4; + private KryptonContextMenuSeparator _menuSeparator5; + private KryptonContextMenuItem _menuConditionalFormatting; + private int colSelected = 1; //for menu + private const int FormattingBARSolidGradientSepIndex = 3; + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + //For the Drag and drop of columns + private Rectangle DragDropRectangle; + private int DragDropSourceIndex; + private int DragDropTargetIndex; + private int DragDropCurrentIndex = -1; + private int DragDropType; //0=column, 1=row + + private bool _hideColumnOnGrouping; + + //Nodes + private bool _showLines = true; + internal bool _inExpandCollapseMouseCapture = false; + private FillMode _fillMode; + + //Formatting + private List formatConditions; + + /// + /// Group Image Click Event + /// + public event EventHandler GroupImageClick; + /// + /// Node expanding event + /// + public event EventHandler NodeExpanding; + /// + /// Node Expanded event + /// + public event EventHandler NodeExpanded; + /// + /// Node Collapsing Event + /// + public event EventHandler NodeCollapsing; + /// + /// Node Collapsed event + /// + public event EventHandler NodeCollapsed; + + float factorX, factorY; + + #region OutlookGrid constructor + + /// + /// Constructor + /// + 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(); + internalColumns = new OutlookGridColumnCollection(); + _fillMode = FillMode.GROUPSONLY; + + // Cache the current global palette setting + _palette = KryptonManager.CurrentGlobalPalette; + + // Hook into palette events + if (_palette != null) + _palette.PalettePaint += new EventHandler(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(); + + 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); + } + + private void InitializeComponent() + { + components = new Container(); + } + + /// + /// Definitvely removes flickering - may not work on some systems/can cause higher CPU usage. + /// + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED + return cp; + } + } + + + #endregion OutlookGrid constructor + + #region OutlookGrid Properties + + /// + /// Gets the RowTemplate of the grid. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new DataGridViewRow RowTemplate + { + get + { + return base.RowTemplate; + } + } + + /// + /// Gets if the grid is grouped + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsGridGrouped + { + get + { + return !(groupCollection.Count == 0); + } + } + + /// + /// Gets or sets the OutlookGridGroupBox + /// + [Category("Behavior")] + [Description("Associate the OutlookGridGroupBox with the grid.")] + [DefaultValue(null)] + public KryptonOutlookGridGroupBox GroupBox + { + get + { + return groupBox; + } + set + { + groupBox = value; + } + } + + /// + /// Gets or sets the list of rows in the grid (without grouping,... for having a copy) + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public List InternalRows + { + get { return internalRows; } + set { internalRows = value; } + } + + /// + /// Gets or sets the previous selected group row + /// + [Browsable(false)] + public int PreviousSelectedGroupRow + { + get + { + return _previousGroupRowSelected; + } + + set + { + _previousGroupRowSelected = value; + } + } + + /// + /// Gets the Krypton Palette of the OutlookGrid + /// + [Browsable(false)] + public IPalette GridPalette + { get { return _palette; } } + + /// + /// Gets or sets the group collection. + /// + /// OutlookGridGroupCollection. + [Browsable(false)] + public OutlookGridGroupCollection GroupCollection + { + get + { + return groupCollection; + } + set + { + groupCollection = value; + } + } + + /// + /// Gets or sets the HideColumnOnGrouping property. + /// + /// True if the column should be hidden when it is grouped, false otherwise. + [Category("Behavior")] + [Description("Hide the column when it is grouped.")] + [DefaultValue(false)] + public bool HideColumnOnGrouping + { + get + { + return _hideColumnOnGrouping; + } + set + { + _hideColumnOnGrouping = value; + } + } + + /// + /// Gets or sets the conditional formatting items list. + /// + /// + /// The conditional formatting items list. + /// + [Category("Behavior")] + [Description("Conditional formatting.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public List ConditionalFormatting + { + get + { + return formatConditions; + } + set + { + formatConditions = value; + } + } + + + /// + /// Gets or sets a value indicating whether the lines are shown between nodes. + /// + /// + /// true if [show lines]; otherwise, false. + /// + [DefaultValue(true)] + public bool ShowLines + { + get { return _showLines; } + set + { + if (value != _showLines) + { + _showLines = value; + Invalidate(); + } + } + } + + /// + /// Gets or sets the fill mode. + /// + /// + /// The fill mode. + /// + public FillMode FillMode + { + get { return _fillMode; } + set + { + if (value != _fillMode) + { + _fillMode = value; + Invalidate(); + } + } + } + + /// + /// Enables integrated context menu + /// + [DefaultValue(true)] + public bool AllowDefaultContextmenu + { + get { return _allowdefaultcontextmenu; } + set { _allowdefaultcontextmenu = value; } + } + + #endregion OutlookGrid property definitions + + #region OutlookGrid Overrides + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (_mementoBack != null) + { + _mementoBack.Dispose(); + _mementoBack = null; + } + + // (10) Unhook from the palette events + if (_palette != null) + { + _palette.PalettePaint -= new EventHandler(OnPalettePaint); + _palette = null; + } + + // (11) Unhook from the static events, otherwise we cannot be garbage collected + KryptonManager.GlobalPaletteChanged -= new EventHandler(OnGlobalPaletteChanged); + + //Unhook from specific events + if (groupBox != null) + { + groupBox.ColumnGroupAdded -= ColumnGroupAddedEvent; + groupBox.ColumnSortChanged -= ColumnSortChangedEvent; + groupBox.ColumnGroupRemoved -= ColumnGroupRemovedEvent; + groupBox.ClearGrouping -= ClearGroupingEvent; + groupBox.FullCollapse -= FullCollapseEvent; + groupBox.FullExpand -= FullExpandEvent; + groupBox.ColumnGroupOrderChanged -= ColumnGroupIndexChangedEvent; + groupBox.GroupExpand -= GridGroupExpandEvent; + groupBox.GroupCollapse -= GridGroupCollapseEvent; + groupBox.GroupIntervalClick -= GroupIntervalClickEvent; + groupBox.SortBySummaryCount -= SortBySummaryCountEvent; + } + } + + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnCellBeginEdit(DataGridViewCellCancelEventArgs e) + { + OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; + if (row.IsGroupRow) + e.Cancel = true; + else + base.OnCellBeginEdit(e); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnCellDoubleClick(DataGridViewCellEventArgs e) + { + if (e.RowIndex >= 0) + { + OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; + if (row.IsGroupRow) + { + row.Group.Collapsed = !row.Group.Collapsed; + + //this is a workaround to make the grid re-calculate it's contents and background bounds + // so the background is updated correctly. + // this will also invalidate the control, so it will redraw itself + row.Visible = false; + row.Visible = true; + return; + } + } + base.OnCellDoubleClick(e); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnMouseUp(MouseEventArgs e) + { + // used to keep extra mouse moves from selecting more rows when collapsing + base.OnMouseUp(e); + _inExpandCollapseMouseCapture = false; + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnMouseDown(MouseEventArgs e) + { + //stores values for drag/drop operations if necessary + if (AllowDrop) + { + if (HitTest(e.X, e.Y).ColumnIndex == -1 && HitTest(e.X, e.Y).RowIndex > -1) + { + //if this is a row header cell + if (Rows[HitTest(e.X, e.Y).RowIndex].Selected) + { + //if this row is selected + DragDropType = 1; + Size DragSize = SystemInformation.DragSize; + DragDropRectangle = new Rectangle(new Point(e.X - (DragSize.Width / 2), e.Y - (DragSize.Height / 2)), DragSize); + DragDropSourceIndex = HitTest(e.X, e.Y).RowIndex; + } + else + { + DragDropRectangle = Rectangle.Empty; + } + } + else if (HitTest(e.X, e.Y).ColumnIndex > -1 && HitTest(e.X, e.Y).RowIndex == -1) + { + //if this is a column header cell + //if (this.Columns[this.HitTest(e.X, e.Y).ColumnIndex].Selected) + //{ + DragDropType = 0; + DragDropSourceIndex = HitTest(e.X, e.Y).ColumnIndex; + Size DragSize = SystemInformation.DragSize; + DragDropRectangle = new Rectangle(new Point(e.X - (DragSize.Width / 2), e.Y - (DragSize.Height / 2)), DragSize); + //} + //else + //{ + // DragDropRectangle = Rectangle.Empty; + //} //end if + } + else + { + DragDropRectangle = Rectangle.Empty; + } + } + else + { + DragDropRectangle = Rectangle.Empty; + } + base.OnMouseDown(e); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnMouseMove(MouseEventArgs e) + { + // while we are expanding and collapsing a node mouse moves are + // supressed to keep selections from being messed up. + if (!_inExpandCollapseMouseCapture) + { + bool dragdropdone = false; + //handles drag/drop operations + if (AllowDrop) + { + if ((e.Button & MouseButtons.Left) == MouseButtons.Left && Cursor.Current != Cursors.SizeWE) + { + if (DragDropRectangle != Rectangle.Empty && !DragDropRectangle.Contains(e.X, e.Y)) + { + if (DragDropType == 0) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(DragDropSourceIndex); + string groupInterval = ""; + string groupType = ""; + string groupSortBySummaryCount = ""; + + if (col.GroupingType != null) + { + groupType = col.GroupingType.GetType().Name.ToString(); + if (groupType == typeof(OutlookGridDateTimeGroup).Name) + groupInterval = ((OutlookGridDateTimeGroup)col.GroupingType).Interval.ToString(); + groupSortBySummaryCount = CommonHelper.BoolToString(col.GroupingType.SortBySummaryCount); + } + //column drag/drop + string info = String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", col.Name.ToString(), col.DataGridViewColumn.HeaderText.ToString(), col.DataGridViewColumn.HeaderCell.SortGlyphDirection.ToString(), col.DataGridViewColumn.SortMode.ToString(), groupType, groupInterval, groupSortBySummaryCount); + DragDropEffects DropEffect = DoDragDrop(info, DragDropEffects.Move); + dragdropdone = true; + } + else if (DragDropType == 1) + { + //row drag/drop + DragDropEffects DropEffect = DoDragDrop(Rows[DragDropSourceIndex], DragDropEffects.Move); + dragdropdone = true; + } + } + } + } + base.OnMouseMove(e); + if (dragdropdone) + CellOver = new Point(-2, -2);//To avoid that the column header appears in a pressed state - Modification of ToolKit + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnDragLeave(EventArgs e) + { + if (DragDropCurrentIndex > -1 && DragDropType == 0) + { + DataGridViewColumn col = Columns[DragDropCurrentIndex]; + if (groupBox != null && groupBox.Contains(col.Name)) + { + DragDropCurrentIndex = -1; + //this.InvalidateColumn(col.Index); + Invalidate(); + } + else + { + DragDropCurrentIndex = -1; + } + } + + base.OnDragLeave(e); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnDragOver(DragEventArgs drgevent) + { + //runs while the drag/drop is in progress + if (AllowDrop) + { + drgevent.Effect = DragDropEffects.Move; + if (DragDropType == 0) + { + //column drag/drop + int CurCol = HitTest(PointToClient(new Point(drgevent.X, drgevent.Y)).X, PointToClient(new Point(drgevent.X, drgevent.Y)).Y).ColumnIndex; + if (DragDropCurrentIndex != CurCol) + { + DragDropCurrentIndex = CurCol; + Invalidate(); //repaint + } + } + else if (DragDropType == 1) + { + //row drag/drop + int CurRow = HitTest(PointToClient(new Point(drgevent.X, drgevent.Y)).X, PointToClient(new Point(drgevent.X, drgevent.Y)).Y).RowIndex; + if (DragDropCurrentIndex != CurRow) + { + DragDropCurrentIndex = CurRow; + Invalidate(); //repaint + } + } + } + base.OnDragOver(drgevent); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnDragDrop(DragEventArgs drgevent) + { + //runs after a drag/drop operation for column/row has completed + if (AllowDrop) + { + if (drgevent.Effect == DragDropEffects.Move) + { + Point ClientPoint = PointToClient(new Point(drgevent.X, drgevent.Y)); + if (DragDropType == 0) + { + //if this is a column drag/drop operation + DragDropTargetIndex = HitTest(ClientPoint.X, ClientPoint.Y).ColumnIndex; + if (DragDropTargetIndex > -1 && DragDropCurrentIndex < ColumnCount - 1) + { + DragDropCurrentIndex = -1; + //************************************************* + //'SourceColumn' is null after the line of code + //below executes... Why? This works fine for rows!! + string r = drgevent.Data.GetData(typeof(string)) as string; + string[] res = r.Split('|'); + DataGridViewColumn SourceColumn = Columns[res[0]]; + //int SourceDisplayIndex = SourceColumn.DisplayIndex; + DataGridViewColumn TargetColumn = Columns[DragDropTargetIndex]; + // int TargetDisplayIndex = TargetColumn.DisplayIndex; + SourceColumn.DisplayIndex = TargetColumn.DisplayIndex; + + //Debug + List listcol = new List(); + foreach (DataGridViewColumn col in Columns) + { + listcol.Add(col); + } + foreach (DataGridViewColumn col in listcol.OrderBy(x => x.DisplayIndex)) + { + Console.WriteLine(col.Name + " " + col.DisplayIndex); + } + Console.WriteLine("-----------------"); + + //************************************************* + //this.Columns.RemoveAt(DragDropSourceIndex); + //this.Columns.Insert(DragDropTargetIndex, SourceColumn); + + SourceColumn.Selected = false; + TargetColumn.Selected = false; + //this.Columns[DragDropTargetIndex].Selected = true; + CurrentCell = this[DragDropTargetIndex, 0]; + } //end if + } + else if (DragDropType == 1) + { + //if this is a row drag/drop operation + DragDropTargetIndex = HitTest(ClientPoint.X, ClientPoint.Y).RowIndex; + if (DragDropTargetIndex > -1 && DragDropCurrentIndex < RowCount - 1) + { + DragDropCurrentIndex = -1; + DataGridViewRow SourceRow = drgevent.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow; + Rows.RemoveAt(DragDropSourceIndex); + Rows.Insert(DragDropTargetIndex, SourceRow); + Rows[DragDropTargetIndex].Selected = true; + CurrentCell = this[0, DragDropTargetIndex]; + } + } + } + } + DragDropCurrentIndex = -1; + Invalidate(); + base.OnDragDrop(drgevent); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + /// Draws a line for drag and drop + protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) + { + //draws red drag/drop target indicator lines if necessary + if (DragDropCurrentIndex > -1) + { + if (DragDropType == 0) + { + //column drag/drop + if (e.ColumnIndex == DragDropCurrentIndex)// && DragDropCurrentIndex < this.ColumnCount) + { + //if this cell is in the same column as the mouse cursor + using (Pen p = new Pen(Color.Red, 1)) + { + e.Graphics.DrawLine(p, e.CellBounds.Left - 1, e.CellBounds.Top, e.CellBounds.Left - 1, e.CellBounds.Bottom); + } + } //end if + } + else if (DragDropType == 1) + { + //row drag/drop + if (e.RowIndex == DragDropCurrentIndex && DragDropCurrentIndex < RowCount - 1) + { + //if this cell is in the same row as the mouse cursor + + using (Pen p = new Pen(Color.Red, 1)) + { + e.Graphics.DrawLine(p, e.CellBounds.Left, e.CellBounds.Top - 1, e.CellBounds.Right, e.CellBounds.Top - 1); + } + } + } + } + base.OnCellPainting(e); + } + + /// + /// Overrides OnCellMouseEnter + /// + /// DataGridViewCellEventArgs + protected override void OnCellMouseEnter(DataGridViewCellEventArgs e) + { + base.OnCellMouseEnter(e); + } + + /// + /// Overrides OnCellMouseDown - Check if the user has clicked on +/- of a group row + /// + /// + protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e) + { + //base.OnCellMouseDown(e); //needed. + if (e.RowIndex < 0) + { + base.OnCellMouseDown(e); // To allow column resizing + return; + } + OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; + //System.Diagnostics.Debug.WriteLine("OnCellMouseDown " + DateTime.Now.Ticks.ToString() + "IsIconHit" + row.IsIconHit(e).ToString()); + if (_previousGroupRowSelected != -1 && _previousGroupRowSelected != e.RowIndex) + InvalidateRow(PreviousSelectedGroupRow); + + PreviousSelectedGroupRow = -1; + if (row.IsGroupRow) + { + PreviousSelectedGroupRow = e.RowIndex; + ClearSelection(); //unselect + if (row.IsIconHit(e)) + { + row.Group.Collapsed = !row.Group.Collapsed; + + //this is a workaround to make the grid re-calculate it's contents and backgroun bounds + // so the background is updated correctly. + // this will also invalidate the control, so it will redraw itself + row.Visible = false; + row.Visible = true; + //When collapsing the first row still seeing it. + if (row.Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = row.Index; + } + else if (row.IsGroupImageHit(e)) + { + OnGroupImageClick(new OutlookGridGroupImageEventArgs(row)); + } + else + { + InvalidateRow(e.RowIndex); + } + } + else + { + base.OnCellMouseDown(e); + } + } + + /// + /// Overrides OnColumnHeaderMouseClick + /// + /// DataGridViewCellMouseEventArgs + protected override void OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e) + { + colSelected = e.ColumnIndex; //To keep a track on which column we have pressed + //runs when the mouse is clicked over a column header cell + if (e.ColumnIndex > -1) + { + if (e.Button == MouseButtons.Right) + { + if (AllowDefaultContextmenu) + { + ShowColumnHeaderContextMenu(e.ColumnIndex); + } + } + else if (e.Button == MouseButtons.Left) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(e.ColumnIndex); + if (col != null) + { + if (col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable) + { + SortOrder previousSort = col.SortDirection; + //Reset all sorting column only if not Ctrl or Shift or the column is grouped + if (Control.ModifierKeys != Keys.Shift && Control.ModifierKeys != Keys.Control && !col.IsGrouped) + { + ResetAllSortingColumns(); + } + + //Remove this SortIndex + if (Control.ModifierKeys == Keys.Control) + { + UnSortColum(col); + } + //Add the first or a new SortIndex + else + { + if (previousSort == SortOrder.None) + { + SortColumn(col, SortOrder.Ascending); + } + else + { + SortColumn(col, (previousSort == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending); + } + } + +#if DEBUG + internalColumns.DebugOutput(); +#endif + + //Refresh the groupBox if the column is grouped + if (col.IsGrouped) + { + ForceRefreshGroupBox(); + } + + //Apply the changes + Fill(); + } + } + } + } + base.OnColumnHeaderMouseClick(e); + } + + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnCellFormatting(DataGridViewCellFormattingEventArgs e) + { + //Allows to have a picture in the first column + if (e.DesiredType.Name == "Image" && e.Value != null && e.Value.GetType().Name != e.DesiredType.Name && e.Value.GetType().Name != "Bitmap") + { + e.Value = null; + } + + base.OnCellFormatting(e); + } + + #endregion + + #region OutlookGrid Events + + /// + /// Called when [palette paint]. + /// + /// The sender. + /// The instance containing the event data. + private void OnPalettePaint(object sender, PaletteLayoutEventArgs e) + { + Invalidate(); + } + + /// + /// Called when [global palette changed]. + /// + /// The sender. + /// The instance containing the event data. + private void OnGlobalPaletteChanged(object sender, EventArgs e) + { + // (5) Unhook events from old palette + if (_palette != null) + _palette.PalettePaint -= new EventHandler(OnPalettePaint); + + // (6) Cache the new IPalette that is the global palette + _palette = KryptonManager.CurrentGlobalPalette; + _paletteRedirect.Target = _palette; //!!!!!! important + + //Reflect changes for the grouped heights + int h = StaticValues._defaultGroupRowHeight; // default height + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + h = StaticValues._2013GroupRowHeight; // special height for office 2013 + + //For each outlookgridcolumn + for (int j = 0; j < internalColumns.Count; j++) + { + if (internalColumns[j].GroupingType != null) + internalColumns[j].GroupingType.Height = h; + } + + // (7) Hook into events for the new palette + if (_palette != null) + _palette.PalettePaint += new EventHandler(OnPalettePaint); + + // (8) Change of palette means we should repaint to show any changes + Invalidate(); + } + + /// + /// Clear sorting for the column selected by the menu + /// + /// + /// + private void OnColumnClearSorting(object sender, EventArgs e) + { + if (colSelected > -1) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + UnSortColum(col); + Fill(); + } + } + + /// + /// Ascending sort for the column selected by the menu + /// + /// + /// + private void OnColumnSortAscending(object sender, EventArgs e) + { + if (colSelected > -1) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + SortColumn(col, SortOrder.Ascending); + if (col.IsGrouped) + { + ForceRefreshGroupBox(); + } + Fill(); + } + } + + /// + /// Descending sort for the column selected by the menu + /// + /// + /// + private void OnColumnSortDescending(object sender, EventArgs e) + { + if (colSelected > -1) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + SortColumn(col, SortOrder.Descending); + if (col.IsGrouped) + { + ForceRefreshGroupBox(); + } + Fill(); + } + } + + /// + /// Grouping for the column selected by the menu + /// + /// + /// + private void OnGroupByThisColumn(object sender, EventArgs e) + { + if (colSelected > -1) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + GroupColumn(col, SortOrder.Ascending, null); + ForceRefreshGroupBox(); + Fill(); + } + } + + /// + /// Ungrouping for the column selected by the menu + /// + /// + /// + private void OnUnGroupByThisColumn(object sender, EventArgs e) + { + if (colSelected > -1) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + UnGroupColumn(col.Name); + ForceRefreshGroupBox(); + Fill(); + } + } + + private void OnGroupCollapse(object sender, EventArgs e) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + Collapse(col.Name); + } + + private void OnGroupExpand(object sender, EventArgs e) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + Expand(col.Name); + } + + private void OnSortBySummary(object sender, EventArgs e) + { + + KryptonContextMenuItem item = (KryptonContextMenuItem)sender; + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + col.GroupingType.SortBySummaryCount = item.Checked; + ForceRefreshGroupBox(); + Fill(); + } + + private void OnGroupIntervalClick(object sender, EventArgs e) + { + KryptonContextMenuItem item = (KryptonContextMenuItem)sender; + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + ((OutlookGridDateTimeGroup)col.GroupingType).Interval = (OutlookGridDateTimeGroup.DateInterval)Enum.Parse(typeof(OutlookGridDateTimeGroup.DateInterval), item.Tag.ToString()); + ForceRefreshGroupBox(); + Fill(); + } + + private void OnConditionalFormattingClick(object sender, EventArgs e) + { + KryptonContextMenuImageSelect item = (KryptonContextMenuImageSelect)sender; + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault(); + ConditionalFormatting newformat = ((List)item.Tag)[item.SelectedIndex]; + if (format == null) + { + formatConditions.Add(new Formatting.ConditionalFormatting(col.DataGridViewColumn.Name, newformat.FormatType, newformat.FormatParams)); + } + else + { + format.FormatType = newformat.FormatType; + format.FormatParams = newformat.FormatParams; + } + ((KryptonContextMenuImageSelect)sender).SelectedIndex = -1; //I'm unable to get only one imageselect checked between solid and gradient, so reset the selected image + Fill(); + } + + private void OnTwoColorsCustomClick(object sender, EventArgs e) + { + CustomFormatRule fm = new CustomFormatRule(EnumConditionalFormatType.TWOCOLOURSRANGE); + fm.ShowDialog(); + if (fm.DialogResult == DialogResult.OK) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault(); + if (format == null) + { + ConditionalFormatting newformat = new Formatting.ConditionalFormatting(col.DataGridViewColumn.Name, EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(fm.colMin, fm.colMax)); + formatConditions.Add(newformat); + } + else + { + format.FormatType = EnumConditionalFormatType.TWOCOLOURSRANGE; + format.FormatParams = new TwoColoursParams(fm.colMin, fm.colMax); + } + Fill(); + } + fm.Dispose(); + } + + + private void OnThreeColorsCustomClick(object sender, EventArgs e) + { + CustomFormatRule fm = new CustomFormatRule(EnumConditionalFormatType.THREECOLOURSRANGE); + fm.ShowDialog(); + if (fm.DialogResult == DialogResult.OK) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault(); + if (format == null) + { + ConditionalFormatting newformat = new Formatting.ConditionalFormatting(col.DataGridViewColumn.Name, EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(248, 105, 107), Color.FromArgb(255, 235, 132), Color.FromArgb(99, 190, 123))); + formatConditions.Add(newformat); + } + else + { + format.FormatType = EnumConditionalFormatType.THREECOLOURSRANGE; + format.FormatParams = new ThreeColoursParams(Color.FromArgb(248, 105, 107), Color.FromArgb(255, 235, 132), Color.FromArgb(99, 190, 123)); + } + Fill(); + } + fm.Dispose(); + } + + private void OnBARCustomClick(object sender, EventArgs e) + { + CustomFormatRule fm = new CustomFormatRule(EnumConditionalFormatType.BAR); + fm.ShowDialog(); + if (fm.DialogResult == DialogResult.OK) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault(); + if (format == null) + { + ConditionalFormatting newformat = new Formatting.ConditionalFormatting(col.DataGridViewColumn.Name, EnumConditionalFormatType.BAR, new BarParams(fm.colMin, fm.gradient)); + formatConditions.Add(newformat); + } + else + { + format.FormatType = EnumConditionalFormatType.BAR; + format.FormatParams = new BarParams(fm.colMin, fm.gradient); + } + Fill(); + } + fm.Dispose(); + } + + private void OnClearConditionalClick(object sender, EventArgs e) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(colSelected); + formatConditions.RemoveAll(x => x.ColumnName == col.Name); + for (int i = 0; i < internalRows.Count; i++) + { + FormattingCell fCell = (FormattingCell)internalRows[i].Cells[colSelected]; + //fCell.FormatType = formatConditions[i].FormatType; + fCell.FormatParams = null; + } + Fill(); + } + + + private void OnColumnVisibleCheckedChanged(object sender, EventArgs e) + { + KryptonContextMenuCheckBox item = (KryptonContextMenuCheckBox)sender; + Columns[(int)item.Tag].Visible = item.Checked; + } + + /// + /// Shows the groupbox + /// + /// + /// + private void OnShowGroupBox(object sender, EventArgs e) + { + if (groupBox != null) + groupBox.Show(); + + } + + /// + /// Hide the groupbox + /// + /// + /// + private void OnHideGroupBox(object sender, EventArgs e) + { + if (groupBox != null) + groupBox.Hide(); + } + + /// + /// Resizes the selected column by the menu to best fit + /// + /// + /// + private void OnBestFitColumn(object sender, EventArgs e) + { + if (colSelected > -1) + { + Cursor.Current = Cursors.WaitCursor; + AutoResizeColumn(colSelected, DataGridViewAutoSizeColumnMode.AllCells); + Cursor.Current = Cursors.Default; + } + } + + /// + /// Resizes all columns to best fit + /// + /// + /// + private void OnBestFitAllColumns(object sender, EventArgs e) + { + Cursor.Current = Cursors.WaitCursor; + AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); + Cursor.Current = Cursors.Default; + } + + /// + /// Handles the ColumnSortChangedEvent event. Update the header (glyph) and fill the grid too. + /// + /// Source of the event. + /// A OutlookGridColumnEventArgs that contains the event data. + private void ColumnSortChangedEvent(object sender, OutlookGridColumnEventArgs e) + { +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives ColumnSortChangedEvent : " + e.Column.Name + " " + e.Column.SortDirection.ToString()); +#endif + internalColumns[e.Column.Name].SortDirection = e.Column.SortDirection; + internalColumns[e.Column.Name].DataGridViewColumn.HeaderCell.SortGlyphDirection = e.Column.SortDirection; + Fill(); + } + + /// + /// Handles the ColumnGroupAddedEvent event. Fill the grid too. + /// + /// Source of the event. + /// A OutlookGridColumnEventArgs that contains the event data. + private void ColumnGroupAddedEvent(object sender, OutlookGridColumnEventArgs e) + { + GroupColumn(e.Column.Name, e.Column.SortDirection, null); + //We fill again the grid with the new Grouping info + Fill(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives ColumnGroupAddedEvent : " + e.Column.Name); +#endif + } + + /// + /// Handles the ColumnGroupRemovedEvent event. Fill the grid too. + /// + /// Source of the event. + /// A OutlookGridColumnEventArgs that contains the event data. + private void ColumnGroupRemovedEvent(object sender, OutlookGridColumnEventArgs e) + { + UnGroupColumn(e.Column.Name); + //We fill again the grid with the new Grouping info + Fill(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives ColumnGroupRemovedEvent : " + e.Column.Name); +#endif + } + + /// + /// Handles the ClearGroupingEvent event. Fill the grid too. + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void ClearGroupingEvent(object sender, EventArgs e) + { + ClearGroups(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives ClearGroupingEvent"); +#endif + } + + /// + /// Handles the FullCollapseEvent event. + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void FullCollapseEvent(object sender, EventArgs e) + { + CollapseAll(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives FullCollapseEvent"); +#endif + } + + /// + /// Handles the FullExpandEvent event. + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void FullExpandEvent(object sender, EventArgs e) + { + ExpandAll(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives FullExpandEvent"); +#endif + } + + /// + /// Handles the GroupExpandEvent event. + /// + /// + /// + private void GridGroupExpandEvent(object sender, OutlookGridColumnEventArgs e) + { + Expand(e.Column.Name); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives GridGroupExpandEvent"); +#endif + } + + private void GridGroupCollapseEvent(object sender, OutlookGridColumnEventArgs e) + { + Collapse(e.Column.Name); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives GridGroupCollapseEvent"); +#endif + } + + private void ColumnGroupIndexChangedEvent(object sender, OutlookGridColumnEventArgs e) + { + //TODO 25/01/2014 + internalColumns.ChangeGroupIndex(e.Column); + Fill(); //to reflect the changes + ForceRefreshGroupBox(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives ColumnGroupIndexChangedEvent"); +#endif + } + + private void GroupIntervalClickEvent(object sender, OutlookGridColumnEventArgs e) + { + OutlookGridColumn col = internalColumns.FindFromColumnName(e.Column.Name); + ((OutlookGridDateTimeGroup)col.GroupingType).Interval = ((OutlookGridDateTimeGroup)e.Column.GroupingType).Interval; + Fill(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives GroupIntervalClickEvent"); +#endif + } + + private void SortBySummaryCountEvent(object sender, OutlookGridColumnEventArgs e) + { + OutlookGridColumn col = internalColumns.FindFromColumnName(e.Column.Name); + col.GroupingType.SortBySummaryCount = e.Column.GroupingType.SortBySummaryCount; + Fill(); +#if (DEBUG) + Console.WriteLine("OutlookGrid - Receives SortBySummaryCountEvent"); +#endif + } + + /// + /// Raises the GroupImageClick event. + /// + /// A OutlookGridGroupImageEventArgs that contains the event data. + protected virtual void OnGroupImageClick(OutlookGridGroupImageEventArgs e) + { + if (GroupImageClick != null) + GroupImageClick(this, e); + } + + /// + /// Raises the NodeExpanding event. + /// + /// A ExpandingEventArgs that contains the event data. + protected virtual void OnNodeExpanding(ExpandingEventArgs e) + { + if (NodeExpanding != null) + { + NodeExpanding(this, e); + } + } + + /// + /// Raises the NodeExpanded event. + /// + /// A ExpandedEventArgs that contains the event data. + protected virtual void OnNodeExpanded(ExpandedEventArgs e) + { + if (NodeExpanded != null) + { + NodeExpanded(this, e); + } + } + + /// + /// Raises the NodeCollapsing event. + /// + /// A CollapsingEventArgs that contains the event data. + protected virtual void OnNodeCollapsing(CollapsingEventArgs e) + { + if (NodeCollapsing != null) + { + NodeCollapsing(this, e); + } + + } + + /// + /// Raises the NodeCollapsed event. + /// + /// A CollapsedEventArgs that contains the event data. + protected virtual void OnNodeCollapsed(CollapsedEventArgs e) + { + if (NodeCollapsed != null) + { + NodeCollapsed(this, e); + } + } + + #endregion + + #region OutlookGrid methods + + /// + /// 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,...) + /// + /// The DataGridViewColumn. + /// The group type for the column. + /// The sort direction. + /// The column's position in grouping and at which level. + /// the column's position among sorted columns. + public void AddInternalColumn(DataGridViewColumn col, IOutlookGridGroup group, SortOrder sortDirection, int groupIndex, int sortIndex) + { + AddInternalColumn(new OutlookGridColumn(col, group, sortDirection, groupIndex, sortIndex)); + //internalColumns.Add(new OutlookGridColumn(col, group, sortDirection, groupIndex, sortIndex)); + ////Already reflect the SortOrder on the column + //col.HeaderCell.SortGlyphDirection = sortDirection; + //if (this._hideColumnOnGrouping && groupIndex > -1 && group.AllowHiddenWhenGrouped) + // col.Visible = false; + } + + /// + /// 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,...) + /// + /// The configured OutlookGridColumn. + public void AddInternalColumn(OutlookGridColumn col) + { + Debug.Assert(col != null); + if (col != null) + { + internalColumns.Add(col); + //Already reflect the SortOrder on the column + if (col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable) + { + col.DataGridViewColumn.HeaderCell.SortGlyphDirection = col.SortDirection; + } + if (_hideColumnOnGrouping && col.GroupIndex > -1 && col.GroupingType.AllowHiddenWhenGrouped) + col.DataGridViewColumn.Visible = false; + } + } + + /// + /// Add an array of OutlookGridColumns for internal use of OutlookGrid. The columns must already exist in the datagridview. Do this *BEFORE* using the grid (sorting and grouping, filling,...) + /// + /// + public void AddRangeInternalColumns(params OutlookGridColumn[] cols) + { + Debug.Assert(cols != null); + // All columns with DisplayIndex != -1 are put into the initialColumns array + foreach (OutlookGridColumn col in cols) + { + AddInternalColumn(col); + } + } + + /// + /// Group a column + /// + /// The name of the column. + /// The sort direction of the group./ + /// The IOutlookGridGroup object. + public void GroupColumn(string columnName, SortOrder sortDirection, IOutlookGridGroup gr) + { + GroupColumn(internalColumns[columnName], sortDirection, gr); + } + + /// + /// Group a column + /// + /// The name of the column. + /// The sort direction of the group./ + /// The IOutlookGridGroup object. + 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 + } + + /// + /// Ungroup a column + /// + /// The OutlookGridColumn. + public void UnGroupColumn(string columnName) + { + UnGroupColumn(internalColumns[columnName]); + } + + /// + /// Ungroup a column + /// + /// The OutlookGridColumn. + 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 + } + + /// + /// Sort the column. Call Fill after to make the changes + /// + /// The outlookGridColumn + /// The new SortOrder. + 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 + } + + /// + /// UnSort the column. Call Fill after to make the changes + /// + /// The outlookGridColumn. + 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 + } + + /// + /// Collapse all groups + /// + public void CollapseAll() + { + SetGroupCollapse(true); + } + + /// + /// Expand all groups + /// + public void ExpandAll() + { + SetGroupCollapse(false); + } + + /// + /// Expand all groups associated to a specific column + /// + /// The DataGridViewColumn + public void Expand(string col) + { + SetGroupCollapse(col, false); + } + + /// + /// Collapse all groups associated to a specific column + /// + /// The DataGridViewColumn + public void Collapse(string col) + { + SetGroupCollapse(col, true); + } + + /// + /// Expand a group row + /// + /// Index of the row + public void Expand(int row) + { + SetGroupCollapse(row, false); + } + + /// + /// Collapse a group row + /// + /// Index of the row + public void Collapse(int row) + { + SetGroupCollapse(row, true); + } + + /// + /// Clear all groups. Performs a fill grid too. + /// + public void ClearGroups() + { + ClearGroupsWithoutFilling(); + Fill(); + } + + /// + /// Clear all groups. No FillGrid calls. + /// + public void ClearGroupsWithoutFilling() + { + //TODO check that + //reset groups and collapsed statuses + groupCollection.Clear(); + //reset groups in columns + internalColumns.MaxGroupIndex = -1; + for (int i = 0; i < internalColumns.Count; i++) + { + if (internalColumns[i].IsGrouped) + internalColumns[i].DataGridViewColumn.Visible = true; + internalColumns[i].GroupIndex = -1; + } + } + + /// + /// Gets the index of the previous group row if any. + /// + /// Current row index + /// Index of the group row, -1 otherwise + public int PreviousGroupRowIndex(int currentRow) + { + for (int i = currentRow - 1; i >= 0; i--) + { + OutlookGridRow row = (OutlookGridRow)base.Rows[i]; + if (row.IsGroupRow) + { + return i; + } + } + return -1; + } + + /// + /// Gets all the subrows of a grouprow (recursive) + /// + /// The result list of OutlookGridRows + /// The IOutlookGridGroup that contains rows to inspect. + /// A list of OutlookGridRows + public List GetSubRows(ref List list, IOutlookGridGroup grouprow) + { + list.AddRange(grouprow.Rows); + for (int i = 0; i < grouprow.Children.Count; i++) + { + if (grouprow.Children.Count > 0) + GetSubRows(ref list, grouprow.Children[i]); + } + + return list; + } + + /// + /// Register for events concerning the groupbox + /// + public void RegisterGroupBoxEvents() + { + //Register for event of the associated KryptonGroupBox + if (GroupBox != null) + { + groupBox.ColumnGroupAdded += ColumnGroupAddedEvent; + groupBox.ColumnSortChanged += ColumnSortChangedEvent; + groupBox.ColumnGroupRemoved += ColumnGroupRemovedEvent; + groupBox.ClearGrouping += ClearGroupingEvent; + groupBox.FullCollapse += FullCollapseEvent; + groupBox.FullExpand += FullExpandEvent; + groupBox.ColumnGroupOrderChanged += ColumnGroupIndexChangedEvent; + groupBox.GroupCollapse += GridGroupCollapseEvent; + groupBox.GroupExpand += GridGroupExpandEvent; + groupBox.GroupIntervalClick += GroupIntervalClickEvent; + groupBox.SortBySummaryCount += SortBySummaryCountEvent; + } + } + + /// + /// Synchronize the OutlookGrid Group Box with the current status of the grid + /// + public void ForceRefreshGroupBox() + { + if (groupBox != null) + groupBox.UpdateGroupingColumns(internalColumns.FindGroupedColumns()); + } + + /// + /// Show the context menu header + /// + /// The column used by the context menu. + private void ShowColumnHeaderContextMenu(int columnIndex) + { + OutlookGridColumn col = internalColumns.FindFromColumnIndex(columnIndex); + // Create menu items the first time they are needed + if (_menuItems == null) + { + // Create individual items + _menuSortAscending = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTASCENDING"), Properties.Resources.sort_az_ascending2, OnColumnSortAscending); + _menuSortDescending = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTDESCENDING"), Properties.Resources.sort_az_descending2, new EventHandler(OnColumnSortDescending)); + _menuClearSorting = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CLEARSORTING"), Properties.Resources.sort_up_down_delete_16, new EventHandler(OnColumnClearSorting)); + _menuSeparator1 = new KryptonContextMenuSeparator(); + _menuExpand = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("EXPAND"), Properties.Resources.element_plus_16, new EventHandler(OnGroupExpand)); + _menuCollapse = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("COLLAPSE"), Properties.Resources.element_minus_16, new EventHandler(OnGroupCollapse)); + _menuSeparator4 = new KryptonContextMenuSeparator(); + _menuGroupByThisColumn = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("GROUP"), Properties.Resources.element, new EventHandler(OnGroupByThisColumn)); + _menuUngroupByThisColumn = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("UNGROUP"), Properties.Resources.element_delete, new EventHandler(OnUnGroupByThisColumn)); + _menuShowGroupBox = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SHOWGROUPBOX"), null, new EventHandler(OnShowGroupBox)); + _menuHideGroupBox = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("HIDEGROUPBOX"), null, new EventHandler(OnHideGroupBox)); + _menuSeparator2 = new KryptonContextMenuSeparator(); + _menuBestFitColumn = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("BESTFIT"), null, new EventHandler(OnBestFitColumn)); + _menuBestFitAllColumns = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("BESTFITALL"), Properties.Resources.fit_to_size, new EventHandler(OnBestFitAllColumns)); + _menuSeparator3 = new KryptonContextMenuSeparator(); + _menuVisibleColumns = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("COLUMNS"), Properties.Resources.table2_selection_column, null); + _menuGroupInterval = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("GROUPINTERVAL")); + _menuSortBySummary = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTBYSUMMARYCOUNT"), null, new EventHandler(OnSortBySummary)); + _menuSortBySummary.CheckOnClick = true; + _menuSeparator5 = new KryptonContextMenuSeparator(); + _menuConditionalFormatting = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CONDITIONALFORMATTING"), Properties.Resources.table_conditional_16, null); + + //Group Interval + KryptonContextMenuItems _GroupIntervalItems; + KryptonContextMenuItem it = null; + string[] names = Enum.GetNames(typeof(OutlookGridDateTimeGroup.DateInterval)); + KryptonContextMenuItemBase[] arrayOptions = new KryptonContextMenuItemBase[names.Length]; + for (int i = 0; i < names.Length; i++) + { + it = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB(names[i])); + it.Tag = names[i]; + it.Click += OnGroupIntervalClick; + arrayOptions[i] = it; + } + _GroupIntervalItems = new KryptonContextMenuItems(arrayOptions); + _menuGroupInterval.Items.Add(_GroupIntervalItems); + + //Visible Columns + KryptonContextMenuCheckBox itCheckbox = null; + KryptonContextMenuItemBase[] arrayCols = new KryptonContextMenuItemBase[Columns.Count]; + for (int i = 0; i < Columns.Count; i++) + { + itCheckbox = new KryptonContextMenuCheckBox(Columns[i].HeaderText); + itCheckbox.Checked = Columns[i].Visible; + itCheckbox.Tag = Columns[i].Index; + itCheckbox.CheckedChanged += OnColumnVisibleCheckedChanged; + arrayCols[i] = itCheckbox; + } + _menuVisibleColumns.Items.AddRange(arrayCols); + + //Conditional formatting + ImageList imgListFormatting = new ImageList(); + imgListFormatting.ColorDepth = ColorDepth.Depth32Bit; + imgListFormatting.ImageSize = new Size(32, 32); + List tmpTag = new List(); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_blue_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(76, 118, 255), false))); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_green_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(95, 173, 123), false))); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(248, 108, 103), false))); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_yellow_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(255, 185, 56), false))); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_violet_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(185, 56, 255), false))); + imgListFormatting.Images.Add(Properties.Resources.Databar_solid_pink_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(255, 56, 185), false))); + + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_blue_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(76, 118, 255), true))); + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_green_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(95, 173, 123), true))); + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(248, 108, 103), true))); + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_yellow_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(255, 185, 56), true))); + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_violet_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(185, 56, 255), true))); + imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_pink_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.BAR, new BarParams(Color.FromArgb(255, 56, 185), true))); + + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_blue_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(76, 118, 255)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_blue_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(76, 118, 255), Color.White))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_green_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(95, 173, 123)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_green_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(95, 173, 123), Color.White))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(248, 108, 103)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_red_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(248, 108, 103), Color.White))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_yellow_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(255, 185, 56)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_yellow_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(255, 185, 56), Color.White))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_violet_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(185, 56, 255)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_violet_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(185, 56, 255), Color.White))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_pink_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.White, Color.FromArgb(255, 56, 185)))); + imgListFormatting.Images.Add(Properties.Resources.TwoColors_pink_white_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TWOCOLOURSRANGE, new TwoColoursParams(Color.FromArgb(255, 56, 185), Color.White))); + + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_green_yellow_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(84, 179, 112), Color.FromArgb(252, 229, 130), Color.FromArgb(243, 120, 97)))); + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_yellow_green_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(243, 120, 97), Color.FromArgb(252, 229, 130), Color.FromArgb(84, 179, 112)))); + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_green_white_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(84, 179, 112), Color.White, Color.FromArgb(243, 120, 97)))); + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_white_green_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(243, 120, 97), Color.White, Color.FromArgb(84, 179, 112)))); + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_blue_white_red_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(134, 166, 253), Color.White, Color.FromArgb(243, 120, 97)))); + imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_white_blue_32); + tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.THREECOLOURSRANGE, new ThreeColoursParams(Color.FromArgb(243, 120, 97), Color.White, Color.FromArgb(134, 166, 253)))); + + + it = null; + names = Enum.GetNames(typeof(EnumConditionalFormatType)); + arrayOptions = new KryptonContextMenuItemBase[names.Length + 2]; + for (int i = 0; i < names.Length; i++) + { + it = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB(names[i])); + it.Tag = names[i]; + + if (names[i] == EnumConditionalFormatType.BAR.ToString()) + { + it.Image = Properties.Resources.databar_generic_16; + + //Solid + KryptonContextMenuHeading KFormattingBARHeadingSolid = new KryptonContextMenuHeading(); + KFormattingBARHeadingSolid.Text = LanguageManager.Instance.GetStringGB("SolidFill"); + KryptonContextMenuImageSelect KFormattingBARImgSelectSolid = new KryptonContextMenuImageSelect(); + KFormattingBARImgSelectSolid.ImageList = imgListFormatting; + KFormattingBARImgSelectSolid.ImageIndexStart = 0; + KFormattingBARImgSelectSolid.ImageIndexEnd = 5; + KFormattingBARImgSelectSolid.LineItems = 4; + KFormattingBARImgSelectSolid.Tag = tmpTag; + KFormattingBARImgSelectSolid.Click += OnConditionalFormattingClick; + + //Gradient + KryptonContextMenuHeading KFormattingBARHeadingGradient = new KryptonContextMenuHeading(); + KFormattingBARHeadingGradient.Text = LanguageManager.Instance.GetStringGB("GradientFill"); + KryptonContextMenuImageSelect KFormattingBARImgSelectGradient = new KryptonContextMenuImageSelect(); + KFormattingBARImgSelectGradient.ImageList = imgListFormatting; + KFormattingBARImgSelectGradient.ImageIndexStart = 6; + KFormattingBARImgSelectGradient.ImageIndexEnd = 11; + KFormattingBARImgSelectGradient.LineItems = 4; + KFormattingBARImgSelectGradient.Tag = tmpTag; + KFormattingBARImgSelectGradient.Click += OnConditionalFormattingClick; + + //Custom + KryptonContextMenuHeading KFormattingBARHeadingOther = new KryptonContextMenuHeading(); + KFormattingBARHeadingOther.Text = LanguageManager.Instance.GetStringGB("Other"); + KryptonContextMenuItem it2 = null; + it2 = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CustomThreeDots")); + it2.Tag = ""; + it2.Image = Properties.Resources.paint_bucket_green; + it2.Click += OnBARCustomClick; + + KryptonContextMenuItems _BARs = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { it2 }); + + //Menu construction + it.Items.AddRange(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { + KFormattingBARHeadingSolid, + KFormattingBARImgSelectSolid, + KFormattingBARHeadingGradient, + KFormattingBARImgSelectGradient, + KFormattingBARHeadingOther, + _BARs + }); + } + else if (names[i] == EnumConditionalFormatType.TWOCOLOURSRANGE.ToString()) + { + it.Image = Properties.Resources.color2scale_generic_16; + + KryptonContextMenuItems _TwoColors; + + KryptonContextMenuImageSelect KTwoColorsImgSelect = new KryptonContextMenuImageSelect(); + KTwoColorsImgSelect.ImageList = imgListFormatting; + KTwoColorsImgSelect.ImageIndexStart = 12; + KTwoColorsImgSelect.ImageIndexEnd = 23; + KTwoColorsImgSelect.LineItems = 4; + KTwoColorsImgSelect.Tag = tmpTag; + KTwoColorsImgSelect.Click += OnConditionalFormattingClick; + it.Items.Add(KTwoColorsImgSelect); + + KryptonContextMenuSeparator sep1 = new KryptonContextMenuSeparator(); + sep1.Tag = ""; + + KryptonContextMenuItem it2 = null; + it2 = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CustomThreeDots")); + it2.Tag = ""; + it2.Image = Properties.Resources.paint_bucket_green; + it2.Click += OnTwoColorsCustomClick; + + _TwoColors = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { sep1, it2 }); + it.Items.Add(_TwoColors); + } + else if (names[i] == EnumConditionalFormatType.THREECOLOURSRANGE.ToString()) + { + it.Image = Properties.Resources.color3scale_generic_16; + + KryptonContextMenuItems _ThreeColors; + + KryptonContextMenuImageSelect KThreeColorsImgSelect = new KryptonContextMenuImageSelect(); + KThreeColorsImgSelect.ImageList = imgListFormatting; + KThreeColorsImgSelect.ImageIndexStart = 24; + KThreeColorsImgSelect.ImageIndexEnd = 29; + KThreeColorsImgSelect.LineItems = 4; + KThreeColorsImgSelect.Tag = tmpTag; + KThreeColorsImgSelect.Click += OnConditionalFormattingClick; + it.Items.Add(KThreeColorsImgSelect); + + KryptonContextMenuSeparator sep1 = new KryptonContextMenuSeparator(); + sep1.Tag = ""; + + KryptonContextMenuItem it2 = null; + it2 = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CustomThreeDots")); + it2.Tag = ""; + it2.Image = Properties.Resources.paint_bucket_green; + it2.Click += OnThreeColorsCustomClick; + + _ThreeColors = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { sep1, it2 }); + it.Items.Add(_ThreeColors); + } + + arrayOptions[i] = it; + KryptonContextMenuSeparator sep2 = new KryptonContextMenuSeparator(); + sep2.Tag = ""; + arrayOptions[i + 1] = sep2; + KryptonContextMenuItem it3 = null; + it3 = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("ClearRules")); + it3.Image = Properties.Resources.eraser; + it3.Tag = ""; + it3.Click += OnClearConditionalClick; + arrayOptions[i + 2] = it3; + } + KryptonContextMenuItems _ConditionalFormattingItems = new KryptonContextMenuItems(arrayOptions); + _menuConditionalFormatting.Items.Add(_ConditionalFormattingItems); + + //Add items inside an items collection (apart from separator1 which is only added if required) + _menuItems = new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { _menuSortAscending, + _menuSortDescending, + _menuSortBySummary, + _menuClearSorting, + _menuSeparator1, + _menuExpand, + _menuCollapse, + _menuSeparator4, + _menuGroupByThisColumn, + _menuGroupInterval, + _menuUngroupByThisColumn, + _menuShowGroupBox, + _menuHideGroupBox, + _menuSeparator2, + _menuBestFitColumn, + _menuBestFitAllColumns, + _menuSeparator3, + _menuVisibleColumns, + _menuSeparator5, + _menuConditionalFormatting}); + } + + // Ensure we have a krypton context menu if not already present + if (KCtxMenu == null) + KCtxMenu = new KryptonContextMenu(); + + // Update the individual menu options + if (col != null) + { + _menuSortAscending.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable; + _menuSortAscending.Checked = col.SortDirection == SortOrder.Ascending ? true : false; + _menuSortDescending.Checked = col.SortDirection == SortOrder.Descending ? true : false; + _menuSortDescending.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable; + _menuSortBySummary.Visible = col.IsGrouped && col.GroupingType != null; + if (_menuSortBySummary.Visible) + _menuSortBySummary.Checked = col.GroupingType.SortBySummaryCount; + _menuClearSorting.Enabled = col.SortDirection != SortOrder.None && !col.IsGrouped; + _menuClearSorting.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable; + _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible || _menuClearSorting.Visible); + _menuExpand.Visible = col.IsGrouped; + _menuCollapse.Visible = col.IsGrouped; + _menuSeparator4.Visible = (_menuExpand.Visible || _menuCollapse.Visible); + _menuGroupByThisColumn.Visible = !col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable; + _menuGroupInterval.Visible = col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable && col.GroupingType.GetType() == typeof(OutlookGridDateTimeGroup); + if (_menuGroupInterval.Visible) + { + string currentInterval = Enum.GetName(typeof(OutlookGridDateTimeGroup.DateInterval), ((OutlookGridDateTimeGroup)col.GroupingType).Interval); + foreach (KryptonContextMenuItem item in ((KryptonContextMenuItems)_menuGroupInterval.Items[0]).Items) + { + item.Checked = item.Tag.ToString() == currentInterval; + } + } + _menuUngroupByThisColumn.Visible = col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable; + _menuShowGroupBox.Visible = (groupBox != null) && !groupBox.Visible; + _menuHideGroupBox.Visible = (groupBox != null) && groupBox.Visible; + _menuSeparator2.Visible = (_menuGroupByThisColumn.Visible || _menuUngroupByThisColumn.Visible || _menuShowGroupBox.Visible || _menuHideGroupBox.Visible); + _menuBestFitColumn.Visible = true; + if (col.DataGridViewColumn.GetType() == typeof(KryptonDataGridViewFormattingColumn)) + { + _menuSeparator5.Visible = true; + _menuConditionalFormatting.Visible = true; + + //Get the format condition + ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault(); + + for (int i = 0; i < _menuConditionalFormatting.Items[0].ItemChildCount; i++) + { + if (format != null && ((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i].Tag.ToString().Equals(format.FormatType.ToString())) + { + ((KryptonContextMenuItem)((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i]).Checked = true; + } + else + { + if (((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i].GetType() != typeof(KryptonContextMenuSeparator)) + ((KryptonContextMenuItem)((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i]).Checked = false; + } + } + } + else + { + _menuSeparator5.Visible = false; + _menuConditionalFormatting.Visible = false; + } + } + else + { + _menuSortAscending.Visible = false; + _menuSortDescending.Visible = false; + _menuSortBySummary.Visible = false; + _menuClearSorting.Visible = false; + _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible || _menuClearSorting.Visible); + _menuExpand.Visible = false; + _menuCollapse.Visible = false; + _menuSeparator4.Visible = (_menuExpand.Visible || _menuCollapse.Visible); + _menuGroupByThisColumn.Visible = false; + _menuGroupInterval.Visible = false; + _menuUngroupByThisColumn.Visible = false; + _menuShowGroupBox.Visible = (groupBox != null) && !groupBox.Visible; + _menuHideGroupBox.Visible = (groupBox != null) && groupBox.Visible; + _menuSeparator2.Visible = (_menuGroupByThisColumn.Visible || _menuUngroupByThisColumn.Visible || _menuShowGroupBox.Visible || _menuHideGroupBox.Visible); + _menuBestFitColumn.Visible = false; + _menuSeparator5.Visible = false; + _menuConditionalFormatting.Visible = false; + + } + + if (!KCtxMenu.Items.Contains(_menuItems)) + KCtxMenu.Items.Add(_menuItems); + + // Show the menu! + KCtxMenu.Show(this); + } + + /// + /// Clear all sorting columns only (not the grouped ones) + /// + public void ResetAllSortingColumns() + { + internalColumns.MaxSortIndex = -1; + foreach (OutlookGridColumn col in internalColumns) + { + if (!col.IsGrouped && col.SortDirection != SortOrder.None) + { + col.DataGridViewColumn.HeaderCell.SortGlyphDirection = SortOrder.None; + col.SortDirection = SortOrder.None; + col.SortIndex = -1; + } + } +#if DEBUG + internalColumns.DebugOutput(); +#endif + } + + ///// + ///// Sort the grid + ///// + ///// The IComparer object. + //public void Sort(IComparer comparer) + //{ + // Fill(); + //} + + /// + /// Clears the internal rows. + /// + public void ClearInternalRows() + { + internalRows.Clear(); + } + + /// + /// Assign the rows to the internal list. + /// + /// List of OutlookGridRows + public void AssignRows(List l) + { + internalRows = l; + } + + /// + /// Assign the rows to the internal list. + /// + /// DataGridViewRowCollection + public void AssignRows(DataGridViewRowCollection col) + { + //dataSource.Rows = col.Cast().ToList(); + internalRows = col.Cast().ToList(); + } + + /// + /// Collapse/Expand all group rows + /// + /// True if collapsed, false if expanded + private void SetGroupCollapse(bool collapsed) + { + if (!IsGridGrouped || internalRows.Count == 0) + return; + + //// loop through all rows to find the GroupRows + //for (int i = 0; i < this.Rows.Count; i++) + //{ + // if (((OutlookGridRow)this.Rows[i]).IsGroupRow) + // ((OutlookGridRow)this.Rows[i]).Group.Collapsed = collapsed; + //} + RecursiveSetGroupCollapse(groupCollection, collapsed); + + // workaround, make the grid refresh properly + Rows[0].Visible = !Rows[0].Visible; + Rows[0].Visible = !Rows[0].Visible; + + //When collapsing the first row still seeing it. + if (Rows[0].Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = Rows[0].Index; + } + + private void RecursiveSetGroupCollapse(OutlookGridGroupCollection col, bool collapsed) + { + for (int i = 0; i < col.Count; i++) + { + col[i].Collapsed = collapsed; + RecursiveSetGroupCollapse(col[i].Children, collapsed); + } + } + + private void SetGroupCollapse(string c, bool collapsed) + { + if (!IsGridGrouped || internalRows.Count == 0) + return; + + // loop through all rows to find the GroupRows + //for (int i = 0; i < this.Rows.Count; i++) + //{ + // if (((OutlookGridRow)this.Rows[i]).IsGroupRow && ((OutlookGridRow)this.Rows[i]).Group.Column.DataGridViewColumn.Name == c.Name) + // ((OutlookGridRow)this.Rows[i]).Group.Collapsed = collapsed; + //} + RecursiveSetGroupCollapse(c, groupCollection, collapsed); + + // workaround, make the grid refresh properly + Rows[0].Visible = !Rows[0].Visible; + Rows[0].Visible = !Rows[0].Visible; + + //When collapsing the first row still seeing it. + if (Rows[0].Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = Rows[0].Index; + } + + 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); + } + } + + /// + /// Collapse/Expand a group row + /// + /// The index of the group row. + /// True if collapsed, false if expanded. + private void SetGroupCollapse(int rowindex, bool collapsed) + { + if (!IsGridGrouped || internalRows.Count == 0 || rowindex < 0) + return; + + OutlookGridRow row = (OutlookGridRow)base.Rows[rowindex]; + if (row.IsGroupRow) + { + row.Group.Collapsed = collapsed; + + //this is a workaround to make the grid re-calculate it's contents and backgroun bounds + // so the background is updated correctly. + // this will also invalidate the control, so it will redraw itself + row.Visible = false; + row.Visible = true; + + //When collapsing the first row still seeing it. + if (row.Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = row.Index; + } + } + + /// + /// Expand all nodes + /// + public void ExpandAllNodes() + { + if (Rows.Count > 0) + { + foreach (OutlookGridRow r in Rows) + { + RecursiveDescendantSetNodeCollapse(r, false); + } + Rows[0].Visible = !Rows[0].Visible; + Rows[0].Visible = !Rows[0].Visible; + + //When collapsing the first row still seeing it. + if (Rows[0].Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = Rows[0].Index; + } + } + + /// + /// Collapse all nodes + /// + public void CollapseAllNodes() + { + if (Rows.Count > 0) + { + foreach (OutlookGridRow r in Rows) + { + RecursiveDescendantSetNodeCollapse(r, true); + } + Rows[0].Visible = !Rows[0].Visible; + Rows[0].Visible = !Rows[0].Visible; + + //When collapsing the first row still seeing it. + if (Rows[0].Index < FirstDisplayedScrollingRowIndex) + FirstDisplayedScrollingRowIndex = Rows[0].Index; + } + } + + private void RecursiveDescendantSetNodeCollapse(OutlookGridRow r, bool collapsed) + { + //No events - for speed + if (r.HasChildren) + { + r.Collapsed = collapsed; + foreach (OutlookGridRow r2 in r.Nodes.Nodes) + { + RecursiveDescendantSetNodeCollapse(r2, collapsed); + } + } + } + + //private void RecursiveUpwardSetNodeCollaspse(OutlookGridRow r, bool collasped) + //{ + // //No events - for speed + // if (r.ParentNode != null) + // { + // if (r.ParentNode.Collapsed) + // { + // r.ParentNode.Collapsed = collasped; + // RecursiveUpwardSetNodeCollaspse(r.ParentNode, collapsed); + // } + // } + // //sw.Stop(); + // //Console.WriteLine(sw.ElapsedMilliseconds.ToString() + " ms" + r.ToString()); + + //} + + private void RecursiveUpwardSetNodeCollaspse(OutlookGridRow r, bool collapsed) + { + //No events - for speed + if (r.ParentNode != null) + { + r.ParentNode.Collapsed = collapsed; + RecursiveUpwardSetNodeCollaspse(r.ParentNode, collapsed); + } + } + + + /// + /// Ensure the node is visible (all parents exanded) + /// + /// The OutlookGridRow which needs to be visible. + public void EnsureVisibleNode(OutlookGridRow r) + { + RecursiveUpwardSetNodeCollaspse(r, false); + + } + + /// + /// Collapses the node. + /// + /// The OutlookGridRow node. + /// + public bool CollapseNode(OutlookGridRow node) + { + if (!node.Collapsed) + { + CollapsingEventArgs exp = new CollapsingEventArgs(node); + OnNodeCollapsing(exp); + + if (!exp.Cancel) + { + node.SetNodeCollapse(true); + + CollapsedEventArgs exped = new CollapsedEventArgs(node); + OnNodeCollapsed(exped); + } + + return !exp.Cancel; + } + else + { + // row isn't expanded, so we didn't do anything. + return false; + } + } + + /// + /// Expands the node. + /// + /// The OutlookGridRow node. + /// + public bool ExpandNode(OutlookGridRow node) + { + if (node.Collapsed) + { + ExpandingEventArgs exp = new ExpandingEventArgs(node); + OnNodeExpanding(exp); + + if (!exp.Cancel) + { + node.SetNodeCollapse(false); + + ExpandedEventArgs exped = new ExpandedEventArgs(node); + OnNodeExpanded(exped); + } + + return !exp.Cancel; + } + else + { + // row isn't expanded, so we didn't do anything. + return false; + } + } + + /// + /// Expand Node and all its subnodes (without events) + /// + public void ExpandNodeAndSubNodes(OutlookGridRow r) + { + RecursiveDescendantSetNodeCollapse(r, false); + r.Visible = !r.Visible; + r.Visible = !r.Visible; + + ////When collapsing the first row still seeing it. + //if (this.Rows[0].Index < this.FirstDisplayedScrollingRowIndex) + // this.FirstDisplayedScrollingRowIndex = this.Rows[0].Index; + } + + /// + /// Collapse Node and all its subnodes (without events) + /// + public void CollapseNodeAndSubNodes(OutlookGridRow r) + { + RecursiveDescendantSetNodeCollapse(r, true); + r.Visible = !r.Visible; + r.Visible = !r.Visible; + + ////When collapsing the first row still seeing it. + //if (this.Rows[0].Index < this.FirstDisplayedScrollingRowIndex) + // this.FirstDisplayedScrollingRowIndex = this.Rows[0].Index; + } + + #region Grid Fill functions + + + private void NonGroupedRecursiveFillOutlookGridRows(List l, List tmp) + { + for (int i = 0; i < l.Count; i++) + { + tmp.Add(l[i]); + + //Recusive call + if (l[i].HasChildren) + { + NonGroupedRecursiveFillOutlookGridRows(l[i].Nodes.Nodes, tmp); + } + } + } + + private void FillMinMaxFormatConditions(Type typeColumn, int j, List list, int formatColumn) + { + if (typeColumn == typeof(TimeSpan)) + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].Cells[formatColumn].Value != null) + { + + if (((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes < formatConditions[j].minValue) + formatConditions[j].minValue = ((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes; + if (((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes > formatConditions[j].maxValue) + formatConditions[j].maxValue = ((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes; + } + if (list[i].HasChildren) + FillMinMaxFormatConditions(typeColumn, j, list[i].Nodes.Nodes, formatColumn); + } + } + else if (typeColumn == typeof(Decimal)) + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].Cells[formatColumn].Value != null) + { + if (Convert.ToDouble(list[i].Cells[formatColumn].Value) < formatConditions[j].minValue) + formatConditions[j].minValue = Convert.ToDouble(list[i].Cells[formatColumn].Value); + if (Convert.ToDouble(list[i].Cells[formatColumn].Value) > formatConditions[j].maxValue) + formatConditions[j].maxValue = Convert.ToDouble(list[i].Cells[formatColumn].Value); + } + if (list[i].HasChildren) + FillMinMaxFormatConditions(typeColumn, j, list[i].Nodes.Nodes, formatColumn); + } + } + else + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].Cells[formatColumn].Value != null) + { + if ((double)list[i].Cells[formatColumn].Value < formatConditions[j].minValue) + formatConditions[j].minValue = (double)list[i].Cells[formatColumn].Value; + if ((double)list[i].Cells[formatColumn].Value > formatConditions[j].maxValue) + formatConditions[j].maxValue = (double)list[i].Cells[formatColumn].Value; + } + if (list[i].HasChildren) + FillMinMaxFormatConditions(typeColumn, j, list[i].Nodes.Nodes, formatColumn); + } + } + } + + private void FillValueFormatConditions(int formatColumn, Type typeColumn, List list) + { + for (int i = 0; i < list.Count; i++) + { + for (int j = 0; j < formatConditions.Count; j++) + { + formatColumn = Columns[formatConditions[j].ColumnName].Index; + if (list[i].Cells[formatColumn].Value != null) + { + typeColumn = Columns[formatConditions[j].ColumnName].ValueType; + FormattingCell fCell = (FormattingCell)list[i].Cells[formatColumn]; + fCell.FormatType = formatConditions[j].FormatType; + fCell.FormatParams = (IFormatParams)formatConditions[j].FormatParams.Clone(); + switch (formatConditions[j].FormatType) + { + case EnumConditionalFormatType.BAR: + if (typeColumn == typeof(TimeSpan)) + { + ((BarParams)fCell.FormatParams).ProportionValue = ColourFormatting.ConvertBar(((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes, formatConditions[j].minValue, formatConditions[j].maxValue); + } + else if (typeColumn == typeof(Decimal)) + { + ((BarParams)fCell.FormatParams).ProportionValue = ColourFormatting.ConvertBar(Convert.ToDouble(list[i].Cells[formatColumn].Value), formatConditions[j].minValue, formatConditions[j].maxValue); + } + else + { + ((BarParams)fCell.FormatParams).ProportionValue = ColourFormatting.ConvertBar((double)list[i].Cells[formatColumn].Value, formatConditions[j].minValue, formatConditions[j].maxValue); + } + break; + case EnumConditionalFormatType.TWOCOLOURSRANGE: + if (typeColumn == typeof(TimeSpan)) + { + ((TwoColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertTwoRange(((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes, formatConditions[j].minValue, formatConditions[j].maxValue, (TwoColoursParams)formatConditions[j].FormatParams); + } + else if (typeColumn == typeof(Decimal)) + { + ((TwoColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertTwoRange(Convert.ToDouble(list[i].Cells[formatColumn].Value), formatConditions[j].minValue, formatConditions[j].maxValue, (TwoColoursParams)formatConditions[j].FormatParams); + } + else + { + ((TwoColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertTwoRange((double)list[i].Cells[formatColumn].Value, formatConditions[j].minValue, formatConditions[j].maxValue, (TwoColoursParams)formatConditions[j].FormatParams); + } + //list[i].Cells[formatColumn].Style.SelectionBackColor = list[i].Cells[formatColumn].Style.BackColor; + break; + case EnumConditionalFormatType.THREECOLOURSRANGE: + if (typeColumn == typeof(TimeSpan)) + { + ((ThreeColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertThreeRange(((TimeSpan)list[i].Cells[formatColumn].Value).TotalMinutes, formatConditions[j].minValue, formatConditions[j].maxValue, (ThreeColoursParams)formatConditions[j].FormatParams); + } + else if (typeColumn == typeof(Decimal)) + { + ((ThreeColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertThreeRange(Convert.ToDouble(list[i].Cells[formatColumn].Value), formatConditions[j].minValue, formatConditions[j].maxValue, (ThreeColoursParams)formatConditions[j].FormatParams); + } + else + { + ((ThreeColoursParams)fCell.FormatParams).ValueColour = ColourFormatting.ConvertThreeRange((double)list[i].Cells[formatColumn].Value, formatConditions[j].minValue, formatConditions[j].maxValue, (ThreeColoursParams)formatConditions[j].FormatParams); + } + //list[i].Cells[formatColumn].Style.SelectionBackColor = list[i].Cells[formatColumn].Style.BackColor; + break; + } + } + } + + if (list[i].HasChildren) + FillValueFormatConditions(formatColumn, typeColumn, list[i].Nodes.Nodes); + } + } + + + /// + /// Fill the grid (grouping, sorting,...) + /// + public void Fill() + { + Cursor.Current = Cursors.WaitCursor; +#if (DEBUG) + Stopwatch azer = new Stopwatch(); + azer.Start(); +#endif + List list; + List tmp; // = new List(); + IOutlookGridGroup grParent = null; + Rows.Clear(); + groupCollection.Clear(); + + if (internalRows.Count == 0) + return; + list = internalRows; + + + //Apply Formatting + int formatColumn = 0; + Type typeColumn = null; + + //Determine mix and max value + for (int j = 0; j < formatConditions.Count; j++) + { + formatColumn = Columns[formatConditions[j].ColumnName].Index; + typeColumn = Columns[formatConditions[j].ColumnName].ValueType; + formatConditions[j].minValue = double.MaxValue; + formatConditions[j].maxValue = double.MinValue; + FillMinMaxFormatConditions(typeColumn, j, list, formatColumn); + } + + //Passing the necessary information to cells + FillValueFormatConditions(formatColumn, typeColumn, list); + + //End of Formatting +#if (DEBUG) + azer.Stop(); + Console.WriteLine("Formatting : " + azer.ElapsedMilliseconds + " ms"); + azer.Start(); +#endif + // this block is used of grouping is turned off + // this will simply list all attributes of each object in the list + if (internalColumns.CountGrouped() == 0) + { + //Applying sort + //try + //{ + list.Sort(new OutlookGridRowComparer2(internalColumns.GetIndexAndSortSortedOnlyColumns())); + //} + //catch (Exception e) + //{ + // MessageBox.Show("Failed to sort.\n\n Error:" + e.Message, + // "Grid Sorting", + // MessageBoxButtons.OK, + // MessageBoxIcon.Error); + // } + + //Add rows to underlying DataGridView + if (_fillMode == FillMode.GROUPSONLY) + { + Rows.AddRange(list.ToArray()); + } + else + { + tmp = new List(); + NonGroupedRecursiveFillOutlookGridRows(list, tmp); + + //Add all the rows to the grid + Rows.AddRange(tmp.ToArray()); + } + + } + // this block is used when grouping is used + // items in the list must be sorted, and then they will automatically be grouped + else + { + //Group part of the job + //try + //{ + //We get the columns that are grouped + List groupedColumns = internalColumns.FindGroupedColumns(); + + //For each outlookgrid row in the grid + for (int j = 0; j < list.Count; j++) + { + //Reload the groups collection for each rows !! + OutlookGridGroupCollection children = groupCollection; + + //For each grouped column (ordered by GroupIndex) + for (int i = 0; i < groupedColumns.Count; i++) + { + if (i == 0) + grParent = null; + + //Gets the stored value + object value = list[j].Cells[groupedColumns[i].DataGridViewColumn.Index].Value; + object formattedValue; + + //We get the formatting value according to the type of group (Alphabetic, DateTime,...) + groupedColumns[i].GroupingType.Value = value; + formattedValue = groupedColumns[i].GroupingType.Value; + + //We search the corresponding group. + IOutlookGridGroup gr = children.FindGroup(formattedValue); + if (gr == null) + { + gr = (IOutlookGridGroup)groupedColumns[i].GroupingType.Clone(); + gr.ParentGroup = grParent; + gr.Column = groupedColumns[i]; + gr.Value = value; + gr.FormatStyle = groupedColumns[i].DataGridViewColumn.DefaultCellStyle.Format; //We can the formatting applied to the cell to the group + if (value is TextAndImage) + gr.GroupImage = ((TextAndImage)value).Image; + else if (value is Token) + { + Bitmap bmp = new Bitmap(13, 13); + using (Graphics gfx = Graphics.FromImage(bmp)) + { + using (SolidBrush brush = new SolidBrush(((Token)value).BackColor)) + { + gfx.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height); + } + } + gr.GroupImage = bmp; + } + else if (value is System.Drawing.Bitmap) + gr.GroupImage = (System.Drawing.Bitmap)value; + //else if (groupedColumns[i].DataGridViewColumn.GetType() == typeof(KryptonDataGridViewRatingColumn)) + //{ + // gr.GroupImage = (Image)Properties.Resources.ResourceManager.GetObject("star" + value.ToString()); + //} + + gr.Level = i; + children.Add(gr); + } + + //Go deeper in the groups, set current group as parent + grParent = gr; + children = gr.Children; + + //if we have browsed all the groups we are sure to be in the righr group: add rows and update counters ! + if (i == groupedColumns.Count - 1) + { + list[j].Group = gr; + gr.Rows.Add(list[j]); + RecursiveIncrementParentGroupCounters(gr); + } + } + } + + //reset local variable for GC + groupedColumns = null; + //} + //catch (Exception e) + //{ + // MessageBox.Show("Failed to add rows.\n\n Error:" + e.Message, + // "Grid Filling", + // MessageBoxButtons.OK, + // MessageBoxIcon.Error); + //} + + //Sorting part : sort the groups between them and sort the rows inside the groups + //try + //{ + //int index = internalColumns.FindSortedColumnNotgrouped(); + //RecursiveSort(this.groupCollection, index, (index == -1) ? SortOrder.None : internalColumns.FindFromColumnIndex(index).SortDirection); + List> sortList = internalColumns.GetIndexAndSortSortedOnlyColumns(); + if (sortList.Count > 0) + RecursiveSort(groupCollection, sortList); + else + RecursiveSort(groupCollection, internalColumns.GetIndexAndSortGroupedColumns()); + //} + //catch (Exception e) + //{ + // MessageBox.Show("Failed to sort.\n\n Error:" + e.Message, + // "Grid Sorting", + // MessageBoxButtons.OK, + // MessageBoxIcon.Error); + //} + + //Reinit! + tmp = new List(); + //Get a list of rows (grouprow and non-grouprow) + RecursiveFillOutlookGridRows(groupCollection, tmp); + + //Finally add the rows to underlying datagridview after all the magic ! + Rows.AddRange(tmp.ToArray()); + } + Cursor.Current = Cursors.Default; +#if (DEBUG) + azer.Stop(); + Console.WriteLine("FillGrid : " + azer.ElapsedMilliseconds + " ms"); +#endif + } + + /// + /// Sort recursively the OutlookGridRows within groups + /// + /// The OutlookGridGroupCollection. + /// The list of sorted columns + private void RecursiveSort(OutlookGridGroupCollection groupCollection, List> sortList) + { + //We sort the groups + if (groupCollection.Count > 0) + { + if (groupCollection[0].Column.GroupingType.SortBySummaryCount) + groupCollection.Sort(new OutlookGridGroupCountComparer()); + else if (GroupCollection[0].Column.SortDirection != SortOrder.None) + 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); + } + } + + /// + /// Update all the parents counters of a group + /// + /// The group whic + private void RecursiveIncrementParentGroupCounters(IOutlookGridGroup l) + { + //Add +1 to the counter + l.ItemCount++; + if (l.ParentGroup != null) + { + //Recursive call for parent + RecursiveIncrementParentGroupCounters(l.ParentGroup); + } + } + + /// + /// Transform a group in a list of OutlookGridRows. Recursive call + /// + /// The OutlookGridGroupCollection that contains the groups and associated rows. + /// A List of OutlookGridRow + private void RecursiveFillOutlookGridRows(OutlookGridGroupCollection l, List 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); + } + + } + } + #endregion Grid Fill functions + + /// + /// Persist the configuration of the KryptonOutlookGrid + /// + /// The path where the .xml file will be saved. + /// The version of the config file. + public void PersistConfiguration(string path, string version) + { + OutlookGridColumn col = null; + using (XmlWriter writer = XmlWriter.Create(path, new XmlWriterSettings { Indent = true })) + { + writer.WriteStartDocument(); + writer.WriteStartElement("OutlookGrid"); + writer.WriteAttributeString("V", version); + writer.WriteElementString("GroupBox", groupBox.Visible.ToString()); + writer.WriteElementString("HideColumnOnGrouping", CommonHelper.BoolToString(HideColumnOnGrouping)); + writer.WriteStartElement("Columns"); + for (int i = 0; i < internalColumns.Count; i++) + { + col = internalColumns[i]; + writer.WriteStartElement("Column"); + writer.WriteElementString("Name", col.Name); + writer.WriteStartElement("GroupingType"); + if (col.GroupingType != null) + { + writer.WriteElementString("Name", col.GroupingType.GetType().AssemblyQualifiedName); //.GetType().Name.ToString()); + writer.WriteElementString("OneItemText", col.GroupingType.OneItemText); + writer.WriteElementString("XXXItemsText", col.GroupingType.XXXItemsText); + writer.WriteElementString("SortBySummaryCount", CommonHelper.BoolToString(col.GroupingType.SortBySummaryCount)); + writer.WriteElementString("ItemsComparer", (col.GroupingType.ItemsComparer == null) ? "" : col.GroupingType.ItemsComparer.GetType().AssemblyQualifiedName); + if (col.GroupingType.GetType() == typeof(OutlookGridDateTimeGroup)) + { + writer.WriteElementString("GroupDateInterval", ((OutlookGridDateTimeGroup)col.GroupingType).Interval.ToString()); + } + } + writer.WriteEndElement(); + writer.WriteElementString("SortDirection", col.SortDirection.ToString()); + writer.WriteElementString("GroupIndex", col.GroupIndex.ToString()); + writer.WriteElementString("SortIndex", col.SortIndex.ToString()); + writer.WriteElementString("Visible", col.DataGridViewColumn.Visible.ToString()); + writer.WriteElementString("Width", col.DataGridViewColumn.Width.ToString()); + writer.WriteElementString("Index", col.DataGridViewColumn.Index.ToString()); + writer.WriteElementString("DisplayIndex", col.DataGridViewColumn.DisplayIndex.ToString()); + writer.WriteEndElement(); + } + writer.WriteEndElement(); + + //Conditional formatting + writer.WriteStartElement("ConditionalFormatting"); + for (int i = 0; i < formatConditions.Count; i++) + { + formatConditions[i].Persist(writer); + } + writer.WriteEndElement(); // End ConditionalFormatting + writer.WriteEndElement(); //End OutlookGrid + writer.WriteEndDocument(); + writer.Flush(); + } + } + + /// + /// Clears everything in the OutlookGrid (groups, rows, columns, DataGridViewColumns). Ready for a completely new start. + /// + public void ClearEverything() + { + groupCollection.Clear(); + internalRows.Clear(); + internalColumns.Clear(); + Columns.Clear(); + ConditionalFormatting.Clear(); + //Snif everything is gone ! Be Ready for a new start ! + } + + /// + /// Finds the column from its name. + /// + /// The name. + /// + public OutlookGridColumn FindFromColumnName(string name) + { + return internalColumns.FindFromColumnName(name); + } + + /// + /// Finds the column from its index. + /// + /// The index. + /// + public OutlookGridColumn FindFromColumnIndex(int index) + { + return internalColumns.FindFromColumnIndex(index); + } + #endregion OutlookGrid methods + } + + /// + /// Grid filling mode + /// + public enum FillMode + { + /// + /// The grid contains only groups (faster). + /// + GROUPSONLY, + /// + /// The grid contains groups and nodes (no choice, choose this one !) + /// + GROUPSANDNODES + } +} \ No newline at end of file diff --git a/Classes/OutlookGridColumn.cs b/Classes/OutlookGridColumn.cs new file mode 100644 index 0000000..6be2414 --- /dev/null +++ b/Classes/OutlookGridColumn.cs @@ -0,0 +1,149 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Windows.Forms; + +using KryptonOutlookGrid.Interfaces; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Column for the OutlookGrid + /// + public class OutlookGridColumn : IEquatable + { + private IOutlookGridGroup groupingType; + private DataGridViewColumn column; + private SortOrder sortDirection; + private int groupIndex; + private int sortIndex; + private string name; + + #region Constructor + /// + /// Constructor + /// + /// The DataGridViewColumn. + /// The group type for the column. + /// The sort direction. + /// The column's position in grouping and at which level. + /// the column's position among sorted columns. + public OutlookGridColumn(DataGridViewColumn col, IOutlookGridGroup group, SortOrder sortDirection, int groupIndex, int sortIndex) + { + this.column = col; + this.name = col.Name; + this.groupingType = group; + this.sortDirection = sortDirection; + this.groupIndex = groupIndex; + this.sortIndex = sortIndex; + } + + /// + /// Constructor + /// + /// The name. + /// The DataGridViewColumn. + /// The group type for the column. + /// The sort direction. + /// The column's position in grouping and at which level. + /// the column's position among sorted columns. + public OutlookGridColumn(string columnName, DataGridViewColumn col, IOutlookGridGroup group, SortOrder sortDirection, int groupIndex, int sortIndex) + { + this.column = col; + this.name = columnName; + this.groupingType = group; + this.sortDirection = sortDirection; + this.groupIndex = groupIndex; + this.sortIndex = sortIndex; + } + + #endregion + + #region Properties + /// + /// Gets or sets the column name + /// + public string Name + { + get { return name; } + set { name = value; } + } + + /// + /// Gets or sets if the column is grouped + /// + public bool IsGrouped + { + get { return groupIndex > -1; } + } + + /// + /// Gets or sets the sort direction + /// + public SortOrder SortDirection + { + get { return sortDirection; } + set { sortDirection = value; } + } + + /// + /// Gets or sets the associated DataGridViewColumn + /// + public DataGridViewColumn DataGridViewColumn + { + get { return column; } + set { column = value; } + } + + /// + /// Gets or sets the group + /// + public IOutlookGridGroup GroupingType + { + get { return groupingType; } + set { groupingType = value; } + } + + /// + /// Gets or sets the column's position in grouping and at which level + /// + public int GroupIndex + { + get { return groupIndex; } + set { groupIndex = value; } + } + + /// + /// Gets or sets the column's position among sorted columns + /// + public int SortIndex + { + get { return sortIndex; } + set { sortIndex = value; } + } + + #endregion + + #region Implements + + /// + /// Defines Equals methode (interface IEquatable) + /// + /// The OutlookGridColumn to compare with + /// + public bool Equals(OutlookGridColumn other) + { + return column.Name.Equals(other.DataGridViewColumn.Name); + } + + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridColumnCollection.cs b/Classes/OutlookGridColumnCollection.cs new file mode 100644 index 0000000..4c0ac1f --- /dev/null +++ b/Classes/OutlookGridColumnCollection.cs @@ -0,0 +1,259 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// List of the current columns of the OutlookGrid + /// + public class OutlookGridColumnCollection : List + { + private int maxGroupIndex; + private int maxSortIndex; + + /// + /// Constructor + /// + public OutlookGridColumnCollection() + : base() + { + maxGroupIndex = -1; + maxSortIndex = -1; + } + + /// + /// Gets the OutlookGridColumn in the list by its name + /// + /// The column name. + /// OutlookGridColumn + public OutlookGridColumn this[string columnName] + { + get + { + return this.Find(c => c.DataGridViewColumn.Name.Equals(columnName)); + } + } + + /// + /// Add an OutlookGridColumn to the collection. + /// + /// The OutlookGridColumn to add. + public new void Add(OutlookGridColumn item) + { + base.Add(item); + + if (item.GroupIndex > -1) + maxGroupIndex++; + if (item.SortIndex > -1) + maxSortIndex++; + } + + /// + /// Gets or Sets the maximum GroupIndex in the collection + /// + public int MaxGroupIndex + { + get + { + return maxGroupIndex; + } + set + { + maxGroupIndex = value; + } + } + + /// + /// Gets or sets the maximum SortIndex in the collection + /// + public int MaxSortIndex + { + get + { + return maxSortIndex; + } + set + { + maxSortIndex = value; + } + } + + /// + /// Gets the number of columns grouped + /// + /// the number of columns grouped. + public int CountGrouped() + { + return this.Count(c => c.IsGrouped == true); + } + + /// + /// Gets the list of grouped columns + /// + /// The list of grouped columns. + public List FindGroupedColumns() + { + return this.Where(c => c.IsGrouped).OrderBy(c => c.GroupIndex).ToList(); + } + + /// + /// Gets a list of columns which are sorted and not grouped. + /// + /// List of Column indexes and SortDirection ordered by SortIndex. + public List> GetIndexAndSortGroupedColumns() + { + List> res = new List>(); + var tmp = this.OrderBy(x => x.GroupIndex); + foreach (OutlookGridColumn col in tmp) + { + if (col.IsGrouped && col.GroupIndex > -1) + res.Add(Tuple.Create(col.DataGridViewColumn.Index, col.SortDirection, col.GroupingType.ItemsComparer)); + } + return res; + } + + /// + /// Gets the column from its real index (from the underlying DataGridViewColumn) + /// + /// The index + /// The OutlookGridColumn. + public OutlookGridColumn FindFromColumnIndex(int index) + { + return this.FirstOrDefault(c => c.DataGridViewColumn.Index == index); + } + + /// + /// Gets the column from its name + /// + /// The name of the column. + /// The associated OutlookGridColumn. + public OutlookGridColumn FindFromColumnName(string name) + { + return this.FirstOrDefault(x => x.Name == name); + } + + /// + /// Gets a list of columns which are sorted and not grouped. + /// + /// List of Column indexes and SortDirection ordered by SortIndex. + public List> GetIndexAndSortSortedOnlyColumns() + { + List> res = new List>(); + var tmp = this.OrderBy(x => x.SortIndex); + foreach (OutlookGridColumn col in tmp) + { + if (!col.IsGrouped && col.SortIndex > -1) + res.Add(Tuple.Create(col.DataGridViewColumn.Index, col.SortDirection, col.GroupingType.ItemsComparer)); + } + return res; + } + + /// + /// Removes a groupIndex and update the GroupIndex for all columns + /// + /// The OutlookGridColumn that will be removed. + internal void RemoveGroupIndex(OutlookGridColumn col) + { + int removed = col.GroupIndex; + for (int i = 0; i < this.Count; i++) + { + if (this[i].GroupIndex > removed) + { + this[i].GroupIndex--; + } + } + maxGroupIndex--; + col.GroupIndex = -1; + } + + /// + /// Removes a SortIndex and update the SortIndex for all columns + /// + /// The OutlookGridColumn that will be removed. + internal void RemoveSortIndex(OutlookGridColumn col) + { + int removed = col.SortIndex; + for (int i = 0; i < this.Count; i++) + { + if (this[i].SortIndex > removed) + { + this[i].SortIndex--; + } + } + maxSortIndex--; + col.SortIndex = -1; + } + + internal void ChangeGroupIndex(OutlookGridColumn outlookGridColumn) + { + int currentGroupIndex = -1; + int newGroupIndex = outlookGridColumn.GroupIndex; + + for (int i = 0; i < this.Count; i++) + { + if (this[i].Name == outlookGridColumn.Name) + { + currentGroupIndex = this[i].GroupIndex; + } + } + + if (currentGroupIndex == -1) + throw new Exception("OutlookGrid : Unable to interpret the change of GroupIndex!"); + +#if (DEBUG) + Console.WriteLine("currentGroupIndex=" + currentGroupIndex.ToString()); + Console.WriteLine("newGroupIndex=" + newGroupIndex.ToString()); + Console.WriteLine("Before"); + DebugOutput(); +#endif + + for (int i = 0; i < this.Count; i++) + { + if (this[i].IsGrouped) + { + if (this[i].GroupIndex == currentGroupIndex) + { + this[i].GroupIndex = newGroupIndex; + } + else if ((this[i].GroupIndex >= newGroupIndex) && (this[i].GroupIndex < currentGroupIndex)) + { + this[i].GroupIndex++; + } + else if ((this[i].GroupIndex <= newGroupIndex) && (this[i].GroupIndex > currentGroupIndex)) + { + this[i].GroupIndex--; + } + } + } +#if (DEBUG) + Console.WriteLine("After"); + DebugOutput(); +#endif + } + + /// + /// Outputs Debug information to the console. + /// + public void DebugOutput() + { + for (int i = 0; i < this.Count; i++) + { + Console.WriteLine(this[i].Name + " , GroupIndex=" + this[i].GroupIndex.ToString() + ", SortIndex=" + this[i].SortIndex.ToString()); + } + Console.WriteLine("MaxGroupIndex=" + maxGroupIndex.ToString() + ", MaxSortIndex=" + maxSortIndex.ToString()); + } + } +} \ No newline at end of file diff --git a/Classes/OutlookGridColumnEventArgs.cs b/Classes/OutlookGridColumnEventArgs.cs new file mode 100644 index 0000000..c60fdd3 --- /dev/null +++ b/Classes/OutlookGridColumnEventArgs.cs @@ -0,0 +1,46 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Class for events of the column in the groupbox. + /// + public class OutlookGridColumnEventArgs : EventArgs + { + private OutlookGridColumn column; + + /// + /// Constructor + /// + /// The OutlookGridColumn. + public OutlookGridColumnEventArgs(OutlookGridColumn col) + { + this.column = col; + } + + /// + /// Gets or sets the name of the column. + /// + public OutlookGridColumn Column + { + get + { + return this.column; + } + set + { + this.column = value; + } + } + } +} \ No newline at end of file diff --git a/Classes/OutlookGridGroup.cs b/Classes/OutlookGridGroup.cs new file mode 100644 index 0000000..356599e --- /dev/null +++ b/Classes/OutlookGridGroup.cs @@ -0,0 +1,965 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.CustomColumns; +using KryptonOutlookGrid.Helpers; +using KryptonOutlookGrid.Interfaces; +using KryptonOutlookGrid.Utilities.Language; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Each arrange/grouping class must implement the IOutlookGridGroup interface + /// the Group object will determine for each object in the grid, whether it + /// falls in or outside its group. + /// It uses the IComparable.CompareTo function to determine if the item is in the group. + /// This class group the elements by default (string, int, ...) + /// + public class OutlookGridDefaultGroup : IOutlookGridGroup + { + #region "Variables" + /// + /// The Value of the group + /// + protected object val; + /// + /// Boolean if the group is collapsed or not + /// + protected bool collapsed; + /// + /// The associated DataGridView column. + /// + protected OutlookGridColumn column; + /// + /// The number of items in this group. + /// + protected int itemCount; + /// + /// The height (in pixels). + /// + protected int height; + /// + /// The list of rows associated to the group. + /// + protected List rows; + /// + /// The parent group if any. + /// + protected IOutlookGridGroup parentGroup; + /// + /// The level (nested) of grouping + /// + protected int level; + /// + /// The children groups + /// + protected OutlookGridGroupCollection children; + /// + /// The string to format the value of the group + /// + protected string formatStyle; + /// + /// The picture associated to the group + /// + protected Image groupImage; + /// + /// The text associated for the group text (1 item) + /// + protected string oneItemText; + /// + /// The text associated for the group text (XXX items) + /// + protected string xXXItemsText; + /// + /// Allows the column to be hidden when it is grouped by + /// + protected bool allowHiddenWhenGrouped; + /// + /// Sort groups using count items value + /// + protected bool sortBySummaryCount; + /// + /// Specific Comparer object for items in the group, if needed + /// + protected IComparer itemsComparer; + + /// + /// Background for group + /// + protected PaletteBack back; + #endregion + + #region "Constructor" + + /// + /// Initializes a new instance of the class. + /// + 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(); + children = new OutlookGridGroupCollection(); + formatStyle = ""; + oneItemText = LanguageManager.Instance.GetStringGB("OneItem"); + XXXItemsText = LanguageManager.Instance.GetStringGB("XXXItems"); + allowHiddenWhenGrouped = true; + sortBySummaryCount = false; + back = new PaletteBack(null, null); + } + + /// + /// Constructor + /// + /// The parent group if any. + public OutlookGridDefaultGroup(IOutlookGridGroup parentGroup) : this() + { + if (parentGroup != null) + children.ParentGroup = parentGroup; + } + #endregion + + #region IOutlookGridGroup Members + + /// + /// Gets or sets the list of rows associated to the group. + /// + public List Rows + { + get + { + return rows; + } + set + { + rows = value; + } + } + + /// + /// Gets or sets the parent group. + /// + /// The parent group. + public IOutlookGridGroup ParentGroup + { + get + { + return parentGroup; + } + set + { + parentGroup = value; + } + } + + /// + /// Gets or sets the level. + /// + /// The level. + public int Level + { + get + { + return level; + } + set + { + level = value; + } + } + + /// + /// Gets or sets the children. + /// + /// The children. + public OutlookGridGroupCollection Children + { + get + { + return children; + } + set + { + children = value; + } + } + + /// + /// Gets or sets the displayed text + /// + public virtual string Text + { + get + { + string formattedValue = ""; + string res = ""; + //For formatting number we need to cast the object value to the number before applying formatting + if (val == null || string.IsNullOrEmpty(val.ToString())) + { + formattedValue = LanguageManager.Instance.GetStringGB("UNKNOWN"); + } + else if (!String.IsNullOrEmpty(formatStyle)) + { + if (val is string) + { + formattedValue = string.Format(formatStyle, Value.ToString()); + } + else if (val is DateTime) + { + formattedValue = ((DateTime)Value).ToString(formatStyle); + } + else if (val is int) + { + formattedValue = ((int)Value).ToString(formatStyle); + } + else if (val is float) + { + formattedValue = ((float)Value).ToString(formatStyle); + } + else if (val is double) + { + formattedValue = ((double)Value).ToString(formatStyle); + } + else if (val is decimal) + { + formattedValue = ((decimal)Value).ToString(formatStyle); + } + else if (val is long) + { + formattedValue = ((long)Value).ToString(formatStyle); + } + else if (val is TimeSpan) + { + formattedValue = ((TimeSpan)Value).ToString(formatStyle); + } + else + { + formattedValue = Value.ToString(); + } + } + else + { + formattedValue = Value.ToString(); + } + + res = string.Format("{0}: {1} ({2})", column.DataGridViewColumn.HeaderText, formattedValue, itemCount == 1 ? oneItemText : itemCount.ToString() + XXXItemsText); + //if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + // return res.ToUpper(); + //else + return res; + } + //set + //{ + // text = value; + //} + } + + /// + /// Gets or sets the Value of the group + /// + public virtual object Value + { + get + { + return val; + } + set + { + val = value; + } + } + + /// + /// Boolean if the group is collapsed or not + /// + public virtual bool Collapsed + { + get + { + return collapsed; + } + set + { + collapsed = value; + } + } + + /// + /// Gets or sets the associated DataGridView column. + /// + public virtual OutlookGridColumn Column + { + get + { + return column; + } + set + { + column = value; + } + } + + /// + /// Gets or set the number of items in this group. + /// + public virtual int ItemCount + { + get + { + return itemCount; + } + set + { + itemCount = value; + } + } + + /// + /// Gets or sets the height (in pixels). + /// + public virtual int Height + { + get + { + return height; + } + set + { + height = value; + } + } + + /// + /// Gets or sets the Format Info. + /// + public virtual string FormatStyle + { + get + { + return formatStyle; + } + set + { + formatStyle = value; + } + } + + /// + /// Gets or sets the picture. + /// + public virtual Image GroupImage + { + get + { + return groupImage; + } + set + { + groupImage = value; + } + } + + /// + /// Gets or sets the text associated to One Item + /// + public virtual string OneItemText + { + get { return oneItemText; } + set { oneItemText = value; } + } + + /// + /// Gets or sets the text associated to several Items + /// + public virtual string XXXItemsText + { + get { return xXXItemsText; } + set { xXXItemsText = value; } + } + + /// + /// Gets or sets the boolean that hides the column automatically when grouped. + /// + public virtual bool AllowHiddenWhenGrouped + { + get { return allowHiddenWhenGrouped; } + set { allowHiddenWhenGrouped = value; } + } + + /// + /// Gets or sets the boolean that sort groups using summary value + /// + public virtual bool SortBySummaryCount + { + get { return sortBySummaryCount; } + set { sortBySummaryCount = value; } + } + + /// + /// Gets or sets the items comparer. + /// + /// + /// The items comparer. + /// + public virtual IComparer ItemsComparer + { + get { return itemsComparer; } + set { itemsComparer = value; } + } + + /// + /// Background for group + /// + public PaletteBack Back + { + get { return back; } + } + + #endregion + + #region ICloneable Members + + /// + /// Overrides the Clone() function + /// + /// OutlookgGridDefaultGroup + public virtual object Clone() + { + OutlookGridDefaultGroup gr = new OutlookGridDefaultGroup(parentGroup); + CloneMembers(gr); + return gr; + } + + #endregion + + #region IComparable Members + + /// + /// This is a comparison operation based on the type of the value. + /// + /// the value in the related column of the item to compare to + /// + public virtual int CompareTo(object obj) + { + int orderModifier = (Column.SortDirection == SortOrder.Ascending ? 1 : -1); + int compareResult = 0; + object o2 = ((OutlookGridDefaultGroup)obj).Value; + + if ((val == null || val == DBNull.Value) && (o2 != null && o2 != DBNull.Value)) + { + compareResult = 1; + } + else if ((val != null && val != DBNull.Value) && (o2 == null || o2 == DBNull.Value)) + { + compareResult = -1; + } + else + { + if (val is string) + { + compareResult = string.Compare(val.ToString(), o2.ToString()) * orderModifier; + } + else if (val is DateTime) + { + compareResult = ((DateTime)val).CompareTo((DateTime)o2) * orderModifier; + } + else if (val is int) + { + compareResult = ((int)val).CompareTo((int)o2) * orderModifier; + } + else if (val is bool) + { + bool b1 = (bool)val; + bool b2 = (bool)o2; + compareResult = (b1 == b2 ? 0 : b1 == true ? 1 : -1) * orderModifier; + } + else if (val is float) + { + float n1 = (float)val; + float n2 = (float)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (val is double) + { + double n1 = (double)val; + double n2 = (double)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (val is decimal) + { + decimal n1 = (decimal)val; + decimal n2 = (decimal)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (val is long) + { + long n1 = (long)val; + long n2 = (long)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (val is TimeSpan) + { + TimeSpan t1 = (TimeSpan)val; + TimeSpan t2 = (TimeSpan)o2; + compareResult = (t1 > t2 ? 1 : t1 < t2 ? -1 : 0) * orderModifier; + } + else if (val is TextAndImage) + { + compareResult = ((TextAndImage)val).CompareTo((TextAndImage)o2) * orderModifier; + } + //TODO implement a value for Token Column ?? + else if (val is Token) + { + compareResult = ((Token)val).CompareTo((Token)o2) * orderModifier; + } + } + return compareResult; + } + #endregion + + #region Protected + /// + /// Clones every member + /// + /// Destination group + protected void CloneMembers(OutlookGridDefaultGroup group) + { + group.column = column; + group.val = val; + group.collapsed = collapsed; + //group.text = this.text; + group.height = height; + group.groupImage = groupImage; + group.formatStyle = formatStyle; + group.xXXItemsText = XXXItemsText; + group.oneItemText = OneItemText; + group.allowHiddenWhenGrouped = allowHiddenWhenGrouped; + group.sortBySummaryCount = sortBySummaryCount; + group.back = new PaletteBack(null, null); + group.back.Color1 = Back.Color1; + group.back.Color2 = Back.Color2; + group.back.ColorAlign = Back.ColorAlign; + group.back.ColorAngle = Back.ColorAngle; + group.back.ColorStyle = Back.ColorStyle; + group.back.Draw = Back.Draw; + group.back.GraphicsHint = Back.GraphicsHint; + group.back.Image = Back.Image; + group.back.ImageAlign = Back.ImageAlign; + group.back.ImageStyle = Back.ImageStyle; + } + #endregion + + } + + /// + /// This group simple example of an implementation which groups the items into Alphabetic categories + /// based only on the first letter of each item + /// + /// For this we need to override the Value property (used for comparison) + /// and the CompareTo function. + /// Also the Clone method must be overriden, so this Group object can create clones of itself. + /// Cloning of the group is used by the OutlookGrid + /// + public class OutlookGridAlphabeticGroup : OutlookGridDefaultGroup + { + /// + /// Initializes a new instance of the class. + /// + public OutlookGridAlphabeticGroup() + : base() + { + allowHiddenWhenGrouped = false; + } + + /// + /// Constructor. + /// + /// The parentGroup if any. + public OutlookGridAlphabeticGroup(IOutlookGridGroup parentGroup) + : base(parentGroup) + { + allowHiddenWhenGrouped = false; + } + + /// + /// Gets or sets the displayed text. + /// + public override string Text + { + get + { + //return string.Format("{0}: {1} ({2})", LanguageManager.Instance.GetStringGB("AlphabeticGroupText"), Value.ToString(), itemCount == 1 ? LanguageManager.Instance.GetStringGB("OneItem") : itemCount.ToString() + LanguageManager.Instance.GetStringGB("XXXItems")); + return string.Format("{0}: {1} ({2})", column.DataGridViewColumn.HeaderText, Value.ToString(), itemCount == 1 ? OneItemText : itemCount.ToString() + XXXItemsText); + } + //set + //{ + // text = value; + //} + } + + /// + /// Gets or sets the Alphabetic value + /// + public override object Value + { + get + { + return val; + } + set + { + if (value != null && !string.IsNullOrEmpty(value.ToString())) //useful for textand image object + val = value.ToString().Substring(0, 1).ToUpper(); + else + val = ""; + } + } + + #region ICloneable Members + + /// + /// Overrides the Clone() function + /// + /// OutlookGridAlphabeticGroup + public override object Clone() + { + OutlookGridAlphabeticGroup gr = new OutlookGridAlphabeticGroup(parentGroup); + CloneMembers(gr); + return gr; + } + #endregion + + #region Protected + /// + /// Clones every member + /// + /// Destination group + protected void CloneMembers(OutlookGridAlphabeticGroup group) + { + base.CloneMembers(group); + // no additional members + } + #endregion + + #region IComparable Members + /// + /// overide the CompareTo, so only the first character is compared, instead of the whole string + /// this will result in classifying each item into a letter of the Alphabet. + /// for instance, this is usefull when grouping names, they will be categorized under the letters A, B, C etc.. + /// + /// + /// + public override int CompareTo(object obj) + { + int orderModifier = (Column.SortDirection == SortOrder.Ascending ? 1 : -1); + + if (obj is OutlookGridAlphabeticGroup) + { + return string.Compare(val.ToString(), ((OutlookGridAlphabeticGroup)obj).Value.ToString()) * orderModifier; + } + else + { + return 0; + } + } + #endregion IComparable Members + } + + /// this group simple example of an implementation which groups the items into day categories + /// based on, today, yesterday, last week etc + /// + /// for this we need to override the Value property (used for comparison) + /// and the CompareTo function. + /// Also the Clone method must be overriden, so this Group object can create clones of itself. + /// Cloning of the group is used by the OutlookGrid + /// + public class OutlookGridDateTimeGroup : OutlookGridDefaultGroup + { + TextInfo ti = CultureInfo.CurrentCulture.TextInfo; + + /// + /// Enum of Date interval for the OutlookGridDateTimeGroup + /// + public enum DateInterval + { + /// + /// Day + /// + DAY, + /// + /// Month + /// + MONTH, + /// + /// Quarter + /// + QUARTER, + /// + /// Year + /// + YEAR, + /// + /// Smart : intelligent grouping like Outlook for dates + /// + SMART + } + + /// + /// The Date Interval of OutlookGridDateTimeGroup + /// + public DateInterval Interval { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public OutlookGridDateTimeGroup() + : base() + { + allowHiddenWhenGrouped = true; + Interval = DateInterval.SMART; + } + + /// + /// Constructor + /// + /// The parentGroup if any. + public OutlookGridDateTimeGroup(IOutlookGridGroup parentGroup) + : base(parentGroup) + { + allowHiddenWhenGrouped = true; + Interval = DateInterval.SMART; + } + + /// + ///Gets or sets the displayed text. + /// + public override string Text + { + get + { + return string.Format("{0}: {1} ({2})", column.DataGridViewColumn.HeaderText, Value.ToString(), itemCount == 1 ? OneItemText : itemCount.ToString() + XXXItemsText); + } + //set + //{ + // text = value; + //} + } + + private DateTime valDateTime; + + /// + /// Gets or sets the Date value + /// + public override object Value + { + get + { + return val; + } + set + { + switch (Interval) + { + case DateInterval.SMART: + //If no date Time let the valDateTime to the min value ! + if (value != null && value != DBNull.Value) + valDateTime = DateTime.Parse(value.ToString()); + else + valDateTime = DateTime.MinValue; + + val = OutlookGridGroupHelpers.GetDayText(valDateTime); + break; + case DateInterval.YEAR: + //If no date Time let the valDateTime to the min value ! + if (value != null && value != DBNull.Value) + { + valDateTime = DateTime.Parse(value.ToString()); + val = valDateTime.Year; + } + else + { + valDateTime = DateTime.MinValue; + val = LanguageManager.Instance.GetStringGB("NODATE"); + } + break; + case DateInterval.MONTH: + //If no date Time let the valDateTime to the min value ! + if (value != null && value != DBNull.Value) + { + valDateTime = DateTime.Parse(value.ToString()); + val = ti.ToTitleCase(valDateTime.ToString("MMMM")) + " " + valDateTime.Year; + } + else + { + valDateTime = DateTime.MinValue; + val = LanguageManager.Instance.GetStringGB("NODATE"); + } + break; + case DateInterval.DAY: + if (value != null && value != DBNull.Value) + { + valDateTime = DateTime.Parse(value.ToString()); + val = valDateTime.Date.ToShortDateString(); + } + else + { + valDateTime = DateTime.MinValue; + val = LanguageManager.Instance.GetStringGB("NODATE"); + } + break; + case DateInterval.QUARTER: + if (value != null && value != DBNull.Value) + { + valDateTime = DateTime.Parse(value.ToString()); + val = OutlookGridGroupHelpers.GetQuarterAsString(valDateTime) + " " + valDateTime.Year; + } + else + { + valDateTime = DateTime.MinValue; + val = LanguageManager.Instance.GetStringGB("NODATE"); + } + break; + default: + throw new Exception("Unknown Interval !"); + + } + + } + } + + #region ICloneable Members + + /// + /// Overrides the Clone() function + /// + /// OutlookGridDateTimeGroup + public override object Clone() + { + OutlookGridDateTimeGroup gr = new OutlookGridDateTimeGroup(parentGroup); + CloneMembers(gr); + return gr; + } + + #endregion + + #region IComparable Members + + /// + /// Overrides CompareTo + /// + /// + /// + public override int CompareTo(object obj) + { + int orderModifier = (Column.SortDirection == SortOrder.Ascending ? 1 : -1); + DateTime val; + if (obj is DateTime) + { + //TODO necessary ??? + val = DateTime.Parse(obj.ToString()); + } + else if (obj is OutlookGridDateTimeGroup) + { + val = ((OutlookGridDateTimeGroup)obj).valDateTime; + } + else + { + val = new DateTime(); + } + + switch (Interval) + { + case DateInterval.SMART: + if (OutlookGridGroupHelpers.GetDateCode(valDateTime.Date) == OutlookGridGroupHelpers.GetDateCode(val.Date)) + { + return 0; + } + else + { + return DateTime.Compare(valDateTime.Date, val.Date) * orderModifier; + } + case DateInterval.YEAR: + if (valDateTime.Year == val.Year) + { + return 0; + } + else + { + return valDateTime.Year.CompareTo(val.Year) * orderModifier; + } + case DateInterval.MONTH: + if (valDateTime.Month == val.Month && valDateTime.Year == val.Year) + { + return 0; + } + else + { + return valDateTime.Date.CompareTo(val.Date) * orderModifier; + } + case DateInterval.DAY: + if (valDateTime.Date == val.Date) + { + return 0; + } + else + { + return valDateTime.Date.CompareTo(val.Date) * orderModifier; + } + case DateInterval.QUARTER: + if (OutlookGridGroupHelpers.GetQuarter(valDateTime) == OutlookGridGroupHelpers.GetQuarter(val) && valDateTime.Year == val.Year) + { + return 0; + } + else + { + return valDateTime.Date.CompareTo(val.Date) * orderModifier; + } + default: + throw new Exception("Unknown Interval !"); + + } + } + #endregion IComparable Members + + #region Protected + /// + /// Clones every member + /// + /// Destination group + protected void CloneMembers(OutlookGridDateTimeGroup group) + { + base.CloneMembers(group); + group.Interval = Interval; + } + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridGroupBoxColumn.cs b/Classes/OutlookGridGroupBoxColumn.cs new file mode 100644 index 0000000..0b1af10 --- /dev/null +++ b/Classes/OutlookGridGroupBoxColumn.cs @@ -0,0 +1,102 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Column for the OutlookGrid GroupBox + /// + public class OutlookGridGroupBoxColumn : IEquatable + { + #region "Constructor" + ///// + ///// Constructor + ///// + //public OutlookGridGroupBoxColumn() + //{} + + /// + /// Constructor + /// + /// The column name. + /// The display text of the column. + /// The column sort order. + /// The name of the used OutlookGridGroup mode. + public OutlookGridGroupBoxColumn(string columnName, string columnText, SortOrder sort, string groupingType) + { + Text = columnText; + ColumnName = columnName; + SortDirection = sort; + GroupingType = groupingType; + } + #endregion + + #region "Properties" + + /// + /// Gets or sets the associated Rectangle that represents the column + /// + public Rectangle Rect { get; set; } + /// + /// Gets or sets the HeaderText of the column. + /// + public string Text { get; set; } + /// + /// Gets or sets the boolean that indicates if the column is in a pressed state. + /// + public bool Pressed { get; set; } + /// + /// Gets or sets the Sort direction of the column. + /// + public SortOrder SortDirection { get; set; } + /// + /// Gets or sets the associated column name + /// + public string ColumnName { get; set; } + /// + /// Gets or sets the boolean that indicates if the column is currently beeing dragged. + /// + public bool IsMoving { get; set; } + /// + /// Gets or sets the boolean that indicates if the column is currently beeing hovered by the mouse. + /// + public bool IsHovered { get; set; } + /// + /// Gets or sets a string that corresponds to the name of the OutlookGridGroup + /// + public string GroupingType { get; set; } + /// + /// Gets or sets the date interval if the grouping type is OutlookDateTimeGroup + /// + public string GroupInterval { get; set; } + /// + /// Gets or sets the boolean that indicates if the column should be grouped by using the count value + /// + public bool SortBySummaryCount { get; set; } + + #endregion + + #region "Implements" + /// + /// Defines Equals method on the columnName + /// + /// The OutlookGridGroupBoxColumn to compare with. + /// True or False. + public bool Equals(OutlookGridGroupBoxColumn other) + { + return this.ColumnName.Equals(other.ColumnName); + } + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridGroupCollection.cs b/Classes/OutlookGridGroupCollection.cs new file mode 100644 index 0000000..53b8fc2 --- /dev/null +++ b/Classes/OutlookGridGroupCollection.cs @@ -0,0 +1,162 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Collections.Generic; + +using KryptonOutlookGrid.Interfaces; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// List of IOutlookGridGroups + /// + public class OutlookGridGroupCollection + { + #region "Variables" + private IOutlookGridGroup parentGroup; + private List groupList; + #endregion + + #region "Constructor" + /// + /// Initializes a new instance of the class. + /// + public OutlookGridGroupCollection() + { + groupList = new List(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The parent group, if any. + public OutlookGridGroupCollection(IOutlookGridGroup parentGroup) + { + groupList = new List(); + this.parentGroup = parentGroup; + } + #endregion + + #region Properties + + /// + /// Gets or Sets the parent group + /// + public IOutlookGridGroup ParentGroup + { + get + { + return this.parentGroup; + } + internal set + { + this.parentGroup = value; + } + } + + /// + /// Gets the list of IOutlookGridGroup. + /// + public List List + { + get + { + return groupList; + } + } + + /// + /// Gets the number of groups + /// + public int Count + { + get + { + return groupList.Count; + } + } + + #endregion + + #region "Public methods" + + /// + /// Gets the Group object + /// + /// Index in the list of groups. + /// The IOutlookGridGroup. + public IOutlookGridGroup this[int index] + { + get + { + return groupList[index]; + } + } + + /// + /// Adds a new group + /// + /// The IOutlookGridGroup. + public void Add(IOutlookGridGroup group) + { + groupList.Add(group); + } + + /// + /// Sorts the groups + /// + public void Sort() + { + groupList.Sort(); + } + + /// + /// Sorts the groups + /// + internal void Sort(OutlookGridGroupCountComparer comparer) + { + groupList.Sort(comparer); + } + + /// + /// Find a group by its value + /// + /// The value of the group + /// The IOutlookGridGroup. + public IOutlookGridGroup FindGroup(object value) + { + //We must return null if no group exist, then the OutlookGrid will create one. But we must return a group even for a null value. + if (value == null) + { + return groupList.Find(x => x.Value == null); + //return null; + } + //return groupList.Find(x => x.Value.Equals(value)); + return groupList.Find(x => x.Value != null && x.Value.Equals(value)); + } + + #endregion + + #region "Internals" + + internal void Clear() + { + parentGroup = null; + //If a group is collapsed the rows will not appear. Then if we clear the group the rows should not remain "collapsed" + for (int i = 0; i < groupList.Count; i++) + { + groupList[i].Collapsed = false; + } + groupList.Clear(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridGroupCountComparer.cs b/Classes/OutlookGridGroupCountComparer.cs new file mode 100644 index 0000000..6fe00a3 --- /dev/null +++ b/Classes/OutlookGridGroupCountComparer.cs @@ -0,0 +1,60 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +using KryptonOutlookGrid.Interfaces; + +namespace KryptonOutlookGrid.Classes +{ + internal class OutlookGridGroupCountComparer : IComparer + { + public OutlookGridGroupCountComparer() + { + } + + #region IComparer Members + + public int Compare(IOutlookGridGroup x, IOutlookGridGroup y) + { + int compareResult = 0; + try + { + int orderModifier = (x.Column.SortDirection == SortOrder.Ascending ? 1 : -1); + + int c1 = x.ItemCount; + int c2 = y.ItemCount; + compareResult = c1.CompareTo(c2) * orderModifier; + + if (compareResult == 0) + { + compareResult = x.CompareTo(y); + } + return compareResult; + } + catch (Exception ex) + { + throw new Exception("OutlookGridGroupCountComparer: " + this.ToString(), ex); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridGroupImageEventArgs.cs b/Classes/OutlookGridGroupImageEventArgs.cs new file mode 100644 index 0000000..374434a --- /dev/null +++ b/Classes/OutlookGridGroupImageEventArgs.cs @@ -0,0 +1,45 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Class for events of the group image of a group row. + /// + public class OutlookGridGroupImageEventArgs : EventArgs + { + private OutlookGridRow row; + + /// + /// Constructor + /// + /// The OutlookGridRow. + public OutlookGridGroupImageEventArgs(OutlookGridRow row) + { + this.row = row; + } + + /// + /// Gets or sets the row. + /// + public OutlookGridRow Row + { + get + { + return this.row; + } + set + { + this.row = value; + } + } + } +} \ No newline at end of file diff --git a/Classes/OutlookGridRow.cs b/Classes/OutlookGridRow.cs new file mode 100644 index 0000000..8f9ca60 --- /dev/null +++ b/Classes/OutlookGridRow.cs @@ -0,0 +1,698 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Interfaces; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// OutlookGridRow - subclasses the DataGridView's DataGridViewRow class + /// In order to support grouping with the same look and feel as Outlook, the behaviour + /// of the DataGridViewRow is overridden by the OutlookGridRow. + /// The OutlookGridRow has 2 main additional properties: the Group it belongs to and + /// a the IsRowGroup flag that indicates whether the OutlookGridRow object behaves like + /// a regular row (with data) or should behave like a Group row. + /// + public class OutlookGridRow : DataGridViewRow + { + #region "Variables" + + private bool isGroupRow; + private IOutlookGridGroup group; + private bool _collapsed; //For TreeNode + private OutlookGridRowNodeCollection nodeCollection; //For TreeNode + private int _nodeLevel; //For TreeNode + private OutlookGridRow _parentNode; //for TreeNode + #endregion + + #region "Properties" + + /// + /// Gets or sets the group to the row belongs to. + /// + /// + /// The group. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public IOutlookGridGroup Group + { + get { return group; } + set { group = value; } + } + + + /// + /// Gets or sets a value indicating whether this instance is a group row. + /// + /// + /// true if this instance is a group row; otherwise, false. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsGroupRow + { + get { return isGroupRow; } + set { isGroupRow = value; } + } + + /// + /// Gets or sets a value indicating whether this is collapsed. + /// + /// + /// true if collapsed; otherwise, false. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool Collapsed + { + get { return _collapsed; } + set { _collapsed = value; } + } + + /// + /// Gets or sets the nodes. + /// + /// + /// The nodes. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public OutlookGridRowNodeCollection Nodes + { + get { return nodeCollection; } + set { nodeCollection = value; } + } + + /// + /// Gets a value indicating whether this instance is first sibling. + /// + /// + /// true if this instance is first sibling; otherwise, false. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsFirstSibling + { + get + { + return (NodeIndex == 0); + } + } + + /// + /// Gets a value indicating whether this instance is last sibling. + /// + /// + /// true if this instance is last sibling; otherwise, false. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool IsLastSibling + { + get + { + OutlookGridRow parent = _parentNode; + if (parent != null && parent.HasChildren) + { + return (NodeIndex == parent.Nodes.Count - 1); + } + else + return true; + } + } + + /// + /// Gets a value indicating whether this instance has children. + /// + /// + /// true if this instance has children; otherwise, false. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool HasChildren + { + get + { + return nodeCollection.Count > 0; + } + } + + /// + /// Gets or sets the node level. + /// + /// + /// The node level. + /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public int NodeLevel + { + get { return _nodeLevel; } + set { _nodeLevel = value; } + } + + /// + /// Gets or sets the parent node. + /// + /// + /// The parent node. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public OutlookGridRow ParentNode + { + get { return _parentNode; } + set { _parentNode = value; } + } + + /// + /// Gets the index of the node. + /// + /// + /// The index of the node. + /// + public int NodeIndex + { + get + { + if (_parentNode != null) + return _parentNode.Nodes.IndexOf(this); + else + return 0; + } + } + #endregion + + #region "Constructors" + + /// + /// Default Constructor + /// + public OutlookGridRow() + : this(null, false) + { + //nodeCollection = new OutlookGridRowNodeCollection(this); + //NodeLevel = 0; + //Collapsed = true; + } + + /// + /// Constructor + /// + /// The group the row is associated to. + public OutlookGridRow(IOutlookGridGroup group) + : this(group, false) + { + //nodeCollection = new OutlookGridRowNodeCollection(this); + //NodeLevel = 0; + //Collapsed = true; + } + + /// + /// Constructor + /// + /// The group the row is associated to. + /// Determines if it a group row. + public OutlookGridRow(IOutlookGridGroup group, bool isGroupRow) + : base() + { + this.group = group; + this.isGroupRow = isGroupRow; + nodeCollection = new OutlookGridRowNodeCollection(this); + NodeLevel = 0; + Collapsed = true; + } + + #endregion + + #region "Overrides" + + /// + /// Overrides the GetState method + /// + /// + /// + public override DataGridViewElementStates GetState(int rowIndex) + { + //yes its readable at least it was ;) + if ((IsGroupRow && IsAParentCollapsed(group, 0)) || (!IsGroupRow && group != null && (group.Collapsed || IsAParentCollapsed(group, 0))) || (!IsGroupRow && IsAParentNodeOrGroupCollapsed(this, 0))) + { + return base.GetState(rowIndex) & DataGridViewElementStates.Selected; + } + //For the TreeGridView project if the selection mode is FullRow subnodes that where collapsed disappear when parent collapse/expands + //because for an unknown reason the state becomes None instead of at least visible. + if (base.GetState(rowIndex) == DataGridViewElementStates.None) + return DataGridViewElementStates.Visible; + else + return base.GetState(rowIndex); + } + + /// + /// the main difference with a Group row and a regular row is the way it is painted on the control. + /// the Paint method is therefore overridden and specifies how the Group row is painted. + /// Note: this method is not implemented optimally. It is merely used for demonstration purposes + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow) + { + if (isGroupRow) + { + KryptonOutlookGrid grid = (KryptonOutlookGrid)DataGridView; + int rowHeadersWidth = grid.RowHeadersVisible ? grid.RowHeadersWidth : 0; + int groupLevelIndentation = group.Level * StaticValues._groupLevelMultiplier; + + int gridwidth = grid.Columns.GetColumnsWidth(DataGridViewElementStates.Visible); + Rectangle myRowBounds = rowBounds; + myRowBounds.Width = gridwidth; + + PaletteBack paletteBack = group.Back; + paletteBack.SetInherit(grid.StateNormal.DataCell.Back); + + IPaletteBorder paletteBorder = grid.StateNormal.DataCell.Border; + + PaletteState state = PaletteState.Normal; + if (grid.PreviousSelectedGroupRow == rowIndex && (KryptonManager.CurrentGlobalPalette.GetRenderer() != KryptonManager.RenderOffice2013)) + state = PaletteState.CheckedNormal; + + using (RenderContext renderContext = new RenderContext(grid, graphics, myRowBounds, grid.Renderer)) + { + using (GraphicsPath path = grid.Renderer.RenderStandardBorder.GetBackPath(renderContext, myRowBounds, paletteBorder, VisualOrientation.Top, PaletteState.Normal)) + { + //Back + IDisposable unused = grid.Renderer.RenderStandardBack.DrawBack(renderContext, + myRowBounds, + path, + paletteBack, + VisualOrientation.Top, + state, + null); + + // We never save the memento for reuse later + if (unused != null) + { + unused.Dispose(); + unused = null; + } + } + } + + // Draw the botton : solid line for 2007 palettes or dot line for 2010 palettes, full background for 2013 + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010) + { + using (Pen focusPen = new Pen(Color.Gray)) + { + focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; + graphics.DrawLine(focusPen, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 1, gridwidth + 1, rowBounds.Bottom - 1); + } + } + else if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + using (SolidBrush br = new SolidBrush(Color.FromArgb(225, 225, 225))) + { + graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - StaticValues._2013GroupRowHeight, gridwidth + 1, StaticValues._2013GroupRowHeight - 1); + } + } + else + { + using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state))) + { + graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 2, gridwidth + 1, 2); + } + } + + //Draw right vertical bar + if (grid.CellBorderStyle == DataGridViewCellBorderStyle.SingleVertical || grid.CellBorderStyle == DataGridViewCellBorderStyle.Single) + { + using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state))) + { + graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + gridwidth, rowBounds.Top, 1, rowBounds.Height); + } + } + + //Set the icon and lines according to the renderer + if (group.Collapsed) + { + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + graphics.DrawImage(Properties.Resources.CollapseIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); + } + else + { + graphics.DrawImage(Properties.Resources.ExpandIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); + } + } + else + { + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + graphics.DrawImage(Properties.Resources.ExpandIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); + } + else + { + graphics.DrawImage(Properties.Resources.CollapseIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11); + } + } + + //Draw image group + int imageoffset = 0; + if (group.GroupImage != null) + { + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide); + imageoffset = StaticValues._ImageOffsetwidth; + } + else + { + graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide); + imageoffset = StaticValues._ImageOffsetwidth; + } + } + + //Draw text, using the current grid font + int offsetText = rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + imageoffset + groupLevelIndentation; + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._2013OffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state), + TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix); + } + else + { + TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._defaultOffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state), + TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix); + } + + ////Debug Hits + ////ExpandCollaspe icon + //graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * 15, rowBounds.Bottom - 18, 11, 11)); + ////Image + //if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + // graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide)); + //else + // graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide)); + } + else + { + base.Paint(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow); + } + } + + + /// + /// Paints the cells. + /// + /// The graphics. + /// The clip bounds. + /// The row bounds. + /// Index of the row. + /// State of the row. + /// if set to true [is first displayed row]. + /// if set to true [is last visible row]. + /// The paint parts. + /// Will not execute if it is a group row.) + protected override void PaintCells(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow, DataGridViewPaintParts paintParts) + { + if (!isGroupRow) + base.PaintCells(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts); + } + + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + string res = ""; + try + { + res += "OutlookGridRow "; + foreach (DataGridViewCell c in Cells) + { + if (c.Value != null) + res += c.Value.ToString() ?? string.Empty; + } + } + catch { } + return res; + } + + #endregion + + #region "Public methods" + + /// + /// Gets if the row has one parent that is collapsed + /// + /// The group to look at. + /// Fill 0 to first this method (used for recursive). + /// True or false. + public bool IsAParentCollapsed(IOutlookGridGroup gr, int i) + { + i++; + if (gr.ParentGroup != null) + { + //if it is not the original group but it is one parent and if it is collapsed just stop here + //no need to look further to the parents (one of the parents can be expanded...) + //if (i > 1 && gr.Collapsed) + if (gr.ParentGroup.Collapsed) + return true; + else + return IsAParentCollapsed(gr.ParentGroup, i); + } + else + { + //if 1 that means there is no parent + if (i == 1) + return false; + else + return gr.Collapsed; + } + } + + + /// + /// Determines if there is a parent node or a parent group collapsed. + /// + /// The specified row. + /// The i. + /// + public bool IsAParentNodeOrGroupCollapsed(OutlookGridRow row, int i) + { + i++; + //Console.WriteLine(row.ToString()); + if (row.ParentNode != null) + { + //if it is not the original group but it is one parent and if it is collapsed just stop here + //no need to look further to the parents (one of the parents can be expanded...) + if (row.ParentNode.Collapsed) + return true; + else + return IsAParentNodeOrGroupCollapsed(row.ParentNode, i); + } + else //no parent + { + if (i == 1) //if 1 that means there is no parent + { return false; } + else //return the final parent collapsed state + { + if (row.group != null) + { + return row.Collapsed || (row.group.Collapsed || IsAParentCollapsed(row.group, 0)); + } + else + { + return row.Collapsed; + } + + } + } + } + + /// + /// Expand the group the row belongs to. + /// + public void ExpandGroup() + { + SetGroupCollapse(false); + } + + /// + /// Collaspe the group the row belongs to. + /// + public void CollapseGroup() + { + SetGroupCollapse(true); + } + + internal void SetGroupCollapse(bool collapsed) + { + if (IsGroupRow) + { + Group.Collapsed = collapsed; + + //this is a workaround to make the grid re-calculate it's contents and backgroun bounds + // so the background is updated correctly. + // this will also invalidate the control, so it will redraw itself + Visible = false; + Visible = true; + + //When collapsing the first row still seeing it. + if (Index < DataGridView.FirstDisplayedScrollingRowIndex) + DataGridView.FirstDisplayedScrollingRowIndex = Index; + } + } + + internal void SetNodeCollapse(bool collapsed) + { + if (HasChildren) + { + Collapsed = collapsed; + + //this is a workaround to make the grid re-calculate it's contents and backgroun bounds + // so the background is updated correctly. + // this will also invalidate the control, so it will redraw itself + Visible = false; + Visible = true; + + //When collapsing the first row still seeing it. + if (Index < DataGridView.FirstDisplayedScrollingRowIndex) + DataGridView.FirstDisplayedScrollingRowIndex = Index; + } + } + + /// + /// Collapse Node (with events) + /// + public void Collapse() + { + ((KryptonOutlookGrid)DataGridView).CollapseNode(this); + } + + /// + /// Expand Node (with events) + /// + public void Expand() + { + ((KryptonOutlookGrid)DataGridView).ExpandNode(this); + } + + #endregion + + #region "Private methods" + + /// + /// this function checks if the user hit the expand (+) or collapse (-) icon. + /// if it was hit it will return true + /// + /// mouse click event arguments + /// returns true if the icon was hit, false otherwise + internal bool IsIconHit(DataGridViewCellMouseEventArgs e) + { + if (e.ColumnIndex < 0) return false; + if (!isGroupRow) return false; + + KryptonOutlookGrid grid = (KryptonOutlookGrid)DataGridView; + Rectangle rowBounds = grid.GetRowDisplayRectangle(Index, false); + + int rowHeadersWidth = grid.RowHeadersVisible ? grid.RowHeadersWidth : 0; + int l = e.X + grid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Left; + if (isGroupRow && + (l >= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * StaticValues._groupLevelMultiplier) && + (l <= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * StaticValues._groupLevelMultiplier + 11) && + (e.Y >= rowBounds.Height - 18) && + (e.Y <= rowBounds.Height - 7)) + return true; + + return false; + } + + //internal bool IsNodeIconHit(DataGridViewCellMouseEventArgs e) + //{ + // if (e.ColumnIndex < 0) return false; + // if (!this.HasChildren) return false; + + // DataGridViewCell cell = this.Cells[e.ColumnIndex]; + // if (cell.GetType() is KryptonDataGridViewTreeTextCell) { + // cell. + // } + // KryptonOutlookGrid grid = (KryptonOutlookGrid)this.DataGridView; + + + // Rectangle glyphRect = new Rectangle(rect.X + this.GlyphMargin, rect.ContentBounds.Y, INDENT_WIDTH, this.ContentBounds.Height - 1); + + // if ((e.X <= glyphRect.X + 11) && + // (e.X >= glyphRect.X) && + // (e.Y >= glyphRect.Y + (glyphRect.Height / 2) - 4) && + // (e.Y <= glyphRect.Y + (glyphRect.Height / 2) - 4 + 11)) + + + // if (this.isGroupRow && + // (l >= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * StaticValues._groupLevelMultiplier) && + // (l <= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * StaticValues._groupLevelMultiplier + 11) && + // (e.Y >= rowBounds.Height - 18) && + // (e.Y <= rowBounds.Height - 7)) + // return true; + + // return false; + //} + + internal bool IsGroupImageHit(DataGridViewCellMouseEventArgs e) + { + if (e.ColumnIndex < 0) return false; + if (!isGroupRow || group.GroupImage == null) return false; + + + KryptonOutlookGrid grid = (KryptonOutlookGrid)DataGridView; + Rectangle rowBounds = grid.GetRowDisplayRectangle(Index, false); + + int rowHeadersWidth = grid.RowHeadersVisible ? grid.RowHeadersWidth : 0; + int l = e.X + grid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Left; + int offsetHeight; + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + offsetHeight = StaticValues._2013OffsetHeight; + else + offsetHeight = StaticValues._defaultOffsetHeight; + if (isGroupRow && + (l >= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + group.Level * StaticValues._groupLevelMultiplier) && + (l <= rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + group.Level * StaticValues._groupLevelMultiplier + 16) && + (e.Y >= rowBounds.Height - offsetHeight) && + (e.Y <= rowBounds.Height - 6)) + return true; + + return false; + } + + #endregion + + + } +} \ No newline at end of file diff --git a/Classes/OutlookGridRowComparer.cs b/Classes/OutlookGridRowComparer.cs new file mode 100644 index 0000000..777b863 --- /dev/null +++ b/Classes/OutlookGridRowComparer.cs @@ -0,0 +1,129 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +using KryptonOutlookGrid.CustomColumns; + +namespace KryptonOutlookGrid.Classes +{ + internal class OutlookGridRowComparer : IComparer + { + int sortColumnIndex; + SortOrder sortOrderModifier; + + public OutlookGridRowComparer(int sortColumnIndex, SortOrder sortOrder) + { + this.sortColumnIndex = sortColumnIndex; + this.sortOrderModifier = sortOrder; + } + + #region IComparer Members + + public int Compare(OutlookGridRow x, OutlookGridRow y) + { + int compareResult = 0; + int orderModifier = (sortOrderModifier == SortOrder.Ascending ? 1 : -1); + try + { + OutlookGridRow obj1 = (OutlookGridRow)x; + OutlookGridRow obj2 = (OutlookGridRow)y; + + object o1 = obj1.Cells[this.sortColumnIndex].Value; + object o2 = obj2.Cells[this.sortColumnIndex].Value; + if ((o1 == null || o1 == DBNull.Value) && (o2 != null && o2 != DBNull.Value)) + { + compareResult = 1; + } + else if ((o1 != null && o1 != DBNull.Value) && (o2 == null || o2 == DBNull.Value)) + { + compareResult = -1; + } + else + { + if (o1 is string) + { + compareResult = string.Compare(o1.ToString(), o2.ToString()) * orderModifier; + } + else if (o1 is DateTime) + { + compareResult = ((DateTime)o1).CompareTo((DateTime)o2) * orderModifier; + } + else if (o1 is int) + { + compareResult = ((int)o1).CompareTo((int)o2) * orderModifier; + } + else if (o1 is bool) + { + bool b1 = (bool)o1; + bool b2 = (bool)o2; + compareResult = (b1 == b2 ? 0 : b1 == true ? 1 : -1) * orderModifier; + } + else if (o1 is float) + { + float n1 = (float)o1; + float n2 = (float)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is double) + { + double n1 = (double)o1; + double n2 = (double)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is decimal) + { + decimal d1 = (decimal)o1; + decimal d2 = (decimal)o2; + compareResult = (d1 > d2 ? 1 : d1 < d2 ? -1 : 0) * orderModifier; + } + else if (o1 is long) + { + long n1 = (long)o1; + long n2 = (long)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is TimeSpan) + { + TimeSpan t1 = (TimeSpan)o1; + TimeSpan t2 = (TimeSpan)o2; + compareResult = (t1 > t2 ? 1 : t1 < t2 ? -1 : 0) * orderModifier; + } + else if (o1 is TextAndImage) + { + compareResult = ((TextAndImage)o1).CompareTo((TextAndImage)o2) * orderModifier; + } + //TODO implement a value for Token Column ?? + else if (o1 is Token) + { + compareResult = ((Token)o1).CompareTo((Token)o2) * orderModifier; + } + } + return compareResult; + } + catch (Exception ex) + { + throw new Exception("OutlookGridRowComparer: " + this.ToString(), ex); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridRowComparer2.cs b/Classes/OutlookGridRowComparer2.cs new file mode 100644 index 0000000..b650c00 --- /dev/null +++ b/Classes/OutlookGridRowComparer2.cs @@ -0,0 +1,140 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System; +using System.Collections; +using System.Collections.Generic; +using System.Windows.Forms; + +using KryptonOutlookGrid.CustomColumns; + +namespace KryptonOutlookGrid.Classes +{ + internal class OutlookGridRowComparer2 : IComparer + { + List> sortColumnIndexAndOrder; + + /// + /// Initializes a new instance of the class. + /// + /// The sort list, tuple (column index, sortorder, Icomparer) + public OutlookGridRowComparer2(List> sortList) + { + sortColumnIndexAndOrder = sortList; + } + + #region IComparer Members + + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// + /// OutlookGridRowComparer: + this.ToString() + public int Compare(OutlookGridRow x, OutlookGridRow y) + { + int compareResult = 0; + int orderModifier; + try + { + for (int i = 0; i < sortColumnIndexAndOrder.Count; i++) + { + if (compareResult == 0) + { + orderModifier = (sortColumnIndexAndOrder[i].Item2 == SortOrder.Ascending ? 1 : -1); + + object o1 = x.Cells[sortColumnIndexAndOrder[i].Item1].Value; + object o2 = y.Cells[sortColumnIndexAndOrder[i].Item1].Value; + if (sortColumnIndexAndOrder[i].Item3 != null) + { + compareResult = sortColumnIndexAndOrder[i].Item3.Compare(o1, o2) * orderModifier; + } + else + { + if ((o1 == null || o1 == DBNull.Value) && (o2 != null && o2 != DBNull.Value)) + { + compareResult = 1; + } + else if ((o1 != null && o1 != DBNull.Value) && (o2 == null || o2 == DBNull.Value)) + { + compareResult = -1; + } + else + { + if (o1 is string) + { + compareResult = string.Compare(o1.ToString(), o2.ToString()) * orderModifier; + } + else if (o1 is DateTime) + { + compareResult = ((DateTime)o1).CompareTo((DateTime)o2) * orderModifier; + } + else if (o1 is int) + { + compareResult = ((int)o1).CompareTo((int)o2) * orderModifier; + } + else if (o1 is bool) + { + bool b1 = (bool)o1; + bool b2 = (bool)o2; + compareResult = (b1 == b2 ? 0 : b1 == true ? 1 : -1) * orderModifier; + } + else if (o1 is float) + { + float n1 = (float)o1; + float n2 = (float)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is double) + { + double n1 = (double)o1; + double n2 = (double)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is decimal) + { + decimal d1 = (decimal)o1; + decimal d2 = (decimal)o2; + compareResult = (d1 > d2 ? 1 : d1 < d2 ? -1 : 0) * orderModifier; + } + else if (o1 is long) + { + long n1 = (long)o1; + long n2 = (long)o2; + compareResult = (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) * orderModifier; + } + else if (o1 is TimeSpan) + { + TimeSpan t1 = (TimeSpan)o1; + TimeSpan t2 = (TimeSpan)o2; + compareResult = (t1 > t2 ? 1 : t1 < t2 ? -1 : 0) * orderModifier; + } + else if (o1 is TextAndImage) + { + compareResult = ((TextAndImage)o1).CompareTo((TextAndImage)o2) * orderModifier; + } + else if (o1 is Token) + { + compareResult = ((Token)o1).CompareTo((Token)o2) * orderModifier; + } + } + } + } + } + return compareResult; + } + catch (Exception ex) + { + throw new Exception("OutlookGridRowComparer: " + ToString(), ex); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridRowNodeCollection.cs b/Classes/OutlookGridRowNodeCollection.cs new file mode 100644 index 0000000..afe38b8 --- /dev/null +++ b/Classes/OutlookGridRowNodeCollection.cs @@ -0,0 +1,261 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- +using System.Collections; +using System.Collections.Generic; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// List of IOutlookGridGroups + /// + public class OutlookGridRowNodeCollection: ICollection, IList + { + #region "Variables" + private OutlookGridRow _parentNode; + private List subNodes; + #endregion + + #region "Constructor" + /// + /// Initializes a new instance of the class. + /// + /// The parent node. + public OutlookGridRowNodeCollection(OutlookGridRow parentNode) + { + _parentNode = parentNode; + subNodes = new List(); + } + #endregion + + #region Properties + + /// + /// Gets the parent node. + /// + /// + /// The parent node. + /// + public OutlookGridRow ParentNode + { + get + { + return _parentNode; + } + internal set + { + _parentNode = value; + } + } + + /// + /// Gets the nodes. + /// + /// + /// The nodes. + /// + public List Nodes + { + get + { + return subNodes; + } + } + + + /// + /// Gets the number of groups + /// + /// + /// The count. + /// + public int Count + { + get + { + return subNodes.Count; + } + } + + /// + /// Gets the readonly state of the list + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + OutlookGridRow IList.this[int index] { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } + + #endregion + + #region "Public methods" + + + /// + /// Gets the at the specified index. + /// + /// + /// The . + /// + /// The index. + /// The IOutlookGridGroup. + public OutlookGridRow this[int index] + { + get + { + return subNodes[index]; + } + set + { + subNodes[index] = value; + value.ParentNode = _parentNode; + value.NodeLevel = ParentNode.NodeLevel + 1; //Not ++ + } + } + + /// + /// Adds the specified . + /// + /// The row. + public void Add(OutlookGridRow row) + { + row.ParentNode = _parentNode; + row.NodeLevel = ParentNode.NodeLevel + 1; //Not ++ + subNodes.Add(row); + } + + /// + /// Inserts the specified at the specified index. + /// + /// The zero based index to add the row + /// The row to insert + public void Insert(int index, OutlookGridRow row) + { + subNodes.Insert(index, row); + row.ParentNode = _parentNode; + row.NodeLevel = ParentNode.NodeLevel + 1; //Not ++ + } + + /// + /// Removes the at the specified index. + /// + /// + public void RemoveAt(int index) + { + OutlookGridRow row = subNodes[index]; + subNodes.RemoveAt(index); + row.ParentNode = null; + row.NodeLevel = 0; + row.Collapsed = false; + } + + /// + /// Sorts this instance. + /// + public void Sort() + { + subNodes.Sort(); + } + + /// + /// Sorts the specified comparer. + /// + /// The comparer. + internal void Sort(OutlookGridRowComparer comparer) + { + subNodes.Sort(comparer); + } + + /// + /// Gets the Index of a + /// + /// The OutlookGrid row. + /// + public int IndexOf(OutlookGridRow row) + { + return subNodes.IndexOf(row); + } + + /// + /// Determines if specified is in list + /// + /// + /// Returns true if specified row is in list + public bool Contains(OutlookGridRow row) + { + return subNodes.Contains(row); + } + + /// + /// Copies all in the list to the specified array + /// + /// Destination Array + /// Startindex in the array + public void CopyTo(OutlookGridRow[] array, int arrayIndex) + { + subNodes.CopyTo(array, arrayIndex); + } + + /// + /// Removes the specified from the list + /// + /// Row to remove + /// + public bool Remove(OutlookGridRow row) + { + bool ret = subNodes.Remove(row); + if (ret) + { + row.ParentNode = null; + row.NodeLevel = 0; + row.Collapsed = false; + } + return ret; + } + + /// + /// Gets the enumerator for this collection + /// + /// The enumerator + public IEnumerator GetEnumerator() + { + return subNodes.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return subNodes.GetEnumerator(); + } + + /// + /// Clears all subnodes. + /// + public void Clear() + { + _parentNode = null; + //If a group is collapsed the rows will not appear. Then if we clear the group the rows should not remain "collapsed" + for (int i = 0; i < subNodes.Count; i++) + { + subNodes[i].Collapsed = false; + } + subNodes.Clear(); + } + + + #endregion + + #region "Internals" + + #endregion + } +} \ No newline at end of file diff --git a/Classes/OutlookGridRowNodeEvents.cs b/Classes/OutlookGridRowNodeEvents.cs new file mode 100644 index 0000000..0ff1d77 --- /dev/null +++ b/Classes/OutlookGridRowNodeEvents.cs @@ -0,0 +1,139 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.ComponentModel; + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Base class for OutlookGridRowNode events + /// + /// + public class OutlookGridRowNodeEventBase : EventArgs + { + private OutlookGridRow _row; + + /// + /// Initializes a new instance of the class. + /// + /// The node. + public OutlookGridRowNodeEventBase(OutlookGridRow node) + { + _row = node; + } + + /// + /// Gets the node. + /// + /// + /// The node. + /// + public OutlookGridRow Node + { + get { return _row; } + } + } + + + /// + /// Base class OutlookGridRowNode cancellable events + /// + /// + public class OutlookGridRowNodeCancelEventBase : CancelEventArgs + { + private OutlookGridRow _row; + + /// + /// Initializes a new instance of the class. + /// + /// The node. + public OutlookGridRowNodeCancelEventBase(OutlookGridRow node) + { + _row = node; + } + + /// + /// Gets the node. + /// + /// + /// The node. + /// + public OutlookGridRow Node + { + get { return _row; } + } + } + + /// + /// Class for Node collapsing events + /// + /// + public class CollapsingEventArgs : OutlookGridRowNodeCancelEventBase + { + /// + /// Initializes a new instance of the class. + /// + /// The node. + public CollapsingEventArgs(OutlookGridRow node) + : base(node) + { + } + } + + /// + /// Class for Node collapsed events + /// + /// + public class CollapsedEventArgs : OutlookGridRowNodeEventBase + { + /// + /// Initializes a new instance of the class. + /// + /// The node. + public CollapsedEventArgs(OutlookGridRow node) + : base(node) + { + } + } + + + /// + /// Class for Node expanding events + /// + /// + public class ExpandingEventArgs : OutlookGridRowNodeCancelEventBase + { + /// + /// Initializes a new instance of the class. + /// + /// The node. + public ExpandingEventArgs(OutlookGridRow node) : base(node) + { + } + } + + + /// + /// Class for Node expanding events + /// + /// + public class ExpandedEventArgs : OutlookGridRowNodeEventBase + { + /// + /// Initializes a new instance of the class. + /// + /// The node. + public ExpandedEventArgs(OutlookGridRow node) : base(node) + { + } + } + +} \ No newline at end of file diff --git a/Classes/StaticValues.cs b/Classes/StaticValues.cs new file mode 100644 index 0000000..86209df --- /dev/null +++ b/Classes/StaticValues.cs @@ -0,0 +1,53 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +namespace KryptonOutlookGrid.Classes +{ + /// + /// Static values + /// + public static class StaticValues + { + /// + /// The default group row height + /// + public static int _defaultGroupRowHeight = 34; + + /// + /// The group row height for 2013 palettes + /// + public static int _2013GroupRowHeight = 24; + + /// + /// The default offset height + /// + public static int _defaultOffsetHeight = 22; + + /// + /// The offset height for 2013 palettes + /// + public static int _2013OffsetHeight = 22; + + /// + /// The image offset width + /// + public static int _ImageOffsetwidth = 18; + + /// + /// The group level multiplier + /// + public static int _groupLevelMultiplier = 15; + + /// + /// The group image side size + /// + public static int _groupImageSide = 16; + } +} \ No newline at end of file diff --git a/Controls/KryptonOutlookGridGroupBox.Designer.cs b/Controls/KryptonOutlookGridGroupBox.Designer.cs new file mode 100644 index 0000000..5195c04 --- /dev/null +++ b/Controls/KryptonOutlookGridGroupBox.Designer.cs @@ -0,0 +1,47 @@ +namespace KryptonOutlookGrid.Controls +{ + partial class KryptonOutlookGridGroupBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + //protected override void Dispose(bool disposing) + //{ + // if (disposing && (components != null)) + // { + // components.Dispose(); + // } + // base.Dispose(disposing); + //} + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // KryptonOutlookGridGroupBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.Name = "KryptonOutlookGridGroupBox"; + this.Size = new System.Drawing.Size(744, 46); + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/Controls/KryptonOutlookGridGroupBox.cs b/Controls/KryptonOutlookGridGroupBox.cs new file mode 100644 index 0000000..870ea64 --- /dev/null +++ b/Controls/KryptonOutlookGridGroupBox.cs @@ -0,0 +1,986 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Classes; +using KryptonOutlookGrid.Utilities.Language; + +namespace KryptonOutlookGrid.Controls +{ + /// + /// GroupBox for the Krypton OutlookGrid + /// + public partial class KryptonOutlookGridGroupBox : UserControl + { + private List columnsList; + private string _dragColumnToGroupText; + + //Krypton + private IPalette _palette; + private PaletteRedirect _paletteRedirect; + private PaletteBackInheritRedirect _paletteBack; + private PaletteBorderInheritRedirect _paletteBorder; + private PaletteContentInheritRedirect _paletteContent; + private PaletteDataGridViewRedirect _paletteDataGridView; + private PaletteDataGridViewAll _paletteDataGridViewAll; + private IDisposable _mementoBack; + private PaletteBorder _border; + + //Mouse + private Point _mouse; + private bool isDragging; + private int indexselected; + + //Dpi scaling + private float factorX, factorY; + + //Context menu + private KryptonContextMenu KCtxMenu; + private KryptonContextMenuItems _menuItems; + private KryptonContextMenuItem _menuSortAscending; + private KryptonContextMenuItem _menuSortDescending; + private KryptonContextMenuSeparator _menuSeparator1; + private KryptonContextMenuItem _menuExpand; + private KryptonContextMenuItem _menuCollapse; + private KryptonContextMenuItem _menuUnGroup; + private KryptonContextMenuSeparator _menuSeparator2; + private KryptonContextMenuItem _menuFullExpand; + private KryptonContextMenuItem _menuFullCollapse; + private KryptonContextMenuSeparator _menuSeparator3; + private KryptonContextMenuItem _menuClearGrouping; + private KryptonContextMenuItem _menuHideGroupBox; + private KryptonContextMenuItem _menuGroupInterval; + private KryptonContextMenuItem _menuSortBySummary; + + /// + /// Column Sort Changed Event + /// + public event EventHandler ColumnSortChanged; + /// + /// Column Group Added Event + /// + public event EventHandler ColumnGroupAdded; + /// + /// Column Group removed Event + /// + public event EventHandler ColumnGroupRemoved; + /// + /// Clear grouping event + /// + public event EventHandler ClearGrouping; + /// + /// Full Expand event + /// + public event EventHandler FullExpand; + /// + /// Full Collapse event + /// + public event EventHandler FullCollapse; + /// + /// Group Expand event + /// + public event EventHandler GroupExpand; + /// + /// Group Collapse event + /// + public event EventHandler GroupCollapse; + /// + /// Column Group Order Changed Event + /// + public event EventHandler ColumnGroupOrderChanged; + /// + /// Group Interval Click event + /// + public event EventHandler GroupIntervalClick; + /// + /// Sort by Summary Count event + /// + public event EventHandler SortBySummaryCount; + + #region Constructor + + /// + /// Constructor + /// + public KryptonOutlookGridGroupBox() + { + // To remove flicker we use double buffering for drawing + SetStyle( + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw, true); + + InitializeComponent(); + + columnsList = new List(); + + // Cache the current global palette setting + _palette = KryptonManager.CurrentGlobalPalette; + + // Hook into palette events + if (_palette != null) + _palette.PalettePaint += new EventHandler(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 + // Store the inherit instances + _paletteBack = new PaletteBackInheritRedirect(_paletteRedirect); + _paletteBorder = new PaletteBorderInheritRedirect(_paletteRedirect); + _paletteContent = new PaletteContentInheritRedirect(_paletteRedirect); + _paletteDataGridView = new PaletteDataGridViewRedirect(_paletteRedirect, null); + _paletteDataGridViewAll = new PaletteDataGridViewAll(_paletteDataGridView, null); + + // Create storage that maps onto the inherit instances + _border = new PaletteBorder(_paletteBorder, null); + _dragColumnToGroupText = LanguageManager.Instance.GetStringGB("DRAGCOLUMNTOGROUP"); + + using (Graphics g = CreateGraphics()) + { + factorX = g.DpiX > 96 ? (1f * g.DpiX / 96) : 1f; + factorY = g.DpiY > 96 ? (1f * g.DpiY / 96) : 1f; + } + } + + #endregion + + #region Properties + + /// + /// Gets access to the common textbox appearance entries that other states can override. + /// + [Category("Visuals")] + [Description("Overrides borders settings.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteBorder Border + { + get { return _border; } + } + + /// + /// Getsor sets the text that appears when no column is grouped. + /// + [Category("Text")] + [Description("The text that appears when no column is grouped.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + [Localizable(true)] + public String DragColumnToGroupText + { + get { return _dragColumnToGroupText; } + set { _dragColumnToGroupText = value; } + } + + #endregion + + #region Overrides + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (_mementoBack != null) + { + _mementoBack.Dispose(); + _mementoBack = null; + } + + // (10) Unhook from the palette events + if (_palette != null) + { + _palette.PalettePaint -= new EventHandler(OnPalettePaint); + _palette = null; + } + + // (11) Unhook from the static events, otherwise we cannot be garbage collected + KryptonManager.GlobalPaletteChanged -= new EventHandler(OnGlobalPaletteChanged); + } + + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + /// + /// Overrides the paint event + /// + /// PaintEventArgs + protected override void OnPaint(PaintEventArgs e) + { + int nextPosition = (int)(5 * factorX); + if (_palette != null) + { + // (3) Get the renderer associated with this palette + IRenderer renderer = _palette.GetRenderer(); + + // (4) Create the rendering context that is passed into all renderer calls + using (RenderContext renderContext = new RenderContext(this, e.Graphics, e.ClipRectangle, renderer)) + { + _paletteBack.Style = PaletteBackStyle.PanelClient; + _paletteBorder.Style = PaletteBorderStyle.HeaderPrimary; + using (GraphicsPath path = renderer.RenderStandardBorder.GetBackPath(renderContext, e.ClipRectangle, _paletteBorder, VisualOrientation.Top, PaletteState.Normal)) + { + _mementoBack = renderer.RenderStandardBack.DrawBack(renderContext, + ClientRectangle, + path, + _paletteBack, + VisualOrientation.Top, + PaletteState.Normal, + _mementoBack); + } + renderer.RenderStandardBorder.DrawBorder(renderContext, ClientRectangle, _border, VisualOrientation.Top, PaletteState.Normal); + + //If no grouped columns, draw to the indicating text + if (columnsList.Count == 0) + { + TextRenderer.DrawText(e.Graphics, _dragColumnToGroupText, _palette.GetContentShortTextFont(PaletteContentStyle.LabelNormalPanel, PaletteState.Normal), e.ClipRectangle, _palette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalPanel, PaletteState.Normal), + TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping); + } + + PaletteState state; + _paletteBack.Style = PaletteBackStyle.GridHeaderColumnList; + _paletteBorder.Style = PaletteBorderStyle.GridHeaderColumnList; + // PaintGroupBox(e.Graphics, e.ClipRectangle, this.Font, "Drag a column here to group", columnsList.Count > 0); + + + + //Draw the column boxes + foreach (OutlookGridGroupBoxColumn current in this.columnsList) + { + Rectangle rectangle = default(Rectangle); + rectangle.Width = (int)(100 * factorX); + rectangle.X = nextPosition; + rectangle.Y = (e.ClipRectangle.Height - (int)(25 * factorY)) / 2; + rectangle.Height = (int)(25 * factorY); + nextPosition += (int)(105 * factorX); //next position + current.Rect = rectangle; + + if (current.IsHovered) + state = PaletteState.Tracking; + else if (current.Pressed) + state = PaletteState.Pressed; + else + state = PaletteState.Normal; + // Do we need to draw the background? + if (_paletteBack.GetBackDraw(PaletteState.Normal) == InheritBool.True) + { + //Back + using (GraphicsPath path = renderer.RenderStandardBorder.GetBackPath(renderContext, rectangle, _paletteBorder, VisualOrientation.Top, PaletteState.Normal)) + { + _mementoBack = renderer.RenderStandardBack.DrawBack(renderContext, + rectangle, + path, + _paletteBack, + VisualOrientation.Top, + state, + _mementoBack); + } + + //Border + renderer.RenderStandardBorder.DrawBorder(renderContext, rectangle, _paletteBorder, VisualOrientation.Top, state); + + //Text + TextRenderer.DrawText(e.Graphics, current.Text, _palette.GetContentShortTextFont(PaletteContentStyle.GridHeaderColumnList, state), rectangle, _palette.GetContentShortTextColor1(PaletteContentStyle.GridHeaderColumnList, state), + TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping); + + //Sort Glyph + renderer.RenderGlyph.DrawGridSortGlyph(renderContext, current.SortDirection, rectangle, _paletteDataGridViewAll.HeaderColumn.Content, state, false); + } + + //Draw the column box while it is moving + if (current.IsMoving) + { + Rectangle rectangle1 = new Rectangle(_mouse.X, _mouse.Y, current.Rect.Width, current.Rect.Height); + //this.Renderer.PaintMovingColumn(graphics, this.currentDragColumn, rectangle1); + using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(70, Color.Gray))) + { + e.Graphics.FillRectangle(solidBrush, rectangle1); + } + + TextRenderer.DrawText(e.Graphics, current.Text, _palette.GetContentShortTextFont(PaletteContentStyle.GridHeaderColumnList, PaletteState.Disabled), rectangle1, _palette.GetContentShortTextColor1(PaletteContentStyle.GridHeaderColumnList, PaletteState.Disabled), + TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping); + } + } + } + } + + base.OnPaint(e); + } + + /// + /// Overrides the MouseDown event. + /// + /// A MouseEventArgs that contains the event data. + protected override void OnMouseDown(MouseEventArgs e) + { + foreach (OutlookGridGroupBoxColumn c in this.columnsList) + { + if (c.Rect != null) + { + if (c.Rect.Contains(e.X, e.Y) && (e.Button == System.Windows.Forms.MouseButtons.Left)) + { + c.Pressed = true; + } + } + } + this.Invalidate(); + base.OnMouseDown(e); + } + + /// + /// Overrides the MouseUp event. + /// + /// A MouseEventArgs that contains the event data. + protected override void OnMouseUp(MouseEventArgs e) + { + List l = new List(); + OutlookGridGroupBoxColumn columnMovingInsideGroupBox = null; + + foreach (OutlookGridGroupBoxColumn c in this.columnsList) + { + if (c.Rect != null) + { + if (c.IsMoving && !this.Bounds.Contains(e.Location)) + { + l.Add(c); + } + //We move an existing colum inside the groupbox + else if (c.IsMoving && this.Bounds.Contains(e.Location)) + { + columnMovingInsideGroupBox = c; + } + + //Stop moving and pressing + c.Pressed = false; + c.IsMoving = false; + } + } + + //no more dragging + isDragging = false; + + //Ungroup columns dragged outside the box + if (l.Count > 0) + { + foreach (OutlookGridGroupBoxColumn c in l) + { + //Warn the Grid + OnColumnGroupRemoved(new OutlookGridColumnEventArgs(new OutlookGridColumn(c.ColumnName, null, null, SortOrder.None, -1, -1))); + + columnsList.Remove(c); + } + } + + + if (columnMovingInsideGroupBox != null) + { + if (e.Location.X != columnMovingInsideGroupBox.Rect.X && (e.Location.X < columnMovingInsideGroupBox.Rect.X || e.Location.X > (columnMovingInsideGroupBox.Rect.X + columnMovingInsideGroupBox.Rect.Width))) + { + int i = 0; //first group order is 0 + + foreach (OutlookGridGroupBoxColumn existingColumns in this.columnsList) + { + if (e.Location.X > (existingColumns.Rect.X + existingColumns.Rect.Width / 2) && existingColumns != columnMovingInsideGroupBox) + { + i++; + } + } + OnColumnGroupOrderChanged(new OutlookGridColumnEventArgs(new OutlookGridColumn(columnMovingInsideGroupBox.ColumnName, null, null, SortOrder.None, i, -1))); + //MessageBox.Show("Changed order = " + i.ToString()); + } + } + + this.Invalidate(); + base.OnMouseDown(e); + } + + /// + /// Overrides the MouseClick event. + /// + /// A MouseEventArgs that contains the event data. + protected override void OnMouseClick(MouseEventArgs e) + { + if (e.Button == System.Windows.Forms.MouseButtons.Right) + { + indexselected = -1; + for (int i = 0; i < this.columnsList.Count; i++) + { + if (columnsList[i].Rect != null && columnsList[i].Rect.Contains(e.X, e.Y)) + { + indexselected = i; + } + } + ShowColumnBoxContextMenu(); + } + else if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + //On MouseClick is before OnMouseUp, so if it is moving, don't click... + bool somethingIsMoving = false; + foreach (OutlookGridGroupBoxColumn c in this.columnsList) + { + if (c.IsMoving) + somethingIsMoving = true; + } + + if (!somethingIsMoving) + { + foreach (OutlookGridGroupBoxColumn c in this.columnsList) + { + if (c.Rect != null && c.Rect.Contains(e.X, e.Y)) + { + c.SortDirection = c.SortDirection == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending; + //Warn the Grid + OnColumnSortChanged(new OutlookGridColumnEventArgs(new OutlookGridColumn(c.ColumnName, null, null, c.SortDirection, -1, -1))); + } + } + } + } + + base.OnMouseClick(e); + } + + /// + /// Overrides the MouseMove event. + /// + /// A MouseEventArgs that contains the event data. + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + _mouse = e.Location; + foreach (OutlookGridGroupBoxColumn c in this.columnsList) + { + if (c.Rect != null) + { + //Update hovering + c.IsHovered = c.Rect.Contains(e.X, e.Y); + + //declare dragging + if (c.Rect.Contains(e.X, e.Y) && (e.Button == System.Windows.Forms.MouseButtons.Left) && !isDragging) + { + isDragging = true; + c.IsMoving = true; + //Console.WriteLine(_mouse.ToString()); + } + } + } + Invalidate(); + } + + #endregion + + #region Events + + /// + /// Handles OnPalettePaint Event + /// + /// Source of the event. + /// A PaletteLayoutEventArgs that contains the event data. + private void OnPalettePaint(object sender, PaletteLayoutEventArgs e) + { + Invalidate(); + } + + /// + /// Handles OnGlobalPaletteChanged event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnGlobalPaletteChanged(object sender, EventArgs e) + { + // (5) Unhook events from old palette + if (_palette != null) + _palette.PalettePaint -= new EventHandler(OnPalettePaint); + + // (6) Cache the new IPalette that is the global palette + _palette = KryptonManager.CurrentGlobalPalette; + _paletteRedirect.Target = _palette; //!!!!!! + + // (7) Hook into events for the new palette + if (_palette != null) + _palette.PalettePaint += new EventHandler(OnPalettePaint); + + // (8) Change of palette means we should repaint to show any changes + Invalidate(); + } + + /// + /// Raises the ColumnSortChanged event. + /// + /// A OutlookGridColumnEventArgs that contains the event data. + protected virtual void OnColumnSortChanged(OutlookGridColumnEventArgs e) + { + if (ColumnSortChanged != null) + ColumnSortChanged(this, e); + } + + /// + /// Raises the ColumnGroupAdded event. + /// + /// A OutlookGridColumnEventArgs that contains the event data. + protected virtual void OnColumnGroupAdded(OutlookGridColumnEventArgs e) + { + if (ColumnGroupAdded != null) + ColumnGroupAdded(this, e); + } + + /// + /// Raises the ColumnGroupRemoved event. + /// + /// A OutlookGridColumnEventArgs that contains the event data. + protected virtual void OnColumnGroupRemoved(OutlookGridColumnEventArgs e) + { + if (ColumnGroupRemoved != null) + ColumnGroupRemoved(this, e); + } + + /// + /// Raises the ColumnGroupOrderChanged event. + /// + /// A OutlookGridColumnEventArgs that contains the event data. + protected virtual void OnColumnGroupOrderChanged(OutlookGridColumnEventArgs e) + { + if (ColumnGroupOrderChanged != null) + ColumnGroupOrderChanged(this, e); + } + + /// + /// Raises the ClearGrouping event. + /// + /// A EventArgs that contains the event data. + protected virtual void OnClearGrouping(EventArgs e) + { + if (ClearGrouping != null) + ClearGrouping(this, e); + } + + /// + /// Raises the FullExpand event. + /// + /// A EventArgs that contains the event data. + protected virtual void OnFullExpand(EventArgs e) + { + if (FullExpand != null) + FullExpand(this, e); + } + + /// + /// Raises the FullCollapse event. + /// + /// A EventArgs that contains the event data. + protected virtual void OnFullCollapse(EventArgs e) + { + if (FullCollapse != null) + FullCollapse(this, e); + } + + /// + /// Raises the Group Expand event. + /// + /// A EventArgs that contains the event data. + protected virtual void OnGroupExpand(OutlookGridColumnEventArgs e) + { + if (GroupExpand != null) + GroupExpand(this, e); + } + + /// + /// Raises the Group Collapse event. + /// + /// A EventArgs that contains the event data. + protected virtual void OnGroupCollapse(OutlookGridColumnEventArgs e) + { + if (GroupCollapse != null) + GroupCollapse(this, e); + } + + /// + /// Raises the GroupIntervalClick event. + /// + /// A EventArgs that contains the event data. + private void OnGroupIntervalClick(OutlookGridColumnEventArgs e) + { + if (GroupIntervalClick != null) + GroupIntervalClick(this, e); + } + + /// + /// Raises the OnSortBySummaryCount event. + /// + /// A EventArgs that contains the event data. + private void OnSortBySummaryCount(OutlookGridColumnEventArgs e) + { + if (SortBySummaryCount != null) + SortBySummaryCount(this, e); + } + + /// + /// Handles the HideGroupBox event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnHideGroupBox(object sender, EventArgs e) + { + this.Hide(); + } + + /// + /// Handles the ClearGrouping event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnClearGrouping(object sender, EventArgs e) + { + OnClearGrouping(new EventArgs()); + columnsList.Clear(); + this.Invalidate(); + } + + /// + /// Handles the FullCollapse event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnFullCollapse(object sender, EventArgs e) + { + OnFullCollapse(new EventArgs()); + } + + /// + /// Handles the FullExpand event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnFullExpand(object sender, EventArgs e) + { + OnFullExpand(new EventArgs()); + } + + /// + /// Handles the GroupCollapse event + /// + /// Source of the event. + /// A OutlookGridColumnEventArgs that contains the event data. + private void OnGroupCollapse(object sender, EventArgs e) + { + OnGroupCollapse(new OutlookGridColumnEventArgs(new OutlookGridColumn(columnsList[indexselected].ColumnName, null, null, SortOrder.None, -1, -1))); + } + + /// + /// Handles the GroupExpand event + /// + /// Source of the event. + /// A OutlookGridColumnEventArgs that contains the event data. + private void OnGroupExpand(object sender, EventArgs e) + { + OnGroupExpand(new OutlookGridColumnEventArgs(new OutlookGridColumn(columnsList[indexselected].ColumnName, null, null, SortOrder.None, -1, -1))); + } + + /// + /// Handles the SortAscending event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnSortAscending(object sender, EventArgs e) + { + //Change the sortOrder in the list + OutlookGridGroupBoxColumn col = columnsList[indexselected]; + col.SortDirection = SortOrder.Ascending; + //Raise event + OnColumnSortChanged(new OutlookGridColumnEventArgs(new OutlookGridColumn(col.ColumnName, null, null, SortOrder.Ascending, -1, -1))); + //Redraw + this.Invalidate(); + } + + /// + /// Handles the SortDescending event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnSortDescending(object sender, EventArgs e) + { + //Change the sortOrder in the list + OutlookGridGroupBoxColumn col = columnsList[indexselected]; + col.SortDirection = SortOrder.Descending; + //Raise event + OnColumnSortChanged(new OutlookGridColumnEventArgs(new OutlookGridColumn(col.ColumnName, null, null, SortOrder.Descending, -1, -1))); + //Redraw + this.Invalidate(); + } + + /// + /// Handles the UnGroup event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + private void OnUngroup(object sender, EventArgs e) + { + OutlookGridGroupBoxColumn col = columnsList[indexselected]; + OnColumnGroupRemoved(new OutlookGridColumnEventArgs(new OutlookGridColumn(col.ColumnName, null, null, SortOrder.None, -1, -1))); + columnsList.Remove(col); + this.Invalidate(); + } + + /// + /// Handles the GroupIntervalClick event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + 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)); + } + + /// + /// Handles the OnSortBySummaryCount event + /// + /// Source of the event. + /// A EventArgs that contains the event data. + 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)); + } + + /// + /// Handles the DragDrop event. Add a new grouping column following a drag drop from the grid + /// + /// Source of the event. + /// A DragEventArgs that contains the event data. + private void KryptonOutlookGridGroupBox_DragDrop(object sender, DragEventArgs e) + { + string columnToMove = e.Data.GetData(typeof(string)) as string; + string columnName; + string columnText; + SortOrder sortOrder; + DataGridViewColumnSortMode sortMode; + string[] res = columnToMove.Split('|'); + columnName = res[0]; + columnText = res[1]; + sortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), res[2]);//SortOrder.Ascending; + if (sortOrder == SortOrder.None) + sortOrder = SortOrder.Ascending; + sortMode = (DataGridViewColumnSortMode)Enum.Parse(typeof(DataGridViewColumnSortMode), res[3]); + OutlookGridGroupBoxColumn colToAdd = new OutlookGridGroupBoxColumn(columnName, columnText, sortOrder, res[4]); + //if (res[4] == typeof(OutlookGridDateTimeGroup).Name) + colToAdd.GroupInterval = res[5]; + colToAdd.SortBySummaryCount = CommonHelper.StringToBool(res[6]); + if (!String.IsNullOrEmpty(columnToMove) && !columnsList.Contains(colToAdd) && sortMode != DataGridViewColumnSortMode.NotSortable) + { + //Determine the position of the new Group amongst the others + int i = 0; //first group order is 0 + //We are sure that we are going to browse the columns from left to right + foreach (OutlookGridGroupBoxColumn existingColumn in this.columnsList) + { + if (e.X > (existingColumn.Rect.X + existingColumn.Rect.Width / 2)) + { + i++; + } + } + columnsList.Insert(i, colToAdd); + + //try + //{ + //Warns the grid of a new grouping + OnColumnGroupAdded(new OutlookGridColumnEventArgs(new OutlookGridColumn(columnName, null, null, sortOrder, i, -1))); + this.Invalidate(); + //} + //catch (Exception exc) + //{ + // MessageBox.Show("Failed to group.\n\n Error:" + exc.Message, + // "Grid GroupBox", + // MessageBoxButtons.OK, + // MessageBoxIcon.Error); + //} + } + } + + /// + /// Hnadles the DragEnter event. + /// + /// Source of the event. + /// A DragEventArgs that contains the event data. + private void KryptonOutlookGridGroupBox_DragEnter(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.Move; + } + + #endregion + + #region Methods + + /// + /// Show the context menu for column box + /// + private void ShowColumnBoxContextMenu() + { + if (_menuItems == null) + { + // Create individual items + _menuSortAscending = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTASCENDING"), Properties.Resources.sort_az_ascending2, new EventHandler(OnSortAscending)); + _menuSortDescending = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTDESCENDING"), Properties.Resources.sort_az_descending2, new EventHandler(OnSortDescending)); + _menuSeparator1 = new KryptonContextMenuSeparator(); + _menuExpand = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("EXPAND"), Properties.Resources.element_plus_16, new EventHandler(OnGroupExpand)); + _menuCollapse = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("COLLAPSE"), Properties.Resources.element_minus_16, new EventHandler(OnGroupCollapse)); + _menuUnGroup = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("UNGROUP"), Properties.Resources.element_delete, new EventHandler(OnUngroup)); + _menuSeparator2 = new KryptonContextMenuSeparator(); + _menuFullExpand = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("FULLEXPAND"), Properties.Resources.elements_plus_16, new EventHandler(OnFullExpand)); + _menuFullCollapse = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("FULLCOLLAPSE"), Properties.Resources.elements_minus_16, new EventHandler(OnFullCollapse)); + _menuSeparator3 = new KryptonContextMenuSeparator(); + _menuClearGrouping = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CLEARGROUPING"), Properties.Resources.element_selection_delete, new EventHandler(OnClearGrouping)); + _menuHideGroupBox = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("HIDEGROUPBOX"), null, new EventHandler(OnHideGroupBox)); + _menuGroupInterval = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("GROUPINTERVAL")); + _menuSortBySummary = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTBYSUMMARYCOUNT"), null, new EventHandler(OnSortBySummaryCount)); + _menuSortBySummary.CheckOnClick = true; + + //Group Interval + KryptonContextMenuItems _GroupIntervalItems; + KryptonContextMenuItem it = null; + string[] names = Enum.GetNames(typeof(OutlookGridDateTimeGroup.DateInterval)); + KryptonContextMenuItemBase[] arrayOptions = new KryptonContextMenuItemBase[names.Length]; + for (int i = 0; i < names.Length; i++) + { + it = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB(names[i])); + it.Tag = names[i]; + it.Click += OnGroupIntervalClick; + arrayOptions[i] = it; + } + _GroupIntervalItems = new KryptonContextMenuItems(arrayOptions); + _menuGroupInterval.Items.Add(_GroupIntervalItems); + + // Add items inside an items collection (apart from separator1 which is only added if required) + _menuItems = new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { _menuSortAscending, + _menuSortDescending, + _menuSortBySummary, + _menuSeparator1, + _menuGroupInterval, + _menuExpand, + _menuCollapse, + _menuUnGroup, + _menuSeparator2, + _menuFullExpand, + _menuFullCollapse, + _menuSeparator3, + _menuClearGrouping, + _menuHideGroupBox + }); + } + + // Ensure we have a krypton context menu if not already present + if (this.KCtxMenu == null) + KCtxMenu = new KryptonContextMenu(); + + + // Update the individual menu options + OutlookGridGroupBoxColumn col = null; + if (indexselected > -1) + col = columnsList[indexselected]; + + _menuSortAscending.Visible = col != null; + _menuSortDescending.Visible = col != null; + _menuSortAscending.Checked = col != null && col.SortDirection == SortOrder.Ascending; + _menuSortDescending.Checked = col != null && col.SortDirection == SortOrder.Descending; + _menuSortBySummary.Visible = col != null; + _menuSortBySummary.Checked = col != null && col.SortBySummaryCount; + _menuExpand.Visible = col != null; + _menuCollapse.Visible = col != null; + _menuGroupInterval.Visible = col != null && col.GroupingType == typeof(OutlookGridDateTimeGroup).Name; + if (_menuGroupInterval.Visible) + { + foreach (KryptonContextMenuItem item in ((KryptonContextMenuItems)_menuGroupInterval.Items[0]).Items) + { + item.Checked = item.Tag.ToString() == col.GroupInterval; + } + } + _menuUnGroup.Visible = col != null; + _menuFullExpand.Enabled = columnsList.Count > 0; + _menuFullCollapse.Enabled = columnsList.Count > 0; + _menuClearGrouping.Enabled = columnsList.Count > 0; + + _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible); + _menuSeparator2.Visible = (_menuExpand.Visible || _menuCollapse.Visible || _menuUnGroup.Visible); + _menuSeparator3.Visible = (_menuFullExpand.Visible || _menuFullCollapse.Visible); + + if (!KCtxMenu.Items.Contains(_menuItems)) + KCtxMenu.Items.Add(_menuItems); + + // Show the menu! + KCtxMenu.Show(this); + } + + /// + /// DO NOT USE THIS FUNCTION YOURSELF, USE the corresponding function in OutlookGrid + /// Update the grouping columns. + /// + /// The list of OutlookGridColumn + public void UpdateGroupingColumns(List list) + { + columnsList.Clear(); + OutlookGridGroupBoxColumn colToAdd; + for (int i = 0; i < list.Count; i++) + { + if (list[i].IsGrouped) + { + colToAdd = new OutlookGridGroupBoxColumn(list[i].DataGridViewColumn.Name, list[i].DataGridViewColumn.HeaderText, list[i].SortDirection, list[i].GroupingType.GetType().Name); + if (colToAdd.GroupingType == typeof(OutlookGridDateTimeGroup).Name) + colToAdd.GroupInterval = ((OutlookGridDateTimeGroup)list[i].GroupingType).Interval.ToString(); + columnsList.Add(colToAdd); + } + } + this.Invalidate(); + } + + + /// + /// Checks if the column exists in the GroupBox control + /// + /// The column name. + /// True if exists, otherwise false. + public bool Contains(string columnName) + { + for (int i = 0; i < columnsList.Count; i++) + { + if (columnsList[i].ColumnName == columnName) + return true; + } + return false; + } + + #endregion + } +} \ No newline at end of file diff --git a/Controls/KryptonOutlookGridGroupBox.resx b/Controls/KryptonOutlookGridGroupBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Controls/KryptonOutlookGridGroupBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewFormattingColumn.cs b/Custom Columns/KryptonDataGridViewFormattingColumn.cs new file mode 100644 index 0000000..cf98608 --- /dev/null +++ b/Custom Columns/KryptonDataGridViewFormattingColumn.cs @@ -0,0 +1,192 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Formatting; +using KryptonOutlookGrid.Formatting.Params; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Class for a KryptonDataGridViewFormattingColumn : KryptonDataGridViewTextBoxColumn with conditional formatting abilities + /// + /// + public class KryptonDataGridViewFormattingColumn : KryptonDataGridViewTextBoxColumn + { + private bool _contrastTextColour; + + /// + /// Initializes a new instance of the class. + /// + public KryptonDataGridViewFormattingColumn() + : base() + { + this.CellTemplate = new FormattingCell(); + this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + this.ValueType = typeof(FormattingCell); + ContrastTextColour = false; + } + + /// + /// Gets or sets a value indicating whether [contrast text colour]. + /// + /// + /// true if [contrast text colour]; otherwise, false. + /// + public bool ContrastTextColour + { + get + { + return _contrastTextColour; + } + + set + { + _contrastTextColour = value; + } + } + } + + /// + /// Formatting cell + /// + /// + public class FormattingCell : KryptonDataGridViewTextBoxCell + { + + /// + /// Gets or sets the type of the format. + /// + /// + /// The type of the format. + /// + public EnumConditionalFormatType FormatType { get; set; } + /// + /// Gets or sets the format parameters. + /// + /// + /// The format parameters. + /// + public IFormatParams FormatParams { get; set; } + + + /// + /// Contrasts the colour. + /// + /// The colour. + /// + private Color ContrastColour(Color colour) + { + int d = 0; + // Counting the perceptive luminance - human eye favors green color... + double a = (1 + - (((0.299 * colour.R) + + ((0.587 * colour.G) + (0.114 * colour.B))) + / 255)); + if ((a < 0.5)) + { + d = 0; + } + else + { + // bright colors - black font + d = 255; + } + + // dark colors - white font + return Color.FromArgb(d, d, d); + } + + /// + /// Paints the specified graphics. + /// + /// The graphics. + /// The clip bounds. + /// The cell bounds. + /// Index of the row. + /// State of the cell. + /// The value. + /// The formatted value. + /// The error text. + /// The cell style. + /// The advanced border style. + /// The paint parts. + protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, + System.Windows.Forms.DataGridViewPaintParts paintParts) + { + if (FormatParams != null) // null can happen when cell set to Formatting but no condition has been set ! + { + switch (FormatType) + { + case EnumConditionalFormatType.BAR: + int barWidth; + BarParams par = (BarParams)FormatParams; + barWidth = (int)((cellBounds.Width - 10) * par.ProportionValue); + Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor; + Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor; + + if (barWidth > 0) //(double)value > 0 && + { + Rectangle r = new Rectangle(cellBounds.X + 3, cellBounds.Y + 3, barWidth, cellBounds.Height - 8); + if (par.GradientFill) + { + using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, par.BarColour, Color.White, LinearGradientMode.Horizontal)) //Color.FromArgb(255, 247, 251, 242) + { + graphics.FillRectangle(linearBrush, r); + } + } + else + { + using (SolidBrush solidBrush = new SolidBrush(par.BarColour)) //Color.FromArgb(255, 247, 251, 242) + { + graphics.FillRectangle(solidBrush, r); + } + } + + using (Pen pen = new Pen(par.BarColour)) //Color.FromArgb(255, 140, 197, 66))) + { + graphics.DrawRectangle(pen, r); + } + } + + break; + case EnumConditionalFormatType.TWOCOLOURSRANGE: + TwoColoursParams TWCpar = (TwoColoursParams)FormatParams; + Style.BackColor = TWCpar.ValueColour; + // if (ContrastTextColor) + Style.ForeColor = ContrastColour(TWCpar.ValueColour); + break; + case EnumConditionalFormatType.THREECOLOURSRANGE: + ThreeColoursParams THCpar = (ThreeColoursParams)FormatParams; + Style.BackColor = THCpar.ValueColour; + Style.ForeColor = ContrastColour(THCpar.ValueColour); + break; + default: + Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor; + Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor; + break; + } + } + else + { + Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor; + Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor; + } + + base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, + DataGridViewPaintParts.None | DataGridViewPaintParts.ContentForeground); + } + } +} \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewPercentageColumn.cs b/Custom Columns/KryptonDataGridViewPercentageColumn.cs new file mode 100644 index 0000000..7b22f26 --- /dev/null +++ b/Custom Columns/KryptonDataGridViewPercentageColumn.cs @@ -0,0 +1,211 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Globalization; +using System.Text; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Hosts a collection of KryptonDataGridViewPercentageColumn cells. + /// + /// + public class KryptonDataGridViewPercentageColumn : DataGridViewColumn// KryptonDataGridViewTextBoxColumn + { + #region Identity + /// + /// Initialize a new instance of the KryptonDataGridViewPercentageColumn class. + /// + public KryptonDataGridViewPercentageColumn() + : base(new DataGridViewPercentageCell()) + { + this.DefaultCellStyle.Format = "P"; + } + + /// + /// Returns a standard compact string representation of the column. + /// + public override string ToString() + { + StringBuilder builder = new StringBuilder(0x40); + builder.Append("KryptonDataGridViewPercentageColumn { Name="); + builder.Append(base.Name); + builder.Append(", Index="); + builder.Append(base.Index.ToString(CultureInfo.CurrentCulture)); + builder.Append(" }"); + return builder.ToString(); + } + + #endregion + + /// + /// Overrides CellTemplate + /// + public override DataGridViewCell CellTemplate + { + get { return base.CellTemplate; } + + set + { + // Ensure that the cell used for the template is a DataGridViewPercentageCell. + if ((value != null) && !value.GetType().IsAssignableFrom(typeof(DataGridViewPercentageCell))) + { + throw new InvalidCastException("Must be a DataGridViewPercentageCell"); + } + base.CellTemplate = value; + + } + } + + } +} + +/// +/// Class for a DataGridViewPercentageCell +/// +public class DataGridViewPercentageCell : KryptonDataGridViewTextBoxCell +{ + /// + /// Constructor + /// + public DataGridViewPercentageCell() + { + this.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; + } + + /// + /// Specify the type of object used for editing. This is how the WinForms + /// framework figures out what type of edit control to make. + /// + public override Type EditType + { + get { return typeof(PercentageEditingControl); } + } + + /// + /// Overrides TypeValue + /// + public override Type ValueType + { + get { return typeof(double); } + } + + /// + /// Specify the default cell contents upon creation of a new cell. + /// + public override object DefaultNewRowValue + { + get { return 0; } + } + + /// + /// Overrides Paint + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, + System.Windows.Forms.DataGridViewPaintParts paintParts) + { + //Draw the bar + int barWidth; + if ((double)value >= 1.0) + { + barWidth = (int)(cellBounds.Width - 10); + } + else + { + barWidth = (int)((cellBounds.Width - 10) * (double)value); + } + + if ((double)value > 0 && barWidth > 0) + { + Rectangle r = new Rectangle(cellBounds.X + 3, cellBounds.Y + 3, barWidth, cellBounds.Height - 8); + + using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, KryptonManager.CurrentGlobalPalette.GetBackColor1(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), KryptonManager.CurrentGlobalPalette.GetBackColor2(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), LinearGradientMode.Vertical)) + { + graphics.FillRectangle(linearBrush, r); + } + + using (Pen pen = new Pen(KryptonManager.CurrentGlobalPalette.GetBorderColor1(PaletteBorderStyle.GridHeaderColumnList, PaletteState.Normal))) + { + graphics.DrawRectangle(pen, r); + } + + //TODO : implement customization like conditional formatting + //using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, Color.FromArgb(255, 140, 197, 66), Color.FromArgb(255, 247, 251, 242), LinearGradientMode.Horizontal)) + //{ + // graphics.FillRectangle(linearBrush, r); + //} + + //using (Pen pen = new Pen(Color.FromArgb(255, 140, 197, 66))) + //{ + // graphics.DrawRectangle(pen, r); + + //} + } + + base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, + DataGridViewPaintParts.None | DataGridViewPaintParts.ContentForeground); + } +} + +/// +/// Public class for the underlying editing control +/// +[ToolboxItem(false)] +public class PercentageEditingControl : DataGridViewTextBoxEditingControl +{ + /// + /// Constructor + /// + public PercentageEditingControl() + : base() + { + } + + /// + /// Returns if the character is a valid digit + /// + /// The character. + /// True if valid digit, false otherwise. + private bool IsValidForNumberInput(char c) + { + return Char.IsDigit(c); + // OrElse c = Chr(8) OrElse c = "."c OrElse c = "-"c OrElse c = "("c OrElse c = ")"c + } + + /// + /// Overrides onKeypPress + /// + /// + protected override void OnKeyPress(KeyPressEventArgs e) + { + if (!IsValidForNumberInput(e.KeyChar)) + { + e.Handled = true; + } + } +} \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewRatingColumn.cs b/Custom Columns/KryptonDataGridViewRatingColumn.cs new file mode 100644 index 0000000..d277bf9 --- /dev/null +++ b/Custom Columns/KryptonDataGridViewRatingColumn.cs @@ -0,0 +1,191 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +//http://blogs.msdn.com/b/markrideout/archive/2006/01/18/media-player-like-rating-datagridview-column.aspx +//MS-PL License + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Class for a rating column + /// + public class KryptonDataGridViewRatingColumn : DataGridViewImageColumn + { + /// + /// Constructor + /// + public KryptonDataGridViewRatingColumn() + { + this.CellTemplate = new RatingCell(); + this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + this.ValueType = typeof(int); + } + } + + /// + /// Class for a rating cell + /// + public class RatingCell : DataGridViewImageCell + { + /// + /// Constructor + /// + public RatingCell() + { + //Value type is an integer. + //Formatted value type is an image since we derive from the ImageCell + this.ValueType = typeof(int); + } + + /// + /// Overrides GetFormattedValue + /// + /// + /// + /// + /// + /// + /// + /// + protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) + { + if (value == null) + return null; //For example it is also the case for group row... + else + return starImages[(int)value]; + } + + /// + /// Overrides DefaultNewRowValue + /// + public override object DefaultNewRowValue + { + //default new row to 3 stars + get { return 3; } + } + + /// + /// Overrides Paint + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) + { + Image cellImage = (Image)formattedValue; + if (!this.ReadOnly) + { + int starNumber = GetStarFromMouse(cellBounds, this.DataGridView.PointToClient(Control.MousePosition)); + + if (starNumber != -1) + cellImage = starHotImages[starNumber]; + } + //suppress painting of selection + base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, cellImage, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.SelectionBackground)); + } + + /// + /// Update cell's value when the user clicks on a star + /// + /// A DataGridViewCellEventArgs that contains the event data. + protected override void OnContentClick(DataGridViewCellEventArgs e) + { + base.OnContentClick(e); + if (!this.ReadOnly) + { + int starNumber = GetStarFromMouse(this.DataGridView.GetCellDisplayRectangle(this.DataGridView.CurrentCellAddress.X, this.DataGridView.CurrentCellAddress.Y, false), this.DataGridView.PointToClient(Control.MousePosition)); + + if (starNumber != -1) + this.Value = starNumber; + } + } + + #region Invalidate cells when mouse moves or leaves the cell + + /// + /// Overrides OnMouseLeave + /// + /// the row that contains the cell. + protected override void OnMouseLeave(int rowIndex) + { + base.OnMouseLeave(rowIndex); + this.DataGridView.InvalidateCell(this); + } + + /// + /// Overrides OnMouseMove + /// + /// A DataGridViewCellMouseEventArgs that contains the event data. + protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) + { + base.OnMouseMove(e); + this.DataGridView.InvalidateCell(this); + } + #endregion + + #region Private Implementation + + static Image[] starImages; + static Image[] starHotImages; + const int IMAGEWIDTH = 58; + + private int GetStarFromMouse(Rectangle cellBounds, Point mouseLocation) + { + if (cellBounds.Contains(mouseLocation)) + { + int mouseXRelativeToCell = (mouseLocation.X - cellBounds.X); + int imageXArea = (cellBounds.Width / 2) - (IMAGEWIDTH / 2); + if (((mouseXRelativeToCell + 4) < imageXArea) || (mouseXRelativeToCell >= (imageXArea + IMAGEWIDTH))) + return -1; + else + { + int oo = (int)Math.Round((((float)(mouseXRelativeToCell - imageXArea + 2) / (float)IMAGEWIDTH) * 10f), MidpointRounding.AwayFromZero); + if (oo > 10 || oo < 0) System.Diagnostics.Debugger.Break(); + return oo; + } + } + else + return -1; + } + + //setup star images + #region Load star images + + static RatingCell() + { + starImages = new Image[11]; + starHotImages = new Image[11]; + // load normal stars + for (int i = 0; i <= 10; i++) + starImages[i] = (Image)Properties.Resources.ResourceManager.GetObject("star" + i.ToString()); + + // load hot normal stars + for (int i = 0; i <= 10; i++) + starHotImages[i] = (Image)Properties.Resources.ResourceManager.GetObject("starhot" + i.ToString()); + } + #endregion + + #endregion + + } +} \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewTextAndImageColumn.cs b/Custom Columns/KryptonDataGridViewTextAndImageColumn.cs new file mode 100644 index 0000000..ea61776 --- /dev/null +++ b/Custom Columns/KryptonDataGridViewTextAndImageColumn.cs @@ -0,0 +1,399 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.Text; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Hosts a collection of KryptonDataGridViewTextAndImageCell cells. + /// + public class KryptonDataGridViewTextAndImageColumn : DataGridViewColumn + { + #region Instance Fields + + private DataGridViewColumnSpecCollection _buttonSpecs; + private Image imageValue; + private Size imageSize; + + #endregion + + #region Events + /// + /// Occurs when the user clicks a button spec. + /// + public event EventHandler ButtonSpecClick; + #endregion + + #region Identity + /// + /// Initialize a new instance of the KryptonDataGridViewTextBoxColumn class. + /// + public KryptonDataGridViewTextAndImageColumn() + : base(new KryptonDataGridViewTextAndImageCell()) + { + _buttonSpecs = new DataGridViewColumnSpecCollection(this); + SortMode = DataGridViewColumnSortMode.Automatic; + } + + /// + /// Returns a String that represents the current Object. + /// + /// A String that represents the current Object. + public override string ToString() + { + StringBuilder builder = new StringBuilder(0x40); + builder.Append("KryptonDataGridViewTextAndImageColumn { Name="); + builder.Append(base.Name); + builder.Append(", Index="); + builder.Append(base.Index.ToString(CultureInfo.CurrentCulture)); + builder.Append(" }"); + return builder.ToString(); + } + + /// + /// Create a cloned copy of the column. + /// + /// + public override object Clone() + { + KryptonDataGridViewTextAndImageColumn cloned = base.Clone() as KryptonDataGridViewTextAndImageColumn; + cloned.imageValue = imageValue; + cloned.imageSize = imageSize; + // Move the button specs over to the new clone + foreach (ButtonSpec bs in ButtonSpecs) + cloned.ButtonSpecs.Add(bs.Clone()); + + return cloned; + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + + base.Dispose(disposing); + } + #endregion + + #region Public + + ///// + ///// Gets or Sets the image + ///// + //public Image Image + //{ + // get { return this.imageValue; } + // set + // { + // if (this.Image != value) + // { + // this.imageValue = value; + // this.imageSize = value.Size; + // if (this.InheritedStyle != null) + // { + // Padding inheritedPadding = this.InheritedStyle.Padding; + // this.InheritedStyle.Padding = new Padding(imageSize.Width + 2, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); + // //Padding inheritedPadding = this.InheritedStyle.Padding; + // //this.Style.Padding = new Padding(18, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); + + // } + // } + // } + //} + + /// + /// Gets or sets the maximum number of characters that can be entered into the text box. + /// + [Category("Behavior")] + [DefaultValue(typeof(int), "32767")] + public int MaxInputLength + { + get + { + if (TextBoxCellTemplate == null) + throw new InvalidOperationException("KryptonDataGridViewTextAndImageColumn cell template required"); + + return TextBoxCellTemplate.MaxInputLength; + } + + set + { + if (MaxInputLength != value) + { + TextBoxCellTemplate.MaxInputLength = value; + if (DataGridView != null) + { + DataGridViewRowCollection rows = DataGridView.Rows; + int count = rows.Count; + for (int i = 0; i < count; i++) + { + DataGridViewTextBoxCell cell = rows.SharedRow(i).Cells[Index] as DataGridViewTextBoxCell; + if (cell != null) + cell.MaxInputLength = value; + } + } + } + } + } + + /// + /// Gets or sets the sort mode for the column. + /// + [DefaultValue(typeof(DataGridViewColumnSortMode), "Automatic")] + public new DataGridViewColumnSortMode SortMode + { + get { return base.SortMode; } + set { base.SortMode = value; } + } + + /// + /// Gets or sets the template used to model cell appearance. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public override DataGridViewCell CellTemplate + { + get { return base.CellTemplate; } + + set + { + if ((value != null) && !(value is KryptonDataGridViewTextAndImageCell)) + throw new InvalidCastException("Can only assign a object of type KryptonDataGridViewTextAndImageCell"); + + base.CellTemplate = value; + } + } + + /// + /// Gets the collection of the button specifications. + /// + [Category("Data")] + [Description("Set of extra button specs to appear with control.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public DataGridViewColumnSpecCollection ButtonSpecs + { + get { return _buttonSpecs; } + } + #endregion + + #region Private + private KryptonDataGridViewTextAndImageCell TextBoxCellTemplate + { + get { return (KryptonDataGridViewTextAndImageCell)CellTemplate; } + } + #endregion + + #region Internal + internal void PerfomButtonSpecClick(DataGridViewButtonSpecClickEventArgs args) + { + if (ButtonSpecClick != null) + ButtonSpecClick(this, args); + } + + internal Size ImageSize + { + get { return imageSize; } + } + #endregion + } + + /// + /// Class for TextAndImage object + /// + public class TextAndImage : IComparable + { + /// + /// The text + /// + public string Text; + /// + /// The image + /// + public Image Image; + + /// + /// Constructor + /// + public TextAndImage() + { } + + /// + /// Constructor + /// + /// The text. + /// The image. + public TextAndImage(string text, Image img) + { + Text = text; + Image = img; + } + + /// + /// Overrides ToString + /// + /// String that represents TextAndImage + public override string ToString() + { + return Text; + } + + /// + /// Overrides Equals + /// + /// The object to compare + /// true if equal, false otherwise. + public override bool Equals(object obj) + { + return Text.Equals(obj.ToString()); + } + + /// + /// Overrides GetHashCode + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Compares to. + /// + /// The other. + /// + public int CompareTo(TextAndImage other) + { + return Text.CompareTo(other.Text); + } + } + + /// + /// Class for a TextAndImage cell + /// + public class KryptonDataGridViewTextAndImageCell : KryptonDataGridViewTextBoxCell + { + private Image imageValue; + private Size imageSize; + + /// + /// Constructor + /// + public KryptonDataGridViewTextAndImageCell() + : base() + { + } + + /// + /// Overrides ValueType + /// + public override Type ValueType + { + get { return typeof(TextAndImage); } + } + + /// + /// Sets the value. + /// + /// Index of the row. + /// The value. + /// + protected override bool SetValue(int rowIndex, object value) + { + if (value != null) + Image = ((TextAndImage)value).Image; + return base.SetValue(rowIndex, value); + } + + /// + /// Overrides Clone + /// + /// The cloned KryptonDataGridViewTextAndImageCell + public override object Clone() + { + KryptonDataGridViewTextAndImageCell c = base.Clone() as KryptonDataGridViewTextAndImageCell; + c.imageValue = imageValue; + c.imageSize = imageSize; + return c; + } + + /// + /// Gets or sets the image. + /// + /// + /// The image. + /// + public Image Image + { + get { return imageValue; } + set + { + if (Image != value) + { + imageValue = value; + imageSize = value.Size; + + //if (this.InheritedStyle != null) + //{ + Padding inheritedPadding = Style.Padding; + //Padding inheritedPadding = this.InheritedStyle.Padding; + Style.Padding = new Padding(imageSize.Width + 2, + inheritedPadding.Top, inheritedPadding.Right, + inheritedPadding.Bottom); + //} + } + } + } + + /// + /// Overrides Paint + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) + { + //TODO : improve we assume it is a 16x16 image + if (Value != null && ((TextAndImage)Value).Image != null) + { + //Padding inheritedPadding = this.InheritedStyle.Padding; + //this.Style.Padding = new Padding(18, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); + // Draw the image clipped to the cell. + System.Drawing.Drawing2D.GraphicsContainer container = graphics.BeginContainer(); + graphics.SetClip(cellBounds); + graphics.DrawImage(((TextAndImage)Value).Image, new Rectangle(cellBounds.Location.X + 2, cellBounds.Location.Y + ((cellBounds.Height - 16) / 2) - 1, 16, 16)); + graphics.EndContainer(container); + } + + // Paint the base content + base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); + } + } +} \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewTokenColumn.cs b/Custom Columns/KryptonDataGridViewTokenColumn.cs new file mode 100644 index 0000000..ce77f15 --- /dev/null +++ b/Custom Columns/KryptonDataGridViewTokenColumn.cs @@ -0,0 +1,375 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Token object + /// + public class Token : IComparable + { + /// + /// Default constructor + /// + public Token() + { + } + + /// + /// Constructor + /// + /// Text of the token + /// Background color + /// Foreground text color + public Token(string text, Color bg, Color fg) + { + this.Text = text; + this.BackColor = bg; + this.ForeColor = fg; + } + + /// + /// Text of the token + /// + public string Text { get; set; } + /// + /// Background color + /// + public Color BackColor { get; set; } + /// + /// Foreground text color + /// + public Color ForeColor { get; set; } + + /// + /// Compare a Token to another + /// + /// + /// + public int CompareTo(Token other) + { + return this.Text.CompareTo(other.Text); + } + + /// + /// Overrides ToString + /// + /// String that represents TextAndImage + public override string ToString() + { + return Text; + } + + /// + /// Overrides Equals + /// + /// The object to compare + /// true if equal, false otherwise. + public override bool Equals(object obj) + { + return this.Text.Equals(obj.ToString()); + } + + /// + /// Overrides GetHashCode + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + /// + /// Class for a Token cell + /// + public class TokenCell : KryptonDataGridViewTextBoxCell + { + //List TokenList; + /// + /// Constructor + /// + public TokenCell() + : base() + { + //Value type is an integer. + //Formatted value type is an image since we derive from the ImageCell + this.ValueType = typeof(TokenCell); + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + Token tok = (Token)this.Value; + if (tok != null) + { + return tok.Text; + } + else + { + return ""; + } + } + + /// + /// Overrides Paint + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) + { + float factorX = graphics.DpiX > 96 ? (1f * graphics.DpiX / 96) : 1f; + float factorY = graphics.DpiY > 96 ? (1f * graphics.DpiY / 96) : 1f; + + int nextPosition = cellBounds.X + (int)(1 * factorX); + Font f = KryptonManager.CurrentGlobalPalette.GetContentShortTextFont(PaletteContentStyle.GridDataCellList, PaletteState.Normal); + + Token tok = (Token)this.Value; + if (tok != null) + { + Rectangle rectangle = new Rectangle(); + Size s = TextRenderer.MeasureText(tok.Text, f); + rectangle.Width = s.Width + (int)(10 * factorX); + rectangle.X = nextPosition; + rectangle.Y = cellBounds.Y + (int)(2 * factorY); + rectangle.Height = (int)(17 * factorY); + nextPosition += rectangle.Width + (int)(5 * factorX); + + graphics.FillRectangle(new SolidBrush(tok.BackColor), rectangle); + TextRenderer.DrawText(graphics, tok.Text, f, rectangle, tok.ForeColor); + } + } + + /// + /// Overrides GetPreferredSize + /// + /// + /// + /// + /// + /// + protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) + { + float factorX = graphics.DpiX > 96 ? (1f * graphics.DpiX / 96) : 1f; + float factorY = graphics.DpiY > 96 ? (1f * graphics.DpiY / 96) : 1f; + + Size tmpSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize); + Font f = KryptonManager.CurrentGlobalPalette.GetContentShortTextFont(PaletteContentStyle.GridDataCellList, PaletteState.Normal); + int nextPosition = (int)(1 * factorX); + if (this.Value != null) + { + Token tok = (Token)this.Value; + Size s = TextRenderer.MeasureText(tok.Text, f); + nextPosition += s.Width + (int)(10 * factorX) + (int)(5 * factorX); + + tmpSize.Width = nextPosition; + } + return tmpSize; + } + + /// + /// Update cell's value when the user clicks on a star + /// + /// A DataGridViewCellEventArgs that contains the event data. + protected override void OnContentClick(DataGridViewCellEventArgs e) + { + base.OnContentClick(e); + } + + #region Invalidate cells when mouse moves or leaves the cell + + /// + /// Overrides OnMouseLeave + /// + /// the row that contains the cell. + protected override void OnMouseLeave(int rowIndex) + { + base.OnMouseLeave(rowIndex); + } + + /// + /// Overrides OnMouseMove + /// + /// A DataGridViewCellMouseEventArgs that contains the event data. + protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) + { + base.OnMouseMove(e); + } + #endregion + } + + /// + /// Class for a rating celle + /// + public class TokenListCell : KryptonDataGridViewTextBoxCell + { + //List TokenList; + /// + /// Constructor + /// + public TokenListCell() + : base() + { + //Value type is an integer. + //Formatted value type is an image since we derive from the ImageCell + this.ValueType = typeof(List); + } + + /// + /// Overrides Paint + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) + { + float factorX = graphics.DpiX > 96 ? (1f * graphics.DpiX / 96) : 1f; + float factorY = graphics.DpiY > 96 ? (1f * graphics.DpiY / 96) : 1f; + + int nextPosition = cellBounds.X + (int)(1 * factorX); + Font f = KryptonManager.CurrentGlobalPalette.GetContentShortTextFont(PaletteContentStyle.GridDataCellList, PaletteState.Normal); + + foreach (Token tok in (List)this.Value) + { + Rectangle rectangle = new Rectangle(); + Size s = TextRenderer.MeasureText(tok.Text, f); + rectangle.Width = s.Width + (int)(10 * factorX); + rectangle.X = nextPosition; + rectangle.Y = cellBounds.Y + (int)(2 * factorY); + rectangle.Height = (int)(17 * factorY); + nextPosition += rectangle.Width + (int)(5 * factorX); + + graphics.FillRectangle(new SolidBrush(tok.BackColor), rectangle); + TextRenderer.DrawText(graphics, tok.Text, f, rectangle, tok.ForeColor); + } + } + + /// + /// Overrides GetPreferredSize + /// + /// + /// + /// + /// + /// + protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) + { + float factorX = graphics.DpiX > 96 ? (1f * graphics.DpiX / 96) : 1f; + float factorY = graphics.DpiY > 96 ? (1f * graphics.DpiY / 96) : 1f; + + Size tmpSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize); + Font f = KryptonManager.CurrentGlobalPalette.GetContentShortTextFont(PaletteContentStyle.GridDataCellList, PaletteState.Normal); + int nextPosition = (int)(1 * factorX); + if (this.Value != null) + { + foreach (Token tok in (List)this.Value) + { + Size s = TextRenderer.MeasureText(tok.Text, f); + nextPosition += s.Width + (int)(10 * factorX) + (int)(5 * factorX); + } + tmpSize.Width = nextPosition; + } + return tmpSize; + } + + /// + /// Update cell's value when the user clicks on a star + /// + /// A DataGridViewCellEventArgs that contains the event data. + protected override void OnContentClick(DataGridViewCellEventArgs e) + { + base.OnContentClick(e); + } + + #region Invalidate cells when mouse moves or leaves the cell + + /// + /// Overrides OnMouseLeave + /// + /// the row that contains the cell. + protected override void OnMouseLeave(int rowIndex) + { + base.OnMouseLeave(rowIndex); + } + + /// + /// Overrides OnMouseMove + /// + /// A DataGridViewCellMouseEventArgs that contains the event data. + protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) + { + base.OnMouseMove(e); + } + #endregion + } + + /// + /// Class for a rating column + /// + public class KryptonDataGridViewTokenColumn : KryptonDataGridViewTextBoxColumn + { + /// + /// Constructor + /// + public KryptonDataGridViewTokenColumn() + : base() + { + this.CellTemplate = new TokenCell(); + this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + this.ValueType = typeof(TokenCell); + } + } + + /// + /// Class for a rating column + /// + public class KryptonDataGridViewTokenListColumn : KryptonDataGridViewTextBoxColumn + { + /// + /// Constructor + /// + public KryptonDataGridViewTokenListColumn() + : base() + { + this.CellTemplate = new TokenListCell(); + this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + this.ValueType = typeof(List); + } + } +} \ No newline at end of file diff --git a/Custom Columns/KryptonDataGridViewTreeTextColumn.cs b/Custom Columns/KryptonDataGridViewTreeTextColumn.cs new file mode 100644 index 0000000..1aebdcc --- /dev/null +++ b/Custom Columns/KryptonDataGridViewTreeTextColumn.cs @@ -0,0 +1,353 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Drawing; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Classes; + +namespace KryptonOutlookGrid.CustomColumns +{ + /// + /// Special column used to enable nodes in the grid. + /// + /// + public class KryptonDataGridViewTreeTextColumn : KryptonDataGridViewTextBoxColumn + { + + /// + /// Initializes a new instance of the class. + /// + public KryptonDataGridViewTreeTextColumn() + : base() + { + CellTemplate = new KryptonDataGridViewTreeTextCell(); + } + } + + /// + /// Class for a TextAndImage cell + /// + public class KryptonDataGridViewTreeTextCell : KryptonDataGridViewTextBoxCell + { + private const int INDENT_WIDTH = 20; + private const int INDENT_MARGIN = 5; + private Padding defaultPadding; + // private int glyphWidth; + + /// + /// Constructor + /// + public KryptonDataGridViewTreeTextCell() + : base() + { + defaultPadding = Style.Padding; + } + + /// + /// Overrides Clone + /// + /// The cloned KryptonDataGridViewTextAndImageCell + public override object Clone() + { + KryptonDataGridViewTreeTextCell c = base.Clone() as KryptonDataGridViewTreeTextCell; + return c; + } + + /// + /// Gets the glyph margin. + /// + /// + /// The glyph margin. + /// + protected virtual int GlyphMargin + { + get + { + return ((Level - 1) * INDENT_WIDTH) + INDENT_MARGIN; + } + + + } + + /// + /// Gets the level. + /// + /// + /// The level. + /// + public int Level + { + get + { + OutlookGridRow row = (OutlookGridRow)OwningRow; + if (row != null) + { + return row.NodeLevel + 1; //during calculation 0 level must be 1 for multiplication + } + else + return -1; + } + } + + /// + /// Updates the style. + /// + /// padding especially. + public void UpdateStyle() + { + OutlookGridRow node = OwningNode; + //Console.WriteLine(DateTime.Now.ToString() + " " + node.ToString()); + bool hasChildNodes = node.HasChildren; + int level = Level; + int plus = 0; + //if (hasChildNodes) + // plus = 15; + Style.Padding = new Padding(defaultPadding.Left + (level * INDENT_WIDTH) + INDENT_MARGIN + plus, + defaultPadding.Top, defaultPadding.Right, defaultPadding.Bottom); + + + } + + /// + /// Paints the specified graphics. + /// + /// The graphics. + /// The clip bounds. + /// The cell bounds. + /// Index of the row. + /// State of the cell. + /// The value. + /// The formatted value. + /// The error text. + /// The cell style. + /// The advanced border style. + /// The paint parts. + protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) + { + OutlookGridRow node = OwningNode; + // Console.WriteLine(DateTime.Now.ToString() + " " + node.ToString()); + //bool hasChildNodes = node.HasChildren; + //int level = this.Level ; + //int plus = 0; + //if (hasChildNodes) + // plus = 15; + //Padding currentPadding = this.InheritedStyle.Padding; + // this.Style.Padding = new Padding(defaultPadding.Left + (level * INDENT_WIDTH) + INDENT_MARGIN, + // defaultPadding.Top, defaultPadding.Right, defaultPadding.Bottom); + + //this.Style.Padding = new Padding(currentPadding.Left + (level * INDENT_WIDTH) + _imageWidth + INDENT_MARGIN, + // currentPadding.Top, currentPadding.Right, currentPadding.Bottom); + + //if (this.Value != null && ((TextAndImage)this.Value).Image != null) + //{ + // Padding inheritedPadding = this.InheritedStyle.Padding; + // this.Style.Padding = new Padding(18, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); + // // Draw the image clipped to the cell. + // System.Drawing.Drawing2D.GraphicsContainer container = graphics.BeginContainer(); + // graphics.SetClip(cellBounds); + // graphics.DrawImageUnscaled(((TextAndImage)this.Value).Image, new Point(cellBounds.Location.X + 2, cellBounds.Location.Y + ((cellBounds.Height - 16) / 2) - 1)); + // graphics.EndContainer(container); + //} + + //if (node == null) return; + + //Image image = node.Image; + + //if (this._imageHeight == 0 && image != null) this.UpdateStyle(); + + // paint the cell normally + base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); + + // TODO: Indent width needs to take image size into account + Rectangle glyphRect = new Rectangle(cellBounds.X + GlyphMargin, cellBounds.Y, INDENT_WIDTH, cellBounds.Height - 1); + + + ////TODO: This painting code needs to be rehashed to be cleaner + //int level = this.Level; + + ////TODO: Rehash this to take different Imagelayouts into account. This will speed up drawing + //// for images of the same size (ImageLayout.None) + //if (image != null) + //{ + // Point pp; + // if (_imageHeight > cellBounds.Height) + // pp = new Point(glyphRect.X + this.glyphWidth, cellBounds.Y + _imageHeightOffset); + // else + // pp = new Point(glyphRect.X + this.glyphWidth, (cellBounds.Height / 2 - _imageHeight / 2) + cellBounds.Y); + + // // Graphics container to push/pop changes. This enables us to set clipping when painting + // // the cell's image -- keeps it from bleeding outsize of cells. + // System.Drawing.Drawing2D.GraphicsContainer gc = graphics.BeginContainer(); + // { + // graphics.SetClip(cellBounds); + // graphics.DrawImageUnscaled(image, pp); + // } + // graphics.EndContainer(gc); + //} + + // Paint tree lines + if (((Classes.KryptonOutlookGrid)node.DataGridView).ShowLines) + { + using (Pen linePen = new Pen(SystemBrushes.ControlDark, 1.0f)) + { + linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; + bool isLastSibling = node.IsLastSibling; + bool isFirstSibling = node.IsFirstSibling; + + if (node.NodeLevel == 0) + { + // the Root nodes display their lines differently + if (isFirstSibling && isLastSibling) + { + // only node, both first and last. Just draw horizontal line + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + } + else if (isLastSibling) + { + // last sibling doesn't draw the line extended below. Paint horizontal then vertical + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2); + } + else if (isFirstSibling) + { + // first sibling doesn't draw the line extended above. Paint horizontal then vertical + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.X + 4, cellBounds.Bottom); + } + else + { + // normal drawing draws extended from top to bottom. Paint horizontal then vertical + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom); + } + } + else + { + if (isLastSibling) + { + // last sibling doesn't draw the line extended below. Paint horizontal then vertical + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2); + } + else + { + // normal drawing draws extended from top to bottom. Paint horizontal then vertical + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2); + graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom); + } + + // paint lines of previous levels to the root + OutlookGridRow previousNode = node.ParentNode; + int horizontalStop = (glyphRect.X + 4) - INDENT_WIDTH; + + while (previousNode != null)//.IsRoot) + { + if (previousNode.HasChildren && !previousNode.IsLastSibling) + { + // paint vertical line + graphics.DrawLine(linePen, horizontalStop, cellBounds.Top, horizontalStop, cellBounds.Bottom); + } + previousNode = previousNode.ParentNode; + horizontalStop = horizontalStop - INDENT_WIDTH; + } + } + + } + } + + if (node.HasChildren) + { + // Paint node glyphs + if (node.Collapsed) + { + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + graphics.DrawImage(Properties.Resources.CollapseIcon2010, glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 11, 11); + } + else + { + graphics.DrawImage(Properties.Resources.ExpandIcon, glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 11, 11); + } + } + else + { + if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013) + { + graphics.DrawImage(Properties.Resources.ExpandIcon2010, glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 11, 11); + } + else + { + graphics.DrawImage(Properties.Resources.CollapseIcon, glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 11, 11); + } + } + } + //graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red)), glyphRect); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnMouseUp(DataGridViewCellMouseEventArgs e) + { + base.OnMouseUp(e); + + OutlookGridRow node = OwningNode; + if (node != null) + ((Classes.KryptonOutlookGrid)node.DataGridView)._inExpandCollapseMouseCapture = false; + } + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnMouseDown(DataGridViewCellMouseEventArgs e) + { + Rectangle dis = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false); + Rectangle glyphRect = new Rectangle(dis.X + GlyphMargin, dis.Y, INDENT_WIDTH, dis.Height - 1); + + //if (e.X > this.InheritedStyle.Padding.Left) + if ((e.X + dis.X <= glyphRect.X + 11) && + (e.X + dis.X >= glyphRect.X)) + { + + // Expand the node + //TODO: Calculate more precise location + OutlookGridRow node = OwningNode; + if (node != null) + { + ((Classes.KryptonOutlookGrid)node.DataGridView)._inExpandCollapseMouseCapture = true; + + if (node.Collapsed) + node.Expand(); + else + node.Collapse(); + } + } + else + { + base.OnMouseDown(e); + } + } + + /// + /// Gets the owning node. + /// + /// + /// The owning node. + /// + public OutlookGridRow OwningNode + { + get { return base.OwningRow as OutlookGridRow; } + } + } +} \ No newline at end of file diff --git a/Formatting/ColourFormatting.cs b/Formatting/ColourFormatting.cs new file mode 100644 index 0000000..c864144 --- /dev/null +++ b/Formatting/ColourFormatting.cs @@ -0,0 +1,166 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Drawing; + +using KryptonOutlookGrid.Formatting.Params; + +using static ColourHelper; + +namespace KryptonOutlookGrid.Formatting +{ + /// + /// Color Formatting class : all the magic ! + /// + public static class ColourFormatting + { + /// + /// Returns the percentage value for a Bar formatting. + /// + /// The value. + /// The minimum. + /// The maximum. + /// + public static double ConvertBar(double value, double min, double max) + { + double percent; + if (min == max) + { + percent = 1.0; + } + else + { + //Min can be different from 0 + percent = (value - min) / (max - min); + } + return percent; + } + + /// + /// Returns the color for a 2scale color formatting. + /// + /// The value. + /// The minimum. + /// The maximum. + /// The 2color parameters. + /// + public static Color ConvertTwoRange(double value, double min, double max, TwoColoursParams par) + { + HSVColour A = ColourToHSV(par.MinimumColour); + HSVColour B = ColourToHSV(par.MaximumColour); + + //Ratio + double percent; + if (min == max) + { + percent = 1.0; + } + else + { + //Min can be different from 0 + percent = (value - min) / (max - min); + } + return Color.FromArgb((int)Math.Round(par.MinimumColour.A + (par.MaximumColour.A - par.MinimumColour.A) * percent), (int)Math.Round(par.MinimumColour.R + (par.MaximumColour.R - par.MinimumColour.R) * percent), (int)Math.Round(par.MinimumColour.G + (par.MaximumColour.G - par.MinimumColour.G) * percent), (int)Math.Round(par.MinimumColour.B + (par.MaximumColour.B - par.MinimumColour.B) * percent)); + } + + /// + /// Returns the color for a 3scale color formatting. + /// + /// The value. + /// The minimum. + /// The maximum. + /// The 3color parameters. + /// + public static Color ConvertThreeRange(double value, double min, double max, ThreeColoursParams par) + { + HSVColour A = ColourToHSV(par.MinimumColour); + HSVColour B = ColourToHSV(par.MaximumColour); + HSVColour C = ColourToHSV(par.MediumColour); + + //Ratio + double percent; + if (min == max) + { + percent = 1.0; + } + else + { + //Min can be different from 0 + percent = (value - min) / (max - min); + } + + if (percent == 0.5) + { + return par.MediumColour; + } + else if (percent <= 0.5) + { + return Color.FromArgb((int)Math.Round(par.MinimumColour.A + (par.MediumColour.A - par.MinimumColour.A) * percent), (int)Math.Round(par.MinimumColour.R + (par.MediumColour.R - par.MinimumColour.R) * percent), (int)Math.Round(par.MinimumColour.G + (par.MediumColour.G - par.MinimumColour.G) * percent), (int)Math.Round(par.MinimumColour.B + (par.MediumColour.B - par.MinimumColour.B) * percent)); + } + else + { + return Color.FromArgb((int)Math.Round(par.MediumColour.A + (par.MaximumColour.A - par.MediumColour.A) * percent), (int)Math.Round(par.MediumColour.R + (par.MaximumColour.R - par.MediumColour.R) * percent), (int)Math.Round(par.MediumColour.G + (par.MaximumColour.G - par.MediumColour.G) * percent), (int)Math.Round(par.MediumColour.B + (par.MaximumColour.B - par.MediumColour.B) * percent)); + } + } + + private static HSVColour ColourToHSV(Color colour) + { + int max = Math.Max(colour.R, Math.Max(colour.G, colour.B)); + int min = Math.Min(colour.R, Math.Min(colour.G, colour.B)); + + double hue = colour.GetHue(); + double saturation = (max == 0) ? 0 : 1d - (1d * min / max); + double value = max / 255d; + + return new HSVColour((float)hue, (float)saturation, (float)value); + } + + private static Color ColourFromHSV(double hue, double saturation, double value) + { + int hi = Convert.ToInt32(Math.Floor(hue / 60)) % 6; + double f = hue / 60 - Math.Floor(hue / 60); + + value = value * 255; + int v = Convert.ToInt32(value); + int p = Convert.ToInt32(value * (1 - saturation)); + int q = Convert.ToInt32(value * (1 - f * saturation)); + int t = Convert.ToInt32(value * (1 - (1 - f) * saturation)); + + if (hi == 0) + return Color.FromArgb(255, v, t, p); + else if (hi == 1) + return Color.FromArgb(255, q, v, p); + else if (hi == 2) + return Color.FromArgb(255, p, v, t); + else if (hi == 3) + return Color.FromArgb(255, p, q, v); + else if (hi == 4) + return Color.FromArgb(255, t, p, v); + else + return Color.FromArgb(255, v, p, q); + } + /// + /// Interpolate colors 0.0 - 1.0 + /// + private static Color Interpolate(double percent, params Color[] colours) + { + int left = (int)Math.Floor(percent * (colours.Length - 1)); + int right = (int)Math.Ceiling(percent * (colours.Length - 1)); + Color colorLeft = colours[left]; + Color colorRight = colours[right]; + + double step = 1.0 / (colours.Length - 1); + double percentRight = (percent - (left * step)) / step; + double percentLeft = 1.0 - percentRight; + return Color.FromArgb((byte)(colorLeft.A * percentLeft + colorRight.A * percentRight), (byte)(colorLeft.R * percentLeft + colorRight.R * percentRight), (byte)(colorLeft.G * percentLeft + colorRight.G * percentRight), (byte)(colorLeft.B * percentLeft + colorRight.B * percentRight)); + } + } +} diff --git a/Formatting/CondtionalFormatting.cs b/Formatting/CondtionalFormatting.cs new file mode 100644 index 0000000..2f83f3e --- /dev/null +++ b/Formatting/CondtionalFormatting.cs @@ -0,0 +1,97 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Xml; + +namespace KryptonOutlookGrid.Formatting +{ + /// + /// Conditional Formatting class + /// + public class ConditionalFormatting + { + /// + /// Gets or sets the name of the column. + /// + /// + /// The name of the column. + /// + public string ColumnName { get; set; } + /// + /// Gets or sets the type of the Conditional Formatting. + /// + /// + /// The type of the Conditional Formatting. + /// + public EnumConditionalFormatType FormatType { get; set; } + /// + /// Gets or sets the Conditional Formatting parameters. + /// + /// + /// The Conditional Formatting parameters. + /// + public IFormatParams FormatParams { get; set; } + /// + /// Gets or sets the minimum value. + /// + /// + /// The minimum value. + /// + public double minValue { get; set; } + /// + /// Gets or sets the maximum value. + /// + /// + /// The maximum value. + /// + public double maxValue { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public ConditionalFormatting() { } + + /// + /// Initializes a new instance of the class. (Only use for context menu !) + /// + /// Type of the Conditional Formatting. + /// The Conditional Formatting parameters. + public ConditionalFormatting(EnumConditionalFormatType formatType, IFormatParams formatParams) + { + FormatType = formatType; + FormatParams = formatParams; + } + + /// + /// Initializes a new instance of the class. + /// + /// Name of the column. + /// Type of the Conditional Formatting. + /// The Conditional Formatting parameters. + public ConditionalFormatting(string columnName, EnumConditionalFormatType formatType, IFormatParams formatParams) + { + ColumnName = columnName; + FormatType = formatType; + FormatParams = formatParams; + } + + internal void Persist(XmlWriter writer) + { + writer.WriteStartElement("Condition"); + writer.WriteElementString("ColumnName", ColumnName); + writer.WriteElementString("FormatType", FormatType.ToString()); + writer.WriteStartElement("FormatParams"); + FormatParams.Persist(writer); + writer.WriteEndElement(); //FormatParams + //No need to persist min/max Value. + writer.WriteEndElement(); //Condition + } + } +} \ No newline at end of file diff --git a/Formatting/CustomFormatRule.Designer.cs b/Formatting/CustomFormatRule.Designer.cs new file mode 100644 index 0000000..a32b786 --- /dev/null +++ b/Formatting/CustomFormatRule.Designer.cs @@ -0,0 +1,201 @@ +namespace KryptonOutlookGrid.Formatting +{ + partial class CustomFormatRule + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomFormatRule)); + this.kpnlBackdrop = new ComponentFactory.Krypton.Toolkit.KryptonPanel(); + this.kbtnCancel = new ComponentFactory.Krypton.Toolkit.KryptonButton(); + this.kryptonButton1 = new ComponentFactory.Krypton.Toolkit.KryptonButton(); + this.kcolMin = new ComponentFactory.Krypton.Toolkit.KryptonColorButton(); + this.kcolMed = new ComponentFactory.Krypton.Toolkit.KryptonColorButton(); + this.kcolMax = new ComponentFactory.Krypton.Toolkit.KryptonColorButton(); + this.kcmbFill = new ComponentFactory.Krypton.Toolkit.KryptonComboBox(); + this.pbxPreview = new System.Windows.Forms.PictureBox(); + this.kcmbFormat = new ComponentFactory.Krypton.Toolkit.KryptonComboBox(); + this.klblFill = new ComponentFactory.Krypton.Toolkit.KryptonLabel(); + this.klblPreview = new ComponentFactory.Krypton.Toolkit.KryptonLabel(); + this.klblFormat = new ComponentFactory.Krypton.Toolkit.KryptonLabel(); + ((System.ComponentModel.ISupportInitialize)(this.kpnlBackdrop)).BeginInit(); + this.kpnlBackdrop.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbFill)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbxPreview)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbFormat)).BeginInit(); + this.SuspendLayout(); + // + // kpnlBackdrop + // + this.kpnlBackdrop.Controls.Add(this.kbtnCancel); + this.kpnlBackdrop.Controls.Add(this.kryptonButton1); + this.kpnlBackdrop.Controls.Add(this.kcolMin); + this.kpnlBackdrop.Controls.Add(this.kcolMed); + this.kpnlBackdrop.Controls.Add(this.kcolMax); + this.kpnlBackdrop.Controls.Add(this.kcmbFill); + this.kpnlBackdrop.Controls.Add(this.pbxPreview); + this.kpnlBackdrop.Controls.Add(this.kcmbFormat); + this.kpnlBackdrop.Controls.Add(this.klblFill); + this.kpnlBackdrop.Controls.Add(this.klblPreview); + this.kpnlBackdrop.Controls.Add(this.klblFormat); + resources.ApplyResources(this.kpnlBackdrop, "kpnlBackdrop"); + this.kpnlBackdrop.Name = "kpnlBackdrop"; + // + // kbtnCancel + // + resources.ApplyResources(this.kbtnCancel, "kbtnCancel"); + this.kbtnCancel.Name = "kbtnCancel"; + this.kbtnCancel.StateCommon.Content.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kbtnCancel.Values.Image = global::KryptonOutlookGrid.Properties.Resources._18795___critical_messagebox; + this.kbtnCancel.Values.Text = resources.GetString("kbtnCancel.Values.Text"); + this.kbtnCancel.Click += new System.EventHandler(this.kbtnCancel_Click); + // + // kryptonButton1 + // + resources.ApplyResources(this.kryptonButton1, "kryptonButton1"); + this.kryptonButton1.Name = "kryptonButton1"; + this.kryptonButton1.StateCommon.Content.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kryptonButton1.Values.Image = global::KryptonOutlookGrid.Properties.Resources._18850___ok; + this.kryptonButton1.Values.Text = resources.GetString("kryptonButton1.Values.Text"); + this.kryptonButton1.Click += new System.EventHandler(this.kryptonButton1_Click); + // + // kcolMin + // + resources.ApplyResources(this.kcolMin, "kcolMin"); + this.kcolMin.Name = "kcolMin"; + this.kcolMin.SelectedColor = System.Drawing.Color.White; + this.kcolMin.Splitter = false; + this.kcolMin.StateCommon.Content.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kcolMin.Values.Text = resources.GetString("kcolMin.Values.Text"); + this.kcolMin.VisibleNoColor = false; + this.kcolMin.SelectedColorChanged += new System.EventHandler(this.kcolMin_SelectedColorChanged); + // + // kcolMed + // + resources.ApplyResources(this.kcolMed, "kcolMed"); + this.kcolMed.Name = "kcolMed"; + this.kcolMed.SelectedColor = System.Drawing.Color.White; + this.kcolMed.Splitter = false; + this.kcolMed.StateCommon.Content.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kcolMed.Values.Text = resources.GetString("kcolMed.Values.Text"); + this.kcolMed.VisibleNoColor = false; + this.kcolMed.SelectedColorChanged += new System.EventHandler(this.kcolMed_SelectedColorChanged); + // + // kcolMax + // + resources.ApplyResources(this.kcolMax, "kcolMax"); + this.kcolMax.Name = "kcolMax"; + this.kcolMax.SelectedColor = System.Drawing.Color.White; + this.kcolMax.Splitter = false; + this.kcolMax.StateCommon.Content.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kcolMax.Values.Text = resources.GetString("kcolMax.Values.Text"); + this.kcolMax.VisibleNoColor = false; + this.kcolMax.SelectedColorChanged += new System.EventHandler(this.kcolMax_SelectedColorChanged); + // + // kcmbFill + // + this.kcmbFill.DropDownWidth = 692; + resources.ApplyResources(this.kcmbFill, "kcmbFill"); + this.kcmbFill.Name = "kcmbFill"; + this.kcmbFill.StateCommon.ComboBox.Content.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kcmbFill.SelectedIndexChanged += new System.EventHandler(this.kcmbFill_SelectedIndexChanged); + // + // pbxPreview + // + this.pbxPreview.BackColor = System.Drawing.Color.Transparent; + resources.ApplyResources(this.pbxPreview, "pbxPreview"); + this.pbxPreview.Name = "pbxPreview"; + this.pbxPreview.TabStop = false; + this.pbxPreview.Paint += new System.Windows.Forms.PaintEventHandler(this.pbxPreview_Paint); + // + // kcmbFormat + // + this.kcmbFormat.DropDownWidth = 692; + resources.ApplyResources(this.kcmbFormat, "kcmbFormat"); + this.kcmbFormat.Name = "kcmbFormat"; + this.kcmbFormat.StateCommon.ComboBox.Content.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.kcmbFormat.SelectedIndexChanged += new System.EventHandler(this.kcmbFormat_SelectedIndexChanged); + // + // klblFill + // + resources.ApplyResources(this.klblFill, "klblFill"); + this.klblFill.Name = "klblFill"; + this.klblFill.StateCommon.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.klblFill.Values.Text = resources.GetString("klblFill.Values.Text"); + // + // klblPreview + // + resources.ApplyResources(this.klblPreview, "klblPreview"); + this.klblPreview.Name = "klblPreview"; + this.klblPreview.StateCommon.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.klblPreview.Values.Text = resources.GetString("klblPreview.Values.Text"); + // + // klblFormat + // + resources.ApplyResources(this.klblFormat, "klblFormat"); + this.klblFormat.Name = "klblFormat"; + this.klblFormat.StateCommon.ShortText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.klblFormat.Values.Text = resources.GetString("klblFormat.Values.Text"); + // + // CustomFormatRule + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.kpnlBackdrop); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "CustomFormatRule"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.CustomFormatRule_Load); + ((System.ComponentModel.ISupportInitialize)(this.kpnlBackdrop)).EndInit(); + this.kpnlBackdrop.ResumeLayout(false); + this.kpnlBackdrop.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbFill)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbxPreview)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbFormat)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private ComponentFactory.Krypton.Toolkit.KryptonPanel kpnlBackdrop; + private ComponentFactory.Krypton.Toolkit.KryptonButton kbtnCancel; + private ComponentFactory.Krypton.Toolkit.KryptonButton kryptonButton1; + private ComponentFactory.Krypton.Toolkit.KryptonColorButton kcolMin; + private ComponentFactory.Krypton.Toolkit.KryptonColorButton kcolMed; + private ComponentFactory.Krypton.Toolkit.KryptonColorButton kcolMax; + private ComponentFactory.Krypton.Toolkit.KryptonComboBox kcmbFill; + private System.Windows.Forms.PictureBox pbxPreview; + private ComponentFactory.Krypton.Toolkit.KryptonComboBox kcmbFormat; + private ComponentFactory.Krypton.Toolkit.KryptonLabel klblFill; + private ComponentFactory.Krypton.Toolkit.KryptonLabel klblPreview; + private ComponentFactory.Krypton.Toolkit.KryptonLabel klblFormat; + } +} \ No newline at end of file diff --git a/Formatting/CustomFormatRule.cs b/Formatting/CustomFormatRule.cs new file mode 100644 index 0000000..ac2d901 --- /dev/null +++ b/Formatting/CustomFormatRule.cs @@ -0,0 +1,231 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using ComponentFactory.Krypton.Toolkit; + +using KryptonOutlookGrid.Utilities.Language; + +namespace KryptonOutlookGrid.Formatting +{ + public partial class CustomFormatRule : KryptonForm + { + /// + /// The colours + /// + public Color colMin, colMedium, colMax; + + /// + /// The Conditional Formatting type + /// + public EnumConditionalFormatType mode; + + private void CustomFormatRule_Load(object sender, EventArgs e) + { + kcolMin.SelectedColor = colMin; + + kcolMed.SelectedColor = colMedium; + + kcolMax.SelectedColor = colMax; + + int selectedIndex = -1; + + string[] names = Enum.GetNames(typeof(EnumConditionalFormatType)); + + for (int i = 0; i < names.Length; i++) + { + if (mode.ToString().Equals(names[i])) + { + selectedIndex = i; + } + + kcmbFormat.Items.Add(new KryptonListItem(LanguageManager.Instance.GetStringGB(names[i])) { Tag = names[i] }); + } + + kcmbFormat.SelectedIndex = selectedIndex; + } + + private void kbtnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void kryptonButton1_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void pbxPreview_Paint(object sender, PaintEventArgs e) + { + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + + switch (mode) + { + case EnumConditionalFormatType.TWOCOLOURSRANGE: + // Draw the background gradient. + using (LinearGradientBrush lgbr = new LinearGradientBrush(e.ClipRectangle, colMin, colMax, LinearGradientMode.Horizontal)) + { + e.Graphics.FillRectangle(lgbr, e.ClipRectangle); + } + break; + case EnumConditionalFormatType.THREECOLOURSRANGE: + // Draw the background gradient. + using (LinearGradientBrush lgbr = new LinearGradientBrush(e.ClipRectangle, colMin, colMax, LinearGradientMode.Horizontal)) + { + ColorBlend colourBlend = new ColorBlend(); + + colourBlend.Colors = new Color[] { colMin, colMedium, colMax }; + + colourBlend.Positions = new float[] { 0f, 0.5f, 1.0f }; + + lgbr.InterpolationColors = colourBlend; + + e.Graphics.FillRectangle(lgbr, e.ClipRectangle); + } + break; + case EnumConditionalFormatType.BAR: + if (gradient) + { + using (LinearGradientBrush lgbr = new LinearGradientBrush(e.ClipRectangle, colMin, Color.White, LinearGradientMode.Horizontal)) + { + e.Graphics.FillRectangle(lgbr, e.ClipRectangle); + } + } + else + { + using (SolidBrush sbr = new SolidBrush(colMin)) + { + e.Graphics.FillRectangle(sbr, e.ClipRectangle); + } + } + using (Pen pen = new Pen(colMin)) //Color.FromArgb(255, 140, 197, 66))) + { + Rectangle rect = e.ClipRectangle; + rect.Inflate(-1, -1); + e.Graphics.DrawRectangle(pen, rect); + } + break; + default: + break; + } + } + + private void kcolMin_SelectedColorChanged(object sender, ColorEventArgs e) + { + colMin = kcolMin.SelectedColor; + + pbxPreview.Invalidate(); + } + + private void kcolMed_SelectedColorChanged(object sender, ColorEventArgs e) + { + colMedium = kcolMed.SelectedColor; + + pbxPreview.Invalidate(); + } + + private void kcolMax_SelectedColorChanged(object sender, ColorEventArgs e) + { + colMax = kcolMax.SelectedColor; + + pbxPreview.Invalidate(); + } + + private void kcmbFill_SelectedIndexChanged(object sender, EventArgs e) + { + gradient = kcmbFill.SelectedIndex == 1; + + UpdateUI(); + } + + private void kcmbFormat_SelectedIndexChanged(object sender, EventArgs e) + { + mode = (EnumConditionalFormatType)Enum.Parse(typeof(EnumConditionalFormatType), ((KryptonListItem)kcmbFill.Items[kcmbFill.SelectedIndex]).Tag.ToString()); + + UpdateUI(); + } + + /// + /// Gradient boolean + /// + public bool gradient; + + /// + /// Initializes a new instance of the class. + /// + /// The Conditional Formatting type. + public CustomFormatRule(EnumConditionalFormatType initialmode) + { + InitializeComponent(); + + kcmbFill.SelectedIndex = 0; + + kcmbFormat.SelectedIndex = -1; + + mode = initialmode; + + colMin = Color.FromArgb(84, 179, 112); + + colMedium = Color.FromArgb(252, 229, 130); + + colMax = Color.FromArgb(243, 120, 97); + } + + private void UpdateUI() + { + switch (mode) + { + case EnumConditionalFormatType.TWOCOLOURSRANGE: + klblFill.Enabled = true; + + kcmbFill.Enabled = true; + + kcolMin.Enabled = true; + + kcolMed.Enabled = false; + + kcolMax.Enabled = true; + break; + case EnumConditionalFormatType.THREECOLOURSRANGE: + klblFill.Enabled = false; + + kcmbFill.Enabled = false; + + kcolMin.Enabled = true; + + kcolMed.Enabled = true; + + kcolMax.Enabled = true; + break; + case EnumConditionalFormatType.BAR: + klblFill.Enabled = true; + + kcmbFill.Enabled = true; + + kcmbFormat.Enabled = true; + + kcolMin.Enabled = true; + + kcolMed.Enabled = false; + + kcolMax.Enabled = false; + break; + default: + break; + } + + pbxPreview.Invalidate(); + } + } +} diff --git a/Formatting/CustomFormatRule.fr.resx b/Formatting/CustomFormatRule.fr.resx new file mode 100644 index 0000000..41e6ff2 --- /dev/null +++ b/Formatting/CustomFormatRule.fr.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + &OK + + + &Annuler + + + Aperçu : + + + Couleur maxixum + + + Couleur du milieu + + + Couleur minimum + + + Format : + + + Remplissage : + + + Solide + + + Dégradé + + + Règle personnalisée + + \ No newline at end of file diff --git a/Formatting/CustomFormatRule.resx b/Formatting/CustomFormatRule.resx new file mode 100644 index 0000000..3944bab --- /dev/null +++ b/Formatting/CustomFormatRule.resx @@ -0,0 +1,453 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + NoControl + + + + 542, 245 + + + 120, 30 + + + + 11 + + + &Cancel + + + kbtnCancel + + + ComponentFactory.Krypton.Toolkit.KryptonButton, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 0 + + + 668, 245 + + + 120, 30 + + + 10 + + + &Ok + + + kryptonButton1 + + + ComponentFactory.Krypton.Toolkit.KryptonButton, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 1 + + + True + + + NoControl + + + 12, 121 + + + 164, 30 + + + 9 + + + Mini&mum Colour + + + kcolMin + + + ComponentFactory.Krypton.Toolkit.KryptonColorButton, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 2 + + + True + + + NoControl + + + 194, 121 + + + 164, 30 + + + 8 + + + Med&ium Colour + + + kcolMed + + + ComponentFactory.Krypton.Toolkit.KryptonColorButton, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 3 + + + True + + + NoControl + + + 373, 121 + + + 166, 30 + + + 7 + + + M&aximum Colour + + + kcolMax + + + ComponentFactory.Krypton.Toolkit.KryptonColorButton, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 4 + + + 96, 212 + + + 692, 27 + + + 5 + + + kcmbFill + + + ComponentFactory.Krypton.Toolkit.KryptonComboBox, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 5 + + + 96, 45 + + + 692, 25 + + + 4 + + + pbxPreview + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + kpnlBackdrop + + + 6 + + + 96, 12 + + + 692, 27 + + + 3 + + + kcmbFormat + + + ComponentFactory.Krypton.Toolkit.KryptonComboBox, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 7 + + + 12, 212 + + + 39, 26 + + + 2 + + + Fill: + + + klblFill + + + ComponentFactory.Krypton.Toolkit.KryptonLabel, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 8 + + + 12, 44 + + + 78, 26 + + + 1 + + + Preview: + + + klblPreview + + + ComponentFactory.Krypton.Toolkit.KryptonLabel, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 9 + + + 12, 12 + + + 72, 26 + + + 0 + + + Format: + + + klblFormat + + + ComponentFactory.Krypton.Toolkit.KryptonLabel, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + kpnlBackdrop + + + 10 + + + Fill + + + 0, 0 + + + 4, 5, 4, 5 + + + 800, 286 + + + 0 + + + kpnlBackdrop + + + ComponentFactory.Krypton.Toolkit.KryptonPanel, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + + $this + + + 0 + + + True + + + 9, 21 + + + 800, 286 + + + Segoe UI, 12pt + + + 4, 5, 4, 5 + + + CenterScreen + + + Custom Rule + + + CustomFormatRule + + + ComponentFactory.Krypton.Toolkit.KryptonForm, ComponentFactory.Krypton.Toolkit, Version=5.470.546.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e + + \ No newline at end of file diff --git a/Formatting/EnumConditionalFormatType.cs b/Formatting/EnumConditionalFormatType.cs new file mode 100644 index 0000000..fd9aa5b --- /dev/null +++ b/Formatting/EnumConditionalFormatType.cs @@ -0,0 +1,31 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +namespace KryptonOutlookGrid.Formatting +{ + /// + /// Conditional Formatting type + /// + public enum EnumConditionalFormatType + { + /// + /// Two scale colour + /// + TWOCOLOURSRANGE, + /// + /// Three scale colour + /// + THREECOLOURSRANGE, + /// + /// Bar + /// + BAR + } +} diff --git a/Formatting/IFormatParams.cs b/Formatting/IFormatParams.cs new file mode 100644 index 0000000..e6c9878 --- /dev/null +++ b/Formatting/IFormatParams.cs @@ -0,0 +1,28 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Xml; + +namespace KryptonOutlookGrid.Formatting +{ + /// + /// Parameter class for Conditional Formatting + /// + /// + public interface IFormatParams : ICloneable + { + /// + /// Persists the parameters. + /// + /// The XML writer. + void Persist(XmlWriter writer); + } +} \ No newline at end of file diff --git a/Formatting/Params/BarParams.cs b/Formatting/Params/BarParams.cs new file mode 100644 index 0000000..be5bac4 --- /dev/null +++ b/Formatting/Params/BarParams.cs @@ -0,0 +1,69 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Drawing; +using System.Xml; + +using ComponentFactory.Krypton.Toolkit; + +namespace KryptonOutlookGrid.Formatting.Params +{ + /// + /// Parameters for Bar formatting + /// + /// + public class BarParams : IFormatParams + { + /// + /// The bar color + /// + public Color BarColour; + /// + /// The gradient fill + /// + public bool GradientFill; + /// + /// The proportion value + /// + public double ProportionValue; + + /// + /// Initializes a new instance of the class. + /// + /// Color of the bar. + /// if set to true [gradient fill]. + public BarParams(Color barColour, bool gradientFill) + { + BarColour = barColour; + GradientFill = gradientFill; + } + + /// + /// Crée un objet qui est une copie de l'instance actuelle. + /// + /// + /// Nouvel objet qui est une copie de cette instance. + /// + public object Clone() + { + return MemberwiseClone(); + } + + /// + /// Persists the parameters. + /// + /// The XML writer. + void IFormatParams.Persist(XmlWriter writer) + { + writer.WriteElementString("BarColour", BarColour.ToArgb().ToString()); + writer.WriteElementString("GradientFill", CommonHelper.BoolToString(GradientFill)); + } + } +} \ No newline at end of file diff --git a/Formatting/Params/ThreeColoursParams.cs b/Formatting/Params/ThreeColoursParams.cs new file mode 100644 index 0000000..4548909 --- /dev/null +++ b/Formatting/Params/ThreeColoursParams.cs @@ -0,0 +1,74 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Drawing; +using System.Xml; + +namespace KryptonOutlookGrid.Formatting.Params +{ + /// + /// Three scale colour class parameters + /// + /// + public class ThreeColoursParams : IFormatParams + { + /// + /// The minimum colour + /// + public Color MinimumColour; + /// + /// The medium colour + /// + public Color MediumColour; + /// + /// The maximum colour + /// + public Color MaximumColour; + /// + /// The colour associated to the value + /// + public Color ValueColour; + + /// + /// Initializes a new instance of the class. + /// + /// The minimum colour. + /// Colour of the medium. + /// The maximum colour. + public ThreeColoursParams(Color minColour, Color mediumColour, Color maxColour) + { + MinimumColour = minColour; + MediumColour = mediumColour; + MaximumColour = maxColour; + } + + /// + /// Crée un objet qui est une copie de l'instance actuelle. + /// + /// + /// Nouvel objet qui est une copie de cette instance. + /// + public object Clone() + { + return MemberwiseClone(); + } + + /// + /// Persists the parameters. + /// + /// The XML writer. + void IFormatParams.Persist(XmlWriter writer) + { + writer.WriteElementString("MinimumColour", MinimumColour.ToArgb().ToString()); + writer.WriteElementString("MediumColour", MediumColour.ToArgb().ToString()); + writer.WriteElementString("MaximumColour", MaximumColour.ToArgb().ToString()); + } + } +} \ No newline at end of file diff --git a/Formatting/Params/TwoColoursParams.cs b/Formatting/Params/TwoColoursParams.cs new file mode 100644 index 0000000..b29fd23 --- /dev/null +++ b/Formatting/Params/TwoColoursParams.cs @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System.Drawing; +using System.Xml; + +namespace KryptonOutlookGrid.Formatting.Params +{ + /// + /// Two scale colour class parameters + /// + /// + public class TwoColoursParams : IFormatParams + { + /// + /// Minimum colour + /// + public Color MinimumColour; + /// + /// Maximum colour + /// + public Color MaximumColour; + /// + /// Colour associated to the value between min and max color + /// + public Color ValueColour; + + /// + /// Initializes a new instance of the class. + /// + /// The minimum colour. + /// The maximum colour. + public TwoColoursParams(Color minColour, Color maxColour) + { + MinimumColour = minColour; + MaximumColour = maxColour; + } + + /// + /// Crée un objet qui est une copie de l'instance actuelle. + /// + /// + /// Nouvel objet qui est une copie de cette instance. + /// + public object Clone() + { + return MemberwiseClone(); + } + + /// + /// Persists the parameters. + /// + /// The XML writer. + public void Persist(XmlWriter writer) + { + writer.WriteElementString("MinimumColour", MinimumColour.ToArgb().ToString()); + writer.WriteElementString("MaximumColour", MaximumColour.ToArgb().ToString()); + } + } +} \ No newline at end of file diff --git a/Helpers/ColourHelper.cs b/Helpers/ColourHelper.cs new file mode 100644 index 0000000..d57b003 --- /dev/null +++ b/Helpers/ColourHelper.cs @@ -0,0 +1,339 @@ +using System; +using System.Drawing; + +/// +/// Helper for color manipulations +/// +public static class ColourHelper +{ + #region Structures for HSL and HSV colors + + /// + /// HSV Structure + /// + public struct HSVColour + { + private float hue; + /// + /// Hue value, from 0° to 360° + /// + public float Hue + { + get { return hue; } + set { hue = value; } + } + + private float saturation; + /// + /// Saturation value, from 0 to 1 + /// + public float Saturation + { + get { return saturation; } + set { saturation = value; } + } + + private float valueOrBrightness; + /// + /// Value or Brightness value, from 0 to 1 + /// + public float ValueOrBrightness + { + get { return valueOrBrightness; } + set { valueOrBrightness = value; } + } + + /// + /// Initializes a new instance of the struct. + /// + /// The hue. + /// The saturation. + /// The value. + public HSVColour(float hue, float saturation, float value) + { + this.hue = hue; + this.saturation = saturation; + this.valueOrBrightness = value; + } + } + + /// + /// HSL Structure + /// + public struct HSLColour + { + private float hue; + /// + /// Hue value, from 0° to 360° + /// + public float Hue + { + get { return hue; } + set { hue = value; } + } + + private float saturation; + /// + /// Saturation value, from 0 to 1 + /// + public float Saturation + { + get { return saturation; } + set { saturation = value; } + } + + private float lightness; + /// + /// Value or Lightness value, from 0 to 1 + /// + public float Lightness + { + get { return lightness; } + set { lightness = value; } + } + + /// + /// Initializes a new instance of the struct. + /// + /// The hue. + /// The saturation. + /// The lightness. + public HSLColour(float hue, float saturation, float lightness) + { + this.hue = hue; + this.saturation = saturation; + this.lightness = lightness; + } + } + + #endregion + + + /// + /// Returns a System.Color from HSL values + /// + /// Hue (0 to 360°) + /// Saturation (0 to 1) + /// Value/Brightness (0 to 1) + /// + public static Color FromHSV(float h, float s, float v) + { + // Hue checking + if (h < 0f) h = 0f; + else if (h > 360f) h = 360f; + + // Saturation checking + if (s < 0f) s = 0f; + else if (s > 1f) s = 1f; + + // Value/Brightness checking + if (v < 0f) v = 0f; + else if (v > 1f) v = 1f; + + // === Conversion === + float fRed = 0f; + float fGreen = 0f; + float fBlue = 0f; + + if (s == 0) + { + // No saturation => shade of gray + int grayValue = Convert.ToInt32(v * 255); + return Color.FromArgb(grayValue, grayValue, grayValue); + } + else + { + float hVal = h / 360f; // 0 <= hVah < 1 + + float varH = hVal * 6f; + if (varH == 6f) varH = 0f; + int i = (int)varH; //Or ... vari = floor( varh ) + float var1 = v * (1f - s); + float var2 = v * (1f - s * (varH - (float)i)); + float var3 = v * (1f - s * (1f - (varH - i))); + + switch (i) + { + case 0: fRed = v; fGreen = var3; fBlue = var1; break; + case 1: fRed = var2; fGreen = v; fBlue = var1; break; + case 2: fRed = var1; fGreen = v; fBlue = var3; break; + case 3: fRed = var1; fGreen = var2; fBlue = v; break; + case 4: fRed = var3; fGreen = var1; fBlue = v; break; + default: fRed = v; fGreen = var1; fBlue = var2; break; + } + + return Color.FromArgb((int)(fRed * 255f), (int)(fGreen * 255f), (int)(fBlue * 255f)); + } + } + + + /// + /// Returns HSV values from RGB + /// + /// Red component from 0 to 255 + /// Green component from 0 to 255 + /// Blue component from 0 to 255 + /// + public static HSVColour ToHSV(int red, int green, int blue) + { + float varR = red / 255f; //RGB from 0 to 255 + float varG = green / 255f; + float varB = blue / 255f; + + float varMin = Math.Min(varR, Math.Min(varG, varB)); //Min. value of RGB + float varMax = Math.Max(varR, Math.Max(varG, varB)); //Max. value of RGB + float deltaMax = varMax - varMin; //Delta RGB value + + float h = 0; + float s = 0; + float v = 0; + + // Value / Brightness + v = varMax; + + if (deltaMax == 0) + { + // Gray scale + h = 0; //HSV results from 0 to 1 + s = 0; + } + else + { + // Saturation + s = deltaMax / varMax; + + // Hue + float deltaR = (((varMax - varR) / 6f) + (deltaMax / 2f)) / deltaMax; + float deltaG = (((varMax - varG) / 6f) + (deltaMax / 2f)) / deltaMax; + float deltaB = (((varMax - varB) / 6f) + (deltaMax / 2f)) / deltaMax; + + if (varR == varMax) h = deltaB - deltaG; + else if (varG == varMax) h = (1f / 3f) + deltaR - deltaB; + else if (varB == varMax) h = (2f / 3f) + deltaG - deltaR; + + if (h < 0f) h += 1; + if (h > 1f) h -= 1; + } + + return new HSVColour(h * 360f, s, v); + } + + + /// + /// Returns a System.Color from HSL values + /// + /// Hue (0 to 360°) + /// Saturation (0 to 1) + /// Lightness (0 to 1) + /// + public static Color FromHSL(float h, float s, float l) + { + // Hue checking + if (h < 0f) h = 0f; + else if (h > 360f) h = 360f; + + // Saturation checking + if (s < 0f) s = 0f; + else if (s > 1f) s = 1f; + + // Lightness checking + if (l < 0f) l = 0f; + else if (l > 1f) l = 1f; + + // === Conversion === + if (s == 0) + { + // No saturation => shade of gray + int grayValue = Convert.ToInt32(l * 255); + return Color.FromArgb(grayValue, grayValue, grayValue); + } + + float var1, var2, hval; + + if (l < 0.5f) + var2 = l * (1f + s); + else + var2 = (l + s) - (s * l); + + var1 = 2f * l - var2; + hval = h / 360f; + + int red = Convert.ToInt32(255f * FromHueToRGB(var1, var2, hval + (1f / 3f))); + int green = Convert.ToInt32(255f * FromHueToRGB(var1, var2, hval)); + int blue = Convert.ToInt32(255f * FromHueToRGB(var1, var2, hval - (1f / 3f))); + + return Color.FromArgb(red, green, blue); + } + + private static float FromHueToRGB(float var1, float var2, float hue) + { + float rgbColor; + + if (hue < 0f) hue += 1f; + if (hue > 1f) hue -= 1f; + + if ((6f * hue) < 1f) + rgbColor = (var1 + (var2 - var1) * 6f * hue); + else if ((2f * hue) < 1f) + rgbColor = var2; + else if ((3f * hue) < 2f) + rgbColor = (var1 + (var2 - var1) * ((2f / 3f) - hue) * 6f); + else + rgbColor = var1; + + return rgbColor; + } + + /// + /// Returns HSL values from RGB + /// + /// Red component from 0 to 255 + /// Green component from 0 to 255 + /// Blue component from 0 to 255 + /// + public static HSLColour ToHSL(int red, int green, int blue) + { + float varR = red / 255f; //RGB from 0 to 255 + float varG = green / 255f; + float varB = blue / 255f; + + float varMin = Math.Min(varR, Math.Min(varG, varB)); //Min. value of RGB + float varMax = Math.Max(varR, Math.Max(varG, varB)); //Max. value of RGB + float deltaMax = varMax - varMin; //Delta RGB value + + float h = 0; + float s = 0; + float l = 0; + + // Lightness + l = (varMax + varMin) / 2f; + + if (deltaMax == 0) + { + // Gray scale + h = 0; //HSL results from 0 to 1 + s = 0; + } + else + { + // Saturation + if (l < 0.5f) s = deltaMax / (varMax + varMin); + else s = deltaMax / (2f - varMax - varMin); + + // Hue + float deltaR = (((varMax - varR) / 6f) + (deltaMax / 2f)) / deltaMax; + float deltaG = (((varMax - varG) / 6f) + (deltaMax / 2f)) / deltaMax; + float deltaB = (((varMax - varB) / 6f) + (deltaMax / 2f)) / deltaMax; + + if (varR == varMax) h = deltaB - deltaG; + else if (varG == varMax) h = (1f / 3f) + deltaR - deltaB; + else if (varB == varMax) h = (2f / 3f) + deltaG - deltaR; + + if (h < 0f) h += 1f; + if (h > 1f) h -= 1f; + } + + return new HSLColour(h * 360f, s, l); + } + +} diff --git a/Helpers/OutlookGridGroupHelpers.cs b/Helpers/OutlookGridGroupHelpers.cs new file mode 100644 index 0000000..1053566 --- /dev/null +++ b/Helpers/OutlookGridGroupHelpers.cs @@ -0,0 +1,259 @@ +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Globalization; + +using KryptonOutlookGrid.Utilities.Language; + +namespace KryptonOutlookGrid.Helpers +{ + /// + /// Class containing functions for the IOutlookGridGroups + /// + public class OutlookGridGroupHelpers + { + /// + /// Gets the title for a specific datetime + /// + /// The DateTime + /// The text to display + public static string GetDayText(DateTime date) + { + switch (GetDateCode(date)) + { + case "NODATE": + return LanguageManager.Instance.GetStringGB("NODATE");// "Today"; + case "TODAY": + return LanguageManager.Instance.GetStringGB("TODAY");// "Today"; + case "YESTERDAY": + return LanguageManager.Instance.GetStringGB("YESTERDAY");//"Yesterday"; + case "TOMORROW": + return LanguageManager.Instance.GetStringGB("TOMORROW");//"Tomorrow"; + case "Monday": + case "Tuesday": + case "Wednesday": + case "Thursday": + case "Friday": + case "Saturday": + case "Sunday": + return UppercaseFirst(date.ToString("dddd")); + case "NEXTWEEK": + return LanguageManager.Instance.GetStringGB("NEXTWEEK");//"Next Week"; + case "INTWOWEEKS": //dans le deux semaines a venir + return LanguageManager.Instance.GetStringGB("INTWOWEEKS");//"In two weeks"; //dans le deux semaines a venir + case "INTHREEWEEKS": //dans les trois semaines à venir + return LanguageManager.Instance.GetStringGB("INTHREEWEEKS");//"In three weeks"; //dans les trois semaines à venir + case "LATERDURINGTHISMONTH": //Plus tard au cours de ce mois + return LanguageManager.Instance.GetStringGB("LATERDURINGTHISMONTH");//"Later during this month"; //Plus tard au cours de ce mois + case "NEXTMONTH": //Prochain mois + return LanguageManager.Instance.GetStringGB("NEXTMONTH");//"Next month"; //Prochain mois + case "AFTERNEXTMONTH": //Au-delà du prochain mois + return LanguageManager.Instance.GetStringGB("AFTERNEXTMONTH");//"After next month"; //Au-delà du prochain mois + case "PREVIOUSWEEK": + return LanguageManager.Instance.GetStringGB("PREVIOUSWEEK");//"Previous Week"; + case "TWOWEEKSAGO": //Il y a deux semaines + return LanguageManager.Instance.GetStringGB("TWOWEEKSAGO");//"Two weeks ago"; //Il y a deux semaines + case "THREEWEEKSAGO": //Il y a deux semaines + return LanguageManager.Instance.GetStringGB("THREEWEEKSAGO");//"Three weeks ago"; //Il y a deux semaines + case "EARLIERDURINGTHISMONTH": //Il y a deux semaines + return LanguageManager.Instance.GetStringGB("EARLIERDURINGTHISMONTH");//"Earlier during this month"; //Plus tot au cours de ce mois + case "PREVIOUSMONTH": //Il y a deux semaines + return LanguageManager.Instance.GetStringGB("PREVIOUSMONTH");//"Previous Month"; //Mois dernier + case "BEFOREPREVIOUSMONTH": //Mois dernier + return LanguageManager.Instance.GetStringGB("BEFOREPREVIOUSMONTH");//"Before Previous Month"; //Avant le mois dernier + default: + return date.Date.ToShortDateString(); + } + } + + /// + /// Gets the code according to a datetime + /// + /// The DateTime to analyze. + /// The associated code. + public static string GetDateCode(DateTime date) + { + if (date.Date == DateTime.MinValue)//Today + { + return "NODATE"; + } + else if (date.Date == DateTime.Now.Date)//Today + { + return "TODAY"; + } + else if (date.Date == DateTime.Now.AddDays(-1).Date) + { + return "YESTERDAY"; + } + else if (date.Date == DateTime.Now.AddDays(1).Date) + { + return "TOMORROW"; + } + else if ((date.Date >= GetFirstDayOfWeek(DateTime.Now)) && (date.Date <= GetLastDayOfWeek(DateTime.Now))) + { + return date.Date.DayOfWeek.ToString();//"DAYOFWEEK"; + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now)) && (date.Date <= GetLastDayOfWeek(DateTime.Now).AddDays(6))) + { + return "NEXTWEEK"; + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now).AddDays(6)) && (date.Date <= GetLastDayOfWeek(DateTime.Now).AddDays(12))) + { + return "INTWOWEEKS"; //dans les deux semaines a venir + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now).AddDays(12)) && (date.Date <= GetLastDayOfWeek(DateTime.Now).AddDays(18))) + { + return "INTHREEWEEKS"; //dans les trois semaines à venir + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now).AddDays(18)) && (date.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1)))//AddDays(DateTime.DaysInMonth(DateTime.Now.Year,DateTime.Now.Month)-1))) + { + return "LATERDURINGTHISMONTH"; //Plus tard au cours de ce mois + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now).AddDays(18)) && (date.Date > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1)) && (date.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(2).AddDays(-1))) + { + return "NEXTMONTH"; //Prochain mois + } + else if ((date.Date > GetLastDayOfWeek(DateTime.Now).AddDays(18)) && (date.Date > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(2).AddDays(-1))) + { + return "AFTERNEXTMONTH"; //Au-delà du prochain mois + } + else if ((date.Date < GetFirstDayOfWeek(DateTime.Now)) && (date.Date >= GetFirstDayOfWeek(DateTime.Now).AddDays(-7))) + { + return "PREVIOUSWEEK"; + } + else if ((date.Date <= GetFirstDayOfWeek(DateTime.Now).AddDays(-7)) && (date.Date >= GetFirstDayOfWeek(DateTime.Now).AddDays(-14))) + { + return "TWOWEEKSAGO"; //Il y a deux semaines + } + else if ((date.Date <= GetFirstDayOfWeek(DateTime.Now).AddDays(-14)) && (date.Date >= GetFirstDayOfWeek(DateTime.Now).AddDays(-21))) + { + return "THREEWEEKSAGO"; //Il y a deux semaines + } + else if ((date.Date <= GetFirstDayOfWeek(DateTime.Now).AddDays(-21)) && (date.Date >= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1))) + { + return "EARLIERDURINGTHISMONTH"; //Il y a deux semaines + } + else if ((date.Date <= GetFirstDayOfWeek(DateTime.Now).AddDays(-21)) && (date.Date >= new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 1)) && (date.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1))) + { + return "PREVIOUSMONTH"; //Il y a deux semaines + } + else if ((date.Date <= GetFirstDayOfWeek(DateTime.Now).AddDays(-21)) && (date.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 1).AddDays(-1))) + { + return "BEFOREPREVIOUSMONTH"; //Mois dernier + } + else + { + return date.Date.ToShortDateString(); + } + } + + /// + /// Uppercase the first letter of the string + /// + /// The string. + /// The tring with the first letter uppercased. + private static string UppercaseFirst(string s) + { + if (string.IsNullOrEmpty(s)) + { + return string.Empty; + } + char[] a = s.ToCharArray(); + a[0] = char.ToUpper(a[0]); + return new string(a); + } + + /// + /// Returns the first day of the week that the specified date is in using the current culture. + /// + /// The date to analyse + /// The first day of week. + public static DateTime GetFirstDayOfWeek(DateTime dayInWeek) + { + CultureInfo defaultCultureInfo = CultureInfo.CurrentCulture; + return GetFirstDayOfWeek(dayInWeek, defaultCultureInfo); + } + + /// + /// Returns the last day of the week that the specified date is in using the current culture. + /// + /// The date to analyse + /// The last day of week. + public static DateTime GetLastDayOfWeek(DateTime dayInWeek) + { + CultureInfo defaultCultureInfo = CultureInfo.CurrentCulture; + return GetFirstDayOfWeek(dayInWeek, defaultCultureInfo).AddDays(6); + } + + /// + /// Returns the first day of the week that the specified date is in. + /// + /// The date to analyse + /// The CultureInfo + /// The first day of week. + public static DateTime GetFirstDayOfWeek(DateTime dayInWeek, CultureInfo cultureInfo) + { + DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek; + DateTime firstDayInWeek = dayInWeek.Date; + int difference = ((int)dayInWeek.DayOfWeek) - ((int)firstDay); + difference = (7 + difference) % 7; + return dayInWeek.AddDays(-difference).Date; + } + + /// + /// Gets the user-friendly and localized text of quarter + /// + /// + /// + public static string GetQuarterAsString(DateTime dateTime) + { + switch (GetQuarter(dateTime)) + { + case 1: + return LanguageManager.Instance.GetStringGB("Q1"); + case 2: + return LanguageManager.Instance.GetStringGB("Q2"); + case 3: + return LanguageManager.Instance.GetStringGB("Q3"); + case 4: + return LanguageManager.Instance.GetStringGB("Q4"); + default: + return ""; + } + } + + /// + /// Gets the quarter according to the month. + /// + /// The date DateTime + /// The quarter number. + public static int GetQuarter(DateTime dateTime) + { + if (dateTime.Month <= 3) + return 1; + if (dateTime.Month <= 6) + return 2; + if (dateTime.Month <= 9) + return 3; + return 4; + } + + /// + /// Returns a fully qualified type name without the version, culture, or token + /// + /// + /// + public static string SimpleQualifiedName(Type t) + { + return string.Concat(t.FullName, ", ", t.Assembly.GetName().Name); + } + } +} \ No newline at end of file diff --git a/Interfaces/IOutlookGridGroup.cs b/Interfaces/IOutlookGridGroup.cs new file mode 100644 index 0000000..9aa1193 --- /dev/null +++ b/Interfaces/IOutlookGridGroup.cs @@ -0,0 +1,142 @@ +// Copyright 2006 Herre Kuijpers - +// +// This source file(s) may be redistributed, altered and customized +// by any means PROVIDING the authors name and all copyright +// notices remain intact. +// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED. USE IT AT YOUR OWN RISK. THE AUTHOR ACCEPTS NO +// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE. +//----------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +// Copyright (C) 2013-2015 JDH Software - +// +// This program is provided to you under the terms of the Microsoft Public +// License (Ms-PL) as published at https://kryptonoutlookgrid.codeplex.com/license +// +// Visit http://www.jdhsoftware.com and follow @jdhsoftware on Twitter +// +//-------------------------------------------------------------------------------- + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; + +using KryptonOutlookGrid.Classes; + +using ComponentFactory.Krypton.Toolkit; + +namespace KryptonOutlookGrid.Interfaces +{ + /// + /// IOutlookGridGroup specifies the interface of any implementation of a OutlookGridGroup class + /// Each implementation of the IOutlookGridGroup can override the behaviour of the grouping mechanism + /// Notice also that ICloneable must be implemented. The OutlookGrid makes use of the Clone method of the Group + /// to create new Group clones. Related to this is the OutlookGrid.GroupTemplate property, which determines what + /// type of Group must be cloned. + /// + public interface IOutlookGridGroup : IComparable, ICloneable + { + /// + /// the text to be displayed in the group row + /// + string Text { get; } //set; } + + /// + /// determines the value of the current group. this is used to compare the group value + /// against each item's value. + /// + object Value { get; set; } + + /// + /// indicates whether the group is collapsed. If it is collapsed, it group items (rows) will + /// not be displayed. + /// + bool Collapsed { get; set; } + + /// + /// specifies the number of items that are part of the current group + /// this value is automatically filled each time the grid is re-drawn + /// e.g. after sorting the grid. + /// + int ItemCount { get; set; } + + /// + /// specifies the default height of the group + /// each group is cloned from the GroupStyle object. Setting the height of this object + /// will also set the default height of each group. + /// + int Height { get; set; } + + //New additions + + /// + /// specifies which column is associated with this group + /// + OutlookGridColumn Column { get; set; } + + /// + /// The list of the rows contained in a group + /// + List Rows { get; set; } + + /// + /// The parent group if any + /// + IOutlookGridGroup ParentGroup { get; set; } + + /// + /// The level in the depth of groups + /// + int Level { get; set; } + + /// + /// The children groups + /// + OutlookGridGroupCollection Children { get; set; } + + /// + /// Format style of the cell + /// + string FormatStyle { get; set; } + + /// + /// Image associated to the group if any + /// + Image GroupImage { get; set; } + + /// + /// The text associated for the group text (1 item) + /// + string OneItemText { get; set; } + + /// + /// The text associated for the group text (XXX items) + /// + string XXXItemsText { get; set; } + + /// + /// Allows the column to be hidden when it is grouped by + /// + bool AllowHiddenWhenGrouped { get; set; } + + /// + /// Sort groups using count items value + /// + bool SortBySummaryCount { get; set; } + + /// + /// Gets or sets the items comparer. + /// + /// + /// The items comparer. + /// + IComparer ItemsComparer { get; set; } + + /// + /// Background for group + /// + PaletteBack Back { get; } + } +} \ No newline at end of file diff --git a/Krypton Outlook Grid 2019.csproj b/Krypton Outlook Grid 2019.csproj new file mode 100644 index 0000000..e8a610f --- /dev/null +++ b/Krypton Outlook Grid 2019.csproj @@ -0,0 +1,369 @@ + + + + + Debug + AnyCPU + {2A10C696-45AD-48AA-8EAD-2CB322672972} + Library + Properties + KryptonOutlookGrid + Krypton Outlook Grid + v4.7.2 + 512 + 4.7.405.0 + 5.472.526.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + latest + bin\Debug\Krypton Outlook Grid.xml + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + latest + + + app.manifest + + + + + + + + + + + + + + + + + + + + + + + + + + UserControl + + + KryptonOutlookGridGroupBox.cs + + + + + + + + + + + Form + + + CustomFormatRule.cs + + + + + + + + + + + + True + True + Resources.resx + + + EnglishStringsGB.resx + True + True + + + True + True + EnglishStringsUS.resx + + + + + + + + + + + KryptonOutlookGridGroupBox.cs + + + CustomFormatRule.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + + + ResXFileCodeGenerator + EnglishStringsGB.Designer.cs + + + ResXFileCodeGenerator + EnglishStringsUS.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.472.2098 + + + + + xcopy "$(TargetDir)*.*" "$(ProjectDir)..\..\..\..\Bin\Individual Components\Outlook Grid\" /D /R /Y /S + + \ No newline at end of file diff --git a/Krypton Outlook Grid 2019.sln b/Krypton Outlook Grid 2019.sln new file mode 100644 index 0000000..fad0d06 --- /dev/null +++ b/Krypton Outlook Grid 2019.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1169 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Krypton Outlook Grid 2019", "Krypton Outlook Grid 2019.csproj", "{2A10C696-45AD-48AA-8EAD-2CB322672972}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A10C696-45AD-48AA-8EAD-2CB322672972}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A10C696-45AD-48AA-8EAD-2CB322672972}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A10C696-45AD-48AA-8EAD-2CB322672972}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A10C696-45AD-48AA-8EAD-2CB322672972}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {22E1073B-A487-45D7-9991-9044A36AFF49} + EndGlobalSection +EndGlobal diff --git a/Notes/IMPORTANT.txt b/Notes/IMPORTANT.txt new file mode 100644 index 0000000..0463b9a --- /dev/null +++ b/Notes/IMPORTANT.txt @@ -0,0 +1 @@ +PLEASE ENSURE THAT YOU HAVE THE MOST UP-TO-DATE KRYPTON DLLS REFRENCED BEFORE BUILDING! (https://github.com/Wagnerp/Krypton-NET-4.7/releases) \ No newline at end of file diff --git a/Notes/LICENSE.md b/Notes/LICENSE.md new file mode 100644 index 0000000..d806b0a --- /dev/null +++ b/Notes/LICENSE.md @@ -0,0 +1,31 @@ +# Microsoft Public License (Ms-PL) + +This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. + +1. Definitions + +The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. + +A "contribution" is the original software, or any additions or changes to the software. + +A "contributor" is any person that distributes its contribution under this license. + +"Licensed patents" are a contributor's patent claims that read directly on its contribution. + +2. Grant of Rights + +(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. + +(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. + +3. Conditions and Limitations + +(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. + +(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. + +(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. + +(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. + +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a7940ff --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,39 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Krypton Outlook Grid")] +[assembly: AssemblyDescription("KryptonDataGridView with multi sorting and multi grouping abilities")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("JDH Software, Peter Wagner (aka Wagnerp) & Simon Coghlan (aka Smurf-IV)")] +[assembly: AssemblyProduct("Krypton Outlook Grid")] +[assembly: AssemblyCopyright("Copyright © JDH Software 2013-2018 - 2020. Then modifications by Peter Wagner (aka Wagnerp) & Simon Coghlan (aka Smurf-IV) 2018 - 2020. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2a10c696-45ad-48aa-8ead-2cb322672972")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("5.472.729.0")] +[assembly: AssemblyFileVersion("5.472.729.0")] +[assembly: NeutralResourcesLanguage("en-GB")] + diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..db3a120 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,843 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace KryptonOutlookGrid.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KryptonOutlookGrid.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _17871___apply_check_clean_clear_correct_ok_ready_valid_yes { + get { + object obj = ResourceManager.GetObject("_17871___apply_check_clean_clear_correct_ok_ready_valid_yes", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _18520___agt_stop { + get { + object obj = ResourceManager.GetObject("_18520___agt_stop", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _18795___critical_messagebox { + get { + object obj = ResourceManager.GetObject("_18795___critical_messagebox", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _18850___ok { + get { + object obj = ResourceManager.GetObject("_18850___ok", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _93808___calc_cancel_stock { + get { + object obj = ResourceManager.GetObject("_93808___calc_cancel_stock", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _94777___stock_stop { + get { + object obj = ResourceManager.GetObject("_94777___stock_stop", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap CollapseIcon { + get { + object obj = ResourceManager.GetObject("CollapseIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap CollapseIcon2010 { + get { + object obj = ResourceManager.GetObject("CollapseIcon2010", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap color2scale_generic_16 { + get { + object obj = ResourceManager.GetObject("color2scale_generic_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap color3scale_generic_16 { + get { + object obj = ResourceManager.GetObject("color3scale_generic_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap databar_generic_16 { + get { + object obj = ResourceManager.GetObject("databar_generic_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_blue_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_blue_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_green_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_green_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_pink_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_pink_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_red_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_rose_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_rose_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_violet_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_violet_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient_yellow_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient_yellow_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_gradient2_blue_32 { + get { + object obj = ResourceManager.GetObject("Databar_gradient2_blue_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_blue_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_blue_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_green_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_green_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_pink_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_pink_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_red_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_rose_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_rose_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_violet_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_violet_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Databar_solid_yellow_32 { + get { + object obj = ResourceManager.GetObject("Databar_solid_yellow_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap element { + get { + object obj = ResourceManager.GetObject("element", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap element_delete { + get { + object obj = ResourceManager.GetObject("element_delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap element_minus_16 { + get { + object obj = ResourceManager.GetObject("element_minus_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap element_plus_16 { + get { + object obj = ResourceManager.GetObject("element_plus_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap element_selection_delete { + get { + object obj = ResourceManager.GetObject("element_selection_delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap elements_minus_16 { + get { + object obj = ResourceManager.GetObject("elements_minus_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap elements_plus_16 { + get { + object obj = ResourceManager.GetObject("elements_plus_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap eraser { + get { + object obj = ResourceManager.GetObject("eraser", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ExpandIcon { + get { + object obj = ResourceManager.GetObject("ExpandIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ExpandIcon2010 { + get { + object obj = ResourceManager.GetObject("ExpandIcon2010", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fit_to_size { + get { + object obj = ResourceManager.GetObject("fit_to_size", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap navigate_minus { + get { + object obj = ResourceManager.GetObject("navigate_minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap navigate_plus { + get { + object obj = ResourceManager.GetObject("navigate_plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap paint_bucket_green { + get { + object obj = ResourceManager.GetObject("paint_bucket_green", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap sort_az_ascending2 { + get { + object obj = ResourceManager.GetObject("sort_az_ascending2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap sort_az_descending2 { + get { + object obj = ResourceManager.GetObject("sort_az_descending2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap sort_up_down_delete_16 { + get { + object obj = ResourceManager.GetObject("sort_up_down_delete_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star_yellow { + get { + object obj = ResourceManager.GetObject("star_yellow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star_yellow_disabled { + get { + object obj = ResourceManager.GetObject("star_yellow_disabled", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star_yellow_half_16 { + get { + object obj = ResourceManager.GetObject("star_yellow_half_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star0 { + get { + object obj = ResourceManager.GetObject("star0", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star1 { + get { + object obj = ResourceManager.GetObject("star1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star2 { + get { + object obj = ResourceManager.GetObject("star2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star3 { + get { + object obj = ResourceManager.GetObject("star3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star4 { + get { + object obj = ResourceManager.GetObject("star4", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap star5 { + get { + object obj = ResourceManager.GetObject("star5", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot0 { + get { + object obj = ResourceManager.GetObject("starhot0", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot1 { + get { + object obj = ResourceManager.GetObject("starhot1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot2 { + get { + object obj = ResourceManager.GetObject("starhot2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot3 { + get { + object obj = ResourceManager.GetObject("starhot3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot4 { + get { + object obj = ResourceManager.GetObject("starhot4", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap starhot5 { + get { + object obj = ResourceManager.GetObject("starhot5", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap table_conditional_16 { + get { + object obj = ResourceManager.GetObject("table_conditional_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap table2_selection_column { + get { + object obj = ResourceManager.GetObject("table2_selection_column", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_blue_white_red_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_blue_white_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_green_white_red_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_green_white_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_green_yellow_red_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_green_yellow_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_red_white_blue_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_red_white_blue_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_red_white_green_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_red_white_green_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThreeColors_red_yellow_green_32 { + get { + object obj = ResourceManager.GetObject("ThreeColors_red_yellow_green_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_blue_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_blue_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_green_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_green_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_pink_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_pink_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_red_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_red_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_violet_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_violet_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_blue_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_blue_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_green_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_green_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_pink_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_pink_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_red_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_red_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_violet_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_violet_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_white_yellow_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_white_yellow_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap TwoColors_yellow_white_32 { + get { + object obj = ResourceManager.GetObject("TwoColors_yellow_white_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..45c75a8 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\CollapseIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\CollapseIcon2010.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\color2scale_generic_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\color3scale_generic_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\databar_generic_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient2_blue_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_blue_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_green_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_pink_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_rose_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_violet_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_gradient_yellow_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_blue_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_green_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_pink_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_rose_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_violet_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Databar_solid_yellow_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\element.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\elements_minus_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\elements_plus_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\element_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\element_minus_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\element_plus_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\element_selection_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\eraser.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ExpandIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ExpandIcon2010.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\fit_to_size.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\navigate_minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\navigate_plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\paint_bucket_green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sort_az_ascending2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sort_az_descending2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sort_up_down_delete_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\starhot5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star_yellow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star_yellow_disabled.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\star_yellow_half_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\table2_selection_column.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\table_conditional_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_blue_white_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_green_white_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_green_yellow_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_red_white_blue_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_red_white_green_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ThreeColors_red_yellow_green_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_blue_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_green_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_pink_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_red_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_violet_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_blue_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_green_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_pink_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_red_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_violet_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_white_yellow_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\TwoColors_yellow_white_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\17871 - apply check clean clear correct ok ready valid yes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\18520 - agt stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\18795 - critical messagebox.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\18850 - ok.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\93808 - calc cancel stock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\94777 - stock stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Resources/17871 - apply check clean clear correct ok ready valid yes.png b/Resources/17871 - apply check clean clear correct ok ready valid yes.png new file mode 100644 index 0000000..1fafd44 Binary files /dev/null and b/Resources/17871 - apply check clean clear correct ok ready valid yes.png differ diff --git a/Resources/18520 - agt stop.png b/Resources/18520 - agt stop.png new file mode 100644 index 0000000..74bea69 Binary files /dev/null and b/Resources/18520 - agt stop.png differ diff --git a/Resources/18795 - critical messagebox.png b/Resources/18795 - critical messagebox.png new file mode 100644 index 0000000..5919bbf Binary files /dev/null and b/Resources/18795 - critical messagebox.png differ diff --git a/Resources/18850 - ok.png b/Resources/18850 - ok.png new file mode 100644 index 0000000..d8ca4f6 Binary files /dev/null and b/Resources/18850 - ok.png differ diff --git a/Resources/93808 - calc cancel stock.png b/Resources/93808 - calc cancel stock.png new file mode 100644 index 0000000..34f9649 Binary files /dev/null and b/Resources/93808 - calc cancel stock.png differ diff --git a/Resources/94777 - stock stop.png b/Resources/94777 - stock stop.png new file mode 100644 index 0000000..372752b Binary files /dev/null and b/Resources/94777 - stock stop.png differ diff --git a/Resources/CollapseIcon.png b/Resources/CollapseIcon.png new file mode 100644 index 0000000..c41bda4 Binary files /dev/null and b/Resources/CollapseIcon.png differ diff --git a/Resources/CollapseIcon2010.png b/Resources/CollapseIcon2010.png new file mode 100644 index 0000000..546a733 Binary files /dev/null and b/Resources/CollapseIcon2010.png differ diff --git a/Resources/Databar_gradient2_blue_32.png b/Resources/Databar_gradient2_blue_32.png new file mode 100644 index 0000000..b5004fc Binary files /dev/null and b/Resources/Databar_gradient2_blue_32.png differ diff --git a/Resources/Databar_gradient_blue_32.png b/Resources/Databar_gradient_blue_32.png new file mode 100644 index 0000000..807c86c Binary files /dev/null and b/Resources/Databar_gradient_blue_32.png differ diff --git a/Resources/Databar_gradient_green_32.png b/Resources/Databar_gradient_green_32.png new file mode 100644 index 0000000..99175d7 Binary files /dev/null and b/Resources/Databar_gradient_green_32.png differ diff --git a/Resources/Databar_gradient_pink_32.png b/Resources/Databar_gradient_pink_32.png new file mode 100644 index 0000000..7cdf53c Binary files /dev/null and b/Resources/Databar_gradient_pink_32.png differ diff --git a/Resources/Databar_gradient_red_32.png b/Resources/Databar_gradient_red_32.png new file mode 100644 index 0000000..45eed83 Binary files /dev/null and b/Resources/Databar_gradient_red_32.png differ diff --git a/Resources/Databar_gradient_rose_32.png b/Resources/Databar_gradient_rose_32.png new file mode 100644 index 0000000..7cdf53c Binary files /dev/null and b/Resources/Databar_gradient_rose_32.png differ diff --git a/Resources/Databar_gradient_violet_32.png b/Resources/Databar_gradient_violet_32.png new file mode 100644 index 0000000..ecf1edf Binary files /dev/null and b/Resources/Databar_gradient_violet_32.png differ diff --git a/Resources/Databar_gradient_yellow_32.png b/Resources/Databar_gradient_yellow_32.png new file mode 100644 index 0000000..9c03bd4 Binary files /dev/null and b/Resources/Databar_gradient_yellow_32.png differ diff --git a/Resources/Databar_solid_blue_32.png b/Resources/Databar_solid_blue_32.png new file mode 100644 index 0000000..80c841d Binary files /dev/null and b/Resources/Databar_solid_blue_32.png differ diff --git a/Resources/Databar_solid_green_32.png b/Resources/Databar_solid_green_32.png new file mode 100644 index 0000000..f1d2467 Binary files /dev/null and b/Resources/Databar_solid_green_32.png differ diff --git a/Resources/Databar_solid_pink_32.png b/Resources/Databar_solid_pink_32.png new file mode 100644 index 0000000..b5bc8b8 Binary files /dev/null and b/Resources/Databar_solid_pink_32.png differ diff --git a/Resources/Databar_solid_red_32.png b/Resources/Databar_solid_red_32.png new file mode 100644 index 0000000..e23775f Binary files /dev/null and b/Resources/Databar_solid_red_32.png differ diff --git a/Resources/Databar_solid_rose_32.png b/Resources/Databar_solid_rose_32.png new file mode 100644 index 0000000..b5bc8b8 Binary files /dev/null and b/Resources/Databar_solid_rose_32.png differ diff --git a/Resources/Databar_solid_violet_32.png b/Resources/Databar_solid_violet_32.png new file mode 100644 index 0000000..06afeb1 Binary files /dev/null and b/Resources/Databar_solid_violet_32.png differ diff --git a/Resources/Databar_solid_yellow_32.png b/Resources/Databar_solid_yellow_32.png new file mode 100644 index 0000000..718ea17 Binary files /dev/null and b/Resources/Databar_solid_yellow_32.png differ diff --git a/Resources/ExpandIcon.png b/Resources/ExpandIcon.png new file mode 100644 index 0000000..29081d4 Binary files /dev/null and b/Resources/ExpandIcon.png differ diff --git a/Resources/ExpandIcon2010.png b/Resources/ExpandIcon2010.png new file mode 100644 index 0000000..c21ce68 Binary files /dev/null and b/Resources/ExpandIcon2010.png differ diff --git a/Resources/ThreeColors_blue_white_red_32.png b/Resources/ThreeColors_blue_white_red_32.png new file mode 100644 index 0000000..ae73b5e Binary files /dev/null and b/Resources/ThreeColors_blue_white_red_32.png differ diff --git a/Resources/ThreeColors_green_white_red_32.png b/Resources/ThreeColors_green_white_red_32.png new file mode 100644 index 0000000..e455721 Binary files /dev/null and b/Resources/ThreeColors_green_white_red_32.png differ diff --git a/Resources/ThreeColors_green_yellow_red_32.png b/Resources/ThreeColors_green_yellow_red_32.png new file mode 100644 index 0000000..45a0d7d Binary files /dev/null and b/Resources/ThreeColors_green_yellow_red_32.png differ diff --git a/Resources/ThreeColors_red_white_blue_32.png b/Resources/ThreeColors_red_white_blue_32.png new file mode 100644 index 0000000..04c610f Binary files /dev/null and b/Resources/ThreeColors_red_white_blue_32.png differ diff --git a/Resources/ThreeColors_red_white_green_32.png b/Resources/ThreeColors_red_white_green_32.png new file mode 100644 index 0000000..432f6c4 Binary files /dev/null and b/Resources/ThreeColors_red_white_green_32.png differ diff --git a/Resources/ThreeColors_red_yellow_green_32.png b/Resources/ThreeColors_red_yellow_green_32.png new file mode 100644 index 0000000..e3a6171 Binary files /dev/null and b/Resources/ThreeColors_red_yellow_green_32.png differ diff --git a/Resources/TwoColors_blue_white_32.png b/Resources/TwoColors_blue_white_32.png new file mode 100644 index 0000000..60f577d Binary files /dev/null and b/Resources/TwoColors_blue_white_32.png differ diff --git a/Resources/TwoColors_green_white_32.png b/Resources/TwoColors_green_white_32.png new file mode 100644 index 0000000..11ab3ec Binary files /dev/null and b/Resources/TwoColors_green_white_32.png differ diff --git a/Resources/TwoColors_pink_white_32.png b/Resources/TwoColors_pink_white_32.png new file mode 100644 index 0000000..d6ba96f Binary files /dev/null and b/Resources/TwoColors_pink_white_32.png differ diff --git a/Resources/TwoColors_red_white_32.png b/Resources/TwoColors_red_white_32.png new file mode 100644 index 0000000..9ebb121 Binary files /dev/null and b/Resources/TwoColors_red_white_32.png differ diff --git a/Resources/TwoColors_violet_white_32.png b/Resources/TwoColors_violet_white_32.png new file mode 100644 index 0000000..54875cc Binary files /dev/null and b/Resources/TwoColors_violet_white_32.png differ diff --git a/Resources/TwoColors_white_blue_32.png b/Resources/TwoColors_white_blue_32.png new file mode 100644 index 0000000..d48f79c Binary files /dev/null and b/Resources/TwoColors_white_blue_32.png differ diff --git a/Resources/TwoColors_white_green_32.png b/Resources/TwoColors_white_green_32.png new file mode 100644 index 0000000..cb24224 Binary files /dev/null and b/Resources/TwoColors_white_green_32.png differ diff --git a/Resources/TwoColors_white_pink_32.png b/Resources/TwoColors_white_pink_32.png new file mode 100644 index 0000000..5ecd0c3 Binary files /dev/null and b/Resources/TwoColors_white_pink_32.png differ diff --git a/Resources/TwoColors_white_red_32.png b/Resources/TwoColors_white_red_32.png new file mode 100644 index 0000000..e94a34b Binary files /dev/null and b/Resources/TwoColors_white_red_32.png differ diff --git a/Resources/TwoColors_white_violet_32.png b/Resources/TwoColors_white_violet_32.png new file mode 100644 index 0000000..8c86483 Binary files /dev/null and b/Resources/TwoColors_white_violet_32.png differ diff --git a/Resources/TwoColors_white_yellow_32.png b/Resources/TwoColors_white_yellow_32.png new file mode 100644 index 0000000..e7b120e Binary files /dev/null and b/Resources/TwoColors_white_yellow_32.png differ diff --git a/Resources/TwoColors_yellow_white_32.png b/Resources/TwoColors_yellow_white_32.png new file mode 100644 index 0000000..41f13ae Binary files /dev/null and b/Resources/TwoColors_yellow_white_32.png differ diff --git a/Resources/color2scale_generic_16.png b/Resources/color2scale_generic_16.png new file mode 100644 index 0000000..8b57ba5 Binary files /dev/null and b/Resources/color2scale_generic_16.png differ diff --git a/Resources/color3scale_generic_16.png b/Resources/color3scale_generic_16.png new file mode 100644 index 0000000..e0876a0 Binary files /dev/null and b/Resources/color3scale_generic_16.png differ diff --git a/Resources/databar_generic_16.png b/Resources/databar_generic_16.png new file mode 100644 index 0000000..e02a4c5 Binary files /dev/null and b/Resources/databar_generic_16.png differ diff --git a/Resources/element.png b/Resources/element.png new file mode 100644 index 0000000..9747dec Binary files /dev/null and b/Resources/element.png differ diff --git a/Resources/element_delete.png b/Resources/element_delete.png new file mode 100644 index 0000000..421142c Binary files /dev/null and b/Resources/element_delete.png differ diff --git a/Resources/element_minus_16.png b/Resources/element_minus_16.png new file mode 100644 index 0000000..e4992dc Binary files /dev/null and b/Resources/element_minus_16.png differ diff --git a/Resources/element_plus_16.png b/Resources/element_plus_16.png new file mode 100644 index 0000000..8233437 Binary files /dev/null and b/Resources/element_plus_16.png differ diff --git a/Resources/element_selection_delete.png b/Resources/element_selection_delete.png new file mode 100644 index 0000000..4973b06 Binary files /dev/null and b/Resources/element_selection_delete.png differ diff --git a/Resources/elements_minus_16.png b/Resources/elements_minus_16.png new file mode 100644 index 0000000..43bf664 Binary files /dev/null and b/Resources/elements_minus_16.png differ diff --git a/Resources/elements_plus_16.png b/Resources/elements_plus_16.png new file mode 100644 index 0000000..43928e9 Binary files /dev/null and b/Resources/elements_plus_16.png differ diff --git a/Resources/eraser.png b/Resources/eraser.png new file mode 100644 index 0000000..6ac2829 Binary files /dev/null and b/Resources/eraser.png differ diff --git a/Resources/fit_to_size.png b/Resources/fit_to_size.png new file mode 100644 index 0000000..9734bd6 Binary files /dev/null and b/Resources/fit_to_size.png differ diff --git a/Resources/navigate_minus.png b/Resources/navigate_minus.png new file mode 100644 index 0000000..bb65279 Binary files /dev/null and b/Resources/navigate_minus.png differ diff --git a/Resources/navigate_plus.png b/Resources/navigate_plus.png new file mode 100644 index 0000000..22a7dc8 Binary files /dev/null and b/Resources/navigate_plus.png differ diff --git a/Resources/paint_bucket_green.png b/Resources/paint_bucket_green.png new file mode 100644 index 0000000..25e4d93 Binary files /dev/null and b/Resources/paint_bucket_green.png differ diff --git a/Resources/sort_az_ascending2.png b/Resources/sort_az_ascending2.png new file mode 100644 index 0000000..28b8a41 Binary files /dev/null and b/Resources/sort_az_ascending2.png differ diff --git a/Resources/sort_az_descending2.png b/Resources/sort_az_descending2.png new file mode 100644 index 0000000..0abfff8 Binary files /dev/null and b/Resources/sort_az_descending2.png differ diff --git a/Resources/sort_up_down_delete_16.png b/Resources/sort_up_down_delete_16.png new file mode 100644 index 0000000..0452b95 Binary files /dev/null and b/Resources/sort_up_down_delete_16.png differ diff --git a/Resources/star0.png b/Resources/star0.png new file mode 100644 index 0000000..4e0bc23 Binary files /dev/null and b/Resources/star0.png differ diff --git a/Resources/star1.png b/Resources/star1.png new file mode 100644 index 0000000..ffc7184 Binary files /dev/null and b/Resources/star1.png differ diff --git a/Resources/star2.png b/Resources/star2.png new file mode 100644 index 0000000..471ccec Binary files /dev/null and b/Resources/star2.png differ diff --git a/Resources/star3.png b/Resources/star3.png new file mode 100644 index 0000000..888f667 Binary files /dev/null and b/Resources/star3.png differ diff --git a/Resources/star4.png b/Resources/star4.png new file mode 100644 index 0000000..e256aa6 Binary files /dev/null and b/Resources/star4.png differ diff --git a/Resources/star5.png b/Resources/star5.png new file mode 100644 index 0000000..abacb93 Binary files /dev/null and b/Resources/star5.png differ diff --git a/Resources/star_yellow.png b/Resources/star_yellow.png new file mode 100644 index 0000000..2990e70 Binary files /dev/null and b/Resources/star_yellow.png differ diff --git a/Resources/star_yellow_disabled.png b/Resources/star_yellow_disabled.png new file mode 100644 index 0000000..ada6b5c Binary files /dev/null and b/Resources/star_yellow_disabled.png differ diff --git a/Resources/star_yellow_half_16.png b/Resources/star_yellow_half_16.png new file mode 100644 index 0000000..2ae4a01 Binary files /dev/null and b/Resources/star_yellow_half_16.png differ diff --git a/Resources/starhot0.png b/Resources/starhot0.png new file mode 100644 index 0000000..4e0bc23 Binary files /dev/null and b/Resources/starhot0.png differ diff --git a/Resources/starhot1.png b/Resources/starhot1.png new file mode 100644 index 0000000..a61d3b2 Binary files /dev/null and b/Resources/starhot1.png differ diff --git a/Resources/starhot2.png b/Resources/starhot2.png new file mode 100644 index 0000000..b5069c7 Binary files /dev/null and b/Resources/starhot2.png differ diff --git a/Resources/starhot3.png b/Resources/starhot3.png new file mode 100644 index 0000000..7973d84 Binary files /dev/null and b/Resources/starhot3.png differ diff --git a/Resources/starhot4.png b/Resources/starhot4.png new file mode 100644 index 0000000..ed59d9e Binary files /dev/null and b/Resources/starhot4.png differ diff --git a/Resources/starhot5.png b/Resources/starhot5.png new file mode 100644 index 0000000..9b29b45 Binary files /dev/null and b/Resources/starhot5.png differ diff --git a/Resources/table2_selection_column.png b/Resources/table2_selection_column.png new file mode 100644 index 0000000..b5aa552 Binary files /dev/null and b/Resources/table2_selection_column.png differ diff --git a/Resources/table_conditional_16.png b/Resources/table_conditional_16.png new file mode 100644 index 0000000..2fe9fc3 Binary files /dev/null and b/Resources/table_conditional_16.png differ diff --git a/Utilities/Language/EnglishStringsGB.Designer.cs b/Utilities/Language/EnglishStringsGB.Designer.cs new file mode 100644 index 0000000..1b51836 --- /dev/null +++ b/Utilities/Language/EnglishStringsGB.Designer.cs @@ -0,0 +1,594 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace KryptonOutlookGrid.Utilities.Language { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class EnglishStringsGB { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EnglishStringsGB() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KryptonOutlookGrid.Utilities.Language.EnglishStringsGB", typeof(EnglishStringsGB).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to After next month. + /// + internal static string AFTERNEXTMONTH { + get { + return ResourceManager.GetString("AFTERNEXTMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Alphabetic. + /// + internal static string AlphabeticGroupText { + get { + return ResourceManager.GetString("AlphabeticGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Data Bars. + /// + internal static string Bar { + get { + return ResourceManager.GetString("Bar", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Before previous month. + /// + internal static string BEFOREPREVIOUSMONTH { + get { + return ResourceManager.GetString("BEFOREPREVIOUSMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Best fit. + /// + internal static string BESTFIT { + get { + return ResourceManager.GetString("BESTFIT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Best fit (all columns). + /// + internal static string BESTFITALL { + get { + return ResourceManager.GetString("BESTFITALL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string Cancel { + get { + return ResourceManager.GetString("Cancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear grouping. + /// + internal static string CLEARGROUPING { + get { + return ResourceManager.GetString("CLEARGROUPING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear rules.... + /// + internal static string ClearRules { + get { + return ResourceManager.GetString("ClearRules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear sorting. + /// + internal static string CLEARSORTING { + get { + return ResourceManager.GetString("CLEARSORTING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Collapse. + /// + internal static string COLLAPSE { + get { + return ResourceManager.GetString("COLLAPSE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Columns. + /// + internal static string COLUMNS { + get { + return ResourceManager.GetString("COLUMNS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Conditional formatting. + /// + internal static string CONDITIONALFORMATTING { + get { + return ResourceManager.GetString("CONDITIONALFORMATTING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Custom.... + /// + internal static string CustomThreeDots { + get { + return ResourceManager.GetString("CustomThreeDots", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Date. + /// + internal static string DateGroupText { + get { + return ResourceManager.GetString("DateGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Day. + /// + internal static string Day { + get { + return ResourceManager.GetString("Day", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Drag a column header here to group by that column. + /// + internal static string DRAGCOLUMNTOGROUP { + get { + return ResourceManager.GetString("DRAGCOLUMNTOGROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Earlier during this month. + /// + internal static string EARLIERDURINGTHISMONTH { + get { + return ResourceManager.GetString("EARLIERDURINGTHISMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expand. + /// + internal static string EXPAND { + get { + return ResourceManager.GetString("EXPAND", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finish. + /// + internal static string Finish { + get { + return ResourceManager.GetString("Finish", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full collapse. + /// + internal static string FULLCOLLAPSE { + get { + return ResourceManager.GetString("FULLCOLLAPSE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full expand. + /// + internal static string FULLEXPAND { + get { + return ResourceManager.GetString("FULLEXPAND", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Group by this column. + /// + internal static string GROUP { + get { + return ResourceManager.GetString("GROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Group interval. + /// + internal static string GROUPINTERVAL { + get { + return ResourceManager.GetString("GROUPINTERVAL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide GroupBox. + /// + internal static string HIDEGROUPBOX { + get { + return ResourceManager.GetString("HIDEGROUPBOX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In three weeks. + /// + internal static string INTHREEWEEKS { + get { + return ResourceManager.GetString("INTHREEWEEKS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In two weeks. + /// + internal static string INTWOWEEKS { + get { + return ResourceManager.GetString("INTWOWEEKS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Later during this month. + /// + internal static string LATERDURINGTHISMONTH { + get { + return ResourceManager.GetString("LATERDURINGTHISMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Month. + /// + internal static string Month { + get { + return ResourceManager.GetString("Month", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next month. + /// + internal static string NEXTMONTH { + get { + return ResourceManager.GetString("NEXTMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next Week. + /// + internal static string NEXTWEEK { + get { + return ResourceManager.GetString("NEXTWEEK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No date. + /// + internal static string NODATE { + get { + return ResourceManager.GetString("NODATE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 1 item. + /// + internal static string OneItem { + get { + return ResourceManager.GetString("OneItem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Other. + /// + internal static string Other { + get { + return ResourceManager.GetString("Other", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous month. + /// + internal static string PREVIOUSMONTH { + get { + return ResourceManager.GetString("PREVIOUSMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous week. + /// + internal static string PREVIOUSWEEK { + get { + return ResourceManager.GetString("PREVIOUSWEEK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q1. + /// + internal static string Q1 { + get { + return ResourceManager.GetString("Q1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q2. + /// + internal static string Q2 { + get { + return ResourceManager.GetString("Q2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q3. + /// + internal static string Q3 { + get { + return ResourceManager.GetString("Q3", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q4. + /// + internal static string Q4 { + get { + return ResourceManager.GetString("Q4", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Quarter. + /// + internal static string Quarter { + get { + return ResourceManager.GetString("Quarter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show GroupBox. + /// + internal static string SHOWGROUPBOX { + get { + return ResourceManager.GetString("SHOWGROUPBOX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Smart. + /// + internal static string Smart { + get { + return ResourceManager.GetString("Smart", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Solid Fill. + /// + internal static string SolidFill { + get { + return ResourceManager.GetString("SolidFill", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort ascending. + /// + internal static string SORTASCENDING { + get { + return ResourceManager.GetString("SORTASCENDING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort by summary count. + /// + internal static string SORTBYSUMMARYCOUNT { + get { + return ResourceManager.GetString("SORTBYSUMMARYCOUNT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort descending. + /// + internal static string SORTDESCENDING { + get { + return ResourceManager.GetString("SORTDESCENDING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Three Colour Scale. + /// + internal static string ThreeColoursRange { + get { + return ResourceManager.GetString("ThreeColoursRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Three weeks ago. + /// + internal static string THREEWEEKSAGO { + get { + return ResourceManager.GetString("THREEWEEKSAGO", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Today. + /// + internal static string TODAY { + get { + return ResourceManager.GetString("TODAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tomorrow. + /// + internal static string TOMORROW { + get { + return ResourceManager.GetString("TOMORROW", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Two Colour Scale. + /// + internal static string TwoColoursRange { + get { + return ResourceManager.GetString("TwoColoursRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Two weeks ago. + /// + internal static string TWOWEEKSAGO { + get { + return ResourceManager.GetString("TWOWEEKSAGO", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ungroup. + /// + internal static string UNGROUP { + get { + return ResourceManager.GetString("UNGROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unknown. + /// + internal static string UNKNOWN { + get { + return ResourceManager.GetString("UNKNOWN", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to items. + /// + internal static string XXXItems { + get { + return ResourceManager.GetString("XXXItems", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Year. + /// + internal static string Year { + get { + return ResourceManager.GetString("Year", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Year. + /// + internal static string YearGroupText { + get { + return ResourceManager.GetString("YearGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Yesterday. + /// + internal static string YESTERDAY { + get { + return ResourceManager.GetString("YESTERDAY", resourceCulture); + } + } + } +} diff --git a/Utilities/Language/EnglishStringsGB.resx b/Utilities/Language/EnglishStringsGB.resx new file mode 100644 index 0000000..c790a7d --- /dev/null +++ b/Utilities/Language/EnglishStringsGB.resx @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + After next month + + + Alphabetic + + + Data Bars + Enum + + + Before previous month + + + Best fit + + + Best fit (all columns) + + + Cancel + + + Clear grouping + + + Clear rules... + + + Clear sorting + + + Collapse + + + Columns + + + Conditional formatting + + + Custom... + + + Date + + + Day + Enum + + + Drag a column header here to group by that column + + + Earlier during this month + + + Expand + + + Finish + + + Full collapse + + + Full expand + + + Group by this column + + + Group interval + + + Hide GroupBox + + + In three weeks + + + In two weeks + + + Later during this month + + + Month + Enum + + + Next month + + + Next Week + + + No date + + + 1 item + + + Other + + + Previous month + + + Previous week + + + Q1 + + + Q2 + + + Q3 + + + Q4 + + + Quarter + Enum + + + Show GroupBox + + + Smart + Enum + + + Solid Fill + + + Sort ascending + + + Sort by summary count + + + Sort descending + + + Three Colour Scale + Enum + + + Three weeks ago + + + Today + + + Tomorrow + + + Two Colour Scale + Enum + + + Two weeks ago + + + Ungroup + + + Unknown + + + items + + + Year + Enum + + + Year + + + Yesterday + + \ No newline at end of file diff --git a/Utilities/Language/EnglishStringsUS.Designer.cs b/Utilities/Language/EnglishStringsUS.Designer.cs new file mode 100644 index 0000000..99fc8b8 --- /dev/null +++ b/Utilities/Language/EnglishStringsUS.Designer.cs @@ -0,0 +1,594 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace KryptonOutlookGrid.Utilities.Language { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class EnglishStringsUS { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal EnglishStringsUS() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KryptonOutlookGrid.Utilities.Language.EnglishStringsUS", typeof(EnglishStringsUS).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to After next month. + /// + internal static string AFTERNEXTMONTH { + get { + return ResourceManager.GetString("AFTERNEXTMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Alphabetic. + /// + internal static string AlphabeticGroupText { + get { + return ResourceManager.GetString("AlphabeticGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Data Bars. + /// + internal static string Bar { + get { + return ResourceManager.GetString("Bar", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Before previous month. + /// + internal static string BEFOREPREVIOUSMONTH { + get { + return ResourceManager.GetString("BEFOREPREVIOUSMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Best fit. + /// + internal static string BESTFIT { + get { + return ResourceManager.GetString("BESTFIT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Best fit (all columns). + /// + internal static string BESTFITALL { + get { + return ResourceManager.GetString("BESTFITALL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string Cancel { + get { + return ResourceManager.GetString("Cancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear grouping. + /// + internal static string CLEARGROUPING { + get { + return ResourceManager.GetString("CLEARGROUPING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear rules.... + /// + internal static string ClearRules { + get { + return ResourceManager.GetString("ClearRules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear sorting. + /// + internal static string CLEARSORTING { + get { + return ResourceManager.GetString("CLEARSORTING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Collapse. + /// + internal static string COLLAPSE { + get { + return ResourceManager.GetString("COLLAPSE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Columns. + /// + internal static string COLUMNS { + get { + return ResourceManager.GetString("COLUMNS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Conditional formatting. + /// + internal static string CONDITIONALFORMATTING { + get { + return ResourceManager.GetString("CONDITIONALFORMATTING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Custom.... + /// + internal static string CustomThreeDots { + get { + return ResourceManager.GetString("CustomThreeDots", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Date. + /// + internal static string DateGroupText { + get { + return ResourceManager.GetString("DateGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Day. + /// + internal static string Day { + get { + return ResourceManager.GetString("Day", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Drag a column header here to group by that column. + /// + internal static string DRAGCOLUMNTOGROUP { + get { + return ResourceManager.GetString("DRAGCOLUMNTOGROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Earlier during this month. + /// + internal static string EARLIERDURINGTHISMONTH { + get { + return ResourceManager.GetString("EARLIERDURINGTHISMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expand. + /// + internal static string EXPAND { + get { + return ResourceManager.GetString("EXPAND", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finish. + /// + internal static string Finish { + get { + return ResourceManager.GetString("Finish", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full collapse. + /// + internal static string FULLCOLLAPSE { + get { + return ResourceManager.GetString("FULLCOLLAPSE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full expand. + /// + internal static string FULLEXPAND { + get { + return ResourceManager.GetString("FULLEXPAND", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Group by this column. + /// + internal static string GROUP { + get { + return ResourceManager.GetString("GROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Group interval. + /// + internal static string GROUPINTERVAL { + get { + return ResourceManager.GetString("GROUPINTERVAL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide GroupBox. + /// + internal static string HIDEGROUPBOX { + get { + return ResourceManager.GetString("HIDEGROUPBOX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In three weeks. + /// + internal static string INTHREEWEEKS { + get { + return ResourceManager.GetString("INTHREEWEEKS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In two weeks. + /// + internal static string INTWOWEEKS { + get { + return ResourceManager.GetString("INTWOWEEKS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Later during this month. + /// + internal static string LATERDURINGTHISMONTH { + get { + return ResourceManager.GetString("LATERDURINGTHISMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Month. + /// + internal static string Month { + get { + return ResourceManager.GetString("Month", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next month. + /// + internal static string NEXTMONTH { + get { + return ResourceManager.GetString("NEXTMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next Week. + /// + internal static string NEXTWEEK { + get { + return ResourceManager.GetString("NEXTWEEK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No date. + /// + internal static string NODATE { + get { + return ResourceManager.GetString("NODATE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 1 item. + /// + internal static string OneItem { + get { + return ResourceManager.GetString("OneItem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Other. + /// + internal static string Other { + get { + return ResourceManager.GetString("Other", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous month. + /// + internal static string PREVIOUSMONTH { + get { + return ResourceManager.GetString("PREVIOUSMONTH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous week. + /// + internal static string PREVIOUSWEEK { + get { + return ResourceManager.GetString("PREVIOUSWEEK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q1. + /// + internal static string Q1 { + get { + return ResourceManager.GetString("Q1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q2. + /// + internal static string Q2 { + get { + return ResourceManager.GetString("Q2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q3. + /// + internal static string Q3 { + get { + return ResourceManager.GetString("Q3", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Q4. + /// + internal static string Q4 { + get { + return ResourceManager.GetString("Q4", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Quarter. + /// + internal static string Quarter { + get { + return ResourceManager.GetString("Quarter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show GroupBox. + /// + internal static string SHOWGROUPBOX { + get { + return ResourceManager.GetString("SHOWGROUPBOX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Smart. + /// + internal static string Smart { + get { + return ResourceManager.GetString("Smart", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Solid Fill. + /// + internal static string SolidFill { + get { + return ResourceManager.GetString("SolidFill", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort ascending. + /// + internal static string SORTASCENDING { + get { + return ResourceManager.GetString("SORTASCENDING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort by summary count. + /// + internal static string SORTBYSUMMARYCOUNT { + get { + return ResourceManager.GetString("SORTBYSUMMARYCOUNT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sort descending. + /// + internal static string SORTDESCENDING { + get { + return ResourceManager.GetString("SORTDESCENDING", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Three Color Scale. + /// + internal static string ThreeColorsRange { + get { + return ResourceManager.GetString("ThreeColorsRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Three weeks ago. + /// + internal static string THREEWEEKSAGO { + get { + return ResourceManager.GetString("THREEWEEKSAGO", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Today. + /// + internal static string TODAY { + get { + return ResourceManager.GetString("TODAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tomorrow. + /// + internal static string TOMORROW { + get { + return ResourceManager.GetString("TOMORROW", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Two Color Scale. + /// + internal static string TwoColorsRange { + get { + return ResourceManager.GetString("TwoColorsRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Two weeks ago. + /// + internal static string TWOWEEKSAGO { + get { + return ResourceManager.GetString("TWOWEEKSAGO", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ungroup. + /// + internal static string UNGROUP { + get { + return ResourceManager.GetString("UNGROUP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unknown. + /// + internal static string UNKNOWN { + get { + return ResourceManager.GetString("UNKNOWN", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to items. + /// + internal static string XXXItems { + get { + return ResourceManager.GetString("XXXItems", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Year. + /// + internal static string Year { + get { + return ResourceManager.GetString("Year", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Year. + /// + internal static string YearGroupText { + get { + return ResourceManager.GetString("YearGroupText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Yesterday. + /// + internal static string YESTERDAY { + get { + return ResourceManager.GetString("YESTERDAY", resourceCulture); + } + } + } +} diff --git a/Utilities/Language/EnglishStringsUS.resx b/Utilities/Language/EnglishStringsUS.resx new file mode 100644 index 0000000..3dbbae9 --- /dev/null +++ b/Utilities/Language/EnglishStringsUS.resx @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + After next month + + + Alphabetic + + + Data Bars + Enum + + + Before previous month + + + Best fit + + + Best fit (all columns) + + + Cancel + + + Clear grouping + + + Clear rules... + + + Clear sorting + + + Collapse + + + Columns + + + Conditional formatting + + + Custom... + + + Date + + + Day + Enum + + + Drag a column header here to group by that column + + + Earlier during this month + + + Expand + + + Finish + + + Full collapse + + + Full expand + + + Group by this column + + + Group interval + + + Hide GroupBox + + + In three weeks + + + In two weeks + + + Later during this month + + + Month + Enum + + + Next month + + + Next Week + + + No date + + + 1 item + + + Other + + + Previous month + + + Previous week + + + Q1 + + + Q2 + + + Q3 + + + Q4 + + + Quarter + Enum + + + Show GroupBox + + + Smart + Enum + + + Solid Fill + + + Sort ascending + + + Sort by summary count + + + Sort descending + + + Three Color Scale + Enum + + + Three weeks ago + + + Today + + + Tomorrow + + + Two Color Scale + Enum + + + Two weeks ago + + + Ungroup + + + Unknown + + + items + + + Year + Enum + + + Year + + + Yesterday + + \ No newline at end of file diff --git a/Utilities/Language/FrenchStrings.resx b/Utilities/Language/FrenchStrings.resx new file mode 100644 index 0000000..3032118 --- /dev/null +++ b/Utilities/Language/FrenchStrings.resx @@ -0,0 +1,308 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plus tôt durant ce mois + + + Plus tard durant ce mois + + + Avant le mois dernier + + + Après le mois prochain + + + Il y a trois semaines + + + Dans trois semaines + + + Dans deux semaines + + + Mois prochain + + + Semaine prochaine + + + Semaine dernière + + + Mois dernier + + + Aujourd'hui + + + Demain + + + Il y a deux semaines + + + Hier + + + Faites glisser ici un entête de colonne pour grouper par cette colonne + + + Meilleur ajustement (toutes colonnes) + + + Supprimer les regroupements + + + Supprimer le tri + + + Tout réduire + + + Tout étendre + + + Regrouper par ce champ + + + Cacher la boîte de regroupement + + + Afficher la boîte de regroupement + + + Tri croissant + + + Tri décroissant + + + Ne pas regrouper par ce champ + + + Meilleur ajustement + + + Pas de date + + + Alphabétique + + + Date + + + 1 élément + + + éléments + + + Année + + + Colonnes + + + Réduire + + + Etendre + + + Intervalle de regroupement + + + Trim. 1 + + + Trim. 2 + + + Trim. 3 + + + Trim. 4 + + + Jour + Enum + + + Mois + Enum + + + Trimestre + Enum + + + Intelligent + Enum + + + Année + Enum + + + Trier par nombre d'éléments + + + Inconnu + + + Mise en forme conditionnelle + + + Barres de données + Enum + + + Remplissage dégradé + + + Remplissage uni + + + Échelle de trois couleurs + Enum + + + Échelle de deux couleurs + Enum + + + Effacer règles... + + + Personnalisé... + + + Autre + + + Annuler + + + Terminer + + \ No newline at end of file diff --git a/Utilities/Language/LanguageManager.cs b/Utilities/Language/LanguageManager.cs new file mode 100644 index 0000000..b6402cb --- /dev/null +++ b/Utilities/Language/LanguageManager.cs @@ -0,0 +1,94 @@ +using System.Globalization; +using System.Reflection; +using System.Resources; +using System.Threading; + +namespace KryptonOutlookGrid.Utilities.Language +{ + /// + /// This class handles the current localisation + /// + public class LanguageManager + { + // Local variable to store a reference to the instance of LanguageManager + public static LanguageManager languageManager = null; + + public static readonly object myLock = new object(); + + public ResourceManager resourceManagerUS, resourceManagerGB; + + private CultureInfo cultureInfo; + + //Used for blocking critical sections on updates + private object locker = new object(); + + private LanguageManager() + { + resourceManagerUS = new ResourceManager("KryptonOutlookGrid.Utilities.Language.EnglishStringsUS", Assembly.GetExecutingAssembly()); + + resourceManagerGB = new ResourceManager("KryptonOutlookGrid.Utilities.Language.EnglishStringsGB", Assembly.GetExecutingAssembly()); + + cultureInfo = Thread.CurrentThread.CurrentCulture; + } + + /// + /// Gets or sets the P locker. + /// + /// The P locker. + public object PLocker + { + get + { + return this.locker; + } + + set + { + this.locker = value; + } + } + + /// + /// Gets the instance of the singleton. + /// + public static LanguageManager Instance + { + get + { + if (languageManager == null) + { + lock (myLock) + { + if (languageManager == null) + { + languageManager = new LanguageManager(); + } + } + } + + return languageManager; + } + } + + /// + /// Get localised string for USA + /// + /// + /// + /// + public string GetStringUS(string name) + { + return resourceManagerUS.GetString(name, cultureInfo); + } + + /// + /// Get localised string for GB + /// + /// + /// + public string GetStringGB(string name) + { + return resourceManagerGB.GetString(name, cultureInfo); + } + } +} \ No newline at end of file diff --git a/app.manifest b/app.manifest new file mode 100644 index 0000000..b9577f3 --- /dev/null +++ b/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +