/// <summary> /// Clears all subnodes. /// </summary> internal 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(); }
/// <summary> /// Determines if there is a parent node or a parent group collapsed. /// </summary> /// <param name="row">The specified row.</param> /// <param name="i">The i.</param> /// <returns></returns> 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); } } } }
/// <summary> /// Initializes a new instance of the <see cref="ExpandedEventArgs"/> class. /// </summary> /// <param name="node">The node.</param> public ExpandedEventArgs(OutlookGridRow node) : base(node) { }
/// <summary> /// Expand Node and all its subnodes (without events) /// </summary> 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; }
/// <summary> /// Expands the node. /// </summary> /// <param name="node">The OutlookGridRow node.</param> /// <returns></returns> 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; } }
/// <summary> /// Gets the Index of a row /// </summary> /// <param name="row">The OutlookGrid row.</param> /// <returns></returns> public int IndexOf(OutlookGridRow row) { return subNodes.IndexOf(row); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridRowNodeCollection"/> class. /// </summary> /// <param name="parentNode">The parent node.</param> public OutlookGridRowNodeCollection(OutlookGridRow parentNode) { _parentNode = parentNode; subNodes = new List <OutlookGridRow>(); }
/// <summary> /// Gets the Index of a row /// </summary> /// <param name="row">The OutlookGrid row.</param> /// <returns></returns> public int IndexOf(OutlookGridRow row) { return(subNodes.IndexOf(row)); }
/// <summary> /// Initializes a new instance of the <see cref="CollapsingEventArgs"/> class. /// </summary> /// <param name="node">The node.</param> public CollapsingEventArgs(OutlookGridRow node) : base(node) { }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridRowNodeEventBase"/> class. /// </summary> /// <param name="node">The node.</param> public OutlookGridRowNodeEventBase(OutlookGridRow node) { _row = node; }
/// <summary> /// Constructor /// </summary> /// <param name="row">The OutlookGridRow.</param> public OutlookGridGroupImageEventArgs(OutlookGridRow row) { this.row = row; }
/// <summary> /// Determines if there is a parent node or a parent group collapsed. /// </summary> /// <param name="row">The specified row.</param> /// <param name="i">The i.</param> /// <returns></returns> 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; } } } }
private void LoadData() { //Setup Rows OutlookGridRow row = new OutlookGridRow(); List<OutlookGridRow> l = new List<OutlookGridRow>(); OutlookGrid1.SuspendLayout(); OutlookGrid1.ClearInternalRows(); OutlookGrid1.FillMode = FillMode.GroupsAndNodes; List<Token> tokensList = new List<Token>(); tokensList.Add(new Token("Best seller", Color.Orange, Color.Black)); tokensList.Add(new Token("New", Color.LightGreen, Color.Black)); tokensList.Add(null); tokensList.Add(null); tokensList.Add(null); Random random = new Random(); //.Next permet de retourner un nombre aléatoire contenu dans la plage spécifiée entre parenthèses. XmlDocument doc = new XmlDocument(); doc.Load("invoices.xml"); IFormatProvider culture = new CultureInfo("en-US", true); foreach (XmlNode customer in doc.SelectNodes("//invoice")) //TODO for instead foreach for perfs... { try { row = new OutlookGridRow(); row.CreateCells(OutlookGrid1, new object[] { customer["CustomerID"].InnerText, customer["CustomerName"].InnerText, customer["Address"].InnerText, customer["City"].InnerText, new TextAndImage(customer["Country"].InnerText,GetFlag(customer["Country"].InnerText)), DateTime.Parse(customer["OrderDate"].InnerText,culture), customer["ProductName"].InnerText, double.Parse(customer["Price"].InnerText, CultureInfo.InvariantCulture), //We put a float the formatting in design does the rest (double)random.Next(101) /100, tokensList[random.Next(5)] }); if (random.Next(2) == 1) { //Sub row OutlookGridRow row2 = new OutlookGridRow(); row2.CreateCells(OutlookGrid1, new object[] { customer["CustomerID"].InnerText + " 2", customer["CustomerName"].InnerText + " 2", customer["Address"].InnerText + "2", customer["City"].InnerText + " 2", new TextAndImage(customer["Country"].InnerText,GetFlag(customer["Country"].InnerText)), DateTime.Now, customer["ProductName"].InnerText + " 2", (double)random.Next(1000), (double)random.Next(101) /100, tokensList[random.Next(5)] }); row.Nodes.Add(row2); ((KryptonDataGridViewTreeTextCell)row2.Cells[1]).UpdateStyle(); //Important : after added to the parent node } l.Add(row); ((KryptonDataGridViewTreeTextCell)row.Cells[1]).UpdateStyle(); //Important : after added to the rows list } catch (Exception ex) { MessageBox.Show("Gasp...Something went wrong ! " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } OutlookGrid1.ResumeLayout(); OutlookGrid1.AssignRows(l); OutlookGrid1.ForceRefreshGroupBox(); OutlookGrid1.Fill(); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridRowNodeCollection"/> class. /// </summary> /// <param name="parentNode">The parent node.</param> public OutlookGridRowNodeCollection(OutlookGridRow parentNode) { _parentNode = parentNode; subNodes = new List<OutlookGridRow>(); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridRowNodeCancelEventBase"/> class. /// </summary> /// <param name="node">The node.</param> public OutlookGridRowNodeCancelEventBase(OutlookGridRow node) { _row = node; }
/// <summary> /// Initializes a new instance of the <see cref="ExpandingEventArgs"/> class. /// </summary> /// <param name="node">The node.</param> public ExpandingEventArgs(OutlookGridRow node) : base(node) { }
/// <summary> /// Adds the specified row. /// </summary> /// <param name="row">The row.</param> public void Add(OutlookGridRow row) { row.ParentNode = _parentNode; row.NodeLevel = ParentNode.NodeLevel + 1; //Not ++ subNodes.Add(row); }
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); } }
/// <summary> /// Ensure the node is visible (all parents exanded) /// </summary> /// <param name="r">The OutlookGridRow which needs to be visible.</param> public void EnsureVisibleNode(OutlookGridRow r) { RecursiveUpwardSetNodeCollaspse(r, false); }