private void CommitCollapseState(Node node, CollapseState state, ref TransactionFramework.TransactionChain chain) { var relationships = node.Proxy.Relationships.FindRelationships(FromConnectionType, MapContainerRelationshipType); var isComplete = false; foreach (Proxy.IRelationship relationship in relationships) { var potentialMapNodes = relationship.Nodes.FindNodes(ToConnectionType); foreach (Proxy.INode mapNode in potentialMapNodes) { if (mapNode.Id == Map.Id) { isComplete = true; node.Proxy.Metadata.Add(relationship, FromConnectionType, _collapseStateKey, state.ToString(), ref chain); break; } } if (isComplete) { break; } } }
private void RemoveNode(JetListViewNode parentNode, JetListViewNode childNode) { ClearChildren(childNode); CollapseState oldCollapseState = parentNode.CollapseState; OnNodeRemoving(childNode); if (IsNodeVisible(childNode)) { OnVisibleNodeRemoving(childNode); } parentNode.RemoveChild(childNode); _nodeMap.Remove(childNode.Data, parentNode); OnNodeRemoved(childNode); if (IsNodeVisible(childNode)) { OnVisibleNodeRemoved(childNode); } if (parentNode != _rootNode && IsNodeVisible(parentNode) && oldCollapseState != parentNode.CollapseState) { OnNodeChanged(parentNode); } }
private void UpdateItemThread(IResource resource, ConversationNode node) { ConversationNode newParentNode = FindParentInList(resource, false); if (newParentNode != null) { if (node.Parent != null) { node.Parent.RemoveChild(node); } newParentNode.AddChild(node); if (newParentNode.LvNode == null) { // the new parent belongs to a thread which wasn't expanded _listView.Nodes.Remove(resource); node.LvNode = null; } else { CollapseState oldState = newParentNode.LvNode.CollapseState; node.LvNode.SetParent(newParentNode.LvNode); if (oldState == CollapseState.NoChildren) { newParentNode.LvNode.Expanded = false; } } } else { node.LvNode.SetParent(null); } }
public void SetCollapseState(Guid nodeId, CollapseState collapseState) { if (States.ContainsKey(nodeId)) { States[nodeId] = collapseState; } else { States.Add(nodeId, collapseState); } }
private void CollapseNodes(ChildrenControlCollection collection) { State = CollapseState.Collapsed; foreach (var nodecontrol in collection.NodeControls) { nodecontrol.IsCollapsed = true; } foreach (var arrowControl in collection.ArrowControls) { arrowControl.IsCollapsed = true; arrowControl.DeSelect(); } NodeControl.ParentSurface.ReScanForCollapseStates(); AutoRealignIfInExplorerMode(); }
public void ExpandNodes(ChildrenControlCollection collection) { State = CollapseState.Expanded; foreach (var nodecontrol in collection.NodeControls) { nodecontrol.IsCollapsed = false; } foreach (var arrowControl in collection.ArrowControls) { if (!arrowControl.From.IsCollapsed && !arrowControl.To.IsCollapsed) { arrowControl.IsCollapsed = false; } } NodeControl.ParentSurface.ReScanForCollapseStates(); AutoRealignIfInExplorerMode(); }
public Node(Node nodeToCopy) { MapManager = nodeToCopy.MapManager; Proxy = nodeToCopy.Proxy; IsTranscluded = nodeToCopy.IsTranscluded; _numTransclusions = nodeToCopy._numTransclusions; NodeImage = nodeToCopy.NodeImage; VideoInfo = nodeToCopy.VideoInfo; _skinName = nodeToCopy._skinName; _location = nodeToCopy._location; Metadata = nodeToCopy.Metadata; foreach (var metadata in nodeToCopy.NodeProperties.UIMetadata) { NodeProperties.UIMetadata.Add(metadata.Key, metadata.Value); } DescriptionType = nodeToCopy.DescriptionType; _viewerCollapseState = CollapseState.None; _authorCollapseState = CollapseState.None; }
internal JetListViewNode Add(object item, JetListViewNode parentNode) { lock (this) { _lastUpdatedNode = null; if (parentNode == null) { parentNode = _rootNode; } if (parentNode != _rootNode) { _flatList = false; } CollapseState oldCollapseState = parentNode.CollapseState; JetListViewNode node = new JetListViewNode(this, item); parentNode.AddChild(node); _nodeMap.Add(item, node); if (_filters != null) { filtersAccept = _filters.AcceptNode(node); node.SetFiltersAccept(filtersAccept); if (!filtersAccept) { parentNode.UpdateUnacceptedChildCount(); } } OnNodeAdded(node); if (IsNodeVisible(node)) { OnVisibleNodeAdded(node); } if (parentNode != _rootNode && IsNodeVisible(parentNode) && oldCollapseState != parentNode.CollapseState) { OnNodeChanged(parentNode); } return(node); } }
static void usbDump(int numPackets) { // Packets are saved during the collapsing process PacketQueue pktQ = new PacketQueue(); // Info for the packet that was just read PacketInfo curPacket; // Collapsing counts and time collapsing started CollapseInfo collapseInfo = new CollapseInfo(); CollapseState state = CollapseState.IDLE; bool reRun = false; byte pid = 0; int signalErrors = 0; int packetnum = 0; samplerateKHz = BeagleApi.bg_samplerate(beagle, 0); int idle_samples = IDLE_THRESHOLD * samplerateKHz; // Configure Beagle 480 for realtime capture BeagleApi.bg_usb480_capture_configure(beagle, BeagleUsb480CaptureMode.BG_USB480_CAPTURE_REALTIME, BeagleUsb2TargetSpeed.BG_USB2_AUTO_SPEED_DETECT); // Filter packets intended for the Beagle analyzer. This is only // relevant when one host controller is being used. BeagleApi.bg_usb480_hw_filter_config(beagle, BeagleApi.BG_USB2_HW_FILTER_SELF); // Start the capture if (BeagleApi.bg_enable(beagle, BeagleProtocol.BG_PROTOCOL_USB) != (int)BeagleStatus.BG_OK) { Console.Write("error: could not enable USB capture; exiting...\n"); Environment.Exit(1); } // Output the header... Console.Write("index,time(ns),USB,status,pid,data0 ... dataN(*)\n"); Console.Out.Flush(); // ...then start decoding packets while (packetnum < numPackets || (numPackets == 0)) { curPacket = pktQ.getTail(); curPacket.length = BeagleApi.bg_usb480_read( beagle, ref curPacket.status, ref curPacket.events, ref curPacket.timeSop, ref curPacket.timeDuration, ref curPacket.timeDataOffset, 1024, curPacket.data); curPacket.timeSopNS = timestampToNS(curPacket.timeSop, samplerateKHz); // Exit if observed end of capture if ((curPacket.status & BeagleApi.BG_READ_USB_END_OF_CAPTURE) != 0) { usbPrintSummaryPacket(ref packetnum, collapseInfo, ref signalErrors); break; } // Check for invalid packet or Beagle error if (curPacket.length < 0) { String errorStatus = ""; errorStatus += String.Format("error={0:d}", curPacket.length); usbPrintPacket(packetnum, curPacket, errorStatus); break; } // Check for USB error if (curPacket.status == BeagleApi.BG_READ_USB_ERR_BAD_SIGNALS) { ++signalErrors; } // Set the PID for collapsing state machine below. Treat // KEEP_ALIVEs as packets. if (curPacket.length > 0) { pid = curPacket.data[0]; } else if ((curPacket.events & BeagleApi.BG_EVENT_USB_KEEP_ALIVE) != 0 && (curPacket.status & BeagleApi.BG_READ_USB_ERR_BAD_PID) == 0) { pid = (byte)PacketGroup.KEEP_ALIVE; } else { pid = 0; } // Collapse these packets approprietly: // KEEP_ALIVE* SOF* (IN (ACK|NAK))* (PING NAK)* // (SPLIT (OUT|SETUP) NYET)* (SPLIT IN (ACK|NYET|NACK))* // If the time elapsed since collapsing began is greater than // the threshold, output the counts and zero out the counters. if (curPacket.timeSop - collapseInfo.timeSop >= (ulong)idle_samples) { usbPrintSummaryPacket(ref packetnum, collapseInfo, ref signalErrors); } while (true) { reRun = false; switch (state) { // The initial state of the state machine. Collapse SOFs // and KEEP_ALIVEs. Save IN, PING, or SPLIT packets and // move to the next state for the next packet. Otherwise, // print the collapsed packet counts and the current // packet. case CollapseState.IDLE: switch (pid) { case (byte)PacketGroup.KEEP_ALIVE: collapse(PacketGroup.KEEP_ALIVE, collapseInfo, pktQ); break; case BeagleApi.BG_USB_PID_SOF: collapse(PacketGroup.SOF, collapseInfo, pktQ); break; case BeagleApi.BG_USB_PID_IN: pktQ.savePacket(); state = CollapseState.IN; break; case BeagleApi.BG_USB_PID_PING: pktQ.savePacket(); state = CollapseState.PING; break; case BeagleApi.BG_USB_PID_SPLIT: pktQ.savePacket(); state = CollapseState.SPLIT; break; default: usbPrintSummaryPacket(ref packetnum, collapseInfo, ref signalErrors); if (curPacket.length > 0 || curPacket.events != 0 || (curPacket.status != 0 && curPacket.status != BeagleApi.BG_READ_TIMEOUT)) { usbPrintPacket(packetnum, curPacket, null); packetnum++; } break; } break; // Collapsing IN+ACK or IN+NAK. Otherwise, output any // saved packets and rerun the collapsing state machine // on the current packet. case CollapseState.IN: state = CollapseState.IDLE; switch (pid) { case BeagleApi.BG_USB_PID_ACK: collapse(PacketGroup.IN_ACK, collapseInfo, pktQ); break; case BeagleApi.BG_USB_PID_NAK: collapse(PacketGroup.IN_NAK, collapseInfo, pktQ); break; default: reRun = true; break; } break; // Collapsing PING+NAK case CollapseState.PING: state = CollapseState.IDLE; switch (pid) { case BeagleApi.BG_USB_PID_NAK: collapse(PacketGroup.PING_NAK, collapseInfo, pktQ); break; default: reRun = true; break; } break; // Expecting an IN, OUT, or SETUP case CollapseState.SPLIT: switch (pid) { case BeagleApi.BG_USB_PID_IN: pktQ.savePacket(); state = CollapseState.SPLIT_IN; break; case BeagleApi.BG_USB_PID_OUT: pktQ.savePacket(); state = CollapseState.SPLIT_OUT; break; case BeagleApi.BG_USB_PID_SETUP: pktQ.savePacket(); state = CollapseState.SPLIT_SETUP; break; default: state = CollapseState.IDLE; reRun = true; break; } break; // Collapsing SPLIT+IN+NYET, SPLIT+IN+NAK, SPLIT+IN+ACK case CollapseState.SPLIT_IN: state = CollapseState.IDLE; switch (pid) { case BeagleApi.BG_USB_PID_NYET: collapse(PacketGroup.SPLIT_IN_NYET, collapseInfo, pktQ); break; case BeagleApi.BG_USB_PID_NAK: collapse(PacketGroup.SPLIT_IN_NAK, collapseInfo, pktQ); break; case BeagleApi.BG_USB_PID_ACK: collapse(PacketGroup.SPLIT_IN_ACK, collapseInfo, pktQ); break; default: reRun = true; break; } break; // Collapsing SPLIT+OUT+NYET case CollapseState.SPLIT_OUT: state = CollapseState.IDLE; switch (pid) { case BeagleApi.BG_USB_PID_NYET: collapse(PacketGroup.SPLIT_OUT_NYET, collapseInfo, pktQ); break; default: reRun = true; break; } break; // Collapsing SPLIT+SETUP+NYET case CollapseState.SPLIT_SETUP: state = CollapseState.IDLE; switch (pid) { case BeagleApi.BG_USB_PID_NYET: collapse(PacketGroup.SPLIT_SETUP_NYET, collapseInfo, pktQ); break; default: reRun = true; break; } break; } if (reRun == false) { break; } // The state machine is about to be re-run. This // means that a complete packet sequence wasn't collapsed // and there are packets in the queue that need to be // output before we can process the current packet. outputSaved(ref packetnum, ref signalErrors, collapseInfo, pktQ); } } // Stop the capture BeagleApi.bg_disable(beagle); }
public void OnChangeCollapseState(CollapseState collapseState) { this.collapseState = collapseState; UserModel.CollapseState = collapseState; UpdateData(); }
public void LoadNode(TNSProxy.IRelationship relationship, TNSProxy.INode node) { Proxy = node; if (node.Status == TNSProxy.LoadState.Full) { /// Check that there isn't more than one MapContainerRelationship. If there is then this node is transcluded. IEnumerable<TNSProxy.IRelationship> mapContainerRelationships = node.Relationships.FindRelationships(MapManager.ConnectionTypes["From"], MapManager.RelationshipTypes["MapContainerRelationship"]); NumTranclusions = mapContainerRelationships.Count(rel => rel.MapManager.RelationshipFactory.FindRelationship(rel.Id) != null); IsTranscluded = (NumTranclusions > 1); //BUG: value changes based on the current view, possibly incorrect as the node is either transcluded or not transcluded regardless of the view TNSProxy.NodeMetadataCollection metadata = node.Metadata; string xPositionAsString = "0"; string yPositionAsString = "0"; if (metadata.FindMetadata(relationship, "XPosition") != null) { xPositionAsString = metadata.FindMetadata(relationship, "XPosition").Value; } if (metadata.FindMetadata(relationship, "YPosition") != null) { yPositionAsString = metadata.FindMetadata(relationship, "YPosition").Value; } if (metadata.FindMetadata(relationship, "CollapseState") != null) { _viewerCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "CollapseState").Value, true); } else { _viewerCollapseState = CollapseState.None; } if (metadata.FindMetadata(relationship, "Visibility") != null) { _viewerVisibility = metadata.FindMetadata(relationship, "Visibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase) ? Visibility.Visible : Visibility.Collapsed; } else { _viewerVisibility = Visibility.Visible; } if (metadata.FindMetadata(relationship, "AuthorCollapseState") != null) { _authorCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "AuthorCollapseState").Value, true); } else { _authorCollapseState = CollapseState.None; } if (metadata.FindMetadata(relationship, "AuthorVisibility") != null) { _authorVisibility = metadata.FindMetadata(relationship, "AuthorVisibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase) ? Visibility.Visible : Visibility.Collapsed; } else { _authorVisibility = Visibility.Visible; } if (!string.IsNullOrEmpty(xPositionAsString) && !string.IsNullOrEmpty(yPositionAsString)) { double xPosition; double yPosition; if (double.TryParse(xPositionAsString, out xPosition) && double.TryParse(yPositionAsString, out yPosition)) { _location = new Point(xPosition, yPosition); } } IDictionary<string, TNSProxy.IMetadataSet> nodeMetadata = metadata.FindMetadata(null, (TNSProxy.ConnectionType)null); foreach (TNSProxy.IMetadataSet metadataSet in nodeMetadata.Values) { IMetadata viewModelMetadata = ViewModelMetadataFactory.CreateMetadata(metadataSet); viewModelMetadata.PropertyChanged += OnMetadataPropertyChanged; Metadata.Add(viewModelMetadata.Name, viewModelMetadata); NodeProperties.UIMetadata.Add(viewModelMetadata.Name, viewModelMetadata.Value); } if (!_isMetadataChangeRegistered) { Metadata.CollectionChanged += OnCollectionChanged; _isMetadataChangeRegistered = true; } } }
public void LoadNode(TNSProxy.IRelationship relationship, TNSProxy.INode node) { Proxy = node; if (node.Status == TNSProxy.LoadState.Full) { /// Check that there isn't more than one MapContainerRelationship. If there is then this node is transcluded. IEnumerable <TNSProxy.IRelationship> mapContainerRelationships = node.Relationships.FindRelationships(MapManager.ConnectionTypes["From"], MapManager.RelationshipTypes["MapContainerRelationship"]); NumTranclusions = mapContainerRelationships.Count(rel => rel.MapManager.RelationshipFactory.FindRelationship(rel.Id) != null); IsTranscluded = (NumTranclusions > 1); //BUG: value changes based on the current view, possibly incorrect as the node is either transcluded or not transcluded regardless of the view TNSProxy.NodeMetadataCollection metadata = node.Metadata; string xPositionAsString = "0"; string yPositionAsString = "0"; if (metadata.FindMetadata(relationship, "XPosition") != null) { xPositionAsString = metadata.FindMetadata(relationship, "XPosition").Value; } if (metadata.FindMetadata(relationship, "YPosition") != null) { yPositionAsString = metadata.FindMetadata(relationship, "YPosition").Value; } if (metadata.FindMetadata(relationship, "CollapseState") != null) { _viewerCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "CollapseState").Value, true); } else { _viewerCollapseState = CollapseState.None; } if (metadata.FindMetadata(relationship, "Visibility") != null) { _viewerVisibility = metadata.FindMetadata(relationship, "Visibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase) ? Visibility.Visible : Visibility.Collapsed; } else { _viewerVisibility = Visibility.Visible; } if (metadata.FindMetadata(relationship, "AuthorCollapseState") != null) { _authorCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "AuthorCollapseState").Value, true); } else { _authorCollapseState = CollapseState.None; } if (metadata.FindMetadata(relationship, "AuthorVisibility") != null) { _authorVisibility = metadata.FindMetadata(relationship, "AuthorVisibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase) ? Visibility.Visible : Visibility.Collapsed; } else { _authorVisibility = Visibility.Visible; } if (!string.IsNullOrEmpty(xPositionAsString) && !string.IsNullOrEmpty(yPositionAsString)) { double xPosition; double yPosition; if (double.TryParse(xPositionAsString, out xPosition) && double.TryParse(yPositionAsString, out yPosition)) { _location = new Point(xPosition, yPosition); } } IDictionary <string, TNSProxy.IMetadataSet> nodeMetadata = metadata.FindMetadata(null, (TNSProxy.ConnectionType)null); foreach (TNSProxy.IMetadataSet metadataSet in nodeMetadata.Values) { IMetadata viewModelMetadata = ViewModelMetadataFactory.CreateMetadata(metadataSet); viewModelMetadata.PropertyChanged += OnMetadataPropertyChanged; Metadata.Add(viewModelMetadata.Name, viewModelMetadata); NodeProperties.UIMetadata.Add(viewModelMetadata.Name, viewModelMetadata.Value); } if (!_isMetadataChangeRegistered) { Metadata.CollectionChanged += OnCollectionChanged; _isMetadataChangeRegistered = true; } } }