public static NodeCollection BuildFirstLevel() { string path = HttpContext.Current.Server.MapPath("~/Examples/"); DirectoryInfo root = new DirectoryInfo(path); DirectoryInfo[] folders = root.GetDirectories(); folders = UIHelpers.SortFolders(root, folders); NodeCollection nodes = new NodeCollection(false); foreach (DirectoryInfo folder in folders) { if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden || excludeList.Contains(folder.Name) || folder.Name.StartsWith("_")) { continue; } ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false); string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls; Node node = new Node(); node.Text = UIHelpers.MarkNew(folder.FullName, folder.Name.Replace("_", " ")); node.IconCls = iconCls; string url = UIHelpers.PhysicalToVirtual(folder.FullName + "/"); node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode()); nodes.Add(node); } return nodes; }
public string GetNodes(string node) { NodeCollection nodes = new NodeCollection(false); if (!string.IsNullOrEmpty(node)) { for (int i = 1; i < 6; i++) { Node asyncNode = new Node(); asyncNode.Text = node + i; asyncNode.NodeID = node + i; nodes.Add(asyncNode); } for (int i = 6; i < 11; i++) { Node treeNode = new Node(); treeNode.Text = node + i; treeNode.NodeID = node + i; treeNode.Leaf = true; nodes.Add(treeNode); } } return nodes.ToJson(); }
private void EvalCollection(IContext context, NodeCollection<ExpressionNode> collection, Stream writer) { foreach (ExpressionNode node in collection) { node.Execute(context, writer); } }
public ForStatement(Token relatedToken) : base(relatedToken) { _blockStatement = new BlockStatement(relatedToken); _init = new NodeCollection<ExpressionNode>(); _inc = new NodeCollection<ExpressionNode>(); }
public CompilationUnitNode() : base(new Token(TokenID.Invalid, 0, 0)) { namespaces = new NodeCollection<NamespaceNode>(); defaultNamespace = new NamespaceNode(RelatedToken); }
public static NodeCollection GetExamplesNodes() { var nodes = new NodeCollection(); string path = HttpContext.Current.Server.MapPath(ExamplesModel.ExamplesRoot); return ExamplesModel.BuildAreasLevel(); }
public ActionResult GetNodes(string node) { if (!string.IsNullOrEmpty(node)) { NodeCollection nodes = new NodeCollection(); SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node); if (siteMapNode == null) { return this.Store(nodes); } SiteMapNodeCollection children = siteMapNode.ChildNodes; if (children != null && children.Count > 0) { foreach (SiteMapNode mapNode in siteMapNode.ChildNodes) { nodes.Add(NodeHelper.CreateNodeWithOutChildren(mapNode)); } } return this.Store(nodes); } return new HttpStatusCodeResult(500); }
public SolverValidator(Solver solver, NodeCollection nodes, Node root, IPositionLookupTable<Node> transpositionTable) { this.solver = solver; this.nodes = nodes; this.root = root; this.transpositionTable = transpositionTable; }
public PPPragmaNode(IdentifierExpression identifier, NodeCollection<ConstantExpression> value, PragmaAction action) : base(identifier.RelatedToken) { this.identifier = identifier; this.value = value; this.Action = action; }
public CompilationUnitNode(): base(new Token( TokenID.Invalid, 0, 0) ) { this.globalAttributes = new NodeCollection<AttributeNode>(); this.namespaces = new NodeCollection<NamespaceNode>(); this.defaultNamespace = new NamespaceNode(RelatedToken); }
public Element(string name, string text, params IAttribute[] attributes) { this._Name = name; this._Attributes = new AttributeCollection(attributes); this._Children = new NodeCollection(new Text(text)); }
/// <summary> /// Get all the children recursive and flattens it into the given list. /// </summary> /// <param name="parent">The parent.</param> /// <param name="listToFill">The list to fill.</param> private void FlattenChildren(Node parent, ref NodeCollection listToFill) { listToFill.Add(parent); foreach (var child in parent.Children) { this.FlattenChildren(child, ref listToFill); } }
public Table() { this.Header = new Header(); this.Details = new Details(); this.TableColumns = new NodeCollection<TableColumn>(); this.TableGroups = new NodeCollection<TableGroup>(); this.Style = new Style(); }
//PageHeader //PageFooter //InteractiveHeight //InteractiveWidth //EmbeddedImages //CodeModules //Classes //DataTransform public Report() { this.DataSources = new NodeCollection<DataSource>(); this.DataSets = new NodeCollection<XDataSet>(); this.EmbeddedImages = new NodeCollection<EmbeddedImage>(); this.ReportParameters = new NodeCollection<ReportParameter>(); }
public Scene() { _renderableNodes = new NodeCollection(); _flatNodes = new NodeCollection(); _environmentalNodes = new NodeCollection(); AmbientColor = Color.FromArgb(0xff, 0x3f, 0x3f, 0x3f); }
/// <summary> /// Makes a diffing engine for collections of elements. /// </summary> /// <param name="expected">The expected elements.</param> /// <param name="actual">The actual elements.</param> /// <param name="path">The current path of the parent node.</param> /// <param name="pathExpected">The path of the parent node of the parent collection.</param> /// <param name="options">Equality options.</param> /// <returns>The resulting diffing engine.</returns> public static IDiffEngine<NodeCollection> ForElements(NodeCollection expected, NodeCollection actual, IXmlPathStrict path, IXmlPathStrict pathExpected, Options options) { if ((options & Options.IgnoreElementsOrder) != 0) { return new DiffEngineForUnorderedElements(expected, actual, path, pathExpected, options); } return new DiffEngineForOrderedItems<NodeCollection, INode>(expected, actual, path, pathExpected, options, OrderedItemType.Element); }
/// <summary> /// Reorder child nodes matching ChildNodeNames /// </summary> /// <param name="element">Element thats getting its children reordered</param> private void ReorderChildNodes(XElement element) { List<NodeCollection> nodeCollections = new List<NodeCollection>(); var children = element.Nodes(); // This indicates if last element matched ChildNodeNames bool inMatchingChildBlock = false; // This value changes each time a non matching ChildNodeName is reached ensuring that only sortable elements are reordered int childBlockIndex = 0; NodeCollection currentNodeCollection = null; // Run through children foreach (var child in children) { if (currentNodeCollection == null) { currentNodeCollection = new NodeCollection(); nodeCollections.Add(currentNodeCollection); } if (child.NodeType == XmlNodeType.Element) { XElement childElement = (XElement)child; var isMatchingChild = ChildNodeNames.Any(match => match.IsMatch(childElement.Name)); if (isMatchingChild == false || inMatchingChildBlock == false) { childBlockIndex++; inMatchingChildBlock = isMatchingChild; } if (isMatchingChild) { currentNodeCollection.SortAttributeValues = SortByAttributes.Select(x => x.GetValue(childElement)).ToArray(); } currentNodeCollection.BlockIndex = childBlockIndex; } currentNodeCollection.Nodes.Add(child); if (child.NodeType == XmlNodeType.Element) currentNodeCollection = null; } if (currentNodeCollection != null) currentNodeCollection.BlockIndex = childBlockIndex + 1; // sort node list nodeCollections = nodeCollections.OrderBy(x => x).ToList(); // replace the element's nodes element.ReplaceNodes(nodeCollections.SelectMany(nc => nc.Nodes)); }
/// <summary>Flattens the whole tree structure underneath me into a simple list.</summary> /// <returns>A enumerable list of flattened nodes.</returns> public IEnumerable<Node> FlattenChildrenRecursive() { // create the list to populate var list = new NodeCollection(); // go recursive ! this.FlattenChildren(this, ref list); return list; }
public void Constructs_ok() { var mockMarkup1 = MockRepository.GenerateStub<INode>(); var mockMarkup2 = MockRepository.GenerateStub<INode>(); var mockMarkup3 = MockRepository.GenerateStub<INode>(); var array = new[] { mockMarkup1, mockMarkup2, mockMarkup3 }; var collection = new NodeCollection(array); Assert.Count(3, collection); Assert.AreElementsSame(array, collection); }
/// <summary> /// Constructs a node instance. /// </summary> /// <param name="type">The type of the node.</param> /// <param name="index">The index of the node.</param> /// <param name="count">The number of elements at the same level.</param> /// <param name="children">The children nodes.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="children"/> is null.</exception> protected NodeBase(NodeType type, int index, int count, IEnumerable<INode> children) { if (children == null) throw new ArgumentNullException("children"); this.type = type; this.index = index; this.count = count; this.children = new NodeCollection(children); }
private void InitializeTransform() { _isInitializingTransform = true; Position = new Coordinate(); PivotPoint = new Coordinate(); Scale = new Coordinate(1f, 1f, 1f); Rotation = new Coordinate(); _isInitializingTransform = false; Children = new NodeCollection(); PrepareWorld(); }
public Node() { Parent = null; Id = Guid.NewGuid().ToString(); Children = new NodeCollection( this ); CreatedAt = DateTime.Now; TrackModified = true; }
public static void Main(string[] args) { var file = new FileInfo("data.bin"); int nodeSize = 0; var collection = new NodeCollection(LoadNodes(file)); if (Log(args, collection)) { return; } if (args.Length == 0 || !Int32.TryParse(args[0], out nodeSize)) { nodeSize = 50000; } Console.Clear(); Console.WriteLine("Node size: {0:#,##0.0}k", nodeSize / 1000.0); var simulator = new Simulator(); var rnd = new MT19937Generator(); Merge(collection); var sw = Stopwatch.StartNew(); long runs = 0; var shrinks = 0; while (true) { runs++; ClearNewStatus(collection); simulator.Simulate(collection, rnd); Write(collection, sw, runs, shrinks); if ((runs & 15) == 15) { collection.Save(file); Merge(collection); } if (collection.Count > nodeSize) { var nodes = collection.ToList(); nodes.Shrink(); collection.Clear(); collection.AddRange(nodes); collection.Save(file); shrinks++; Write(collection, sw, runs, shrinks, true); } } }
public Node(NodeCollection nodes, int row, int column, Direction direction, int pushes, int moves) { this.id = nodes.Allocate(this); this.row = row; this.column = column; this.direction = direction; this.pushes = pushes; this.moves = moves; this.score = 0; #if DEBUG this.hashKey = HashKey.Empty; #endif }
private static void WriteNodes(NodeCollection nodes, StreamWriter writer, string prefix) { foreach (Node node in nodes) { writer.Write(prefix); writer.WriteLine(node.Path.Substring(node.Path.IndexOf(@"\"))); if (node.ChildNodes.Count > 0) { WriteNodes(node.ChildNodes, writer, prefix); } } }
public MainForm(NodeCollection nodes, TimerSwitch timerSwitch, Size clientSize) { InitializeComponent(); this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.nodes = nodes; this.timerSwitch = timerSwitch; this.ClientSize = clientSize; nodes.PropertyChanged += nodes_PropertyChanged; timerSwitch.PropertyChanged += timerSwitch_PropertyChanged; }
private static void Merge(NodeCollection nodes) { var dir = new DirectoryInfo("."); foreach (var file in dir.GetFiles("*.bin")) { if (file.Name != "data.bin") { Console.WriteLine(); nodes.AddRange(Nodes.Load(file)); Console.WriteLine("Merged {0}", file); file.Delete(); } } }
public Node(NodeCollection nodes, int id) { this.nodes = nodes; this.id = id; if (id == -1) { this.array = null; this.index = 0; } else { this.array = nodes.GetArray(this.id); this.index = nodes.GetIndex(this.id); } }
public StoreResult GetNodes(string node) { NodeCollection nodes = new NodeCollection(false); string prefix = DateTime.Now.Second + "_"; for (int i = 0; i < 10; i++) { Node newNode = new Node(); newNode.NodeID = i.ToString(); newNode.Text = prefix + i; newNode.Leaf = true; nodes.Add(newNode); } return this.Store(nodes); }
/// <summary> /// Move VSM to last child of element. /// </summary> /// <param name="element">Element that is getting its VSM moved to the end.</param> private void ReorderChildNodes(XElement element) { List<NodeCollection> nodeCollections = new List<NodeCollection>(); NodeCollection vsmNodeCollection = new NodeCollection(); var children = element.Nodes(); bool hasCollectionBeenAdded = false; NodeCollection currentNodeCollection = null; foreach (var child in children) { if (currentNodeCollection == null) { currentNodeCollection = new NodeCollection(); } currentNodeCollection.Nodes.Add(child); if (child.NodeType == XmlNodeType.Element) { if (this.VSMNode.IsMatch(((XElement)child).Name)) { // Extract VSM for adding to end. vsmNodeCollection = currentNodeCollection; hasCollectionBeenAdded = true; } else if (!hasCollectionBeenAdded) { // Maintain all other nodes. nodeCollections.Add(currentNodeCollection); hasCollectionBeenAdded = true; } currentNodeCollection = null; hasCollectionBeenAdded = false; } } var newNodes = (this.Mode == VisualStateManagerRule.Last) ? nodeCollections.SelectMany(_ => _.Nodes).Concat(vsmNodeCollection.Nodes) : vsmNodeCollection.Nodes.Concat(nodeCollections.SelectMany(_ => _.Nodes)); element.ReplaceNodes(newNodes); }
public void GetPatientDoc(NodeCollection nodes, Node node) { Patient_Doc doc = node.Tag as Patient_Doc; foreach (Node TempNode in nodes) { Class_Text text = TempNode.Tag as Class_Text; if (text != null) { if (text.Issimpleinstance == "1") //多例文书 { if (doc.Textkind_id == text.Id) { TempNode.Nodes.Add(node.DeepCopy()); //TempNode.SelectedImageIndex = 6; //TempNode.ImageIndex = 6; break; } } else { if (TempNode.Nodes.Count == 0) { if (doc.Textkind_id == text.Id) { //TempNode.SelectedImageIndex = 7; TempNode.ImageIndex = 7; break; } } } } if (TempNode.Nodes.Count > 0) { GetPatientDoc(TempNode.Nodes, node); } } }
public static NodeCollection BuildTreeNodes(bool refreshSiteMap) { XmlDocument map = null; XmlElement root = null; XmlElement examplesNode = null; if (refreshSiteMap) { map = new XmlDocument(); XmlDeclaration dec = map.CreateXmlDeclaration("1.0", "utf-8", null); map.AppendChild(dec); root = map.CreateElement("siteMap"); root.SetAttribute("xmlns", "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"); map.AppendChild(root); examplesNode = map.CreateElement("siteMapNode"); examplesNode.SetAttribute("title", "Moduls"); root.AppendChild(examplesNode); } // Reset the static rootCfg so that the main xml file is re-read. if (rootCfg != null) { rootCfg = null; } string path = HttpContext.Current.Server.MapPath("~/Moduls/"); NodeCollection result = UIHelpers.BuildTreeLevel(new DirectoryInfo(path), 1, 3, examplesNode); if (root != null && root.ChildNodes.Count > 0) { map.Save(HttpContext.Current.Server.MapPath("Web.sitemap")); } return(result); }
private void AddSonNode(List <ProgList> _list, NodeCollection _nodes, string parentid) { var _nodestyleBlue = new DevComponents.DotNetBar.ElementStyle(); _nodestyleBlue.TextColor = System.Drawing.Color.Blue; _nodestyleBlue.Font = new System.Drawing.Font("宋体", 14); _nodestyleBlue.BackColor = System.Drawing.Color.FromArgb(207, 221, 238); var _nodestyleRed = new DevComponents.DotNetBar.ElementStyle(); _nodestyleRed.TextColor = System.Drawing.Color.Red; _nodestyleRed.Font = new System.Drawing.Font("宋体", 14); _nodestyleRed.BackColor = System.Drawing.Color.FromArgb(207, 221, 238); var _mlist = _list.FindAll(t => t.Prog_ParantId == parentid); for (int i = 0; i < _mlist.Count; i++) { Node _node = new Node(); _node.Text = _mlist[i].Prog_Descp; _node.Name = _mlist[i].Prog_CLS; _node.Tag = _mlist[i]; if (_mlist[i].Prog_Status == 9) { _node.Style = _nodestyleRed; _node.StyleSelected = _nodestyleRed; } else { _node.Style = _nodestyleBlue; _node.StyleSelected = _nodestyleBlue; } _nodes.Add(_node); _node.EnsureVisible(); this.AddSonNode(_list, _node.Nodes, _mlist[i].Prog_Id); } }
void MoveNoTitle() { if (!Directory.Exists(textBox3.Text + @"\notitle"))//如果不存在就创建file文件夹 { Directory.CreateDirectory(textBox3.Text + @"\notitle"); } DirectoryInfo theFolder = new DirectoryInfo(textBox3.Text); foreach (FileInfo NextFile in theFolder.GetFiles()) { if (NextFile.Extension.Equals(".doc") || NextFile.Extension.Equals(".docx")) { m_SyncContext.Post(ProgressPlus, null); if (NextFile.Name.Contains("$")) { continue; } m_SyncContext.Post(SetTextSafePost, NextFile.Name); Document doc = new Document(NextFile.FullName); NodeCollection nc = doc.GetChildNodes(NodeType.Run, true); int i = 0; foreach (Run r in nc) { i++; if (i > 10) { File.Move(NextFile.FullName, NextFile.Directory.FullName + @"\\notitle\\" + NextFile.Name); break; } string txt = r.GetText(); if (r.ParentParagraph.ParagraphFormat.Alignment == ParagraphAlignment.Center) { break; } } } } }
public void DeleteAllImages() { //ExStart //ExFor:Shape.HasImage //ExFor:Node.Remove //ExSummary:Shows how to delete all images from a document. Document doc = new Document(MyDir + "Images.docx"); Assert.AreEqual(10, doc.GetChildNodes(NodeType.Shape, true).Count); // Here we get all shapes from the document node, but you can do this for any smaller // node too, for example delete shapes from a single section or a paragraph NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true); // We cannot delete shape nodes while we enumerate through the collection // One solution is to add nodes that we want to delete to a temporary array and delete afterwards ArrayList shapesToDelete = new ArrayList(); // Several shape types can have an image including image shapes and OLE objects foreach (Shape shape in shapes.OfType <Shape>()) { if (shape.HasImage) { shapesToDelete.Add(shape); } } // Now we can delete shapes foreach (Shape shape in shapesToDelete) { shape.Remove(); } // The only remaining shape doesn't have an image Assert.AreEqual(1, doc.GetChildNodes(NodeType.Shape, true).Count); Assert.False(((Shape)doc.GetChild(NodeType.Shape, 0, true)).HasImage); //ExEnd }
public void SetSpecificStyleToSdt() { //ExStart //ExFor:StructuredDocumentTag.Style //ExFor:StructuredDocumentTag.StyleName //ExSummary:Shows how to work with styles for content control elements. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Get specific style from the document to apply it to an SDT Style quoteStyle = doc.Styles[StyleIdentifier.Quote]; StructuredDocumentTag sdtPlainText = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline); sdtPlainText.Style = quoteStyle; StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline); sdtRichText.StyleName = "Quote"; // Second method to apply specific style to an SDT control // Insert content controls into the document builder.InsertNode(sdtPlainText); builder.InsertNode(sdtRichText); MemoryStream dstStream = new MemoryStream(); doc.Save(dstStream, SaveFormat.Docx); NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true); foreach (Node node in tags) { StructuredDocumentTag sdt = (StructuredDocumentTag)node; // If style was not defined before, style should be "Default Paragraph Font" Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier); Assert.AreEqual("Quote", sdt.StyleName); } //ExEnd }
// TODO: how do you manage a node that moved???? private void SyncNodes(NodeCollection nodes) { foreach (Node node in nodes) { if (node.IsAreaNode) { SyncAreaNode(node); } else if (node.IsIterationNode) { SyncIterationNode(node); } else { //TODO error } if (node.ChildNodes.Count > 0) { SyncNodes(node.ChildNodes); } } }
public void MarkCommentRepliesDone() { //ExStart //ExFor:Comment.Done //ExFor:CommentCollection //ExSummary:Shows how to mark comment as Done. Document doc = new Document(MyDir + "Comment.Document.docx"); NodeCollection comments = doc.GetChildNodes(NodeType.Comment, true); Comment comment = (Comment)comments[0]; CommentCollection repliesCollection = comment.Replies; foreach (Comment childComment in repliesCollection) { if (!childComment.Done) { // Update comment reply Done mark. childComment.Done = true; } } //ExEnd }
/// <summary> /// Creates an <see cref="ICalculator"/>. /// </summary> public static ICalculator CreateCalculator() { var innerNodeFactory = new NodeFactory(); var nodeFactory = new TransformableNodeFactory(innerNodeFactory, v => new TransformableValue(v)); var statRegistryCollection = new NodeCollection <IStat>(); var statRegistry = new StatRegistry(statRegistryCollection); var valueTransformer = new ValueTransformer(); var prunableGraph = CreateCalculationGraph(nodeFactory, statRegistry, valueTransformer); var defaultView = new DefaultViewNodeRepository(prunableGraph); var suspendableView = new SuspendableViewNodeRepository(prunableGraph); innerNodeFactory.NodeRepository = defaultView; statRegistry.NodeRepository = suspendableView; var suspender = new SuspendableEventsComposite(); suspender.Add(new StatGraphCollectionSuspender(prunableGraph)); suspender.Add(statRegistryCollection); return(new Calculator(suspender, prunableGraph, prunableGraph, suspendableView, statRegistryCollection)); }
public void DetectBulletedParagraphs() { Document doc = new Document(); //ExStart //ExFor:Paragraph.ListFormat //ExFor:ListFormat.IsListItem //ExFor:CompositeNode.GetText //ExFor:List.ListId //ExSummary:Finds and outputs all paragraphs in a document that are bulleted or numbered. NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true); foreach (Paragraph para in paras.OfType<Paragraph>()) { if (para.ListFormat.IsListItem) { Console.WriteLine(String.Format("*** A paragraph belongs to list {0}", para.ListFormat.List.ListId)); Console.WriteLine(para.GetText()); } } //ExEnd }
public static int HowMuchLettersICanHide(string pathToFile) { try { int counterLetters = 0; Document originalDocument = new Document(pathToFile); NodeCollection paragraphs = originalDocument.GetChildNodes(NodeType.Paragraph, true); foreach (Paragraph parag in paragraphs) { counterLetters += parag.Range.Text.Length; } return((counterLetters / 8) > 0 ? counterLetters / 8 : 0); } catch { return(0); } }
static void Main(string[] args) { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); // Insert a comment. Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now); comment.SetText("My comment."); // Place the comment at a node in the document's body. // This comment will show up at the location of its paragraph, // outside the right-side margin of the page, and with a dotted line connecting it to its paragraph. builder.CurrentParagraph.AppendChild(comment); // Collect all comments in the document. NodeCollection comments = doc.GetChildNodes(NodeType.Comment, true); // Remove all comments. comments.Clear(); }
private void CalculateScores(IEntity[] candidates, NodeCollection args) { for (int i = 0; i < candidates.Length; ++i) { IMethod candidate = candidates[i] as IMethod; if (null == candidate) { continue; } IParameter[] parameters = candidate.GetParameters(); int score = candidate.AcceptVarArgs ? CalculateVarArgsScore(parameters, args) : CalculateExactArgsScore(parameters, args); if (score >= 0) { // only positive scores are compatible _scores.Add(new CallableScore(candidate, score)); } } }
private NodeCollection <ArgumentNode> ParseArgumentList() { NodeCollection <ArgumentNode> list = new NodeCollection <ArgumentNode>(); if (_curtok.TokenId == TokenId.RParen) { return(list); } while (true) { ArgumentNode arg = new ArgumentNode(_curtok); arg.Expression = ParseExpression(); list.Add(arg); if (_curtok.TokenId != TokenId.Comma) { break; } Advance(); } return(list); }
public override bool Execute(ExecutionInfo exInfo = null) { if (Node?.Vertices != null && Node.Vertices.Count > 1) { Nodes = new NodeCollection(); //Nodes.Add(Node); VertexCollection vertices = new VertexCollection(Node.Vertices); for (int i = 0; i < vertices.Count; i++) { Vertex v = vertices[i]; if (v.Node != null && v.Owner != null) { if (Nodes.Contains(v.Node)) { Node newNode = Model.Create.CopyOf(Node);//, exInfo); v.Node = newNode; } Nodes.Add(v.Node); } } } return(true); }
public static void Run() { //ExStart:ExtractImagesToFiles // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithImages(); Document doc = new Document(dataDir + "Image.SampleImages.doc"); NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true); int imageIndex = 0; foreach (Shape shape in shapes) { if (shape.HasImage) { string imageFileName = string.Format( "Image.ExportImages.{0}_out_{1}", imageIndex, FileFormatUtil.ImageTypeToExtension(shape.ImageData.ImageType)); shape.ImageData.Save(dataDir + imageFileName); imageIndex++; } } //ExEnd:ExtractImagesToFiles Console.WriteLine("\nAll images extracted from document."); }
public void RepeatingSection() { //ExStart //ExFor:StructuredDocumentTag.SdtType //ExSummary:Shows how to get type of structured document tag. Document doc = new Document(MyDir + "TestRepeatingSection.docx"); NodeCollection sdTags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true); foreach (StructuredDocumentTag sdTag in sdTags.OfType <StructuredDocumentTag>()) { Console.WriteLine("Type of this SDT is: {0}", sdTag.SdtType); } //ExEnd StructuredDocumentTag sdTagRepeatingSection = (StructuredDocumentTag)sdTags[0]; Assert.AreEqual(SdtType.RepeatingSection, sdTagRepeatingSection.SdtType); StructuredDocumentTag sdTagRichText = (StructuredDocumentTag)sdTags[2]; Assert.AreEqual(SdtType.RichText, sdTagRichText.SdtType); }
public NodeCollection BuildEmployeeDetailsTree(NodeCollection nodes) { if (nodes == null) { nodes = new Ext.Net.NodeCollection(); } Node bulk = new Node(); nodes.Add(bulk); Ext.Net.Node employeesLeaf = BuildLeafNode("rootParent_Employee_Leaf", Resources.Common.EmployeeLeaf, "UsetSuit", true, nodes[0]); FillConfigItem(employeesLeaf, "1", "EmployeePages/EmployeeProfile.aspx", Resources.Common.EmployeeLeaf, "icon-Employees", "1"); Ext.Net.Node sponsors = BuildLeafNode("rootParent_Employee_Sponsors", Resources.Common.Sponsors, "Group", true, nodes[0]); Ext.Net.Node EntitlementDeductions = BuildLeafNode("rootParent_Employee_EntitlementDeductions", Resources.Common.EntitlementDeduction, "Group", true, nodes[0]); FillConfigItem(sponsors, "2", "Sponsors.aspx", Resources.Common.Sponsors, "icon-Employees", "1"); FillConfigItem(EntitlementDeductions, "3", "Sponsors.aspx", Resources.Common.EntitlementDeduction, "icon-Employees", "1"); return(nodes); }
public void DeleteAllShapes() { Document doc = new Document(MyDir + "Shape.DeleteAllShapes.doc"); //ExStart //ExFor:Shape //ExSummary:Shows how to delete all shapes from a document. // Here we get all shapes from the document node, but you can do this for any smaller // node too, for example delete shapes from a single section or a paragraph. NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true); shapes.Clear(); // There could also be group shapes, they have different node type, remove them all too. NodeCollection groupShapes = doc.GetChildNodes(NodeType.GroupShape, true); groupShapes.Clear(); //ExEnd Assert.AreEqual(0, doc.GetChildNodes(NodeType.Shape, true).Count); Assert.AreEqual(0, doc.GetChildNodes(NodeType.GroupShape, true).Count); doc.Save(MyDir + @"\Artifacts\Shape.DeleteAllShapes.doc"); }
private static void AddNodes(NodeCollection nodes, Document doc) { // add nodes in same order as they appear in domain. foreach (var domainNode in nodes) { var node = new Node { Id = domainNode.Id, Name = domainNode.Name, ParentId = domainNode.Parent?.Id ?? 0, Position = new Point { X = domainNode.GetProperty(PropertyType.TranslationX).DesignValue, Y = domainNode.GetProperty(PropertyType.TranslationY).DesignValue }, Angle = domainNode.GetProperty(PropertyType.RotationAngle).DesignValue, IsVisible = Property.ValueToBool(domainNode.GetProperty(PropertyType.Visibility).DesignValue) }; doc.Nodes.Add(node); switch (domainNode) { case SpriteNode spriteNode: node.Type = Node.Types.NodeType.Spritenode; node.SpriteKey = spriteNode.SpriteRef.RelativePath; break; case BoneNode boneNode: node.Type = Node.Types.NodeType.Bonenode; node.BoneLength = boneNode.GetProperty(PropertyType.BoneLength).DesignValue; break; default: throw new NotSupportedException($"Unknown node type: {domainNode.GetType().Name}"); } AddNodes(domainNode.Nodes, doc); } }
public List <T> GetAuthByNodesCheck <T>(NodeCollection tree) { List <Node> nodelist = new List <Node>(); foreach (Node node in tree) { List <Node> nodes = new List <Node>(); nodes = GetSonNode(nodes, node); nodelist.AddRange(nodes); } List <Node> checknode = new List <Node>(); foreach (Node node in nodelist) { if (node.Checked) { checknode.Add(node); List <Node> nodes = new List <Node>(); if (node.Parent != null) { nodes = GetParentNode(nodes, node.Parent); checknode.AddRange(nodes); } } } checknode = checknode.Distinct().ToList(); List <T> authorities = new List <T>(); foreach (Node node in checknode) { authorities.Add((T)node.Tag); } return(authorities); }
public MainWindow() { InitializeComponent(); NodeCollection data = new NodeCollection(); data.AddNode(0, "Net supply", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi0)); data.AddNode(1, "PV", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi1)); data.AddNode(2, "Factory", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi2)); data.AddNode(3, "Utilities", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi3)); data.AddNode(4, "Admin Building", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi4)); data.AddNode(5, "Production", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi5)); data.AddNode(6, "Packaging", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi6)); data.AddNode(7, "Compressor", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi7)); data.AddNode(8, "HVAC", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi8)); data.AddNode(9, "Boiler", (Color)ColorConverter.ConvertFromString(CommonClass.ColorPowerBi9)); data.AddNodeLink(0, 4, 3185); data.AddNodeLink(0, 2, 57426); data.AddNodeLink(0, 3, 4259); data.AddNodeLink(1, 2, 2544); data.AddNodeLink(2, 5, 42322); data.AddNodeLink(2, 6, 15104); data.AddNodeLink(3, 7, 704); data.AddNodeLink(3, 8, 2316); data.AddNodeLink(3, 9, 1239); data.AddLevels(0, "0 1"); data.AddLevels(1, "2 3"); data.AddLevels(2, "4 5 6 7 8 9"); textBlock.Text = data.ToString(); data.Paint(canvas); textBlock.Text += data.ToString(); }
private static void CreateTestSuites(ITestManagementTeamProject testProject, ITestPlan newTestPlan, Node node, IStaticTestSuite parentSuite, string parentAreaPath) { NodeCollection childNodes = node.ChildNodes; foreach (Node childNode in childNodes) { IStaticTestSuite newsuite = null; newsuite = (IStaticTestSuite)testProject.TestSuites.Find(68227); newsuite = testProject.TestSuites.CreateStatic(); newsuite.Title = childNode.Name; parentSuite.Entries.Add(newsuite); newTestPlan.Save(); try { //find tc's based on areapath IEnumerable <ITestCase> tcs = testProject.TestCases.Query(string.Format("SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.TeamProject]='{0}' AND [System.AreaPath]='{1}' AND [System.WorkItemType]='Test Case'", testProject.TeamProjectName, parentAreaPath + "\\" + childNode.Name)); //Add the above entries to the static test suite. foreach (ITestCase tc in tcs) { newsuite.Entries.Add(tc); } } catch { MyLogger.Log("Error while adding tcs for node : " + childNode.Name + " whose parent area path is : " + parentAreaPath); } newTestPlan.Save(); if (childNode.HasChildNodes) { CreateTestSuites(testProject, newTestPlan, childNode, newsuite, parentAreaPath + "\\" + childNode.Name); } } }
private void InsertToken(NodeCollection nodeCollection, AuthorityTokenTableEntry token, int depth) { // check if a node for this path segment already exists in the tree PathSegment segment = token.Path.Segments[depth]; Node node = CollectionUtils.SelectFirst <Node>(nodeCollection, delegate(Node n) { return(n.Text == segment.LocalizedText); }); // if not, create the node if (node == null) { node = new Node(segment.LocalizedText); node.CheckStateChanged += new EventHandler(node_CheckStateChanged); nodeCollection.Add(node); } // if this is a leaf node, set the properties of the tree node accordingly if (segment == token.Path.LastSegment) { node.Tag = token; node.Tooltip = token.Description; node.CheckState = token.Selected ? CheckState.Checked : CheckState.Unchecked; // addition of this leaf may need to alter the check state of the parent if (node.Parent != null) { PropagateCheckStateUp(node.Parent); } } else { // otherwise, recur until we hit the leaf InsertToken(node.Nodes, token, depth + 1); } }
/// <summary> /// 书签替换,字典和word书签必须一致,如果字典包含word模板不存在的书签,这些不存在的字典将在word的最后一个书签进行叠加显示 /// </summary> /// <param name="filePath">文件路径</param> /// <param name="asTemplates">字典</param> /// <param name="tableData">表格</param> /// <param name="replaceType">bookmark:书签替换,placeholder:占位符替换</param> public static void FillWordData(string wordFile, string pdfFile, List <ASTemplate> asTemplates, List <TempClass> tableData, ReplaceTypeEnum replaceType = ReplaceTypeEnum.bookmark) { Document doc = new Document(wordFile); DocumentBuilder builder = new DocumentBuilder(doc); //操作word if (replaceType == ReplaceTypeEnum.bookmark) { //书签替换 asTemplates.ForEach(a => { builder.MoveToBookmark(a.Key); //将光标移入书签的位置 builder.Write(a.Value); //填充值 }); } else { //占位符替换 asTemplates.ForEach(a => { //doc.Range.Replace(a.Key, a.Value, false, false); doc.Range.Replace(a.Key, a.Value); }); } //获取表格节点集合 NodeCollection tables = doc.GetChildNodes(NodeType.Table, true); //填充表格数据 for (int i = 0; i < tables.Count(); i++) { AddTableRow(tables[i] as Table, tableData, doc, builder); } doc.Save(wordFile);//保存word //doc.Save(pdfFile, SaveFormat.Pdf);//保存pdf }
public static NodeCollection BuildFirstLevel() { string path = HttpContext.Current.Server.MapPath("~/Examples/"); DirectoryInfo root = new DirectoryInfo(path); DirectoryInfo[] folders = root.GetDirectories(); folders = UIHelpers.SortFolders(root, folders); NodeCollection nodes = new NodeCollection(false); foreach (DirectoryInfo folder in folders) { if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden || excludeList.Contains(folder.Name) || folder.Name.StartsWith("_")) { continue; } ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false); string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls; Node node = new Node(); node.Text = folder.Name.Replace("_", " "); flagNode(ref node, folder.FullName); node.IconCls = iconCls; string url = UIHelpers.PhysicalToVirtual(folder.FullName + "/"); node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode()); nodes.Add(node); } return(nodes); }
public ConstraintsViewModel(DemoControl demo) { View = demo; // Initializing Properties for DiagramViewModel SelectedItems = new SelectorViewModel() { SelectorConstraints = SelectorConstraints.Default | SelectorConstraints.HideDisabledResizer, }; ItemSelectedCommand = new DelegateCommand(OnItemSelected); first = true; #region Nodes and Connectors Nodes = new NodeCollection(); Connectors = new ConnectorCollection(); CreateNode(90, "Rectangle", "Selection = False", "Selection"); CreateNode(290, "Ellipse", "Dragging = False", "Drag"); CreateNode(490, "Heptagon", "Delete = False", "Delete"); CreateNode(690, "Cylinder", "Rotate = False", "Rotate"); CreateNode(890, "Plus", "TextEdit = False", "Edit"); CreateNode(1090, "Diamond", "Resizing = False", "Resize"); CreateNodeforLabel("Rectangle", "Node"); CreateNodeforLabel("Rectangle", "Connector"); CreateConnector(new Point(40, 500), new Point(190, 600), "Selection = False", "Selection"); CreateConnector(new Point(240, 500), new Point(390, 600), "Dragging = True", "Drag"); CreateConnector(new Point(440, 500), new Point(590, 600), "Delete = False", "Delete"); CreateConnector(new Point(640, 500), new Point(790, 600), "EndThumb = False", "EndThumb"); CreateConnector(new Point(840, 500), new Point(990, 600), "EndDraggable = False", "EndDraggable"); CreateConnector(new Point(1040, 500), new Point(1190, 600), "SegmentThumb = False", "SegmentThumb"); #endregion }
public void DeleteAllImages() { Document doc = new Document(MyDir + "Image.SampleImages.doc"); Assert.AreEqual(6, doc.GetChildNodes(NodeType.Shape, true).Count); //ExStart //ExFor:Shape.HasImage //ExFor:Node.Remove //ExSummary:Shows how to delete all images from a document. // Here we get all shapes from the document node, but you can do this for any smaller // node too, for example delete shapes from a single section or a paragraph. NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true); // We cannot delete shape nodes while we enumerate through the collection. // One solution is to add nodes that we want to delete to a temporary array and delete afterwards. ArrayList shapesToDelete = new ArrayList(); foreach (Shape shape in shapes) { // Several shape types can have an image including image shapes and OLE objects. if (shape.HasImage) { shapesToDelete.Add(shape); } } // Now we can delete shapes. foreach (Shape shape in shapesToDelete) { shape.Remove(); } //ExEnd Assert.AreEqual(1, doc.GetChildNodes(NodeType.Shape, true).Count); doc.Save(MyDir + @"\Artifacts\Image.DeleteAllImages.doc"); }
public void FindUnitError() { //Arrange var fileName = @"..\..\..\TestFiles\FindUnitError.doc"; var log = _fixture.log; string xml = @"<?xml version=""1.0"" encoding=""utf - 8"" ?> <configuration> <FindStrainOrDispError row1=""0"" col1=""0"" row2 =""1"" col2 =""1"" charactorString =""测点号"" > <Strain charactorString = ""总应变"" /> <Disp charactorString = ""总变形"" /> </FindStrainOrDispError > </configuration >"; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindUnitError(); using (MemoryStream dstStream = new MemoryStream()) { ai._doc.Save(dstStream, SaveFormat.Doc); } Comment docComment = (Comment)ai._doc.GetChild(NodeType.Comment, 0, true); Comment docComment1 = (Comment)ai._doc.GetChild(NodeType.Comment, 1, true); NodeCollection allComments = ai._doc.GetChildNodes(NodeType.Comment, true); //Assert Assert.Equal(2, allComments.Count); Assert.Equal(1, docComment.Count); Assert.True(docComment.GetText().IndexOf("应为km/h") >= 0); Assert.True(docComment1.GetText().IndexOf("应为km/h") >= 0); //Assert.Equal("\u0005My comment.\r", docComment.GetText()); }
public void DetectBulletedParagraphs() { //ExStart //ExFor:Paragraph.ListFormat //ExFor:ListFormat.IsListItem //ExFor:CompositeNode.GetText //ExFor:List.ListId //ExSummary:Shows how to output all paragraphs in a document that are bulleted or numbered. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.ListFormat.ApplyNumberDefault(); builder.Writeln("Numbered list item 1"); builder.Writeln("Numbered list item 2"); builder.Writeln("Numbered list item 3"); builder.ListFormat.RemoveNumbers(); builder.ListFormat.ApplyBulletDefault(); builder.Writeln("Bulleted list item 1"); builder.Writeln("Bulleted list item 2"); builder.Writeln("Bulleted list item 3"); builder.ListFormat.RemoveNumbers(); NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true); foreach (Paragraph para in paras.OfType <Paragraph>().Where(p => p.ListFormat.IsListItem)) { Console.WriteLine($"This paragraph belongs to list ID# {para.ListFormat.List.ListId}, number style \"{para.ListFormat.ListLevel.NumberStyle}\""); Console.WriteLine($"\t\"{para.GetText().Trim()}\""); } //ExEnd doc = DocumentHelper.SaveOpen(doc); paras = doc.GetChildNodes(NodeType.Paragraph, true); Assert.AreEqual(6, paras.Count(n => (n as Paragraph).ListFormat.IsListItem)); }