static bool DimensionsAreEqual(UIExchangeItem x, UIExchangeItem y) { return(x.ValueDefinition is IQuantity && y.ValueDefinition is IQuantity && Dimension.DescribesSameAs(((IQuantity)x.ValueDefinition).Unit.Dimension, ((IQuantity)y.ValueDefinition).Unit.Dimension)); }
private void buttonViewElementSet_Click(object sender, System.EventArgs e) { Debug.Assert(btnViewer.Enabled); ArrayList elementSets = new ArrayList(); UIExchangeItem item = inputExchangeItemSelector.GetSelectedObject(); if (item != null && item.ElementSet != null) { elementSets.Add(item.ElementSet); } item = outputExchangeItemSelector.GetSelectedObject(); if (item != null && item.ElementSet != null) { elementSets.Add(item.ElementSet); } if (elementSets.Count > 0) { _elementSetViewer.PopulateDialog(elementSets); _elementSetViewer.ShowDialog(); } }
private void outputExchangeItemSelector_SelectionChanged(object sender, System.EventArgs e) { UIExchangeItem item = outputExchangeItemSelector.GetSelectedObject(); PropertyGridSelectObject(item); btnViewer.Enabled = item != null && item is IOutput; }
void AddCheckedExchangeChildren(TreeNode node, List <UIExchangeItem> items) { UIExchangeItem item = (UIExchangeItem)node.Tag; if (node.Checked && item != null) { items.Add(item); } foreach (TreeNode n in node.Nodes) { AddCheckedExchangeChildren(n, items); // RECURSION } }
public bool Predicate(UIExchangeItem item) { if (!(item.ValueDefinition is IQuantity)) { return(false); } foreach (IDimension d in _dimensions) { if (Dimension.DescribesSameAs(d, ((IQuantity)item.ValueDefinition).Unit.Dimension)) { return(true); } } return(false); }
public void TreePopulate(ITimeSpaceComponent source, ITimeSpaceComponent target, List <UIOutputItem> extraSources, TreeOptions options) { _treeOptions = options; List <UIExchangeItem> sources = Sources(source); List <UIExchangeItem> targets = Targets(target); UIExchangeItem toCheck = null; if (extraSources != null) { sources.AddRange(extraSources.ToArray()); if (extraSources.Count > 0) { toCheck = extraSources[0]; } } Filter(sources, targets); if (_treeOptions.IsSource) { _linkableComponent = source; _items = sources; } else if (_treeOptions.IsTarget) { _linkableComponent = target; _items = targets; } else { _linkableComponent = null; _items = new List <UIExchangeItem>(); } TreeCreate(toCheck); }
/// <summary> /// Creates the tree based on element sets and quantities in exchange items /// passed with <see cref="PopulateExchangeItemTree">PopulateExchangeItemTree</see> method. /// </summary> public void TreeCreate(UIExchangeItem toCheck) { _nodes.Clear(); if (_items == null) { treeView.BeginUpdate(); treeView.Nodes.Clear(); treeView.EndUpdate(); return; } ExchangeItemsComparer comparer = new ExchangeItemsComparer(); _items.Sort(comparer); treeView.BeginUpdate(); treeView.Nodes.Clear(); treeView.CheckBoxes = _treeOptions.ShowCheckboxs; // Top Level Dictionary <string, TreeNode> quantities = new Dictionary <string, TreeNode>(); TreeNode node; foreach (UIExchangeItem item in _items) { if (item.ValueDefinition == null) { throw new InvalidOperationException("IValueDefinition == null"); } if (!quantities.ContainsKey(item.ValueDefinition.Caption)) { node = treeView.Nodes.Add(item.ValueDefinition.Caption); node.Tag = null; quantities.Add(item.ValueDefinition.Caption, node); } } // Second level Stack <TreeNode> kids = new Stack <TreeNode>(_items.Count); foreach (UIExchangeItem item in _items) { node = new TreeNode(item.ToString()); node.ImageIndex = node.SelectedImageIndex = ImageIndex(item.ElementSet.ElementType); node.Tag = item; if (item is UIOutputItem && ((UIOutputItem)item).Parent != null) { kids.Push(node); } else { quantities[item.ValueDefinition.Caption].Nodes.Add(node); _nodes.Add(item.ExchangeItem, node); } } // Lower levels if (kids.Count > 0) { Stack <TreeNode> unassigned; UIExchangeItem iParent, iNode; int added; do { added = 0; unassigned = new Stack <TreeNode>(kids.Count); while (kids.Count > 0) { node = kids.Pop(); iNode = (UIExchangeItem)node.Tag; iParent = ((UIOutputItem)iNode).Parent; if (_nodes.ContainsKey(iParent.ExchangeItem)) { _nodes[iParent.ExchangeItem].Nodes.Add(node); _nodes.Add(iNode.ExchangeItem, node); ++added; } else { unassigned.Push(node); } } if (added == 0 && unassigned.Count > 0) { Debug.Assert(false); // cant assign kids break; } kids = unassigned; }while (unassigned.Count > 0); } treeView.ExpandAll(); treeView.EndUpdate(); if (toCheck != null && _nodes.ContainsKey(toCheck.ExchangeItem)) { CheckNode(_nodes[toCheck.ExchangeItem], true); } treeView.Invalidate(); }
public bool Predicate(UIExchangeItem item) { return(_types.Contains(item.ElementSet.ElementType)); }