private static List <Regulation> GetProduction(SyntaxTree syntaxTree) { // <Production> ::= <Vn> "::=" <Canditate> <RightPartList> ; List <Regulation> result = new List <Regulation>(); if (syntaxTree.NodeType.Type == ContextfreeGrammarTreeNodeType.__Production) { Vn left = GetVn(syntaxTree.Children[0]); TreeNodeType leftNode = left.GetTreeNodeType(); { Candidate candidate = GetCandidate(syntaxTree.Children[2]); var regulation = new Regulation(leftNode, (from item in candidate select item.GetTreeNodeType()).ToArray()); result.Add(regulation); } RightPartList rightPartList = GetRightPartList(syntaxTree.Children[3]); foreach (var candidate in rightPartList) { var regulation = new Regulation(leftNode, (from item in candidate select item.GetTreeNodeType()).ToArray()); result.Add(regulation); } } return(result); }
public RelationsConfiguration GetConfiguration(string type, int id) { var legacyTreeNodeType = new TreeNodeType("settings", type); var sevenThreeTreeNodeType = new TreeNodeType(type, null); var objectType = Mappings.TreeNodeObjectTypes.ContainsKey(legacyTreeNodeType) ? Mappings.TreeNodeObjectTypes[legacyTreeNodeType] : Mappings.TreeNodeObjectTypes[sevenThreeTreeNodeType]; var contentTypes = ContentTypeService.GetAllContentTypes().ToList(); var mediaTypes = ApplicationContext.Services.ContentTypeService.GetAllMediaTypes().ToList(); var types = new[] { (objectType == UmbracoObjectTypes.DocumentType ? UmbracoObjectTypes.Document : UmbracoObjectTypes.Media).GetGuid(), }; var relationTypes = ApplicationContext.Services.RelationService.GetAllRelationTypes() .Where(rt => types.Contains(rt.ParentObjectType)) ; var contentType = objectType == UmbracoObjectTypes.DocumentType ? (IContentTypeBase)contentTypes.Single(ct => ct.Id == id) : mediaTypes.Single(ct => ct.Id == id); var contentObjectType = objectType == UmbracoObjectTypes.DocumentType ? UmbracoObjectTypes.Document : UmbracoObjectTypes.Media; return(new RelationsConfiguration { contentTypes = contentTypes, mediaTypes = mediaTypes, relationTypes = relationTypes, configuration = RelationEditor.Configuration.Get(contentObjectType, contentType.Alias) }); }
private void SetStyleTreeVieew() { TreeCtrl.Nodes.Clear(); TreeCtrl.Style.Add("SCROLLBAR-3DLIGHT-COLOR", "darkgray"); TreeCtrl.Style.Add("SCROLLBAR-ARROW-COLOR", "darkgray"); TreeCtrl.Style.Add("CROLLBAR-TRACK-COLOR", "lightslategray"); TreeCtrl.Style.Add("SCROLLBAR-BASE-COLOR", "lightslategray"); TreeCtrl.Style.Add("HEIGHT", "95%"); String imgurl = "../images/treeimages/"; TreeNodeType type = new TreeNodeType(); type = new TreeNodeType(); type.Type = "edificio"; type.ImageUrl = imgurl + "gnome-fs-home.gif"; type.ExpandedImageUrl = imgurl + "gnome-fs-home.gif"; TreeCtrl.TreeNodeTypes.Add(type); type = new TreeNodeType(); type.Type = "servizio"; type.ImageUrl = imgurl + "gnome-mime-text-x-sh.gif"; type.ExpandedImageUrl = imgurl + "gnome-mime-text-x-sh.gif"; TreeCtrl.TreeNodeTypes.Add(type); }
public override void ReadFrom(ApolloBufferReader reader) { int tmp = 0; reader.Read(ref tmp); Type = (TreeNodeType)tmp; switch (Type) { case TreeNodeType.Category: { Category = new CategoryNode(); reader.Read(ref Category); } break; case TreeNodeType.Leaf: { Leaf = new LeafNode(); reader.Read(ref Leaf); break; } default: return; } }
public TreeNode(int id, string name, TreeNodeType treeNodeType, TreeNodeStatus treeNodeStatus, TreeNodeCollection childrenTreeNodes) { Id = id; Name = name; TreeNodeType = treeNodeType; ChildrenTreeNodes = childrenTreeNodes; }
private static bool IsIdentifier(this TreeNodeType node) { if (!node.IsLeave) { throw new ArgumentException(); } { char item = node.Content[0]; SourceCodeCharType charType = item.GetCharType(); if (!( charType == SourceCodeCharType.UnderLine || charType == SourceCodeCharType.Letter)) { return(false); } } for (int i = 1; i < node.Content.Length; i++) { char item = node.Content[i]; SourceCodeCharType charType = item.GetCharType(); if (!( charType == SourceCodeCharType.UnderLine || charType == SourceCodeCharType.Number || charType == SourceCodeCharType.Letter)) { return(false); } } return(true); }
public LSTreeNode(TreeNodeType type, string text) { this.Type = type; this.Text = text; this.Value = text; this.ImageKey = type.ToString(); }
public myListNode(string n, TreeNodeType t, IRObject o) { name = n; type = t; obj = o; this.Text = n; }
//Contructors /// <summary> /// Builds a node with only name and node type (feature, value, root). /// </summary> /// <param name="groupName">The feature name, or the feature value.</param> /// <param name="type">If the node is a feature, value, or the root node.</param> public TreeNode(object groupName, TreeNodeType type) { this.Parent = null; this.Name = groupName; this.Type = type; this.SubNodes = new List <TreeNode>(); this.Leaves = new List <TreeLeaf>(); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeNodeType tnt = e.Node as TreeNodeType; if (tnt != null) { SelectedType = tnt.Type; } }
public PatternTreeNode(InstName name, Func <T, bool> match, TreeNodeType type = TreeNodeType.Op, byte order = 0, bool isImm = false) { Name = name; _match = match; Type = type; Order = order; IsImm = isImm; Uses = new List <PatternTreeNodeUse>(); }
public ITreeNode InsertSiblingBefore(TreeNodeType nodeType) { if (_parentNode == null) { throw new Exception("Cannot insert sibling of root node!"); } return(_parentNode.InsertChild(nodeType, IndexInParent)); }
private static TreeNode CreateNode(string name, object value, TreeNodeType type) { return(new TreeNode(name) { Tag = new TreeNodeTag() { Object = value, Type = type } }); }
/// <summary> /// Add project item to explorer. /// </summary> /// <param name="type">Type of the item.</param> /// <param name="path">Path of the item in Workspace.Project.</param> public void Add(TreeNodeType type, string path, bool expand) { // Check if the path is from Workspace.Project. if (path.Substring(0, Workspace.Project.BaseDirectory.Length) != Workspace.Project.BaseDirectory) { return; } // TODO: Check if file exists in project. short imageIndex = 1; string name = Path.GetFileName(path); string extension = Path.GetExtension(path); // Check extension to know image index. if (extension == ".inc") { imageIndex = 4; } else if (string.IsNullOrEmpty(extension) == false) { imageIndex = 3; } // Create TreeView path of the folder. string directory = Path.Combine(Workspace.Project.Name, Path.GetDirectoryName(path.Remove(0, Workspace.Project.BaseDirectory.Length + 1))); TreeNode parentNode = TreeNodeHelper.GetNodeByPath(this.projectFiles.Nodes, directory); if (parentNode != null) { // Add the node to TreeView. TreeNode childNode = parentNode.Nodes.Add(path, name, imageIndex, imageIndex); childNode.Tag = type; // Now let's sort the TreeView. this.projectFiles.Sort(); if (expand == true && parentNode.IsExpanded == false) { parentNode.Expand(); } if (ItemAdded != null) { ItemAdded(this, new ItemEventArgs(path)); } } else { // TODO: Write the a message to log file. } }
private static string GetUnused(RegulationList grammar, out bool error) { StringBuilder builder = new StringBuilder(); List <TreeNodeType> usedList = new List <TreeNodeType>(); usedList.Add(grammar[0].Left); bool changed = false; int index = 0; do { changed = false; int count = usedList.Count; for (; index < count; index++) { TreeNodeType node = usedList[index]; foreach (var regulation in grammar) { if (regulation.Left == node) { foreach (var item in regulation.RightPart) { if ((!item.IsLeave) && (!usedList.Contains(item))) { usedList.Add(item); changed = true; } } } } } } while (changed); List <TreeNodeType> unusedList = new List <TreeNodeType>(); List <TreeNodeType> allNonLeaveNodeList = grammar.GetAllTreeNodeNonLeaveTypes(); foreach (var node in allNonLeaveNodeList) { if (!usedList.Contains(node)) { unusedList.Add(node); } } builder.AppendLine("===================================================================="); builder.AppendLine(string.Format("{0} unused nodes:", unusedList.Count)); foreach (var item in unusedList) { builder.AppendLine(item.Dump()); } error = unusedList.Count > 0; return(builder.ToString()); }
public TreeNode(Document document, string tagName, TreeNode parentNode, TreeNodeType nodeType, int index) : base(tagName) { _document = document; _parentNode = parentNode; _nodeType = nodeType; if (_parentNode != null) { _parentNode.InsertChild(this, index); } }
public static string ToTypeString(this TreeNodeType _this) { if (s_typeNames.TryGetValue(_this, out string name)) { return(name); } if (!Enum.IsDefined(typeof(TreeNodeType), _this)) { return($"Unknown {(int)_this}"); } return(_this.ToString()); }
private string GetNextDataName(TreeNodeType type) { if (IsStandardDocument) { return((type == TreeNodeType.Page) ? string.Concat(_pageName, _pageCounter++) : String.Concat(_folderName, _folderCounter++)); } else { return(string.Concat(_widgetName, _pageCounter++)); } }
private static TreeNode CreateNode(string name, object value, TreeNodeType type, Func <object, bool> condition) { TreeNode node = new TreeNode(name); if (condition(value)) { node.Tag = new TreeNodeTag() { Object = value, Type = type } } ; return(node); }
public EnumerableTreeNode(TreeNodeType childNodeType, string idScope) : base((value, next) => { foreach (var child in value) { // The nextAsync return value is not needed here because // the IEnumberable element references will remain unchanged next(child, childNodeType); } return(value); }) { IdScope = idScope; }
public static TreeNode AddForEachNode(this TreeNode parent, Func<TreeNodeTag, object> valuesToAdd, Func<object, string> toStringFunc, TreeNodeType type) { foreach (TreeNode node in parent.Nodes) { object rawValue = valuesToAdd((TreeNodeTag)node.Tag); if (rawValue == null) continue; if (rawValue is Array) node.AddSubNodes((object[])rawValue, toStringFunc).MakeOtherType((o) => { return true; } , type); else node.AddSubNodes(new object[] { rawValue }, toStringFunc).MakeOtherType((o) => { return true; }, type); } return parent; }
internal PDFMergeItem( string bookmarkTitle, TreeNodeType treeNodeType, int pageNumber, int depth, FileItem fileItem ) { this.bookmarkTitle = bookmarkTitle; this.TreeNodeType = treeNodeType; this.pageNumber = pageNumber; this.depth = depth; this.fileItem = fileItem; this.mergeItems = null; }
public static TreeNode AddNode(TreeNodeType nodeType, string name = null) { try { TreeNode treeNode = new TreeNode(); string defaultName = ""; switch (nodeType) { case TreeNodeType.Connection: case TreeNodeType.PuttySession: defaultName = Language.strNewConnection; treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed; treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed; break; case TreeNodeType.Container: defaultName = Language.strNewFolder; treeNode.ImageIndex = (int)TreeImageType.Container; treeNode.SelectedImageIndex = (int)TreeImageType.Container; break; case TreeNodeType.Root: defaultName = Language.strNewRoot; treeNode.ImageIndex = (int)TreeImageType.Root; treeNode.SelectedImageIndex = (int)TreeImageType.Root; break; } if (!string.IsNullOrEmpty(name)) { treeNode.Name = name; } else { treeNode.Name = defaultName; } treeNode.Text = treeNode.Name; return(treeNode); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "AddNode failed" + Environment.NewLine + ex.Message, true); } return(null); }
internal void CreateNewItem(LinkedList <char> currentName, int newLevel, TreeNodeType newType) { while (newLevel != CurrentLevel + 1) { CurrentNode = CurrentNode.Father; } CurrentNode.Children.AddLast(new TreeNode { Father = CurrentNode, Level = newLevel, Name = currentName, TreeNodeType = newType, PathLength = CurrentNode.PathLength + currentName.Count + 1 }); CurrentNode = CurrentNode.Children.Last.Value; if (CurrentNode.TreeNodeType == TreeNodeType.File && LengthLongFilePath < CurrentNode.PathLength) { LengthLongFilePath = CurrentNode.PathLength; } }
private void tvSourceTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { tvSourceTree.SelectedNode = e.Node; if (e.Node.Level == 0 && e.Node.Nodes.Count == 0) { TreeNodeType type = (TreeNodeType)e.Node.Tag; _action = null; switch (type) { case TreeNodeType.TABLE: _action = LoadTables; break; case TreeNodeType.TRIGGER: _action = LoadUserTris; break; case TreeNodeType.SEQUENCE: _action = LoadUserSeqs; break; case TreeNodeType.FUNCTION: _action = LoadUserFunctions; break; case TreeNodeType.PROCEDURE: _action = LoadUserProcedures; break; case TreeNodeType.JAVASOURCE: _action = LoadUserJavaSources; break; case TreeNodeType.JOB: _action = LoadJobs; break; case TreeNodeType.VIEW: _action = LoadViews; break; default: break; } DoLoadTreeData(); } }
public void SaveConfiguration(SaveConfigurationCommand saveConfigurationCommand) { var legacyTreeNodeType = new TreeNodeType("settings", saveConfigurationCommand.Type); var sevenThreeTreeNodeType = new TreeNodeType(saveConfigurationCommand.Type, null); var objectType = Mappings.TreeNodeObjectTypes.ContainsKey(legacyTreeNodeType) ? Mappings.TreeNodeObjectTypes[legacyTreeNodeType] : Mappings.TreeNodeObjectTypes[sevenThreeTreeNodeType]; var contentTypes = ContentTypeService.GetAllContentTypes().ToList(); var mappedObjectType = objectType == UmbracoObjectTypes.DocumentType ? UmbracoObjectTypes.Document : UmbracoObjectTypes.Media; var contentType = objectType == UmbracoObjectTypes.DocumentType ? (IContentTypeBase)ContentTypeService.GetContentType(saveConfigurationCommand.Id) : ContentTypeService.GetMediaType(saveConfigurationCommand.Id); RelationEditor.Configuration.Set(mappedObjectType, contentType.Alias, saveConfigurationCommand.Configuration); }
private static T Set <T>( T entryValue, string behaviorName, object behaviorValue, TreeNodeType entryType) where T : class { if (behaviorName is null) { throw new ArgumentNullException(nameof(behaviorName)); } var jToken = behaviorValue is null ? null : JToken.FromObject(behaviorValue); return(CardTree.SetLibraryData(entryValue, new JObject { { behaviorName, jToken } }, entryType, true)); }
public int LengthLongestPath(string input) { LinkedList <char> currentName = new LinkedList <char>(); Tree tree = new Tree(); TreeNodeType newType = TreeNodeType.Directory; int newLevel = 1; for (int i = 0; i < input.Length; i++) { if (input[i] != '\n') { if (input[i] == '.') { newType = TreeNodeType.File; } currentName.AddLast(input[i]); } else { tree.CreateNewItem(currentName, newLevel, newType); currentName = new LinkedList <char>(); newType = TreeNodeType.Directory; newLevel = 1; int j = i + 1; for (; j < input.Length; j++) { if (input[j] != '\t') { break; } newLevel++; } j--; i = j; } } tree.CreateNewItem(currentName, newLevel, newType); return(tree.LengthLongFilePath); }
private static string GetTypeName(Dictionary <uint, string> customTypes, uint value) { bool isCustomType = (value & 0x80000000) == 0; if (isCustomType) { return(customTypes[value]); } else { uint offset = value & ~0x80000000; TreeNodeType nodeType = (TreeNodeType)offset; if (!Enum.IsDefined(typeof(TreeNodeType), nodeType)) { throw new Exception($"Unsupported asset class type name '{nodeType}''"); } return(nodeType.ToTypeString()); } }
static TreeNodeTypeExtentions() { Type type = typeof(TreeNodeType); TreeNodeType[] values = (TreeNodeType[])Enum.GetValues(type); FieldInfo[] fields = type.GetFields(); for (int i = 1; i < fields.Length; i++) { MemberInfo member = fields[i]; EnumNameAttribute name = member.GetCustomAttribute <EnumNameAttribute>(); if (name == null) { continue; } TreeNodeType value = values[i - 1]; s_typeNames.Add(value, name.Name); } }
static TreeNodeTypeExtentions() { int index = 0; Type type = typeof(TreeNodeType); TreeNodeType[] values = (TreeNodeType[])Enum.GetValues(type); IEnumerable <FieldInfo> fields = type.GetRuntimeFields(); foreach (FieldInfo field in fields) { EnumNameAttribute name = field.GetCustomAttribute <EnumNameAttribute>(); if (name != null) { TreeNodeType value = values[index - 1]; s_typeNames.Add(value, name.Name); } index++; } }
public IsAllowedResult IsAllowedEntity(string parentTypeName, string parentAlias, string relationAlias, string treeAlias, int id) { var parentType = (UmbracoObjectTypes)Enum.Parse(typeof(UmbracoObjectTypes), parentTypeName); var config = RelationEditor.Configuration.Get(parentType, parentAlias); var relConfig = config.Get(relationAlias); if (relConfig.Enabled && !relConfig.EnabledChildTypes.Any()) return new IsAllowedResult(true); var treeNodeType = new TreeNodeType(treeAlias, null); if (Mappings.TreeNodeTypes.Contains(treeNodeType)) { var objectType = Mappings.TreeNodeObjectTypes[treeNodeType]; var alias = EntityHelper.FindAlias(objectType, id); return new IsAllowedResult(relConfig.Get(alias).Enabled); } return new IsAllowedResult(false); }
public TreeNodeValue(TreeNodeType type, object value) { this.Type = type; this.Value = value; }
public static TreeNode MakeOtherType(this TreeNode parent, Func<object,bool> condition, TreeNodeType newType) { foreach (TreeNode node in parent.Nodes) { TreeNodeTag tag = node.Tag as TreeNodeTag; if (tag != null) { if (condition(tag.Object)) tag.Type = newType; } } return parent; }
private static TreeNode CreateNode(string name, object value, TreeNodeType type) { return new TreeNode(name) { Tag = new TreeNodeTag() { Object = value, Type = type } }; }
protected TreeNodeImpl(int origin, int location, TreeNodeType nodeType) { Origin = origin; Location = location; NodeType = nodeType; }
private static TreeNode CreateNode(string name, object value, TreeNodeType type, Func<bool> condition) { TreeNode node = new TreeNode(name); if (condition()) node.Tag = new TreeNodeTag() { Object = value, Type = type }; return node; }
public TreeNodeTag(TreeNodeType type, string text) { this.type = type; this.lasttimeText = text; }
public TreeNodeValue(TreeNodeType type) { this.Type = type; this.Value = null; }
public OTreeNode(TreeNodeType t) { TreeNodes[(byte)t].Add(this); }
public AFATreeNode(string strText, TreeNodeType NodeType) : base(strText) { m_NodeType = NodeType; }
public ContentRelationsDto GetRelations( string section, string treeType, int parentId ) { var treeNodeType = new TreeNodeType(section, treeType); var fromType = UmbracoObjectTypes.Unknown; if ( !Mappings.TreeNodeObjectTypes.TryGetValue(treeNodeType, out fromType) || fromType == UmbracoObjectTypes.Unknown ) throw new Exception("Cannot get relation types for unknown object type"); var entity = entityService.Get(parentId, fromType); object alias = null; entity.AdditionalData.TryGetValue("Alias", out alias); var typeConfig = RelationEditor.Configuration.Get(fromType, alias as string); var allRelations = relationService.GetByParentOrChildId(parentId); var allowedObjectTypes = Mappings.AllowedRelations[fromType]; var enabledRelations = typeConfig.EnabledRelations.Select(r => r.Alias).ToArray(); var relationSets = relationService.GetAllRelationTypes() .Where(rt => rt.ParentObjectType == fromType.GetGuid() && enabledRelations.Contains(rt.Alias) && allowedObjectTypes.Any(ar => ar.GetGuid() == rt.ChildObjectType) ) .Select(rt => new RelationSetDto { RelationTypeId = rt.Id, Direction = rt.IsBidirectional ? "bidirectional" : "parentchild", ChildType = Mappings.ObjectTypeTreeTypes[rt.ChildObjectType], Alias = rt.Alias, Name = rt.Name, Relations = allRelations .Where(r => r.RelationTypeId == rt.Id && (rt.IsBidirectional || r.ParentId == parentId) ) .Select(r => { int otherId; Guid relatedType; var isParent = r.ParentId == parentId; if (isParent) { otherId = r.ChildId; relatedType = rt.ChildObjectType; } else { otherId = r.ParentId; relatedType = rt.ParentObjectType; } var relEntity = GetEntity(relatedType, otherId); var otherName = relEntity.Name; var fullPath = GetFullPath(relEntity); return new RelationDto { Readonly = !isParent, ChildId = r.ChildId, FullPath = HttpContext.Current.Server.HtmlEncode(fullPath), ChildName = (configuration.BreadcrumbMode == BreadcrumbMode.ToolTip) ? otherName : HttpContext.Current.Server.HtmlDecode(fullPath), State = RelationStateEnum.Unmodified }; }).ToList() }).ToList(); return new ContentRelationsDto { ParentId = parentId, ParentType = fromType, ParentAlias = alias as string, Sets = relationSets }; }
/// <summary> /// Añade un nodo /// </summary> private TreeNode AddNode(TreeNode trnParent, TreeNodeType intNode, ImageKey intImage, string strText, bool blnBold, Color clrColor, object objTag) { Bau.Controls.Tree.TreeNodeKey objKey = new Bau.Controls.Tree.TreeNodeKey((int) intNode, trvContacts.Nodes.Count + 1, objTag); // Añade el nodo return trvContacts.AddNode(trnParent, objKey, strText, false, (int) intImage, clrColor, blnBold); }