/// <summary> /// The <see cref="Control.Click"/> event handler for the /// <see cref="ToolStripComboBox"/> <see cref="cmuShuffle"/>. /// Occurs when the context menues combine to trial entry is clicked. /// Combines the selected nodes to a trial, if applicable create a new group for /// the trial. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An empty <see cref="EventArgs"/>.</param> private void cmuCombineToTrial_Click(object sender, EventArgs e) { if (this.cmuCombineToTrial.Checked) { NodesCollection nodes = this.trvSlideshow.SelectedNodes; if (nodes.Count > 1) { SlideshowTreeNode firstNode = nodes[0] as SlideshowTreeNode; if (firstNode.Slide != null) { TreeNode parent = firstNode.Parent; foreach (TreeNode subNode in nodes) { if (subNode.Parent != parent) { ExceptionMethods.ProcessMessage( "Please note:", "You can only combine slides with the same parent node to a trial."); return; } } // If all nodes of parent were marked to be a trial // it is enough to mark the parent with the "Trial" tag, // except it is the base node // otherwise create a new "Trial" marked group with the items if (parent.Nodes.Count != nodes.Count || parent.Text == "Slideshow") { this.MoveNodesLevelUp(nodes, true); } else { parent.Tag = "Trial"; ((SlideshowTreeNode)parent).Randomize = false; ((SlideshowTreeNode)parent).SetTreeNodeImageKey((SlideshowTreeNode)parent); } } else { ExceptionMethods.ProcessMessage( "Please note:", "You can only combine slide nodes to a trial."); } } } else { // Remove trial tag NodesCollection nodes = this.trvSlideshow.SelectedNodes; if (nodes.Count == 1) { SlideshowTreeNode firstNode = nodes[0] as SlideshowTreeNode; firstNode.Tag = string.Empty; } } this.trvSlideshow.Invalidate(); this.lsvDetails.Invalidate(); }
public CNeuroNetWrapper(int numInputs, int numOutputs) { _cnet = CNeuroNetWrapperFunctions.__NewNeuroNet(numInputs, numOutputs); _numInputs = numInputs; _numOutputs = numOutputs; _connections = ConnectionsCollection.GetLinkedCollection(_cnet); _nodes = NodesCollection.GetLinkedConnection(_cnet); }
public static void SetSecondary(DependencyObject dependencyObject, NodesCollection nodes) { if (nodes != null) { ((IAttachedObject)nodes).Attach(dependencyObject); } dependencyObject.SetValue(SecondaryProperty, nodes); }
/// <summary>Развертывание информации в LispEnvNodeDescriptor из полученного экземпляра обьекта</summary> public static LispEnvNodeDescriptor LispEnvNodeFactory(NodesCollection col, params object[] args) { //XXX:возможно нужно дописать ILisp l = Lisp.Current; LispEnvNodeDescriptor node = new LispEnvNodeDescriptor(); node.NodeType = "LispEnvNodeDescriptor"; node.MembersCount = l.Interpreter.CurrentPackage.ExternalTable.Count + l.Interpreter.CurrentPackage.InternalTable.Count; return node; }
public override Node VisitIdentifiers(TParser.IdentifiersContext context) { var nodes = new NodesCollection <Identifier>(context.Start); foreach (var exp in context.Identifier()) { nodes.Add(new Identifier(exp.GetText(), exp.Symbol)); } return(nodes); }
public override Node VisitStatements(TParser.StatementsContext context) { var nodes = new NodesCollection <Node>(context.Start); foreach (var statement in context.statement()) { nodes.Add(Visit(statement)); } return(nodes); }
public override Node VisitCommaExpressions(TParser.CommaExpressionsContext context) { var nodes = new NodesCollection <Node>(context.Start); foreach (var exp in context.expression()) { nodes.Add(Visit(exp)); } return(nodes); }
/// <summary> /// Create random problem with given number of nodes /// </summary> /// <param name="numberOfNodes">number of nodes in the proble</param> /// <param name="width">problem space width</param> /// <param name="height">problem space height</param> /// <returns>Generated problem</returns> public static NodesCollection MakeNodes(int numberOfNodes, int width, int height) { Random random = new Random((int)DateTime.Now.Ticks); NodesCollection nodes = new NodesCollection(); for (int i = 0; i < numberOfNodes; i++) { nodes.Add(new Node2D(i + 1, random.NextDouble() * width, random.NextDouble() * height)); } return nodes; }
/// <summary> /// Create random problem with given number of nodes /// </summary> /// <param name="numberOfNodes">number of nodes in the proble</param> /// <param name="width">problem space width</param> /// <param name="height">problem space height</param> /// <returns>Generated problem</returns> public static NodesCollection MakeNodes(int numberOfNodes, int width, int height) { Random random = new Random((int)DateTime.Now.Ticks); NodesCollection nodes = new NodesCollection(); for (int i = 0; i < numberOfNodes; i++) { nodes.Add(new Node2D(i + 1, random.NextDouble() * width, random.NextDouble() * height)); } return(nodes); }
/// <summary> /// Loads nodes that are depots /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>Nodes that are depots</returns> protected List <INode> LoadDepots(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); NodesCollection result = new NodesCollection(); foreach (int id in tspFile.Depots) { result.Add(graphNodes.FindById(id)); } return(result.ToList()); }
/// <summary> /// Loads demands for graph nodes /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>demands for graph nodes</returns> protected Dictionary <INode, int> LoadDemands(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); Dictionary <INode, int> result = new Dictionary <INode, int>(); foreach (int[] entry in tspFile.Demands) { result.Add(graphNodes.FindById(entry[0]), entry[1]); } return(result); }
public static NodesCollection GetLinkedConnection(IntPtr link) { NodesCollection c = null; if (link != null) { c = new NodesCollection(link); } return(c); }
public override Node VisitObjectAccess(TParser.ObjectAccessContext context) { var path = new NodesCollection <Node>(context.Start); VisitObjectAccess(context, path); var obj = new ObjectAccess(path[0], null, path[0].Position); foreach (var node in path.Skip(1)) { obj = new ObjectAccess(node, obj, node.Position); } return(obj); }
public static NodesCollection SelectAll() { NodesCollection List = new NodesCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblNodes_Select_SelectAll_linhnx")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
/// <summary> /// This method is blocking until all asked blocks are downloaded. /// Should be called only once till complete. /// </summary> public async Task <List <Block> > AskBlocks(CancellationToken token, ChainedBlock[] downloadRequests) { // no one should enter if already running Check.Assert(Interlocked.Increment(ref running) == 1); BlockingPullerBehavior[] nodes = GetNodeBehaviors(); var vectors = downloadRequests.Select(r => new InventoryVector(InventoryType.MSG_BLOCK, r.HashBlock)).ToArray(); // find the best block var best = downloadRequests.OrderByDescending(p => p.Height).First(); //sort by height // Be careful to not ask block to a node that do not have it // (we can check the ChainBehavior.PendingTip to know where the node is standing) List <BlockingPullerBehavior> selectnodes = new List <BlockingPullerBehavior>(); foreach (var behavior in nodes) { // filter nodes that are still behind if (behavior.BestKnownTip?.Height >= best.Height) { selectnodes.Add(behavior); } } nodes = selectnodes.ToArray(); StartDownload(vectors, nodes); await Task.Delay(100, token); while (!token.IsCancellationRequested) { // check if blocks have arrived var pending = downloadRequests.Where(d => !this.downloadedBlocks.ContainsKey(d.HashBlock)).ToList(); if (!pending.Any()) { break; } var sorted = pending.OrderBy(p => p.Height).FirstOrDefault(); //sort by height // call to stalling blocks this.OnStalling(sorted); // use the earliest block for stalling await Task.Delay(100, token); } var downloaded = this.downloadedBlocks.Values.ToList(); this.downloadedBlocks.Clear(); running = 0; return(downloaded); }
public override Node VisitObjectDeclaration(TParser.ObjectDeclarationContext context) { var col = new NodesCollection <ObjectMember>(context.Start); if (context.objectMember() == null) { return(col); } foreach (var member in context.objectMember()) { col.Add(VisitObjectMember(member).As <ObjectMember>()); } return(new ObjectDeclaration(col, context.Start)); }
public override Node VisitArrayDeclaration(TParser.ArrayDeclarationContext context) { var col = new NodesCollection <Node>(context.Start); if (context.commaExpressions() == null) { return(new ArrayDeclaration(col, context.Start)); } foreach (var exp in context.commaExpressions().expression()) { col.Add(Visit(exp)); } return(new ArrayDeclaration(col, context.Start)); }
public static NodesCollection SelectByWf(string WF_ID) { NodesCollection List = new NodesCollection(); SqlParameter[] obj = new SqlParameter[1]; obj[0] = new SqlParameter("WF_ID", WF_ID); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblNodes_Select_SelectByWf_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public NodesGroup( Network network, NodeConnectionParameters connectionParameters = null, NodeRequirement requirements = null) { AllowSameGroup = false; MaximumNodeConnection = 8; _Network = network; cs = new object(); _ConnectedNodes = new NodesCollection(); _ConnectionParameters = connectionParameters ?? new NodeConnectionParameters(); _ConnectionParameters = _ConnectionParameters.Clone(); _Requirements = requirements ?? new NodeRequirement(); _Disconnect = new CancellationTokenSource(); }
protected BlockPuller(ConcurrentChain chain, NodesCollection nodes) { this.Chain = chain; this.Nodes = nodes; this.DownloadedBlocks = new ConcurrentDictionary <uint256, DownloadedBlock>(); this.pendingInventoryVectors = new ConcurrentBag <uint256>(); this.map = new ConcurrentDictionary <uint256, BlockPullerBehavior>(); // set the default requirements this.requirements = new NodeRequirement { MinVersion = ProtocolVersion.SENDHEADERS_VERSION, RequiredServices = NodeServices.Network }; }
/// <summary> /// The <see cref="Control.DragDrop"/> event handler for the /// <see cref="TreeView"/> <see cref="trvSlideshow"/>. /// Occurs when a drag-and-drop operation is completed. /// Inserts the moved or copied tree node item and updates the member slideshow. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An <see cref="DragEventArgs"/> that contains the event data. </param> private void trvSlideshow_DragDrop(object sender, DragEventArgs e) { // If the insertion mark is not visible, exit the method. if (e.Effect == DragDropEffects.None) { return; } // Retrieve the client coordinates of the mouse pointer. Point targetPoint = this.trvSlideshow.PointToClient(new Point(e.X, e.Y)); TreeNode targetItem = this.trvSlideshow.GetNodeAt(targetPoint); // Retrieve the dragged items. NodesCollection draggedItems = (NodesCollection)e.Data.GetData(typeof(NodesCollection)); this.trvSlideshow.BeginUpdate(); if (e.Effect == DragDropEffects.Move) { foreach (TreeNode node in draggedItems) { // Update TreeView node.Parent.Nodes.Remove(node); targetItem.Nodes.Add(node); } } else if (e.Effect == DragDropEffects.Copy) { List <string> names = new List <string>(); this.slideshow.GetNodeNames(this.slideshow, ref names); foreach (TreeNode node in draggedItems) { // Update TreeView And Slideshow names SlideshowTreeNode copyNode = (SlideshowTreeNode)node.Clone(); this.RenameNodes(copyNode, ref names); targetItem.Nodes.Add(copyNode); } } this.trvSlideshow.EndUpdate(); this.SlideShowModified(); this.UpdateListView(this.trvSlideshow.SelectedNodes); }
static void Main(string[] args) { Console.WriteLine("[AdlibGraph Version 1.0]"); if (args.Length < 2) { Console.WriteLine("Usage: AdlibGraph applicationFolder dgmlFile"); return; } var adlibNodes = new NodesCollection(); try { var stopWatch = new Stopwatch(); stopWatch.Start(); adlibNodes.LoadNodes(args[0]); adlibNodes.CreateApplicationEdges(); stopWatch.Stop(); Console.WriteLine($"Data for '{args[0]}' loaded in {stopWatch.ElapsedMilliseconds} mS.\n"); const int columnWidth = 8; Console.WriteLine($" {"Nodes",columnWidth} {"Unused",columnWidth} {"%",columnWidth}"); Console.WriteLine($"Applications : {adlibNodes.ApplicationCount,columnWidth:#} {0,columnWidth:#}"); Console.WriteLine($"Methods : {adlibNodes.MethodCount,columnWidth:#} {adlibNodes.UnusedMethodsCount,columnWidth:#}"); Console.WriteLine($"Databases : {adlibNodes.DatabaseCount,columnWidth:#} {adlibNodes.UnusedDatabaseCount,columnWidth:#} {adlibNodes.UnusedDatabaseCount / (double)adlibNodes.DatabaseCount,columnWidth:P1}"); Console.WriteLine($"Screens : {adlibNodes.ScreenCount,columnWidth:#} {adlibNodes.UnusedScreensCount,columnWidth:#} {adlibNodes.UnusedScreensCount / (double)adlibNodes.ScreenCount,columnWidth:P1}"); Console.WriteLine($"Fields : {adlibNodes.FieldCount,columnWidth:#} {adlibNodes.UnusedFieldsCount,columnWidth:#} {adlibNodes.UnusedFieldsCount / (double)adlibNodes.FieldCount,columnWidth:P1}"); Console.WriteLine($"Indexes : {adlibNodes.IndexCount,columnWidth:#} {adlibNodes.UnusedIndexesCount,columnWidth:#} {adlibNodes.UnusedIndexesCount / (double)adlibNodes.IndexCount,columnWidth:P1}"); Console.WriteLine(); Console.WriteLine($"Writing {args[1]}"); adlibNodes.SaveDgml(args[1]); Console.WriteLine("Done"); //adlibNodes.DeleteIndexes(); //adlibNodes.DeleteScreens(); } catch (DirectoryNotFoundException ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public NodeServer(Network network, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION, int internalPort = -1) { AllowLocalPeers = true; InboundNodeConnectionParameters = new NodeConnectionParameters(); internalPort = internalPort == -1 ? network.DefaultPort : internalPort; _LocalEndpoint = new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), internalPort); _Network = network; _ExternalEndpoint = new IPEndPoint(_LocalEndpoint.Address, Network.DefaultPort); _Version = version; var listener = new EventLoopMessageListener<IncomingMessage>(ProcessMessage); _MessageProducer.AddMessageListener(listener); OwnResource(listener); _ConnectedNodes = new NodesCollection(); _ConnectedNodes.Added += _Nodes_NodeAdded; _ConnectedNodes.Removed += _Nodes_NodeRemoved; _ConnectedNodes.MessageProducer.AddMessageListener(listener); _Trace = new TraceCorrelation(NodeServerTrace.Trace, "Node server listening on " + LocalEndpoint); }
public override Node VisitCodeBlock(TParser.CodeBlockContext context) { var body = new NodesCollection <Node>(context.Start); if (context.expression() != null && !context.expression().IsEmpty) { body.Add(Visit(context.expression())); } else if (context.statements() != null && !context.statements().IsEmpty) { body = VisitStatements(context.statements()).As <NodesCollection <Node> >(); } else if (context.statement() != null && !context.statement().IsEmpty) { body.Add(Visit(context.statement())); } return(body); }
/// <summary> /// Build fixed edges given in tsp file /// </summary> /// <param name="nodes">graph nodes</param> /// <returns>List of fixed edges</returns> protected List <IEdge> LoadFixedEdges(IEnumerable <INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); List <IEdge> result = new List <IEdge>(); if (tspFile.FixedEdges != null) { foreach (int[] entry in tspFile.FixedEdges) { if (entry[0] == -1) { break; } result.Add(new Edge(graphNodes.FindById(entry[0]), graphNodes.FindById(entry[1]))); } } return(result); }
private void VisitObjectAccess(TParser.ObjectAccessContext context, NodesCollection <Node> path) { while (true) { var id = new Identifier(context.Identifier().GetText(), context.Identifier().Symbol); path.Add(id); var leftExp = context.expression(); if (leftExp is TParser.ObjectAccessContext objCtx) { context = objCtx; continue; } else { path.Add(Visit(leftExp)); } break; } }
public StatusBarViewModel(NodesCollection nodes, MemPoolService memPoolService, IndexDownloader indexDownloader) { Nodes = nodes; Nodes.Added += Nodes_Added; Nodes.Removed += Nodes_Removed; Peers = Nodes.Count; MemPoolService = memPoolService; MemPoolService.TransactionReceived += MemPoolService_TransactionReceived; Mempool = MemPoolService.TransactionHashes.Count; IndexDownloader = indexDownloader; IndexDownloader.NewFilter += IndexDownloader_NewFilter; IndexDownloader.BestHeightChanged += IndexDownloader_BestHeightChanged; IndexDownloader.TorStatusChanged += IndexDownloader_TorStatusChanged; IndexDownloader.BackendStatusChanged += IndexDownloader_BackendStatusChanged; FiltersLeft = IndexDownloader.GetFiltersLeft(); this.WhenAnyValue(x => x.BlocksLeft).Subscribe(blocks => { SetStatus(); }); this.WhenAnyValue(x => x.FiltersLeft).Subscribe(filters => { SetStatus(); }); this.WhenAnyValue(x => x.Tor).Subscribe(tor => { SetStatus(); }); this.WhenAnyValue(x => x.Backend).Subscribe(backend => { SetStatus(); }); this.WhenAnyValue(x => x.Peers).Subscribe(peers => { SetStatus(); }); }
/// <summary> /// The <see cref="Control.DragOver"/> event handler for the /// <see cref="TreeView"/> <see cref="trvSlideshow"/>. /// Occurs when an object is dragged over the control's bounds. /// Updates the drag cursor with copy or move state, referring to Modifier Key. /// Ensures the visibility of the item under the mouse cursor. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An <see cref="DragEventArgs"/> that contains the event data. </param> private void trvSlideshow_DragOver(object sender, DragEventArgs e) { // Retrieve the client coordinates of the mouse pointer. Point targetPoint = this.trvSlideshow.PointToClient(new Point(e.X, e.Y)); SlideshowTreeNode targetNode = this.trvSlideshow.GetNodeAt(targetPoint) as SlideshowTreeNode; // Retrieve the dragged items. NodesCollection draggedItems = (NodesCollection)e.Data.GetData(typeof(NodesCollection)); if (targetNode != null) { if (((SlideshowTreeNode)draggedItems[0]).Contains(targetNode) || targetNode == draggedItems[0]) { e.Effect = DragDropEffects.None; return; } bool isSlide = targetNode.Slide != null; // If target is not a slide if (!isSlide) { if (Control.ModifierKeys == Keys.Control) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.Move; } return; } } e.Effect = DragDropEffects.None; }
int IComparer <INode> .Compare(INode x, INode y) { var list = new NodesCollection(); var mf = list.Nodes; var intA = mf.FindIndex(p => p.Equals(x)); var intB = mf.FindIndex(p => p.Equals(y)); if (intA > intB) { return(1); } if (intA < intB) { return(-1); } else { return(0); } throw new NotImplementedException(); }
protected virtual IParsedLambda CreateParsedLambda() { //PERF: This ugly processing of nodes for both transformers in one loop is for performance. Perhaps move bach to older cleaner solution var nullableNodeTransformer = new NullableNodeTransformer(); var boolNodeTransformer = new BoolNodeTransformer(); var newNodes = new NodesCollection(); var maxIndex = Nodes.Count; for (var i = 0; i < Nodes.Count; i++) { var nullableNodes = nullableNodeTransformer.Transform(maxIndex, ref i, Nodes[i], Nodes); var merged = nullableNodes.MergeWith(Nodes.Skip(i + 1)).ToArray(); var maxIndexInner = nullableNodes.Length; for (var iInner = 0; iInner < maxIndexInner; iInner++) { var boolNodes = boolNodeTransformer.Transform(maxIndexInner, ref iInner, merged[iInner], new NodesCollection(merged)); newNodes.AddNodes(boolNodes); } } return(new ParsedLambda(newNodes.ToArray())); }
public override ArrayListSerialized Trace(NodesCollection c, NodeDescriptor d, string arcName) { arcName = (arcName == null) ? null : arcName.ToLower(); ArrayListSerialized res = new ArrayListSerialized(); int x = arcName.IndexOf(":"); string ns = ""; if (x >= 0) { ns = arcName.Substring(0, x).Trim(); arcName = arcName.Substring(x + 1).Trim(); } if (d.SubNodes == null) d.SubNodes = new ArrayListSerialized(); if (ns == "special") { if (arcName == "functions") { res = Functions(c, d); } else if (arcName == "vars") { res = Vars(c, d); } d.SubNodes.AddRange(res); } return res; }
public virtual IParsedLambda Parse(OrderByExpression[] orderByExpressions) { Ensure.That(orderByExpressions, "orderByExpressions").HasItems(); var nodesContainer = new NodesCollection(); foreach (var orderByExpression in orderByExpressions.Where(e => e != null)) { var memberExpression = orderByExpression.InnerLambdaExpression.Body.GetRightMostMember(); if (memberExpression == null) { throw new SisoDbException(ExceptionMessages.OrderByExpressionDoesNotTargetMember.Inject(orderByExpression.ToString())); } var callExpression = (orderByExpression.InnerLambdaExpression.Body is UnaryExpression) ? ((UnaryExpression)orderByExpression.InnerLambdaExpression.Body).Operand as MethodCallExpression : orderByExpression.InnerLambdaExpression.Body as MethodCallExpression; if (callExpression != null) { throw new SisoDbException(ExceptionMessages.OrderByParser_UnsupportedMethodForSortingDirection); } var memberType = memberExpression.Type; if (memberType.IsEnumerableType()) { memberType = memberType.GetEnumerableElementType(); } var sortDirection = orderByExpression is OrderByAscExpression ? SortDirections.Asc : SortDirections.Desc; var memberPath = memberExpression.ToPath(); var sortingNode = new SortingNode(memberPath, memberType, DataTypeConverter.Convert(memberType, memberPath), sortDirection); nodesContainer.AddNode(sortingNode); } return(new ParsedLambda(nodesContainer.ToArray())); }
/// <summary> /// This method adds the given <see cref="Slide"/> at the /// current treeview position. /// </summary> /// <param name="newSlide">The new <see cref="Slide"/> to be added to the slideshow.</param> private void AddSlide(Slide newSlide) { // Add node SlideshowTreeNode slideNode = new SlideshowTreeNode(newSlide.Name); slideNode.Name = this.slideshow.GetUnusedNodeID(); slideNode.Slide = newSlide; ((SlideshowTreeNode)slideNode).SetTreeNodeImageKey((SlideshowTreeNode)slideNode); // Get root node for insertion SlideshowTreeNode firstNode = this.trvSlideshow.Nodes[0] as SlideshowTreeNode; // If there is a selected node use this instead NodesCollection selectedNodes = this.trvSlideshow.SelectedNodes; if (selectedNodes.Count > 0) { firstNode = selectedNodes[0] as SlideshowTreeNode; this.trvSlideshow.SelectedNodes.Clear(); } // Add to node, if it is a slide node add to parent instead if (firstNode.Slide != null) { firstNode.Parent.Nodes.Add(slideNode); } else { firstNode.Nodes.Add(slideNode); } // Select added node. this.trvSlideshow.SelectedNodes.Add(slideNode); this.UpdateListView(this.trvSlideshow.SelectedNodes); }
public CNeuroNetWrapper(CNeuroNetWrapper copy) { _numInputs = copy._numInputs; _numOutputs = copy._numOutputs; _cnet = CNeuroNetWrapperFunctions.__NewNeuroNet(_numInputs, _numOutputs); foreach (var n in copy.Nodes) { if (n.ID > _numInputs + _numOutputs) { CNeuroNetWrapperFunctions.__AddNode(_cnet, n.ID); } } foreach (var c in copy.Connections) { CNeuroNetWrapperFunctions.__AddConnection(_cnet, c.From, c.To, c.Weight); } _connections = ConnectionsCollection.GetLinkedCollection(_cnet); _nodes = NodesCollection.GetLinkedConnection(_cnet); }
protected virtual ArrayListSerialized Vars(NodesCollection c, NodeDescriptor d) { ArrayListSerialized res = new ArrayListSerialized(); ILisp l = Lisp.Current; foreach (Symbol s in l.Interpreter.CurrentPackage.ExternalTable.GetSymbols()) { if (s.IsDefined && !(s.GlobalValue is Front.Lisp.Closure)) { NodeDescriptor n = c.GetDescriptor(s.GlobalValue); n.NodePath = s.Name; n.NodeName = s.Name; res.Add(n); c.Add(n); } } foreach (Symbol s in l.Interpreter.CurrentPackage.InternalTable.GetSymbols()) { if (s.IsDefined && !(s.GlobalValue is Front.Lisp.Closure)) { NodeDescriptor n = c.GetDescriptor(s.GlobalValue); n.NodePath = s.Name; n.NodeName = s.Name; res.Add(n); c.Add(n); } } return res; }
/// <summary> /// This method moves the given nodes on level up. /// They can be marked as a trial using the second parameter. /// </summary> /// <param name="nodes">A <see cref="NodesCollection"/> with the <see cref="TreeView"/> nodes.</param> /// <param name="markAsTrial"><strong>True</strong> if the nodes in the collection /// are referred to be one trial in the presentation.</param> private void MoveNodesLevelUp(NodesCollection nodes, bool markAsTrial) { nodes.Sort(); if (nodes.Count > 0) { TreeNode firstNode = nodes[0]; // Skip if the node is the root node if (firstNode.Parent == null) { return; } int insertionIndex = firstNode.Index; string parentNodeName = this.slideshow.GetUnusedNodeID(); SlideshowTreeNode newParent = new SlideshowTreeNode(parentNodeName); newParent.Name = parentNodeName; if (markAsTrial) { newParent.Tag = "Trial"; } newParent.SetTreeNodeImageKey(newParent); firstNode.Parent.Nodes.Insert(insertionIndex, newParent); foreach (TreeNode collectionNode in nodes) { collectionNode.Remove(); newParent.Nodes.Add(collectionNode); } } this.UpdateListView(this.trvSlideshow.SelectedNodes); this.SlideShowModified(); }
public static NodeDescriptor ReflectedNodeFactory(NodesCollection col, params object[] args) { if (args != null && args.Length > 0) return ReflectionNodeHandler.DispatchNode(args[0]); return null; }
//......................................................................... protected virtual ArrayListSerialized SubNodes(NodesCollection c, NodeDescriptor node) { if (node.MembersCount == 0) return null; if (node.NodeObject == null) return null; if (node.SubNodes == null) node.SubNodes = new ArrayListSerialized(); if (node.SubNodes.Count > 0) return node.SubNodes; node.SubNodes.AddRange(GetPublicFields(c, node)); node.SubNodes.AddRange(GetPrivateFields(c, node)); node.SubNodes.AddRange(GetPublicProperties(c, node)); node.SubNodes.AddRange(GetPrivateProperties(c, node)); return node.SubNodes; }
/// <summary> /// This method loads the first node of the given nodes collection /// into the listview. /// </summary> /// <param name="nodes">A <see cref="NodesCollection"/> /// to be shown in the <see cref="ListView"/>.</param> private void UpdateListView(NodesCollection nodes) { if (nodes != null && nodes.Count > 0) { this.UpdateListView(nodes[0]); } }
protected virtual ArrayList GetPublicProperties(NodesCollection c, NodeDescriptor node) { ArrayList publishedFields = new ArrayList(); Type typeresolver = node.NodeObject.GetType(); PropertyInfo[] publicProperties = typeresolver.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance); if (publicProperties.Length > 0) { foreach (PropertyInfo property in publicProperties) { NodeDescriptor subNode = ExtractProperty(c, node, property); subNode.NodeName = property.Name; subNode.NodeMembership = NodeMemberships.isProperty; subNode.NodePublicity = NodePublicities.isNonPublic; node.SubNodes.Add(subNode); } } return publishedFields; }
public abstract ArrayListSerialized Trace(NodesCollection c, NodeDescriptor d, string arcName);
public List<Node> GetDrives() { var drivesList = new NodesCollection().GetDrives(); return drivesList; }
/// <summary> /// Loads nodes that are depots /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>Nodes that are depots</returns> protected List<INode> LoadDepots(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); NodesCollection result = new NodesCollection(); foreach (int id in tspFile.Depots) { result.Add(graphNodes.FindById(id)); } return result; }
//Public'i Fields protected virtual ArrayList GetPublicFields(NodesCollection c, NodeDescriptor node) { ArrayList publishedFields = new ArrayList(); Type typeresolver = node.NodeObject.GetType(); FieldInfo[] publicFields = typeresolver.GetFields(BindingFlags.Public | BindingFlags.Instance); if (publicFields.Length > 0) { foreach (FieldInfo field in publicFields) { object obj = field.GetValue(node.NodeObject); NodeDescriptor subNode = c.GetDescriptor(obj); subNode.NodeName = field.Name; subNode.NodeMembership = NodeMemberships.isField; subNode.NodePublicity = NodePublicities.isPublic; node.SubNodes.Add(subNode); } } return publishedFields; }
public override ArrayListSerialized Trace(NodesCollection c, NodeDescriptor d, string arcName) { arcName = (arcName == null) ? null : arcName.ToLower(); ArrayListSerialized res = new ArrayListSerialized(); int x = arcName.IndexOf(":"); string ns = ""; if (x >= 0) { ns = arcName.Substring(0, x).Trim(); arcName = arcName.Substring(x + 1).Trim(); } if (ns == "special") { if (arcName == "subnodes") { // TODO: рефлектим на запчасти! res = SubNodes(c, d); } } else { if (ns == "") { // TODO: ищем Member'ы c именем arcName } else { // TODO: пока ничего... потом придумаем :-) } } return res; }
public static ExceptionNode ExeptionNodeFactory(NodesCollection col, params object[] args) { if (args != null && args.Length > 0) return ExeptionNodeHandler.DispatchNode(args[0]); return null; }
public override ArrayListSerialized Trace(NodesCollection c, NodeDescriptor d, string arcName) { ArrayListSerialized res = new ArrayListSerialized(); return res; }
/// <summary> /// This method moves the given nodes on level up. /// They can be marked as a trial using the second parameter. /// </summary> /// <param name="nodes">A <see cref="NodesCollection"/> with the <see cref="TreeView"/> nodes.</param> /// <param name="markAsTrial"><strong>True</strong> if the nodes in the collection /// are referred to be one trial in the presentation.</param> private void MoveNodesLevelUp(NodesCollection nodes, bool markAsTrial) { nodes.Sort(); if (nodes.Count > 0) { TreeNode firstNode = nodes[0]; // Skip if the node is the root node if (firstNode.Parent == null) { return; } int insertionIndex = firstNode.Index; string parentNodeName = this.slideshow.GetUnusedNodeID(); SlideshowTreeNode newParent = new SlideshowTreeNode(parentNodeName); newParent.Name = parentNodeName; if (markAsTrial) { newParent.Tag = "Trial"; } newParent.SetTreeNodeImageKey(newParent); firstNode.Parent.Nodes.Insert(insertionIndex, newParent); foreach (TreeNode collectionNode in nodes) { collectionNode.Remove(); newParent.Nodes.Add(collectionNode); } } this.UpdateListView(this.trvSlideshow.SelectedNodes); this.SlideShowModified(); }
public List<Node> GetNodes(Node node) { var nodeResponse = new NodesCollection().GetNodes(node); return nodeResponse; }
/// <summary> /// Loads demands for graph nodes /// </summary> /// <param name="nodes">all nodes in graph</param> /// <returns>demands for graph nodes</returns> protected Dictionary<INode, int> LoadDemands(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); Dictionary<INode, int> result = new Dictionary<INode, int>(); foreach (int[] entry in tspFile.Demands) { result.Add(graphNodes.FindById(entry[0]), entry[1]); } return result; }
/// <summary> /// Build fixed edges given in tsp file /// </summary> /// <param name="nodes">graph nodes</param> /// <returns>List of fixed edges</returns> protected List<IEdge> LoadFixedEdges(IEnumerable<INode> nodes) { NodesCollection graphNodes = new NodesCollection(nodes); List<IEdge> result = new List<IEdge>(); if (tspFile.FixedEdges != null) { foreach (int[] entry in tspFile.FixedEdges) { if (entry[0] == -1) { break; } result.Add(new Edge(graphNodes.FindById(entry[0]), graphNodes.FindById(entry[1]))); } } return result; }
protected virtual NodeDescriptor ExtractProperty(NodesCollection c, NodeDescriptor node, PropertyInfo property) { NodeDescriptor subNode; object obj = null; ParameterInfo[] parInfos = property.GetIndexParameters(); if (parInfos.Length == 0) { try { obj = property.GetValue(node.NodeObject, null); subNode = c.GetDescriptor(obj); } catch (Exception ex){ return c.GetDescriptor(ex); } } else { obj = property; subNode = c.GetDescriptor(obj); subNode.MembersCount = parInfos.Length; subNode.TypeName = property.ReflectedType.Name; subNode.Value = ""; foreach (ParameterInfo parInfo in parInfos) { subNode.Value += string.Format("[{0} {1}] ", parInfo.Name, parInfo.ParameterType.Name); } } return subNode; }