public SignalTreeClass(SignalChooserDialog dlg) { var tpl = dlg.runtimeService.FindParentPageAndRuntimeApp(dlg.NodeItem); NodePage pg = tpl.Item1; NodeRuntimeApplication rta = tpl.Item2; Items = BuildSignalTree(dlg, rta, pg, dlg.SignalId, dlg.m_dataTypefilter); }
public SignalTreeItem(SignalChooserDialog dlg, string text, NodeSignal sig) { if (dlg == null) { throw new ArgumentNullException("dlg"); } m_dlg = dlg; Text = text; m_NodeSignal = sig; }
private Collection<SignalTreeItem> BuildSignalTree(SignalChooserDialog dlg, NodeBase n, NodePage pg, FieldGuid selectedSignalId, FieldDataType.DataTypeEnum dataTypeFilter) { var items = new Collection<SignalTreeItem>(); foreach (var child in n.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; // the following logic sets one or the other, or neither SignalTreeItem item = null; NodeBase searchChildren = null; bool sort = false; var adjustedChild = child; if (nPageCollection != null) { item = new SignalTreeItem(dlg, nPageCollection.PageCollectionName.ToString(), null); } else if (nPage != null) { var pgToUse = nPage; if (pg != null && nPage.PageId == pg.PageId) { pgToUse = pg; adjustedChild = pg; } item = new SignalTreeItem(dlg, pgToUse.PageName.ToString(), null); sort = true; } else if (nInstructionGroup != null || nInstruction != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null) { searchChildren = adjustedChild; } else if (nSignal != null) { if (nSignal.DataType.IsOfType(dataTypeFilter)) { item = new SignalTreeItem(dlg, nSignal.SignalName.ToString(), nSignal); if (nSignal.SignalId == selectedSignalId) { item.IsSelected = true; } } } else if (nDeviceConfiguration != null) { item = new SignalTreeItem(dlg, Resources.Strings.Solution_Pad_DeviceConfigurationItem_Header, null); } else if (nDriver != null) { item = new SignalTreeItem(dlg, nDriver.DriverName.ToString(), null); } else if (nDevice != null) { item = new SignalTreeItem(dlg, nDevice.DeviceName.ToString(), null); } if (searchChildren != null) { var childItems = BuildSignalTree(dlg, searchChildren, pg, selectedSignalId, dataTypeFilter); if(childItems != null) { foreach (var childItem in childItems) { items.Add(childItem); } } } if (item != null) { items.Add(item); var childItems = BuildSignalTree(dlg, adjustedChild, pg, selectedSignalId, dataTypeFilter); if (childItems != null) { if (sort) { var sorted = from c in childItems orderby c.Text select c; childItems = new Collection<SignalTreeItem>(); foreach (var c in sorted) { childItems.Add(c); } } // make sure to have this branch of the tree expanded if the selected node is somewhere down there if (childItems.Count((SignalTreeItem ti) => ti.IsSelected) > 0 || childItems.Count((SignalTreeItem ti) => ti.IsExpanded) > 0) { item.IsExpanded = true; } item.SetItems(childItems); } } } if (items.Count > 0) { return items; } else { return null; } }
public CommitChangesButton(SignalChooserDialog dlg) { m_SignalChooserDialog = dlg; }
public CancelChangesButton(SignalChooserDialog dlg) { m_SignalChooserDialog = dlg; }
private Collection <SignalTreeItem> BuildSignalTree(SignalChooserDialog dlg, NodeBase n, NodePage pg, FieldGuid selectedSignalId, FieldDataType.DataTypeEnum dataTypeFilter) { var items = new Collection <SignalTreeItem>(); foreach (var child in n.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; // the following logic sets one or the other, or neither SignalTreeItem item = null; NodeBase searchChildren = null; bool sort = false; var adjustedChild = child; if (nPageCollection != null) { item = new SignalTreeItem(dlg, nPageCollection.PageCollectionName.ToString(), null); } else if (nPage != null) { var pgToUse = nPage; if (pg != null && nPage.PageId == pg.PageId) { pgToUse = pg; adjustedChild = pg; } item = new SignalTreeItem(dlg, pgToUse.PageName.ToString(), null); sort = true; } else if (nInstructionGroup != null || nInstruction != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null) { searchChildren = adjustedChild; } else if (nSignal != null) { if (nSignal.DataType.IsOfType(dataTypeFilter)) { item = new SignalTreeItem(dlg, nSignal.SignalName.ToString(), nSignal); if (nSignal.SignalId == selectedSignalId) { item.IsSelected = true; } } } else if (nDeviceConfiguration != null) { item = new SignalTreeItem(dlg, Resources.Strings.Solution_Pad_DeviceConfigurationItem_Header, null); } else if (nDriver != null) { item = new SignalTreeItem(dlg, nDriver.DriverName.ToString(), null); } else if (nDevice != null) { item = new SignalTreeItem(dlg, nDevice.DeviceName.ToString(), null); } if (searchChildren != null) { var childItems = BuildSignalTree(dlg, searchChildren, pg, selectedSignalId, dataTypeFilter); if (childItems != null) { foreach (var childItem in childItems) { items.Add(childItem); } } } if (item != null) { items.Add(item); var childItems = BuildSignalTree(dlg, adjustedChild, pg, selectedSignalId, dataTypeFilter); if (childItems != null) { if (sort) { var sorted = from c in childItems orderby c.Text select c; childItems = new Collection <SignalTreeItem>(); foreach (var c in sorted) { childItems.Add(c); } } // make sure to have this branch of the tree expanded if the selected node is somewhere down there if (childItems.Count((SignalTreeItem ti) => ti.IsSelected) > 0 || childItems.Count((SignalTreeItem ti) => ti.IsExpanded) > 0) { item.IsExpanded = true; } item.SetItems(childItems); } } } if (items.Count > 0) { return(items); } else { return(null); } }