public TagsStorage GetTagsStorage(Tag tag) { TagsStorage result = null; foreach (TagsStorage tagsStorage in this) { if (tagsStorage.name == tag.Name || (tagsStorage.tagType != TagType.Object) && tag.Name != "") { if (tag.Tags == null) { result = tagsStorage; } else { result = tagsStorage.GetTagsStorage(tag.Tags); } } } if (result == null) { result = this; } return(result); }
public TagsStorage LoadTags() { TagsStorage rootNode = null; XmlDocument xmlDoc; if (File.Exists(this.path)) { xmlDoc = new XmlDocument(); try { rootNode = new TagsStorage("{=", TagsStorage.TagType.Object); xmlDoc.Load(path); LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags")); } catch (XmlException ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } catch (Exception ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } } return(rootNode); }
public void Add(TagsStorage tagsStorage) { tagsStorage.parent = this; if (tagsList == null) { tagsList = new ArrayList(); } tagsList.Add(tagsStorage); }
public HoveringWindow(Form owner) { InitializeComponent(); this.owner = owner; //this.owner.Click += new EventHandler(control_LostFocus); tvList.GotFocus += new EventHandler(listBox1_GotFocus); TagsLoader tagsLoader = new TagsLoader(); this.tagsStorage = tagsLoader.LoadTags(); }
public HoveringWindow(Form owner) { InitializeComponent(); this.owner = owner; //this.owner.Click += new EventHandler(control_LostFocus); tvList.GotFocus += new EventHandler(listBox1_GotFocus); TagsLoader tagsLoader = new TagsLoader(); this.tagsStorage = tagsLoader.LoadTags(); }
private void UpdateHoveringWindowList(string text) { TagsStorage activeTagStorage = null; TreeNode treeNode; if (text.Length > 2) { text = text.Substring(2, text.Length - 2); Tag tag = new Tag("Root", text); activeTagStorage = tagsStorage.GetTagsStorage(tag.Tags); } else { activeTagStorage = tagsStorage; } if (activeTagStorage != null) { tvList.Nodes.Clear(); foreach (TagsStorage tags in activeTagStorage) { treeNode = new TreeNode(tags.Name, 0, 0); treeNode.Tag = tags.Type == TagsStorage.TagType.Object ? tags.Name : "\"\""; tvList.Nodes.Add(treeNode); } } // ovo je tmp rjesenje jer " . " bug, raditi preko tagova orginalno int lastIndexOfDot = text.LastIndexOf('.'); string lastText; if (lastIndexOfDot != -1) { lastText = text.Substring(lastIndexOfDot + 1, (text.Length - lastIndexOfDot) - 1); } else { lastText = text; } // select active node base on user input foreach (TreeNode node in tvList.Nodes) { if (node.Text.StartsWith(lastText)) { tvList.SelectedNode = node; break; } } }
private void LoadXMLChild(TagsStorage tagsStorage, XmlNode xmlNode) { TagsStorage newTagsStorage; TagsStorage.TagType tagType; foreach (XmlNode node in xmlNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { if (node.Name == "tag") { if (node.Attributes["type"].Value == "object") { tagType = TagsStorage.TagType.Object; } else if (node.Attributes["type"].Value == "string") { tagType = TagsStorage.TagType.String; } else if (node.Attributes["type"].Value == "int") { tagType = TagsStorage.TagType.Int; } else { tagType = TagsStorage.TagType.Unknown; } if (node.Attributes["type"] != null) { // check if node is type of object // ovo staviti pod isti i, jer je isto code if (node.Attributes["type"].Value == "object") { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else if (node.Name == "syntax") { //tbSyntax.Text = node.InnerText; } else if (node.Name == "result") { //lblResult.Text = "Result: " + node.InnerText; } else if (node.Name == "example") { //lblExample.Text = "Example: " + node.InnerText; } else { if (node.HasChildNodes) { LoadXMLChild(tagsStorage, node); } } } } }
public void Add(TagsStorage tagsStorage) { tagsStorage.parent = this; if (tagsList == null) { tagsList = new ArrayList(); } tagsList.Add(tagsStorage); }
private void LoadXMLChild(TagsStorage tagsStorage, XmlNode xmlNode) { TagsStorage newTagsStorage; TagsStorage.TagType tagType; foreach (XmlNode node in xmlNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { if (node.Name == "tag") { if(node.Attributes["type"].Value == "object") { tagType = TagsStorage.TagType.Object; } else if(node.Attributes["type"].Value == "string") { tagType = TagsStorage.TagType.String; } else if(node.Attributes["type"].Value == "int") { tagType = TagsStorage.TagType.Int; } else { tagType = TagsStorage.TagType.Unknown; } if (node.Attributes["type"] != null) { // check if node is type of object // ovo staviti pod isti i, jer je isto code if (node.Attributes["type"].Value == "object") { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value, tagType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else { if (tagsStorage != null) { // if TagsStorage is not null then build nodes newTagsStorage = new TagsStorage(node.Attributes["name"].Value , tagType); tagsStorage.Add(newTagsStorage); if (node.HasChildNodes) { LoadXMLChild(newTagsStorage, node); } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } } else { ModuleLog.Write("Bad xml format \r\n" + node.InnerXml, this, "LoadXMLChild", ModuleLog.LogType.WARNING); } } else if (node.Name == "syntax") { //tbSyntax.Text = node.InnerText; } else if (node.Name == "result") { //lblResult.Text = "Result: " + node.InnerText; } else if (node.Name == "example") { //lblExample.Text = "Example: " + node.InnerText; } else { if (node.HasChildNodes) { LoadXMLChild(tagsStorage, node); } } } } }
public TagsStorage LoadTags() { TagsStorage rootNode = null; XmlDocument xmlDoc; if (File.Exists(this.path)) { xmlDoc = new XmlDocument(); try { rootNode = new TagsStorage("{=", TagsStorage.TagType.Object); xmlDoc.Load(path); LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags")); } catch (XmlException ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } catch (Exception ex) { ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR); } } return rootNode; }