// ****************************************************************** private static void ExpandItemWithInitialExpandedAttribute(PropertyGrid propertyGrid, GridItem gridItem) { if (gridItem != null) { if (gridItem.GridItemType == GridItemType.Property && gridItem.Expandable) { object[] objs = gridItem.Value.GetType().GetCustomAttributes(typeof(PropertyGridInitialExpandedAttribute), false); if (objs.Length > 0) { if (((PropertyGridInitialExpandedAttribute)objs[0]).InitialExpanded) { gridItem.Expanded = true; } } } foreach (GridItem childItem in gridItem.GridItems) { ExpandItemWithInitialExpandedAttribute(propertyGrid, childItem); } } }
internal void Add (GridItem grid_item) { string key = grid_item.Label; while (list.ContainsKey (key)) key += "_"; list.Add (key, grid_item); }
internal GridItemCollection(GridItem[] entries) { if (entries == null) this.entries = new GridItem[0]; else this.entries = entries; }
private void propertyGrid_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) { _selectedGridItem = e.NewSelection; if (SelectedGridItemChanged != null) { PropertyGrid propertyGrid = sender as PropertyGrid; SelectedGridItemChanged(sender, e); } }
void AutoExpand(GridItem item) { foreach (GridItem property in item.GridItems) { AutoExpand(property); var descriptor = property.PropertyDescriptor; if (descriptor != null && descriptor.Attributes.Contains(new AutoExpandAttribute())) property.Expanded = true; } }
private CatForm cForm = new CatForm(); // 分类选择窗体 /// <summary> /// 构造函数 /// </summary> /// <param name="conn">sql连接</param> /// <param name="fieldID">字段主键字符串</param> /// <param name="primaryKeys">树结点主键数组</param> /// <param name="searchLevel">搜索级别</param> public EditLog(SqlConnection conn, string fieldID, TreeNode node, GridItem item) { this.conn = conn; this.fieldID = fieldID; this.node = node; this.primaryKeys = node.Tag as object[]; this.item = item; InitializeComponent(); ResetTime(); InitTable(); InitData(); }
protected GridEntry (PropertyGrid propertyGrid, GridEntry parent) { if (propertyGrid == null) throw new ArgumentNullException ("propertyGrid"); property_grid = propertyGrid; plus_minus_bounds = new Rectangle (0,0,0,0); top = -1; grid_items = new GridItemCollection (); expanded = false; this.parent = parent; child_griditems_cache = null; }
private void FindItems(GridItem item, List<GridItem> gridItems) { switch (item.GridItemType) { case GridItemType.Root: case GridItemType.Category: foreach (GridItem i in item.GridItems) { this.FindItems(i, gridItems); } break; case GridItemType.Property: gridItems.Add(item); if (item.Expanded) { foreach (GridItem i in item.GridItems) { this.FindItems(i, gridItems); } } break; case GridItemType.ArrayValue: break; } }
public FreeQuery() { Rows = new List<GridRow>(); Rows.Add(new GridRow()); Rows.Add(new GridRow()); GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = new QueryExpression(); Rows[0].Columns.Add(gi); gi = new GridItem(); gi.QOperator = new QueryOperator(); gi.QOperator.SelectedOperator = QueryOperator.Operator.End; gi.QExpression = null; Rows[0].Columns.Add(gi); gi = new GridItem(); gi.QOperator = new QueryOperator(); gi.QOperator.SelectedOperator = QueryOperator.Operator.End; gi.QExpression = null; Rows[1].Columns.Add(gi); }
public SelectedGridItemChangedEventArgs(GridItem oldSel, GridItem newSel) { this.oldSelection = oldSel; this.newSelection = newSel; }
private GridItem FindGridItem(GridItem root, String label, String address) { if (root.Label == label ? root.Value != null ? address != null ? ((Unit)root.Value).ToString() == address : true : address == null : false) return root; else { foreach(GridItem gi in root.GridItems) { GridItem result = FindGridItem(gi, label, address); if (result != null) return result; } return null; } }
/// <include file='doc\SelectedGridItemChangedEvent.uex' path='docs/doc[@for="SelectedGridItemChangedEventArgs.SelectedGridItemChangedEventArgs"]/*' /> /// <devdoc> /// Constructs a SelectedGridItemChangedEventArgs object. /// </devdoc> public SelectedGridItemChangedEventArgs(GridItem oldSel, GridItem newSel) { this.oldSelection = oldSel; this.newSelection = newSel; }
internal void OnPropertyValueSet(GridItem changedItem, object oldValue) { OnPropertyValueChanged(new PropertyValueChangedEventArgs(changedItem, oldValue)); }
//Find the GridItem with the given label. GridItem FindGridItem(GridItem node, string label) { if (string.Compare(node.Label, label, true) == 0) { return node; } foreach (GridItem it in node.GridItems) { if ((node = FindGridItem(it, label)) != null) { return node; } } return null; }
/// <include file='doc\PropertyValueChangedEvent.uex' path='docs/doc[@for="PropertyValueChangedEventArgs.PropertyValueChangedEventArgs"]/*' /> /// <devdoc> /// Constructor /// </devdoc> public PropertyValueChangedEventArgs(GridItem changedItem, object oldValue) { this.changedItem = changedItem; this.oldValue = oldValue; }
public FreeQuery(QueryBuilderForm frm, XmlNode node) { Rows = new List<GridRow>(); Name = node.Attributes["name"].Value; XmlNodeList nl = node.SelectNodes("row"); foreach (XmlNode xmlr in nl) { Rows.Add(new GridRow()); XmlNodeList cl = xmlr.SelectNodes("col"); foreach (XmlNode xmlc in cl) { GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = null; if (xmlc.Attributes["nextoperator"] != null) { gi.QOperator = new QueryOperator(); gi.QOperator.SelectedOperator = (QueryOperator.Operator)Enum.Parse(typeof(QueryOperator.Operator), xmlc.Attributes["nextoperator"].Value); gi.QOperator.PreviousSelectedOperator = gi.QOperator.SelectedOperator; gi.QOperator.SelectedValueChanged += new EventHandler(frm.QOperator_SelectedValueChanged); } if (xmlc.Attributes["field"] != null) { gi.QExpression = new QueryExpression(); gi.QExpression.SetExpressionField(xmlc.Attributes["field"].Value); gi.QExpression.SetExpressionOperator(xmlc.Attributes["operator"].Value); gi.QExpression.ExpressionValue = xmlc.Attributes["condition"].Value; } Rows[Rows.Count-1].Columns.Add(gi); } } }
/// <include file='doc\PropertyValueChangedEvent.uex' path='docs/doc[@for="PropertyValueChangedEventArgs.PropertyValueChangedEventArgs"]/*' /> /// <devdoc> /// Constructor /// </devdoc> public PropertyValueChangedEventArgs(GridItem changedItem, object oldValue) { this.changedItem = changedItem; this.oldValue = oldValue; }
public SelectedGridItemChangedEventArgs ( GridItem oldSel , GridItem newSel ) { old_selection = oldSel; new_selection = newSel; }
public void SetParent (GridItem parent) { this.parent = parent; }
private void CollapseChildren(GridItem gridItem) { if (!gridItem.Expanded) return; foreach(GridItem childGridItem in gridItem.GridItems) { if(childGridItem.Expanded) { childGridItem.Expanded=false; } } }
public PropertyValueChangedEventArgs(GridItem changedItem, object oldValue) { changed_item = changedItem; old_value = oldValue; }
private GridItem RecursiveFindGridItem(GridItem startFromHere, string fullTypeName) { foreach (GridItem item in startFromHere.GridItems) { if (item.Label == fullTypeName) { return item; } if (item.GridItems.Count > 0) { GridItem returned = RecursiveFindGridItem(item, fullTypeName); if (returned != null) { return returned; } } } return null; }
private PropertyInfo GetPropertyInfo(PropertyGrid propertyGrid, GridItem item) { if (propertyGrid == null) throw new ArgumentNullException("propertyGrid"); if (item == null) throw new ArgumentNullException("item"); PropertyInfo result = null; int cnt = propertyGrid.SelectedObjects.Length; Type selectedObjectsType = propertyGrid.SelectedObject.GetType(); // handle the case that the edited property is an expendable property, e.g. of type 'Font'. // In this case, the property that has to be changed is not the edited item itself but it's parent item. if (item.Parent.PropertyDescriptor != null) { // the current selectedItem is a ChildItem of the edited object's property result = selectedObjectsType.GetProperty(item.Parent.PropertyDescriptor.Name); } else if (item.PropertyDescriptor != null) result = selectedObjectsType.GetProperty(item.PropertyDescriptor.Name); return result; }
internal int IndexOf(GridItem grid_item) { return(list.IndexOfValue(grid_item)); }
private GridItem LocateGridItem(GridItem currentItem, string propertyName) { if (currentItem.GridItemType == GridItemType.Property && currentItem.Label.Equals(propertyName, StringComparison.CurrentCulture)) { return currentItem; } GridItem foundItem = null; foreach (GridItem childItem in currentItem.GridItems) { foundItem = LocateGridItem(childItem, propertyName); if (foundItem != null) { break; } } return foundItem; }
private void LoadData() { _lblLabel.Text = _batchRequest.DeploymentLabel; _lblDirectory.Text = _workingDirectory; var dataProvider = _diFactory.CreateInjectedObject<IOfflineDataProvider>(); _deployHistoryList = dataProvider.GetDeployHistoryList(_workingDirectory); _gridItemList = new List<GridItem>(); foreach (var historyItem in _deployHistoryList) { var gridItem = new GridItem(historyItem); _gridItemList.Add(gridItem); } _grdHistory.DataSource = _gridItemList; }
/// <summary> /// プロパティ変更用のコマンドオブジェクトを取得する。 /// </summary> /// <param name="changedItem">変更したアイテム。</param> /// <param name="oldValue">変更前の値。</param> /// <returns>コマンド実行用のパラメータ。</returns> public override KeyValueMap GetPropertyChangeCommand( GridItem changedItem, object oldValue) { return new KeyValueMap() { {"CommandName", "ChangeProjectProperty"}, {"Name", changedItem.PropertyDescriptor.Name}, {"Value", changedItem.Value}, {"OldValue", oldValue} }; }
string getNameOfChangedItem( GridItem changedItem ) { if (changedItem.PropertyDescriptor == null) { throw new InvalidOperationException( @"A property in the grid changed but didn't have a PropertyDescriptor." ) ; } return changedItem.PropertyDescriptor.Name ; }
void QOperator_SelectedValueChanged(object sender, EventArgs e) { QueryOperator qo = sender as QueryOperator; if (_activeQuery != null && qo!=null) { int arow = -1; int acol = -1; for (int r = 0; r < _activeQuery.Rows.Count && arow < 0; r++) { for (int c = 0; c < _activeQuery.Rows[r].Columns.Count && arow<0; c++) { if (_activeQuery.Rows[r].Columns[c].QOperator == qo) { arow = r; acol = c; } } } if (arow >= 0 && acol >= 0) { //add column or row? if (arow > 0) { //operator added to column with expressions //add expression or cut off if (qo.SelectedOperator == QueryOperator.Operator.End && qo.PreviousSelectedOperator!= QueryOperator.Operator.End) { //cut off: all after this: null for (int i = arow + 1; i < _activeQuery.Rows.Count; i++) { //if column exists if (acol < _activeQuery.Rows[i].Columns.Count) { if (_activeQuery.Rows[i].Columns[acol].QExpression != null) { panel2.Controls.Remove(_activeQuery.Rows[i].Columns[acol].QExpression); _activeQuery.Rows[i].Columns[acol].QExpression.Dispose(); _activeQuery.Rows[i].Columns[acol].QExpression = null; } if (_activeQuery.Rows[i].Columns[acol].QOperator != null) { panel2.Controls.Remove(_activeQuery.Rows[i].Columns[acol].QOperator); _activeQuery.Rows[i].Columns[acol].QOperator.Dispose(); _activeQuery.Rows[i].Columns[acol].QOperator = null; } } } } else if (qo.SelectedOperator != QueryOperator.Operator.End && qo.PreviousSelectedOperator == QueryOperator.Operator.End) { //add expression in next row arow++; if (arow <= _activeQuery.Rows.Count) { _activeQuery.Rows.Add(new GridRow()); } for (int i = _activeQuery.Rows[arow].Columns.Count; i <= acol; i++) { GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = null; _activeQuery.Rows[arow].Columns.Add(gi); } _activeQuery.Rows[arow].Columns[acol].QExpression = new QueryExpression(); _activeQuery.Rows[arow].Columns[acol].QExpression.Location = new Point(212 + (212 + 80) * acol - _activeQuery.Rows[arow].Columns[acol].QExpression.Width / 2 - panel2.HorizontalScroll.Value, 40 * arow - panel2.VerticalScroll.Value); panel2.Controls.Add(_activeQuery.Rows[arow].Columns[acol].QExpression); //add end operator in next arow++; if (arow <= _activeQuery.Rows.Count) { _activeQuery.Rows.Add(new GridRow()); } for (int i = _activeQuery.Rows[arow].Columns.Count; i <= acol; i++) { GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = null; _activeQuery.Rows[arow].Columns.Add(gi); } _activeQuery.Rows[arow].Columns[acol].QOperator = new QueryOperator(); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedOperator = QueryOperator.Operator.End; _activeQuery.Rows[arow].Columns[acol].QOperator.Location = new Point(212 + (212 + 80) * acol - _activeQuery.Rows[arow].Columns[acol].QOperator.Width / 2 - panel2.HorizontalScroll.Value, 40 * arow - panel2.VerticalScroll.Value); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedValueChanged += new EventHandler(QOperator_SelectedValueChanged); panel2.Controls.Add(_activeQuery.Rows[arow].Columns[acol].QOperator); } } else { //add column or cutt off //only first row if (qo.SelectedOperator == QueryOperator.Operator.End && qo.PreviousSelectedOperator != QueryOperator.Operator.End) { //cut off for (int r = 0; r < _activeQuery.Rows.Count; r++) { for (int c = acol+1; c < _activeQuery.Rows[r].Columns.Count; c++) { if (_activeQuery.Rows[r].Columns[c].QExpression != null) { panel2.Controls.Remove(_activeQuery.Rows[r].Columns[c].QExpression); _activeQuery.Rows[r].Columns[c].QExpression.Dispose(); _activeQuery.Rows[r].Columns[c].QExpression = null; } if (_activeQuery.Rows[r].Columns[c].QOperator != null) { panel2.Controls.Remove(_activeQuery.Rows[r].Columns[c].QOperator); _activeQuery.Rows[r].Columns[c].QOperator.Dispose(); _activeQuery.Rows[r].Columns[c].QOperator = null; } } } } else if (qo.SelectedOperator != QueryOperator.Operator.End && qo.PreviousSelectedOperator == QueryOperator.Operator.End) { //add for (int i = _activeQuery.Rows[arow].Columns.Count; i <= acol+2; i++) { GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = null; _activeQuery.Rows[arow].Columns.Add(gi); } acol++; _activeQuery.Rows[arow].Columns[acol].QExpression = new QueryExpression(); _activeQuery.Rows[arow].Columns[acol].QExpression.Location = new Point(212 + (212 + 80) * acol - _activeQuery.Rows[arow].Columns[acol].QExpression.Width / 2 - panel2.HorizontalScroll.Value, 40 * arow - panel2.VerticalScroll.Value); panel2.Controls.Add(_activeQuery.Rows[arow].Columns[acol].QExpression); acol++; _activeQuery.Rows[arow].Columns[acol].QOperator = new QueryOperator(); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedOperator = QueryOperator.Operator.End; _activeQuery.Rows[arow].Columns[acol].QOperator.Location = new Point(212 + (212 + 80) * acol - _activeQuery.Rows[arow].Columns[acol].QOperator.Width / 2 - panel2.HorizontalScroll.Value, 40 * arow - panel2.VerticalScroll.Value); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedValueChanged += new EventHandler(QOperator_SelectedValueChanged); panel2.Controls.Add(_activeQuery.Rows[arow].Columns[acol].QOperator); arow++; if (arow <= _activeQuery.Rows.Count) { _activeQuery.Rows.Add(new GridRow()); } acol--; for (int i = _activeQuery.Rows[arow].Columns.Count; i <= acol; i++) { GridItem gi = new GridItem(); gi.QOperator = null; gi.QExpression = null; _activeQuery.Rows[arow].Columns.Add(gi); } _activeQuery.Rows[arow].Columns[acol].QOperator = new QueryOperator(); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedOperator = QueryOperator.Operator.End; _activeQuery.Rows[arow].Columns[acol].QOperator.Location = new Point(212 + (212 + 80) * acol - _activeQuery.Rows[arow].Columns[acol].QOperator.Width / 2 - panel2.HorizontalScroll.Value, 40 * arow - panel2.VerticalScroll.Value); _activeQuery.Rows[arow].Columns[acol].QOperator.SelectedValueChanged += new EventHandler(QOperator_SelectedValueChanged); panel2.Controls.Add(_activeQuery.Rows[arow].Columns[acol].QOperator); } } } } if (qo != null) { qo.PreviousSelectedOperator = qo.SelectedOperator; } }
private GridItem findPropertyItem(string label, GridItem root) { if (root == null) return null; if (root.Label == label) return root; // search the property grid's item tree for the indicated item foreach (GridItem gi in root.GridItems) { GridItem result = findPropertyItem(label, gi); if (result != null) return result; } return null; }
private GridItem FindPreviousGridItemProperty(List<GridItem> gridItems, GridItem startItem) { if (gridItems.Count == 0) return null; if (startItem == null) return null; int startIndex = gridItems.IndexOf(startItem); if (startItem.GridItemType == GridItemType.Property) { startIndex = startIndex - 1; if (startIndex < 0) startIndex = gridItems.Count - 1; } int previousIndex = 0; bool previousIndexValid = false; for (int index = startIndex; index >= 0; index += -1) { if (gridItems[index].GridItemType == GridItemType.Property) { previousIndex = index; previousIndexValid = true; break; // TODO: might not be correct. Was : Exit For } } if (previousIndexValid) return gridItems[previousIndex]; for (int index = gridItems.Count - 1; index >= startIndex + 1; index += -1) { if (gridItems[index].GridItemType == GridItemType.Property) { previousIndex = index; previousIndexValid = true; break; // TODO: might not be correct. Was : Exit For } } if (!previousIndexValid) return null; return gridItems[previousIndex]; }
private void PropertyGridItemSelected(GridItem item) { List<string> tokens = new List<string>(4); while (item != null) { tokens.Add(item.Label); item = item.Parent; } tokens.Reverse(); if (tokens.Count < 3) return; int nodePos = Convert.ToInt32(tokens[2]); StringBuilder str = new StringBuilder(64); for (int i = 3; i < tokens.Count; i++) { str.AppendFormat("{0}{1}", (i > 3) ? "|" : "", tokens[i]); } TransactionNode node = curNodeList[nodePos]; List<PacketSlice> slices = node.GetSlicesForFieldPath(str.ToString()); if (autoHighlightMenuItem.Checked) { UpdateDumpHighlighting(slices.ToArray()); } if (slices.Count >= 1) { ScrollPacketIntoView(slices[0]); } }
private GridItem FindNextGridItemProperty(List<GridItem> gridItems, GridItem startItem) { if (gridItems.Count == 0) return null; if (startItem == null) return null; int startIndex = gridItems.IndexOf(startItem); if (startItem.GridItemType == GridItemType.Property) { startIndex = startIndex + 1; if (startIndex >= gridItems.Count) startIndex = 0; } int nextIndex = 0; bool nextIndexValid = false; for (int index = startIndex; index <= gridItems.Count - 1; index++) { if (gridItems[index].GridItemType == GridItemType.Property) { nextIndex = index; nextIndexValid = true; break; // TODO: might not be correct. Was : Exit For } } if (nextIndexValid) return gridItems[nextIndex]; for (int index = 0; index <= startIndex - 1; index++) { if (gridItems[index].GridItemType == GridItemType.Property) { nextIndex = index; nextIndexValid = true; break; // TODO: might not be correct. Was : Exit For } } if (!nextIndexValid) return null; return gridItems[nextIndex]; }
public SelectedGridItemChangedEventArgs(GridItem oldSel, GridItem newSel) { old_selection = oldSel; new_selection = newSel; }
private void FindChildGridItems(GridItem item, ref List<GridItem> gridItems) { gridItems.Add(item); if (!item.Expandable | item.Expanded) { foreach (GridItem child in item.GridItems) { FindChildGridItems(child, ref gridItems); } } }