/// <summary> /// Helps synchronizing aggregation definition in current row data grid control to /// aggregation definition presented as checked boxes for appropriate attributes in /// tree view control /// </summary> private void dataGrid1_Click(object sender, EventArgs e) { if (sychContr == SynchControls.SynchGridToTreeView) return; try { DataRow dr = GetCurrentDataGridRow(); String strAgg = dr[1].ToString(); String strAggName = dr[0].ToString(); if (checkBoxRelationships.Checked) { sychContr = SynchControls.SynchGridToTreeView; if (CheckOffTreeViewAndReturnRigid(strAgg, true)) dr[2] = "Rigid"; else dr[2] = "Flexible"; } else { int i = 0; foreach (TreeNode parentNode in treeViewAggregation.Nodes) { foreach (TreeNode childNode in parentNode.Nodes) { if (strAgg[i].ToString() == "1") { sychContr = SynchControls.SynchGridToTreeView; childNode.Checked = true; childNode.BackColor = dataGrid1.HeaderBackColor; } else { sychContr = SynchControls.SynchGridToTreeView; childNode.Checked = false; childNode.BackColor = treeViewAggregation.BackColor; } i++; } i++; } } SetEstimatedSize(GetAggregationFromString(strAggName, strAgg)); txtSummary.Text = GetCheckedNodeText(treeViewAggregation.Nodes); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } sychContr = SynchControls.Unknown; }
/// <summary> /// Main function called when user checks/uncheckes dimension attribute. /// If attribute checked it needs to be added to the string representation of an aggregations /// </summary> private void treeViewAggregation_AfterCheck(object sender, TreeViewEventArgs e) { // If happen to synch Tree to grid, we should quit if (sychContr == SynchControls.SynchTreeToGrid) return; if (e.Action == TreeViewAction.Unknown && !boolHandleClick ) return; if (e.Node.Parent == null) return; DataRow dr = GetCurrentDataGridRow(); String strAgg = dr[1].ToString(); int i = 0; int intAttrCount = 0; TreeNode parent = e.Node.Parent; while (parent.Parent != null) { parent = parent.Parent; } if (parent == null) MessageBox.Show("Cannot find parent"); string parentName = parent.Name; while (treeViewAggregation.Nodes[i].Name != parentName) { intAttrCount++; intAttrCount += mg1.Dimensions[treeViewAggregation.Nodes[i].Name].CubeDimension.Attributes.Count; i++; } if (checkBoxRelationships.Checked) { //Find a place of an attribute in the attr string int j = 0; foreach (CubeAttribute cubeDimAttr in mg1.Dimensions[treeViewAggregation.Nodes[i].Name].CubeDimension.Attributes) { if (cubeDimAttr.AttributeID == e.Node.Name) intAttrCount += j; j++; } } else { intAttrCount += e.Node.Index; } if (e.Node.Checked) { strAgg = strAgg.Insert(intAttrCount, "1"); strAgg = strAgg.Remove(intAttrCount + 1, 1); System.Drawing.Color ii = dataGrid1.HeaderBackColor; e.Node.BackColor = ii; } else { strAgg = strAgg.Insert(intAttrCount, "0"); strAgg = strAgg.Remove(intAttrCount + 1, 1); e.Node.BackColor = treeViewAggregation.BackColor; } dr[1] = strAgg; if (sychContr == SynchControls.SynchTreeToGrid) dataGrid1_Click(null, null); sychContr = SynchControls.Unknown; }
public void Init(string strAggDesign, MeasureGroup mg, string[,] inDimAttributes, string[] inDimNames , string[] inDimIDs) { this.Text = this.Text + " Aggregation Design: " + strAggDesign; mg1 = mg; aggDes = mg.AggregationDesigns.GetByName(strAggDesign); dimAttributes = inDimAttributes; dimNames = inDimNames; dimIDs = inDimIDs; DataTable myTable = new DataTable("Aggregations"); DataColumn colItem = new DataColumn("Name", Type.GetType("System.String")); myTable.Columns.Add(colItem); colItem = new DataColumn("Aggregations", Type.GetType("System.String")); myTable.Columns.Add(colItem); colItem = new DataColumn("Type", Type.GetType("System.String")); myTable.Columns.Add(colItem); DataView myDataView = new DataView(myTable); dataGrid1.DataSource = myDataView; DataRow NewRow; foreach (Aggregation agg in aggDes.Aggregations) { NewRow = myTable.NewRow(); NewRow["Aggregations"] = ConvertAggToSting(agg); NewRow["Name"] = agg.Name; myTable.Rows.Add(NewRow); } AddGridStyle(); PopulateTreeView(); checkBoxRelationships.Checked = true; sychContr = SynchControls.Unknown; int i = 0; foreach (DataRow dRow in myDataView.Table.Rows) { dataGrid1.CurrentRowIndex = i; dataGrid1_Click(null, null); i++; } myDataView.AllowNew = false; }