// Get all layers nodes public void getLayerNodes(Node node, Nodes nodes) { if (node.haslayer) { foreach(Node subnode in this.layers.getLayer(node.id).nodes) { nodes.Add(subnode); if (subnode.haslayer) { getLayerNodes(subnode, nodes); } } } }
public void AddChild(T value) { Nodes.Add(new Tree <T>(value)); }
/// <summary> /// Search for string in all nodes </summary> public Nodes searchInAllNodes(string searchFor) { Nodes nodes = new Nodes(); foreach (Layer l in this.layers) { foreach (Node node in l.nodes) { if (node.Contain(searchFor)) { nodes.Add(node); } } } return nodes; }
public gbxmodel(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = "gbxmodel"; Flags = new Bitmask(Reader.ReadInt16()); Reader.SeekTo(Address + 0x30); uScale = Reader.ReadSingle(); vScale = Reader.ReadSingle(); #region MarkerGroups Block Reader.SeekTo(Address + 0xAC); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 64 * i)); } #endregion #region Nodes Block Reader.SeekTo(Address + 0xB8); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Nodes.Add(new Node(Cache, iOffset + 156 * i)); } #endregion #region Regions Block Reader.SeekTo(Address + 0xC4); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Regions.Add(new Region(Cache, iOffset + 76 * i)); } #endregion #region ModelParts Block Reader.SeekTo(Address + 0xD0); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, iOffset + 48 * i) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); } #endregion #region Shaders Block Reader.SeekTo(Address + 0xDC); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Shader(Cache, iOffset + 32 * i)); } #endregion #region BoundingBox Block BoundingBoxes.Add(new BoundingBox()); #endregion }
public void RemoveSameClasses() { var handledNodes = new HashSet <ICallGraphNode>(Nodes.Count); var processingNodes = new Queue <(ICallGraphNode, ICallGraphNode)>(); EntryNodes.Clear(); Nodes.Clear(); var roots = Roots.Values; Roots = new Dictionary <MethodUniqueSignature, ICallGraphNode>(); foreach (var rootNode in roots) { // we keep all parents of root(s) if (!handledNodes.Add(rootNode)) { continue; } var mappedRootNode = new CallInfoNode(rootNode.Info); Roots.Add(mappedRootNode.MethodSignature, mappedRootNode); Nodes.Add(mappedRootNode.MethodSignature, mappedRootNode); if (rootNode.InNodes.Count == 0 && !EntryNodes.ContainsKey(mappedRootNode.MethodSignature)) { EntryNodes.Add(mappedRootNode.MethodSignature, mappedRootNode); } foreach (var inNode in rootNode.InNodes) { var mappedNode = new CallInfoNode(inNode.Info); mappedRootNode.InNodes.Add(mappedNode); mappedNode.OutNodes.Add(mappedRootNode); if (!Nodes.ContainsKey(mappedNode.MethodSignature)) { Nodes.Add(mappedNode.MethodSignature, mappedNode); if (inNode.InNodes.Count == 0) { if (!EntryNodes.ContainsKey(mappedNode.MethodSignature)) { EntryNodes.Add(mappedNode.MethodSignature, mappedNode); } } else { processingNodes.Enqueue((inNode, mappedNode)); } } } } // and keep only different classes for other parents while (processingNodes.Count > 0) { var(node, mappedNode) = processingNodes.Dequeue(); if (!handledNodes.Add(node)) { continue; } var mappedInNodes = new HashSet <ICallGraphNode>(mappedNode.InNodes); foreach (var inNode in node.InNodes) { var classSignature = new MethodUniqueSignature(inNode.MethodSignature.ToClassName()); if (Nodes.TryGetValue(classSignature, out var mappedInNode)) { if (mappedInNode != mappedNode && mappedInNodes.Add(mappedInNode)) { mappedInNode.OutNodes.Add(mappedNode); } } else { mappedInNode = new CallInfoNode(new CallInfo( 0, null, inNode.AssemblyInfo, classSignature, inNode.IsPublic, null)); mappedInNodes.Add(mappedInNode); mappedInNode.OutNodes.Add(mappedNode); Nodes.Add(mappedInNode.MethodSignature, mappedInNode); } if (inNode.InNodes.Count == 0) { if (!EntryNodes.ContainsKey(mappedInNode.MethodSignature)) { EntryNodes.Add(mappedInNode.MethodSignature, mappedInNode); } } else { processingNodes.Enqueue((inNode, mappedInNode)); } } if (mappedNode.InNodes.Count != mappedInNodes.Count) { mappedNode.InNodes.Clear(); mappedNode.InNodes.AddRange(mappedInNodes); } } }
// Add new node on an existing connection public Result AddNode() { if (Connections.Count == 0) { //Cannot Add new node return(Result.fail); } //Get a random connection, it can be disabled too int rndConnNumb = MyRand.Next(0, Connections.Count); Connection rndConn = Connections[rndConnNumb]; //Deactivate this connection rndConn.Enabled = false; //Add a new node on it Node newNode = new Node(NodeCnt); NodeCnt++; newNode.Layer = rndConn.INode.Layer + 1; //Connect INode and new node Connection conn1 = new Connection(rndConn.INode); conn1.Weight = 1.0; conn1.Bias = 0.0; conn1.Enabled = true; conn1.ONode = newNode; InnovationHandler.GetInnovationID(conn1); rndConn.INode.Connections.Add(conn1); //TODO i could consider if the connection was disabled to create two "low" effect connections //Connect new node and Onode Connection conn2 = new Connection(newNode); conn2.Weight = rndConn.Weight; conn2.Bias = rndConn.Bias; conn2.Enabled = true; conn2.ONode = rndConn.ONode; InnovationHandler.GetInnovationID(conn2); newNode.Connections.Add(conn2); //If the connection we are breaking is between layers that are next to eachother //it means we need to add a new layer //else we need to increase the first intermediate layer if ((rndConn.INode.Layer + 1) == rndConn.ONode.Layer) { //New layer is needed //Shift every layer by one after the new layer foreach (var node in Nodes) { if (node.Layer > rndConn.INode.Layer) { node.Layer++; } } OutputLayer++; } else if ((rndConn.INode.Layer + 1) < rndConn.ONode.Layer) { //Layer should already exist } else { throw new Exception("Error: The connection is wrong!"); } //Finally add new object to the lists Nodes.Add(newNode); Connections.Add(conn1); Connections.Add(conn2); return(Result.success); }
/*************************************************************************************************************************/ // CLIPBOARD // paste part of diagram from clipboard public DiagramBlock AddDiagramPart(string DiagramXml, Position position, int layer) { Nodes NewNodes = new Nodes(); Lines NewLines = new Lines(); XmlReaderSettings xws = new XmlReaderSettings(); xws.CheckCharacters = false; string xml = DiagramXml; try { using (XmlReader xr = XmlReader.Create(new StringReader(xml), xws)) { XElement root = XElement.Load(xr); foreach (XElement diagram in root.Elements()) { if (diagram.HasElements) { if (diagram.Name.ToString() == "rectangles") { foreach (XElement block in diagram.Descendants()) { if (block.Name.ToString() == "rectangle") { Node R = new Node(); R.font = this.FontDefault; foreach (XElement el in block.Descendants()) { try { if (el.Name.ToString() == "id") { R.id = Int32.Parse(el.Value); } if (el.Name.ToString() == "text") { R.name = el.Value; } if (el.Name.ToString() == "note") { R.note = el.Value; } if (el.Name.ToString() == "x") { R.position.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "y") { R.position.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "color") { R.color.set(el.Value.ToString()); } if (el.Name.ToString() == "timecreate") { R.timecreate = el.Value; } if (el.Name.ToString() == "timemodify") { R.timemodify = el.Value; } if (el.Name.ToString() == "font") { R.font = Fonts.XmlToFont(el); } if (el.Name.ToString() == "fontcolor") { R.fontcolor.set(el.Value.ToString()); } if (el.Name.ToString() == "link") { R.link = el.Value; } if (el.Name.ToString() == "shortcut") { R.shortcut = Int32.Parse(el.Value); } if (el.Name.ToString() == "mark") { R.mark = bool.Parse(el.Value); } if (el.Name.ToString() == "transparent") { R.transparent = bool.Parse(el.Value); } if (el.Name.ToString() == "embeddedimage") { R.embeddedimage = bool.Parse(el.Value); } if (el.Name.ToString() == "imagedata") { R.image = new Bitmap(new MemoryStream(Convert.FromBase64String(el.Value))); R.height = R.image.Height; R.width = R.image.Width; R.isimage = true; } if (el.Name.ToString() == "image") { R.imagepath = el.Value.ToString(); if (Os.FileExists(R.imagepath)) { try { string ext = ""; ext = Os.getExtension(R.imagepath).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".ico" || ext == ".bmp") // skratenie cesty k suboru { R.image = Media.getImage(R.imagepath); if (ext != ".ico") R.image.MakeTransparent(Color.White); R.height = R.image.Height; R.width = R.image.Width; R.isimage = true; } } catch (Exception ex) { Program.log.write("load image from xml error: " + ex.Message); } } else { R.imagepath = ""; } } if (el.Name.ToString() == "timecreate") { R.timecreate = el.Value; } if (el.Name.ToString() == "timemodify") { R.timemodify = el.Value; } if (el.Name.ToString() == "attachment") { R.attachment = el.Value; } if (el.Name.ToString() == "layer") { R.layer = Int32.Parse(el.Value); } if (el.Name.ToString() == "protect") { R.protect = bool.Parse(el.Value); } } catch (Exception ex) { Program.log.write("Data has wrong structure. : error: " + ex.Message); } } NewNodes.Add(R); } } } if (diagram.Name.ToString() == "lines") { foreach (XElement block in diagram.Descendants()) { if (block.Name.ToString() == "line") { Line L = new Line(); foreach (XElement el in block.Descendants()) { try { if (el.Name.ToString() == "start") { L.start = Int32.Parse(el.Value); } if (el.Name.ToString() == "end") { L.end = Int32.Parse(el.Value); } if (el.Name.ToString() == "arrow") { L.arrow = el.Value == "1" ? true : false; } if (el.Name.ToString() == "color") { L.color.set(el.Value.ToString()); } if (el.Name.ToString() == "width") { L.width = Int32.Parse(el.Value); } if (el.Name.ToString() == "layer") { L.layer = Int32.Parse(el.Value); } } catch (Exception ex) { Program.log.write("Data has wrong structure. : error: " + ex.Message); } } NewLines.Add(L); } } } } } } } catch (Exception ex) { Program.log.write("Data has wrong structure. : error: " + ex.Message); } List<MappedNode> maps = new List<MappedNode>(); Nodes NewReorderedNodes = new Nodes(); // order nodes parent first (layer must exist when sub node is created) this.nodesReorderNodes(0, null, NewNodes, NewReorderedNodes); int layerParent = 0; MappedNode mappedNode; Nodes createdNodes = new Nodes(); Node newNode = null; int oldId = 0; foreach (Node rec in NewReorderedNodes) { layerParent = 0; if (rec.layer == 0) { layerParent = layer; } else { foreach (MappedNode mapednode in maps) { if (rec.layer == mapednode.oldId) { layerParent = mapednode.newNode.id; break; } } } rec.layer = layerParent; rec.position.add(position); rec.resize(); oldId = rec.id; newNode = this.createNode(rec); if (newNode != null) { mappedNode = new MappedNode(); mappedNode.oldId = oldId; mappedNode.newNode = newNode; createdNodes.Add(newNode); maps.Add(mappedNode); } } // fix layers and shortcuts foreach (Node rec in NewNodes) { if (rec.shortcut != 0) { foreach (MappedNode mapednode in maps) { if (rec.shortcut == mapednode.oldId) { rec.shortcut = mapednode.newNode.id; break; } } } } Lines createdLines = new Lines(); Line newLine = null; foreach (Line line in NewLines) { foreach (MappedNode mapbegin in maps) { if (line.start == mapbegin.oldId) { foreach (MappedNode mapend in maps) { if (line.end == mapend.oldId) { newLine = this.Connect( mapbegin.newNode, mapend.newNode, line.arrow, line.color, line.width ); if (newLine != null) { createdLines.Add(newLine); } } } } } } return new DiagramBlock(NewNodes, createdLines); }
protected override void PopulateCore() { Nodes.Add(new ListNode <Object>("Objects", Data.Objects, x => x.Name)); if (Parent != null && mTextureSetNode == null) { string textureSetName = null; var objectDatabase = SourceConfiguration?.ObjectDatabase; var objectSetInfo = objectDatabase?.GetObjectSetInfoByFileName(Name); if (objectSetInfo != null) { textureSetName = objectSetInfo.TextureFileName; } var textureSetNode = Parent.FindNode <TextureSetNode>(textureSetName); if (textureSetNode == null) { if (Name.EndsWith("_obj.bin", StringComparison.OrdinalIgnoreCase)) { textureSetName = $"{Name.Substring( 0, Name.Length - 8 )}_tex.bin"; } else if (Name.EndsWith(".osd", StringComparison.OrdinalIgnoreCase)) { textureSetName = Path.ChangeExtension(Name, "txd"); } textureSetNode = Parent.FindNode <TextureSetNode>(textureSetName); } if (textureSetNode != null && textureSetNode.Data.Textures.Count == Data.TextureIds.Count) { var textureDatabase = SourceConfiguration?.TextureDatabase; textureSetNode.Populate(); for (int i = 0; i < Data.TextureIds.Count; i++) { var texture = textureSetNode.Data.Textures[i]; var textureInfo = textureDatabase?.GetTextureInfo(Data.TextureIds[i]); texture.Id = Data.TextureIds[i]; texture.Name = textureInfo?.Name ?? texture.Name; } Data.TextureSet = textureSetNode.Data; mTextureSetNode = new ReferenceNode("Texture Set", textureSetNode); } else { mTextureSetNode = null; } } if (mTextureSetNode == null && Data.TextureSet != null) { mTextureSetNode = new TextureSetNode("Texture Set", Data.TextureSet); } if (mTextureSetNode != null) { Nodes.Add(mTextureSetNode); } }
public void unsave(string type, Node node, Line line, Position position = null, int layer = 0) { Nodes nodes = new Nodes(); nodes.Add(node); Lines lines = new Lines(); lines.Add(line); this.unsave(type, nodes, lines, position, layer); }
// Get all layers nodes private void nodesReorderNodes(int layer, Node parent, Nodes nodesIn, Nodes nodesOut) { foreach (Node node in nodesIn) { if (node.layer == layer) { if (parent != null) { parent.haslayer = true; } nodesOut.Add(node); nodesReorderNodes(node.id, node, nodesIn, nodesOut); } } }
// split node to lines public Nodes splitNode(Nodes nodes) { if (nodes.Count() > 0) { Nodes newNodes = new Nodes(); int minx = nodes[0].position.x; int miny = nodes[0].position.y; foreach (Node rec in nodes) { if (rec.position.y <= miny) // find most top element { minx = rec.position.x; miny = rec.position.y; } } foreach (Node node in nodes) // create new nodes { string[] lines = node.name.Split(new string[] { "\n" }, StringSplitOptions.None); int posy = node.position.y + node.height + 10; foreach (String line in lines) { if (line.Trim() != "") { Node newNode = this.createNode(new Node(node)); // duplicate content of old node newNode.setName(line); newNode.position.y = posy; posy = posy + newNode.height + 10; newNodes.Add(newNode); } } } return newNodes; } return null; }
// XML LOAD inner part of diagram file. If file is invalid return false public bool LoadInnerXML(string xml) { string FontDefaultString = TypeDescriptor.GetConverter(typeof(Font)).ConvertToString(this.FontDefault); XmlReaderSettings xws = new XmlReaderSettings(); xws.CheckCharacters = false; Nodes nodes = new Nodes(); Lines lines = new Lines(); try { using (XmlReader xr = XmlReader.Create(new StringReader(xml), xws)) { XElement root = XElement.Load(xr); foreach (XElement diagram in root.Elements()) { if (diagram.HasElements) { if (diagram.Name.ToString() == "option") // [options] [config] { foreach (XElement el in diagram.Descendants()) { try { if (el.Name.ToString() == "shiftx") { this.options.homePosition.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "shifty") { this.options.homePosition.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "homelayer") { options.homeLayer = Int32.Parse(el.Value); } if (el.Name.ToString() == "endlayer") { options.endLayer = Int32.Parse(el.Value); } if (el.Name.ToString() == "endPositionx") { this.options.endPosition.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "endPositiony") { this.options.endPosition.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "startShiftX") { options.homePosition.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "startShiftY") { options.homePosition.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "diagramreadonly") { this.options.readOnly = bool.Parse(el.Value); } if (el.Name.ToString() == "grid") { this.options.grid = bool.Parse(el.Value); } if (el.Name.ToString() == "borders") { this.options.borders = bool.Parse(el.Value); } if (el.Name.ToString() == "defaultfont") { if (el.Attribute("type").Value == "font") { this.FontDefault = Fonts.XmlToFont(el); } else { if (FontDefaultString != el.Value) { this.FontDefault = (Font)TypeDescriptor.GetConverter(typeof(Font)).ConvertFromString(el.Value); } } } if (el.Name.ToString() == "coordinates") { this.options.coordinates = bool.Parse(el.Value); } if (el.Name.ToString() == "firstLayereShift.x") { this.options.firstLayereShift.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "firstLayereShift.y") { this.options.firstLayereShift.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "openLayerInNewView") { this.options.openLayerInNewView = bool.Parse(el.Value); } if (el.Name.ToString() == "window.position.restore") { this.options.restoreWindow = bool.Parse(el.Value); } if (el.Name.ToString() == "window.position.x") { this.options.Left = Int32.Parse(el.Value); } if (el.Name.ToString() == "window.position.y") { this.options.Top = Int32.Parse(el.Value); } if (el.Name.ToString() == "window.position.width") { this.options.Width = Int32.Parse(el.Value); } if (el.Name.ToString() == "window.position.height") { this.options.Height = Int32.Parse(el.Value); } if (el.Name.ToString() == "window.state") { this.options.WindowState = Int32.Parse(el.Value); } if (el.Name.ToString() == "icon") { this.options.icon = el.Value; } if (el.Name.ToString() == "backgroundImage") { this.options.backgroundImage = Media.StringToImage(el.Value); } } catch (Exception ex) { Program.log.write("load xml diagram options: " + ex.Message); } } } if (diagram.Name.ToString() == "rectangles") { foreach (XElement block in diagram.Descendants()) { if (block.Name.ToString() == "rectangle") { Node R = new Node(); R.font = this.FontDefault; foreach (XElement el in block.Descendants()) { try { if (el.Name.ToString() == "id") { R.id = Int32.Parse(el.Value); } if (el.Name.ToString() == "font") { if (el.Attribute("type").Value == "font") { R.font = Fonts.XmlToFont(el); } else { if (FontDefaultString != el.Value) { R.font = (Font)TypeDescriptor.GetConverter(typeof(Font)).ConvertFromString(el.Value); } } } if (el.Name.ToString() == "fontcolor") { R.fontcolor.set(el.Value.ToString()); } if (el.Name.ToString() == "text") { R.name = el.Value; } if (el.Name.ToString() == "note") { R.note = el.Value; } if (el.Name.ToString() == "link") { R.link = el.Value; } if (el.Name.ToString() == "scriptid") { R.scriptid = el.Value; } if (el.Name.ToString() == "shortcut") { R.shortcut = Int32.Parse(el.Value); } if (el.Name.ToString() == "mark") { R.mark = bool.Parse(el.Value); } if (el.Name.ToString() == "attachment") { R.attachment = el.Value; } if (el.Name.ToString() == "layer") { R.layer = Int32.Parse(el.Value); } if (el.Name.ToString() == "haslayer") { R.haslayer = bool.Parse(el.Value); } if (el.Name.ToString() == "layershiftx") { R.layerShift.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "layershifty") { R.layerShift.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "x") { R.position.x = Int32.Parse(el.Value); } if (el.Name.ToString() == "y") { R.position.y = Int32.Parse(el.Value); } if (el.Name.ToString() == "width") { R.width = Int32.Parse(el.Value); } if (el.Name.ToString() == "height") { R.height = Int32.Parse(el.Value); } if (el.Name.ToString() == "color") { R.color.set(el.Value.ToString()); } if (el.Name.ToString() == "transparent") { R.transparent = bool.Parse(el.Value); } if (el.Name.ToString() == "embeddedimage") { R.embeddedimage = bool.Parse(el.Value); } if (el.Name.ToString() == "imagedata") { R.image = Media.StringToBitmap(el.Value); R.height = R.image.Height; R.width = R.image.Width; R.isimage = true; } if (el.Name.ToString() == "image") { R.imagepath = el.Value.ToString(); R.loadImage(); } if (el.Name.ToString() == "timecreate") { R.timecreate = el.Value; } if (el.Name.ToString() == "timemodify") { R.timemodify = el.Value; } if (el.Name.ToString() == "protect") { R.protect = bool.Parse(el.Value); } } catch (Exception ex) { Program.log.write("load xml nodes error: " + ex.Message); } } nodes.Add(R); } } } if (diagram.Name.ToString() == "lines") { foreach (XElement block in diagram.Descendants()) { if (block.Name.ToString() == "line") { Line L = new Line(); L.layer = -1; // for identification unset layers foreach (XElement el in block.Descendants()) { try { if (el.Name.ToString() == "start") { L.start = Int32.Parse(el.Value); } if (el.Name.ToString() == "end") { L.end = Int32.Parse(el.Value); } if (el.Name.ToString() == "arrow") { L.arrow = el.Value == "1" ? true : false; } if (el.Name.ToString() == "color") { L.color.set(el.Value.ToString()); } if (el.Name.ToString() == "width") { L.width = Int32.Parse(el.Value); } if (el.Name.ToString() == "layer") { L.layer = Int32.Parse(el.Value); } } catch (Exception ex) { Program.log.write("load xml lines error: " + ex.Message); } } lines.Add(L); } } } } } } } catch (Exception ex) { MessageBox.Show(Translations.fileHasWrongFormat); Program.log.write("load xml error: " + ex.Message); this.CloseFile(); return false; } int newWidth = 0; int newHeight = 0; Nodes nodesReordered = new Nodes(); // order nodes parent first (layer must exist when sub node is created) this.nodesReorderNodes(0, null, nodes, nodesReordered); foreach (Node rec in nodesReordered) // Loop through List with foreach { if (!rec.isimage) { SizeF s = rec.measure(); newWidth = (int)s.Width; newHeight = (int)s.Height; // font change correction > center node if (rec.width != 0 && newWidth != rec.width) { rec.position.x += (rec.width - newWidth) / 2; } if (rec.height != 0 && newHeight != rec.height) { rec.position.y += (rec.height - newHeight) / 2; } rec.resize(); } this.layers.addNode(rec); } this.layers.setLayersParentsReferences(); foreach (Line line in lines) { this.Connect( this.layers.getNode(line.start), this.layers.getNode(line.end), line.arrow, line.color, line.width ); } return true; }
public DiagramBlock getPartOfDiagram(Nodes nodes) { Nodes allNodes = new Nodes(); Lines lines = new Lines(); foreach (Node node in nodes) { allNodes.Add(node); } if (allNodes.Count() > 0) { Nodes subnodes = new Nodes(); foreach (Node node in allNodes) { getLayerNodes(node, subnodes); } foreach (Node node in subnodes) { allNodes.Add(node); } foreach (Line li in this.getAllLines()) { foreach (Node recstart in allNodes) { if (li.start == recstart.id) { foreach (Node recend in allNodes) { if (li.end == recend.id) { lines.Add(li); } } } } } } return new DiagramBlock(allNodes, lines); }
/// <summary> /// TBD /// </summary> /// <param name="member">TBD</param> public void AddMember(Member member) { Nodes = Nodes.Add(member.Address); AddRoutees(); }
public DiagramBlock duplicatePartOfDiagram(Nodes nodes, int layer = 0) { // get part of diagram for duplicate DiagramBlock diagramPart = this.getPartOfDiagram(nodes); List<MappedNode> maps = new List<MappedNode>(); Nodes duplicatedNodes = new Nodes(); foreach (Node node in diagramPart.nodes) { duplicatedNodes.Add(node.clone()); } // order nodes parent first (layer must exist when sub node is created) Nodes NewReorderedNodes = new Nodes(); this.nodesReorderNodes(layer, null, duplicatedNodes, NewReorderedNodes); int layerParent = 0; MappedNode mappedNode; Nodes createdNodes = new Nodes(); Node newNode = null; int oldId = 0; foreach (Node rec in NewReorderedNodes) { layerParent = layer; // find layer id for sub layer foreach (MappedNode mapednode in maps) { if (rec.layer == mapednode.oldId) { layerParent = mapednode.newNode.id; break; } } rec.layer = layerParent; rec.resize(); oldId = rec.id; newNode = this.createNode(rec); if (newNode != null) { mappedNode = new MappedNode(); mappedNode.oldId = oldId; mappedNode.newNode = newNode; createdNodes.Add(newNode); maps.Add(mappedNode); } } // fix layers and shortcuts foreach (Node rec in duplicatedNodes) { if (rec.shortcut != 0) { foreach (MappedNode mapednode in maps) { if (rec.shortcut == mapednode.oldId) { rec.shortcut = mapednode.newNode.id; break; } } } } Lines createdLines = new Lines(); Line newLine = null; foreach (Line line in diagramPart.lines) { foreach (MappedNode mapbegin in maps) { if (line.start == mapbegin.oldId) { foreach (MappedNode mapend in maps) { if (line.end == mapend.oldId) { // create new line by connecting new nodes newLine = this.Connect( mapbegin.newNode, mapend.newNode, line.arrow, line.color, line.width ); if (newLine != null) // skip invalid lines (perent not exist) { createdLines.Add(newLine); } } } } } } return new DiagramBlock(createdNodes, createdLines); }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); Nodes.Add(new TreeNode("A Node")); }
// [DROP] [DROP-FILE] [EVENT] // EVENT DROP file public void DiagramApp_DragDrop(object sender, DragEventArgs e) { #if DEBUG this.logEvent("DragDrop"); #endif try { Nodes newNodes = new Nodes(); string[] formats = e.Data.GetFormats(); string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { Node newrec = this.CreateNode(this.getMousePosition()); newNodes.Add(newrec); newrec.setName(Os.getFileName(file)); newrec.link = file; if (Os.DirectoryExists(file)) // directory { newrec.link = Os.makeRelative(file, this.diagram.FileName); newrec.color.set(Media.getColor(diagram.options.colorDirectory)); } else if (Os.Exists(file)) { newrec.color.set(Media.getColor(diagram.options.colorFile)); if (this.diagram.FileName != "" && Os.FileExists(this.diagram.FileName)) // DROP FILE - skratenie cesty k suboru { newrec.link = Os.makeRelative(file, this.diagram.FileName); } string ext = ""; ext = Os.getExtension(file).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".ico" || ext == ".bmp") // DROP IMAGE skratenie cesty k suboru { newrec.isimage = true; newrec.imagepath = Os.makeRelative(file, this.diagram.FileName); newrec.image = Media.getImage(file); if (ext != ".ico") newrec.image.MakeTransparent(Color.White); newrec.height = newrec.image.Height; newrec.width = newrec.image.Width; } #if !MONO else if (ext == ".lnk") // [LINK] [DROP] extract target { try { string[] shortcutInfo = Os.GetShortcutTargetFile(file); Bitmap icoLnk = Media.extractLnkIcon(file); if (icoLnk != null)// extract icon { newrec.isimage = true; newrec.embeddedimage = true; newrec.image = icoLnk; newrec.image.MakeTransparent(Color.White); newrec.height = newrec.image.Height; newrec.width = newrec.image.Width; } else if (shortcutInfo[0] != "" && Os.FileExists(shortcutInfo[0])) { Bitmap icoExe = Media.extractSystemIcon(shortcutInfo[0]); if (icoExe != null)// extract icon { newrec.isimage = true; newrec.embeddedimage = true; newrec.image = icoExe; newrec.image.MakeTransparent(Color.White); newrec.height = newrec.image.Height; newrec.width = newrec.image.Width; } } newrec.link = Os.makeRelative(file, this.diagram.FileName); } catch (Exception ex) { Program.log.write("extract icon from lnk error: " + ex.Message); } } else { Bitmap ico = Media.extractSystemIcon(file); if (ico != null)// extract icon { newrec.isimage = true; newrec.embeddedimage = true; newrec.image = ico; newrec.image.MakeTransparent(Color.White); newrec.height = newrec.image.Height; newrec.width = newrec.image.Width; } } #endif } } this.diagram.unsave("create", newNodes, null, this.shift, this.currentLayer.id); } catch (Exception ex) { Program.log.write("drop file goes wrong: error: " + ex.Message); } }
public UnicodeStructureNode(int int1, string string0) { Int0 = int1; Nodes.Add(new UnicodeValueNode(string0)); vmethod_0(); }
// EVENT Mouse Up // [MOUSE] [UP] [EVENT] public void DiagramApp_MouseUp(object sender, MouseEventArgs e) { #if DEBUG this.logEvent("MouseUp"); #endif this.actualMousePos.set(e.X, e.Y); Position mouseTranslation = new Position(this.actualMousePos).subtract(this.startMousePos); // States bool mousemove = ((this.actualMousePos.x != this.startMousePos.x) || (this.actualMousePos.y != this.startMousePos.y)); // mouse change position bool buttonleft = e.Button == MouseButtons.Left; bool buttonright = e.Button == MouseButtons.Right; bool buttonmiddle = e.Button == MouseButtons.Middle; bool isreadonly = this.diagram.options.readOnly; bool keyalt = this.keyalt; bool keyctrl = this.keyctrl; bool keyshift = this.keyshift; bool dblclick = this.stateDblclick; bool finishdraging = this.stateDragSelection; bool finishadding = this.stateAddingNode; bool finishselecting = mousemove && this.stateSelectingNodes; MoveTimer.Enabled = false; if(dblclick) { this.stateSelectingNodes = false; } else // KEY DRAG if (finishdraging) // drag node { if (!this.diagram.options.readOnly) { if (this.sourceNode != null && !keyctrl) // return node to starting position after connection is created { Position translation = new Position(this.startNodePos) .subtract(sourceNode.position); if (this.selectedNodes.Count > 0) { foreach (Node node in this.selectedNodes) { node.position.add(translation); } } this.diagram.InvalidateDiagram(); } } } else // KEY DRAG-MMIDDLE if (finishadding) { this.diagram.InvalidateDiagram(); } else // KEY DRAG+MLEFT select nodes with selection rectangle if (finishselecting) { if (mousemove) { Position a = new Position(this.startMousePos) .scale(this.scale) .add(this.shift) .subtract(this.startShift); Position b = new Position(this.actualMousePos) .scale(this.scale); int temp; if (b.x < a.x) { temp = a.x; a.x = b.x; b.x = temp; } if (b.y < a.y) { temp = b.y; b.y = a.y; a.y = temp; } if (!this.keyshift) this.ClearSelection(); foreach (Node rec in this.currentLayer.nodes) { if ( (rec.layer == this.currentLayer.id || rec.id == this.currentLayer.id) && -this.shift.x + a.x <= rec.position.x && rec.position.x + rec.width <= -this.shift.x + b.x && -this.shift.y + a.y <= rec.position.y && rec.position.y + rec.height <= -this.shift.y + b.y) // get all nodes in selection rectangle { if (keyshift && !keyctrl && !keyalt) // KEY SHIFT+MLEFT Invert selection { if (rec.selected) { this.RemoveNodeFromSelection(rec); } else { this.SelectNode(rec); } } if (!keyshift && !keyctrl && !keyalt) // KEY MLEFT select nodes { this.SelectNode(rec); } } } this.diagram.InvalidateDiagram(); } } Node TargetNode = this.findNodeInMousePosition(new Position(e.X, e.Y)); if (buttonleft) // MLEFT { if (!keyalt && keyctrl && !keyshift && TargetNode != null && TargetNode.selected) // CTRL+CLICK add node to selection { this.RemoveNodeFromSelection(TargetNode); this.diagram.InvalidateDiagram(); } else if (!keyalt && keyctrl && !keyshift && TargetNode != null && !TargetNode.selected) // CTRL+CLICK remove node from selection { this.SelectNode(TargetNode); this.diagram.InvalidateDiagram(); } else if (this.stateCoping && mousemove) // CTRL+DRAG copy part of diagram { this.stateCoping = false; DiagramBlock newBlock = this.diagram.duplicatePartOfDiagram(this.selectedNodes, this.currentLayer.id); Position vector = new Position(this.actualMousePos) .scale(this.scale) .subtract(this.vmouse) .subtract(this.shift) .subtract(this.sourceNode.position); // filter only top nodes fromm all new created nodes. NewNodes containing sublayer nodes. Nodes topNodes = new Nodes(); foreach (Node node in newBlock.nodes) { if (node.layer == this.currentLayer.id) { topNodes.Add(node); } } foreach (Node node in topNodes) { node.position.add(vector); } this.diagram.unsave("create", newBlock.nodes, newBlock.lines); this.SelectNodes(topNodes); this.diagram.unsave(); this.diagram.InvalidateDiagram(); } else if (bottomScrollBar != null && rightScrollBar != null && (bottomScrollBar.MouseUp() || rightScrollBar.MouseUp())) { this.diagram.InvalidateDiagram(); } else // KEY MLEFT clear selection if (!mousemove && TargetNode == null && this.sourceNode == null && this.selectedNodes.Count() > 0 && !keyalt && !keyctrl && !keyshift) { this.ClearSelection(); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create node and conect with existing node if (!isreadonly && !keyshift && keyctrl && keyalt && TargetNode == null && this.sourceNode != null) { var s = this.sourceNode; var node = this.CreateNode(new Position(e.X, e.Y)); node.shortcut = s.id; this.diagram.Connect(s, node); this.diagram.unsave("create", node, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create shortcut beetwen objects if (!isreadonly && !keyshift && keyctrl && keyalt && TargetNode != null && this.sourceNode != null && TargetNode != this.sourceNode) { this.diagram.unsave("edit", this.sourceNode, this.shift, this.currentLayer.id); this.sourceNode.link = "#" + TargetNode.id.ToString(); this.diagram.unsave(); this.diagram.InvalidateDiagram(); } else // KEY DRAG move node if ( !isreadonly && ( (TargetNode == null && this.sourceNode != null) || ( TargetNode != null && this.sourceNode != TargetNode && TargetNode.selected ) || (TargetNode != null && this.sourceNode == TargetNode) ) && Math.Sqrt(mouseTranslation.x * mouseTranslation.x + mouseTranslation.y * mouseTranslation.y) > 5 ) { Position vector = new Position(this.actualMousePos) .scale(this.scale) .subtract(this.vmouse) .subtract(this.shift) .subtract(this.sourceNode.position); if (this.selectedNodes.Count > 0) { this.diagram.undoOperations.add("edit", this.selectedNodes, null, this.shift, this.currentLayer.id); foreach (Node node in this.selectedNodes) { node.position.add(vector); } this.diagram.unsave(); } this.diagram.InvalidateDiagram(); } else // KEY DRAG+CTRL create node and conect with existing node if (!isreadonly && !keyshift && !keyctrl && keyalt && TargetNode != null && this.sourceNode == null) { Node node = this.CreateNode( new Position( +this.shift.x - startShift.x + this.startMousePos.x, +this.shift.y - startShift.y + this.startMousePos.y ) ); Line line = this.diagram.Connect( node, TargetNode ); this.diagram.unsave("create", node, line, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create node and make shortcut to target node if (!isreadonly && keyalt && keyctrl && !keyshift && TargetNode != null && this.sourceNode == null) { Node newrec = this.CreateNode( new Position(this.shift).subtract(startShift).add(this.startMousePos) ); newrec.link = "#" + TargetNode.id; this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DBLCLICK open link or edit window after double click on node [dblclick] [open] [edit] if (dblclick && this.sourceNode != null && !keyctrl && !keyalt && !keyshift) { this.resetStates(); this.OpenLinkAsync(this.sourceNode); } else // KEY SHIFT+DBLCLICK open node edit form if (dblclick && this.sourceNode != null && !keyctrl && !keyalt && keyshift) { this.diagram.EditNode(this.sourceNode); } else // KEY CTRL+DBLCLICK open link in node if (dblclick && this.sourceNode != null && keyctrl && !keyalt && !keyshift) { if (this.sourceNode.link != "") { Os.openPathInSystem(this.sourceNode.link); } } else // KEY DBLCLICK+SPACE change position in zoom view mode if (this.stateZooming && dblclick && !keyctrl && !keyalt && !keyshift) { this.shift .subtract( this.actualMousePos .clone() .scale(this.scale) ) .add( (this.ClientSize.Width * this.scale) / 2, (this.ClientSize.Height * this.scale) / 2 ); this.diagram.InvalidateDiagram(); } else // KEY CTRL+SHIFT+MLEFT conect with selected nodes new node or selected node if (!isreadonly && keyshift && keyctrl && this.selectedNodes.Count() > 0 && e.X == this.startMousePos.x && e.Y == this.startMousePos.y) { // TODO Still working this? Node newrec = TargetNode; Nodes newNodes = new Nodes(); if (newrec == null) { newrec = this.CreateNode(this.actualMousePos.clone().subtract(10), false); newNodes.Add(newrec); } Lines newLines = new Lines(); foreach (Node rec in this.selectedNodes) { Line line = this.diagram.Connect(rec, newrec); newLines.Add(line); } this.SelectOnlyOneNode(newrec); this.diagram.unsave("create", newNodes, newLines, this.shift, this.currentLayer.id); } else // KEY ALT+MLEFT // KEY DBLCLICK create new node if (!isreadonly && (dblclick || keyalt) && !keyshift && !keyctrl && TargetNode == null && this.sourceNode == null && e.X == this.startMousePos.x && e.Y == this.startMousePos.y) { Node newNode = this.CreateNode(this.actualMousePos.clone().subtract(10), false); this.diagram.unsave("create", newNode, this.shift, this.currentLayer.id); } else // KEY DRAG+ALT copy style from node to other node if (!isreadonly && !keyshift && !keyctrl && keyalt && TargetNode != null && this.sourceNode != null && this.sourceNode != TargetNode) { if (this.selectedNodes.Count() > 1) { this.diagram.undoOperations.add("edit", this.selectedNodes, null, this.shift, this.currentLayer.id); foreach (Node rec in this.selectedNodes) { rec.copyNodeStyle(TargetNode); } this.diagram.unsave(); } if (this.selectedNodes.Count() == 1 || (this.selectedNodes.Count() == 0 && this.sourceNode != null)) { this.diagram.undoOperations.add("edit", TargetNode, this.shift, this.currentLayer.id); TargetNode.copyNodeStyle(this.sourceNode); if (this.selectedNodes.Count() == 1 && this.selectedNodes[0] != this.sourceNode) { this.ClearSelection(); this.SelectNode(this.sourceNode); } this.diagram.unsave(); } } else // KEY DRAG make link between two nodes if (!isreadonly && !keyctrl && !keyalt && TargetNode != null && this.sourceNode != null && this.sourceNode != TargetNode) { bool arrow = false; if (keyshift) { arrow = true; } Lines newLines = new Lines(); Lines removeLines = new Lines(); if (this.selectedNodes.Count() > 0) { foreach (Node rec in this.selectedNodes) { if (rec != TargetNode) { if (this.diagram.hasConnection(rec, TargetNode)) { Line removeLine = this.diagram.getLine(rec, TargetNode); removeLines.Add(removeLine); this.diagram.Disconnect(rec, TargetNode); } else { Line newLine = this.diagram.Connect(rec, TargetNode, arrow, null); newLines.Add(newLine); } } } } if (newLines.Count() > 0 && removeLines.Count() > 0) { this.diagram.undoOperations.startGroup(); this.diagram.undoOperations.add("create", null, newLines, this.shift, this.currentLayer.id); this.diagram.undoOperations.add("delete", null, removeLines, this.shift, this.currentLayer.id); this.diagram.undoOperations.endGroup(); this.diagram.unsave(); } else if (newLines.Count() > 0) { this.diagram.undoOperations.add("create", null, newLines, this.shift, this.currentLayer.id); } else if (removeLines.Count() > 0) { this.diagram.undoOperations.add("delete", null, removeLines, this.shift, this.currentLayer.id); } this.diagram.InvalidateDiagram(); } // KEY SHIFT+MLEFT add node to selected nodes else if (!keyctrl && keyshift && !keyalt && this.sourceNode == TargetNode && TargetNode != null && !TargetNode.selected) { this.SelectNode(TargetNode); this.diagram.InvalidateDiagram(); } // KEY SHIFT+MLEFT remove node from selected nodes else if (!keyctrl && keyshift && !keyalt && TargetNode != null && (this.sourceNode == TargetNode || TargetNode.selected)) { this.RemoveNodeFromSelection(TargetNode); this.diagram.InvalidateDiagram(); } else if (this.sourceNode == TargetNode && this.stateSourceNodeAlreadySelected) { this.rename(); } } else if (buttonright) // KEY MRIGHT { this.stateMoveView = false; // show popup menu if (e.X == this.startMousePos.x && e.Y == this.startMousePos.y && this.startShift.x == this.shift.x && this.startShift.y == this.shift.y) { Node temp = this.findNodeInMousePosition(new Position(e.X, e.Y)); if (temp == null || (this.sourceNode != temp && !temp.selected)) { this.ClearSelection(); this.SelectOnlyOneNode(temp); } this.diagram.InvalidateDiagram(); PopupMenu.Show(this.Left + e.X, this.Top + e.Y); // [POPUP] show popup } else { // KEY DRAG+MRIGHT move view this.shift.x = (int)(this.startShift.x + (e.X - this.startMousePos.x) * this.scale); this.shift.y = (int)(this.startShift.y + (e.Y - this.startMousePos.y) * this.scale); this.diagram.InvalidateDiagram(); } } else if (buttonmiddle) // MMIDDLE { // KEY DRAG+MMIDDLE conect two existing nodes if (this.sourceNode != null && TargetNode != null) { Line newLine = this.diagram.Connect( sourceNode, TargetNode ); if (newLine != null) { this.diagram.unsave("create", newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } } else // KEY DRAG+MMIDDLE connect exixting node with new node if (this.sourceNode != null && TargetNode == null) { Node newNode = this.CreateNode(this.actualMousePos.clone().subtract(10)); Line newLine = this.diagram.Connect( sourceNode, newNode ); this.diagram.unsave("create", newNode, newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DRAG+MMIDDLE create new node and conect id with existing node if (!isreadonly && TargetNode != null) { Node newNode = this.CreateNode( (new Position(this.shift)).subtract(this.startShift).add(this.startMousePos) ); Line newLine = this.diagram.Connect( newNode, TargetNode ); this.diagram.unsave("create", newNode, newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DRAG+MMIDDLE create new node and conect with new node (create line) if (!isreadonly && TargetNode == null) { Nodes nodes = new Nodes(); Lines lines = new Lines(); Node node1 = this.CreateNode( (new Position(this.shift)).subtract(this.startShift).add(this.startMousePos), false ); nodes.Add(node1); Node node2 = this.CreateNode( this.actualMousePos.clone().subtract(10) ); nodes.Add(node2); lines.Add(this.diagram.Connect( node1, node2 )); this.diagram.unsave("create", nodes, lines, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } } this.resetStates(); }
private void ReadGx2(FileReader reader) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; header = new GTXHeader(); header.Read(reader); Console.WriteLine("header size " + header.HeaderSize); uint surfBlockType; uint dataBlockType; uint mipBlockType; uint vertexShaderHeader = 0x03; uint vertexShaderProgram = 0x05; uint pixelShaderHeader = 0x06; uint pixelShaderProgram = 0x07; uint geometryShaderHeader = 0x08; uint geometryShaderProgram = 0x09; uint userDataBlock = 0x10; if (header.MajorVersion == 6 && header.MinorVersion == 0) { surfBlockType = 0x0A; dataBlockType = 0x0B; mipBlockType = 0x0C; } else if (header.MajorVersion == 6 || header.MajorVersion == 7) { surfBlockType = 0x0B; dataBlockType = 0x0C; mipBlockType = 0x0D; } else { throw new Exception($"Unsupported GTX version {header.MajorVersion}"); } if (header.GpuVersion != 2) { throw new Exception($"Unsupported GPU version {header.GpuVersion}"); } reader.Position = header.HeaderSize; bool blockB = false; bool blockC = false; uint ImageInfo = 0; uint images = 0; while (reader.Position < reader.BaseStream.Length) { Console.WriteLine("BLOCK POS " + reader.Position + " " + reader.BaseStream.Length); GTXDataBlock block = new GTXDataBlock(); block.Read(reader); blocks.Add(block); bool BlockIsEmpty = block.BlockType == BlockType.AlignData || block.BlockType == BlockType.EndOfFile; //Here we use "if" instead of "case" statements as types vary between versions if ((uint)block.BlockType == surfBlockType) { ImageInfo += 1; blockB = true; var surface = new SurfaceInfoParse(); surface.Read(new FileReader(block.data)); if (surface.tileMode == 0 || surface.tileMode > 16) { throw new Exception($"Invalid tileMode {surface.tileMode}!"); } if (surface.numMips > 14) { throw new Exception($"Invalid number of mip maps {surface.numMips}!"); } TextureData textureData = new TextureData(); textureData.surface = surface; textureData.MipCount = surface.numMips; textureData.ArrayCount = surface.depth; textureData.Text = "Texture" + ImageInfo; Nodes.Add(textureData); textures.Add(textureData); } else if ((uint)block.BlockType == dataBlockType) { images += 1; blockC = true; data.Add(block.data); } else if ((uint)block.BlockType == mipBlockType) { mipMaps.Add(block.data); } else if ((uint)block.BlockType == vertexShaderHeader) { Nodes.Add(new BlockDisplay(block.data) { Text = "Vertex Shader Header" }); } else if ((uint)block.BlockType == vertexShaderProgram) { Nodes.Add(new BlockDisplay(block.data) { Text = "Vertex Shader Program" }); } else if ((uint)block.BlockType == pixelShaderHeader) { Nodes.Add(new BlockDisplay(block.data) { Text = "Pixel Shader Header" }); } else if ((uint)block.BlockType == pixelShaderProgram) { Nodes.Add(new BlockDisplay(block.data) { Text = "Pixel Shader Program" }); } else if ((uint)block.BlockType == geometryShaderHeader) { Nodes.Add(new BlockDisplay(block.data) { Text = "Geometry Shader Header" }); } else if ((uint)block.BlockType == geometryShaderProgram) { Nodes.Add(new BlockDisplay(block.data) { Text = "Geometry Shader Program" }); } else if (!BlockIsEmpty) { Nodes.Add(new BlockDisplay(block.data) { Text = $"Block Type {block.BlockType.ToString("X")}" }); } } if (textures.Count != data.Count) { throw new Exception($"Bad size! {textures.Count} {data.Count}"); } int curTex = 0; int curMip = 0; foreach (var node in Nodes) { if (node is TextureData) { TextureData tex = (TextureData)node; tex.surface.data = data[curTex]; tex.surface.bpp = GX2.surfaceGetBitsPerPixel(tex.surface.format) >> 3; tex.Format = FTEX.ConvertFromGx2Format((Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)tex.surface.format); tex.Width = tex.surface.width; tex.Height = tex.surface.height; if (tex.surface.numMips > 1) { tex.surface.mipData = mipMaps[curMip++]; } else { tex.surface.mipData = new byte[0]; } if (tex.surface.mipData == null) { tex.surface.numMips = 1; } curTex++; } } }
// NODE paste public bool paste(Position position) { DataObject retrievedData = (DataObject)Clipboard.GetDataObject(); if (retrievedData.GetDataPresent("DiagramXml")) // [PASTE] [DIAGRAM] [CLIPBOARD OBJECT] insert diagram { DiagramBlock newBlock = this.diagram.AddDiagramPart( retrievedData.GetData("DiagramXml") as string, position.clone().scale(this.scale).subtract(this.shift), this.currentLayer.id ); this.diagram.unsave("create", newBlock.nodes, newBlock.lines); // filter only top nodes fromm all new created nodes. NewNodes containing sublayer nodes. Nodes topNodes = new Nodes(); foreach (Node node in newBlock.nodes) { if (node.layer == this.currentLayer.id) { topNodes.Add(node); } } this.SelectNodes(topNodes); this.diagram.InvalidateDiagram(); } else if (retrievedData.GetDataPresent(DataFormats.StringFormat)) // [PASTE] [TEXT] insert text { Node newrec = this.CreateNode(position); string ClipText = retrievedData.GetData(DataFormats.StringFormat) as string; if (Patterns.isColor(ClipText)) { newrec.setName(ClipText); newrec.color.set(Media.getColor(ClipText)); this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); } else if (Patterns.isURL(ClipText)) // [PASTE] [URL] [LINK] paste link from clipboard { newrec.link = ClipText; newrec.setName(ClipText); this.setNodeNameByLink(newrec, ClipText); this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); } else { newrec.setName(ClipText); // set link to node as path to file if (Os.FileExists(ClipText)) { newrec.setName(Os.getFileName(ClipText)); newrec.link = Os.makeRelative(ClipText, this.diagram.FileName); newrec.color.set(Media.getColor(diagram.options.colorFile)); } // set link to node as path to directory if (Os.DirectoryExists(ClipText)) { newrec.setName(Os.getFileName(ClipText)); newrec.link = Os.makeRelative(ClipText, this.diagram.FileName); newrec.color.set(Media.getColor(diagram.options.colorDirectory)); } this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); } this.diagram.InvalidateDiagram(); } else if (Clipboard.ContainsFileDropList()) // [FILES] [PASTE] insert files from clipboard { StringCollection returnList = Clipboard.GetFileDropList(); Nodes nodes = new Nodes(); foreach (string file in returnList) { Node newrec = this.CreateNode(position); nodes.Add(newrec); newrec.setName(Os.getFileNameWithoutExtension(file)); string ext = Os.getExtension(file); if (ext == ".jpg" || ext == ".png" || ext == ".ico" || ext == ".bmp") // paste image file direct to diagram as image instead of link { this.diagram.setImage(newrec, file); } else if ( this.diagram.FileName != "" && Os.FileExists(this.diagram.FileName) && file.IndexOf(Os.getDirectoryName(this.diagram.FileName)) == 0 ) // [PASTE] [FILE] { // make path relative to saved diagram path int start = Os.getDirectoryName(this.diagram.FileName).Length; int finish = file.Length - start; newrec.link = "." + file.Substring(start, finish); } else if (this.diagram.FileName != "" && Os.DirectoryExists(this.diagram.FileName)) // [PASTE] [DIRECTORY] { // make path relative to saved diagram path int start = Os.getDirectoryName(this.diagram.FileName).Length; int finish = file.Length - start; newrec.link = "." + file.Substring(start, finish); } else { newrec.link = file; } } if (nodes.Count() > 0) { this.diagram.unsave("create", nodes, null, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } } else if (Clipboard.GetDataObject() != null) // [PASTE] [IMAGE] [CLIPBOARD OBJECT] paste image { IDataObject data = Clipboard.GetDataObject(); if (data.GetDataPresent(DataFormats.Bitmap)) { // paste image as embedded data direct inside diagram try { Node newrec = this.CreateNode(position); newrec.image = (Bitmap)data.GetData(DataFormats.Bitmap, true); newrec.height = newrec.image.Height; newrec.width = newrec.image.Width; newrec.isimage = true; newrec.embeddedimage = true; this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } catch (Exception e) { Program.log.write("paste immage error: " + e.Message); } } } return true; }
public Nodes getAllNodes(Node node) { Nodes nodes = new Nodes(); if (node.haslayer) { Layer layer = this.getLayer(node.id); foreach (Node subNode in layer.nodes) { nodes.Add(subNode); if (subNode.haslayer) { Nodes subNodes = this.getAllNodes(subNode); foreach (Node subNode2 in subNodes) { nodes.Add(subNode2); } } } } return nodes; }
// NODE MARK find prev marked node public void prevMarkedNode() { Nodes nodes = this.diagram.getAllNodes(); Nodes markedNodes = new Nodes(); // get all marked nodes foreach (Node node in nodes) { if (node.mark) { markedNodes.Add(node); } } // no marked node found if (markedNodes.Count == 0) { return; } // find last marked node if (lastMarkNode == 0) { lastMarkNode = markedNodes[0].id; this.goToNode(markedNodes[0]); this.diagram.InvalidateDiagram(); return; } //lastMarkNode position in markedNodes bool found = false; int i = 0; for (i = 0; i < markedNodes.Count; i++) { if (lastMarkNode == markedNodes[i].id) { found = true; break; } } //node is not longer marked then start from beginning if (!found) { lastMarkNode = markedNodes[0].id; this.goToNode(markedNodes[0]); this.diagram.InvalidateDiagram(); return; } // find prev node if (0 < i) { lastMarkNode = markedNodes[i - 1].id; this.goToNode(markedNodes[i - 1]); this.diagram.InvalidateDiagram(); return; } // go to last node lastMarkNode = markedNodes[markedNodes.Count - 1].id; this.goToNode(markedNodes[markedNodes.Count - 1]); this.diagram.InvalidateDiagram(); }
private void AddFolderAction(object sender, EventArgs args) { Nodes.Add(new ArchiveFolderNodeWrapper("NewFolder", ArchiveFile, RootNode)); }
/// <summary> /// SEARCH FIRST /// /// Build array of search results and then select first Node. /// /// </summary> /// <param name="find">Search string</param> public void SearchFirst(string find) { Nodes foundNodes = new Nodes(); this.lastFound = -1; this.searchFor = find; foreach (Node node in this.diagram.getAllNodes()) { if (node.note.ToUpper().IndexOf(searchFor.ToUpper()) != -1 || node.name.ToUpper().IndexOf(searchFor.ToUpper()) != -1) { foundNodes.Add(node); } } this.searhPanel.highlight(foundNodes.Count() == 0); Position middle = new Position(); middle.copy(this.currentPosition); middle.x = middle.x - this.ClientSize.Width / 2; middle.y = middle.y - this.ClientSize.Height / 2; int currentLayerId = this.currentLayer.id; foundNodes.Sort((first, second) => { // sort by layers if (first.layer < second.layer) { // current layer first if (currentLayerId == second.layer) { return 1; } return -1; } // sort by layers if (first.layer > second.layer) { // current layer first if (currentLayerId == first.layer) { return -1; } return 1; } Node parent = this.diagram.layers.getLayer(first.layer).parentNode; Position m = (currentLayerId == first.layer) ? middle : (parent != null) ? parent.layerShift : firstLayereShift; double d1 = first.position.convertToStandard().distance(m); double d2 = second.position.convertToStandard().distance(m); // sort by distance if is same layer if (d1 < d2) { return -1; } else { if (d1 > d2) { return 1; } else { return 0; } } }); nodesSearchResult.Clear(); for (int i = 0; i < foundNodes.Count(); i++) { nodesSearchResult.Add(foundNodes[i].id); } this.SearchNext(); }
void _services_TextChanged(object sender, EventArgs e) { // cancel any existing search operation if (_cts != null) { _cts.Cancel(); _cts.Dispose(); _cts = null; } if (_services.Length > 0) { if (!_inSearchMode) { EnterSearchMode(); } if (_services.Length >= MinSearchTermLength) { // start async search operation BeginUpdate(); Nodes.Clear(); Nodes.Add(new ComboTreeNode("Searching...") { Selectable = false, FontStyle = FontStyle.Italic }); EndUpdate(); _cts = new CancellationTokenSource(); ComboTreeNodeCollection results = new ComboTreeNodeCollection(null); var task = Task.Factory.StartNew(() => OnPerformSearch(new PerformSearchEventArgs(_services.Text, _cts.Token, results)), _cts.Token); task.ContinueWith(t => { if (t.IsFaulted) { results.Clear(); string errorText = t.Exception.InnerExceptions.Select(x => x.Message).FirstOrDefault() ?? "an error occured"; results.Add(new ComboTreeNode(String.Format("({0})", errorText)) { Selectable = false, FontStyle = FontStyle.Italic }); } if (!t.IsCanceled) { ApplySearchResults(results); } }); } else { // wait until the search term is long enough BeginUpdate(); Nodes.Clear(); string msg = String.Format("(type at least {0} characters)", MinSearchTermLength); Nodes.Add(new ComboTreeNode(msg) { Selectable = false, FontStyle = FontStyle.Italic }); EndUpdate(); } } else { if (_inSearchMode) { LeaveSearchMode(false); } } }
private bool HasInvariantField(IPTAnalysisNode n) { var x = new Nodes(); x.Add(n); return HasInvariantField(x); }
public void RefreshDisplay() { Nodes.Clear(); Skeleton.Nodes.Clear(); DataObjects.Nodes.Clear(); MatAnims.Nodes.Clear(); JointAnims.Nodes.Clear(); // Stage Stuff if (Root.Map_Head != null) { foreach (Map_Model_Group g in Root.Map_Head.ModelObjects) { Nodes.Add(new MeleeMapModelNode(g)); } } // Bones-------------------------------------- if (Root.GetJOBJinOrder().Length > 0) { Nodes.Add(Skeleton); } int boneIndex = 0; RenderBones = new VBN(); List <DatJOBJ> JOBJS = new List <DatJOBJ>(); foreach (DatJOBJ j in Root.GetJOBJinOrder()) { Bone b = new Bone(RenderBones); b.Text = "Bone_" + (boneIndex); b.position = new float[] { j.TX, j.TY, j.TZ }; b.rotation = new float[] { j.RX, j.RY, j.RZ }; b.scale = new float[] { j.SX, j.SY, j.SZ }; if (j.Parent != null) { b.parentIndex = JOBJS.IndexOf(j.Parent); } JOBJS.Add(j); RenderBones.bones.Add(b); Skeleton.Nodes.Add(new MeleeJointNode(j) { Text = "Bone_" + boneIndex++, RenderBone = b }); } RenderBones.reset(); if (Root.GetDataObjects().Length > 0) { Nodes.Add(DataObjects); SelectedImageKey = "model"; ImageKey = "model"; } // Data Objects-------------------------------------- DatDOBJ[] dataObjects = Root.GetDataObjects(); for (int i = 0; i < dataObjects.Length; i++) { DatDOBJ d = dataObjects[i]; MeleeDataObjectNode n = new MeleeDataObjectNode(d) { Text = $"DataObject {i}" }; DataObjects.Nodes.Add(n); n.RefreshRendering(); n.BoneIndex = JOBJS.IndexOf(n.DOBJ.Parent); n.Checked = true; if (Parent is MeleeDataNode) { MeleeDataNode parentNode = (MeleeDataNode)Parent; if ((parentNode.LodModels.Count > 0) && !parentNode.LodModels.Contains((byte)(i))) { n.Checked = false; n.Text += "Low"; } } } // MaterialAnimation-------------------------------------- if (Root.MatAnims.Count > 0) { Nodes.Add(MatAnims); foreach (DatMatAnim anim in Root.MatAnims) { MatAnims.Nodes.Add(new MeleeMaterialAnimationNode(anim)); } } // Animation-------------------------------------- if (Root.Animations.Count > 0) { Nodes.Add(JointAnims); foreach (DatAnimation anim in Root.Animations) { JointAnims.Nodes.Add(new MeleeJointAnimationNode(anim)); } } // Scripts-------------------------------------- foreach (MeleeLib.DAT.Script.DatFighterData r in Root.FighterData) { Nodes.Add(new MeleeFighterDataNode(r)); } }
/// <summary> /// Check whether a method is pure or not by analyzing the pointsTo and writeEffects info. /// To be pure, the parameters (or locations reachable from them) cannot be modified /// or accessed via escaping locations, and it cannot call non-analyzable methods. /// </summary> /// <param name="ptwe"></param> /// <returns></returns> public bool VerifyPurity() { PointsToAndWriteEffects ptwe = this; if (WeakPurityAndWriteEffectsAnalysis.IsUnsafe(ptwe.Method)) return false; PTGraph ptg = ptwe.PointsToGraph; bool res = false; Nodes pNodes = Nodes.Empty; if (!ptwe.HasNonAnalyzableMethods) { /* Diego 12/8/2007 I replace it // Compute the Parameter nodes to analyze foreach (PNode pn in ptg.AddrPNodes) { // For constructor the "this parameter is ignored // TO CHECK. Maybe we can directly say pNodes = ptg.PNodes // if (!isConstructor(ptg.Method) || pn != ptg.ThisParameterNode) { pNodes.Add(pn); } } For this: */ pNodes = ptg.PVNodes; // A = Nodes forward reachable from the parameters (including this) Nodes A = ptg.NodesForwardReachableFromOnlyOEdges(pNodes); // Diego 12/8/2007 A = ptg.Values(A); // B = Nodes forward reachable from from Escaping and Global nodes Nodes Esc = new Nodes(ptg.E); Esc.Add(GNode.nGBL); Nodes B = ptg.NodesForwardReachableFromNodes(Esc); // Diego 12/8/2007 B = ptg.Values(B); // TO CHECK. Maybe remove //if (isConstructor(ptg.Method)) //{ // B.Remove(ptg.ThisParameterNode); //} // A ^ B == Empty means that (forall n \in A => n \notin B) // if (A.Intersection(B).Count == 0) if (A.IntersectionEmpty(B)) { Set<VariableEffect> writeEffectsforVariables = ptwe.ComputeWriteEffects(); Nodes modifiedNodes = Nodes.Empty; foreach (VariableEffect ve in writeEffectsforVariables) { // Diego 12/8/2007 modifiedNodes.AddRange(ptg.GetLocations(ve.Variable)); modifiedNodes.AddRange(this.Values(ve.Variable)); } // Get the set of modified nodes = map (\(n,f) => f) ptwe.Writeffects //Set<PTAnalysisNode> modifiedNodes = ptwe.ModifiedNodes; // We consider the constructor as Pure if they only affect the variable "this" (JML) if (isConstructor(ptg.Method)) { // modifiedNodes.Remove(ptg.ThisParameterNode); // Diego 8/12/2007 Added value of the paramater addr modifiedNodes.Remove(ptg.Values(ptg.ThisParameterNode)); } // We ignore parameter nodes is they are passed by value // or they are out parameters foreach (PNode pn in ptg.AddrPNodes) { //if(p.n.IsOut || p.Type.IsValueType) if (pn.IsOut || (pn.IsByValue && PTGraph.isValueType(pn.Type))) // modifiedNodes.Remove(pn); // Diego 8/12/2007 Added value of the paramater addr modifiedNodes.Remove(ptg.Values(pn)); } // Check if the method has modified a global node or one reachable from a parameter if ((!modifiedNodes.Contains(GNode.nGBL) /* DELETE && !modifiedNodes.Contains(ptg.GetAddress(PTGraph.GlobalScope)))*/ //&& modifiedNodes.Intersection(A).Count == 0)) && modifiedNodes.IntersectionEmpty(A))) res = true; } else { // This means that the method make a global or escaping node reachable from a parameter // i.e. a node reachable from parameters escapes globaly } } return res; }
public void AddChild(Tree <T> value) { Nodes.Add(value); value.Parent = this; }
private bool IsReachableFromOutside(IPTAnalysisNode n) { Nodes Esc = new Nodes(PointsToGraph.E); Esc.Add(GNode.nGBL); foreach (PNode pn in PointsToGraph.AddrPNodes) { Esc.Add(pn); } return PointsToGraph.IsReachableFrom(n,Esc,true,true,true); }
public void AddNode(XElement node, string nodeCode) { Nodes.Add(node); _addedNodes.Add(nodeCode); }
/// <summary> /// return mapping[n] U ({n} - PNode) /// </summary> /// <param name="n"></param> /// <returns></returns> public Nodes RelatedExtended(IPTAnalysisNode n) { Nodes res = new Nodes(Related(n)); // if (!(n.IsParameterNode) && (!n.IsVariableReference) && !IsRemovedLoadNode(n)) // VariableReference includes ParameterNodes if ((!n.IsVariableReference) && !IsRemovedLoadNode(n)) { if (res.Count != 0 && n.IsParameterValueLNode && n.Label.Method.Equals(calleePTG.Method)) { } else res.Add(n); } return res; }
/// <summary> /// Provided a main execution path, find other Dynamo paths /// relatively. This operation should be called only once at /// the beginning of a Dynamo session. /// </summary> /// <param name="mainExecPath">The main execution directory of Dynamo.</param> public void InitializeCore(string mainExecPath) { if (Directory.Exists(mainExecPath)) { MainExecPath = mainExecPath; } else { throw new Exception(String.Format("The specified main execution path: {0}, does not exist.", mainExecPath)); } AppData = GetDynamoAppDataFolder(MainExecPath); Logs = Path.Combine(AppData, "Logs"); if (!Directory.Exists(Logs)) { Directory.CreateDirectory(Logs); } UserDefinitions = Path.Combine(AppData, "definitions"); if (!Directory.Exists(UserDefinitions)) { Directory.CreateDirectory(UserDefinitions); } Packages = Path.Combine(AppData, "packages"); if (!Directory.Exists(Packages)) { Directory.CreateDirectory(Packages); } var commonData = GetDynamoCommonDataFolder(MainExecPath); CommonDefinitions = Path.Combine(commonData, "definitions"); if (!Directory.Exists(CommonDefinitions)) { Directory.CreateDirectory(CommonDefinitions); } CommonSamples = Path.Combine(commonData, "samples"); if (!Directory.Exists(CommonSamples)) { Directory.CreateDirectory(CommonSamples); } Ui = Path.Combine(MainExecPath, "UI"); if (Nodes == null) { Nodes = new HashSet <string>(); } // Only register the core nodes directory Nodes.Add(Path.Combine(MainExecPath, "nodes")); #if DEBUG var sb = new StringBuilder(); sb.AppendLine(String.Format("MainExecPath: {0}", MainExecPath)); sb.AppendLine(String.Format("Definitions: {0}", UserDefinitions)); sb.AppendLine(String.Format("Packages: {0}", Packages)); sb.AppendLine(String.Format("Ui: {0}", Ui)); sb.AppendLine(String.Format("Asm: {0}", LibG)); Nodes.ToList().ForEach(n => sb.AppendLine(String.Format("Nodes: {0}", n))); Debug.WriteLine(sb); #endif var coreLibs = new List <string> { "VMDataBridge.dll", "ProtoGeometry.dll", "DSCoreNodes.dll", "DSOffice.dll", "DSIronPython.dll", "FunctionObject.ds", "Optimize.ds", "DynamoUnits.dll", "Tessellation.dll", "Analysis.dll" }; foreach (var lib in coreLibs) { AddPreloadLibrary(lib); } }
/// <summary> /// Step 3: Match Outside Edges with Insides Egdes in Callee using resolved aliasing from calling context /// </summary> void MatchOutsideWithInsideInCallee() { foreach (Edge oe in calleePTG.O) { IPTAnalysisNode n1 = oe.Src; IPTAnalysisNode n2 = oe.Dst; Nodes ns = Related(n1); Set<Edge> iedges = calleePTG.I.EdgesFromField(oe.Field); foreach (Edge ie in iedges) { Nodes ns1 = Nodes.Empty; ns1.Add(n1); IPTAnalysisNode n3 = ie.Src; IPTAnalysisNode n4 = ie.Dst; Nodes ns3 = Nodes.Empty; ns3.Add(n3); ns1.AddRange(Related(n1)); ns3.AddRange(Related(n3)); //if (ns1.Intersection(ns3).Count != 0) if (!ns1.Intersection(ns3).IsEmpty) { if (!n1.Equals(n3) || n1.IsLoad) { Nodes ns4notPNode = new Nodes(Related(n4)); if (!(n4 is PNode)) ns4notPNode.Add(n4); Relate(n2, ns4notPNode); } } } foreach (IPTAnalysisNode n in ns) { Nodes adj = callerPTG.I.Adjacents(n, oe.Field, true); Relate(oe.Dst, adj); } } }
protected internal virtual void OnChildAdded(ResourceNode parent, ResourceNode child) { Nodes.Add(Wrap(_owner, child)); }
public void AddNode(Node Node) { Nodes.Add(Node); }
public Graph AddNode(Node n) { return(new Graph(Nodes.Add(n), Connections)); }
public bool doUndo(DiagramView view = null) { if (operations.Count() == 0) { return false; } int group = 0; bool result = false; do { UndoOperation operation = operations.First(); // first restore position where change occurred if (view != null && !view.isOnPosition(operation.position, operation.layer)) { view.goToShift(operation.position); view.goToLayer(operation.layer); view.Invalidate(); return false; } // process all operations in same group if (group != 0 && operation.group != group) { group = 0; break; } group = operation.group; if (operation.type == "delete") { this.doUndoDelete(operation); reverseOperations.Push(operation); } if (operation.type == "create") { this.doUndoCreate(operation); reverseOperations.Push(operation); } if (operation.type == "edit" || operation.type == "move" || operation.type == "changeLineColor" || operation.type == "changeLineWidth" || operation.type == "changeNodeColor" ) { Nodes nodes = new Nodes(); foreach (Node node in operation.nodes) { nodes.Add(this.diagram.GetNodeByID(node.id)); } Lines lines = new Lines(); foreach (Line line in operation.lines) { lines.Add(this.diagram.getLine(line.start, line.end)); } UndoOperation roperation = new UndoOperation( operation.type, nodes, lines, operation.group, operation.position, operation.layer ); reverseOperations.Push(roperation); this.doUndoEdit(operation); } operations.Pop(); result = true; } while (group != 0 && operations.Count() > 0); if (result) { this.saved--; if (!this.saveLost && this.saved == 0) { this.diagram.restoresave(); } else { this.diagram.unsave(); } } return result; }
private void AddNode(string name, Point point) { var node = new Node() {Name = name, Connections = new List<Edge>(), Id = Guid.NewGuid(), Point = point}; Nodes.Add(node); }
/*************************************************************************************************************************/ // ADD UNDO OPERATIONS public void add(string type, Node node, Position position = null, int layer = 0) { Nodes nodes = new Nodes(); if (node != null) { nodes.Add(new Node(node)); } this.add(type, nodes, null, position, layer); }
public async Task <CoreNode> CreateNodeAsync(bool start = false) { var child = Path.Combine(Root, Last.ToString()); Last++; try { var cfgPath = Path.Combine(child, "data", "bitcoin.conf"); if (File.Exists(cfgPath)) { var config = NodeConfigParameters.Load(cfgPath); var rpcPort = config["regtest.rpcport"]; var rpcUser = config["regtest.rpcuser"]; var rpcPassword = config["regtest.rpcpassword"]; var pidFileName = config["regtest.pid"]; var credentials = new NetworkCredential(rpcUser, rpcPassword); try { var rpc = new RPCClient(credentials, new Uri("http://127.0.0.1:" + rpcPort + "/"), Network.RegTest); await rpc.StopAsync(); var pidFile = Path.Combine(child, "data", "regtest", pidFileName); if (File.Exists(pidFile)) { var pid = File.ReadAllText(pidFile); using (var process = Process.GetProcessById(int.Parse(pid))) { process.WaitForExit(); } } else { var allProcesses = Process.GetProcesses(); var bitcoindProcesses = allProcesses.Where(x => x.ProcessName.Contains("bitcoind")); if (bitcoindProcesses.Count() == 1) { var bitcoind = bitcoindProcesses.First(); bitcoind.WaitForExit(); } } } catch (Exception) { } } await IoHelpers.DeleteRecursivelyWithMagicDustAsync(child); await TryRemoveWorkingDirectoryAsync(); Directory.CreateDirectory(WorkingDirectory); } catch (DirectoryNotFoundException) { } var node = await CoreNode.CreateAsync(child, this); Nodes.Add(node); if (start) { await node.StartAsync(); } return(node); }
public ResourceNode( DocumentClient client, dynamic document, ResourceType resoureType, PartitionKeyDefinition partitionKey = null, string nodeText = null, string dataBaseId = null, string documentCollectionId = null ) { _databaseId = dataBaseId; _documentCollectionId = documentCollectionId; _resourceType = resoureType; var docAsResource = (document as Resource); var isDocument = _resourceType == ResourceType.Document; var isOffer = _resourceType == ResourceType.Offer; var isConflict = _resourceType == ResourceType.Conflict; var isPermission = _resourceType == ResourceType.Permission; var isAttachment = _resourceType == ResourceType.Attachment; var isStoredProcedure = _resourceType == ResourceType.StoredProcedure; var isTrigger = _resourceType == ResourceType.Trigger; var isUserDefinedFunction = _resourceType == ResourceType.UserDefinedFunction; var isUser = _resourceType == ResourceType.User; if (isDocument) { var prefix = string.Empty; if (partitionKey != null) { if (partitionKey.Paths.Count > 0) { var path = partitionKey.Paths[0]; prefix = document.GetPropertyValue <string>(path.Substring(1)); prefix = prefix + "_"; } } Text = string.IsNullOrWhiteSpace(nodeText) ? prefix + docAsResource.Id : prefix + nodeText; } else if (isOffer) { string version = document.GetPropertyValue <string>("offerVersion"); if (string.IsNullOrEmpty(version)) { var offer = document as Offer; Text = string.Format("{0}_{1}", offer.OfferType, offer.GetPropertyValue <string>("offerResourceId")); } else { var offer = document as OfferV2; Text = string.Format("{0}_{1}", offer.Content.OfferThroughput, offer.GetPropertyValue <string>("offerResourceId")); } } else { Text = docAsResource.Id; } Tag = document; _client = client; var readMenuItem = AddMenuItem(string.Format("Read {0}", _resourceType), myMenuItemRead_Click); MenuItemHelper.SetCustomShortcut(readMenuItem, Keys.Enter); if (!isConflict && !isOffer) { AddMenuItem(string.Format("Replace {0}", _resourceType), myMenuItemUpdate_Click, Shortcut.CtrlR); } if (!isOffer) { AddMenuItem(string.Format("Delete {0}", _resourceType), myMenuItemDelete_Click, Shortcut.Del); } if (!isConflict && !isOffer) { _contextMenu.MenuItems.Add("-"); AddMenuItem("Copy id to clipboard", myMenuItemCopyIdToClipBoard_Click, Shortcut.CtrlShiftC); AddMenuItem(string.Format("Copy {0} to clipboard", _resourceType), myMenuItemCopyToClipBoard_Click, Shortcut.CtrlC); var cpWithnewIdItem = AddMenuItem(string.Format("Copy {0} to clipboard with new id", _resourceType), myMenuItemCopyToClipBoardWithNewId_Click); MenuItemHelper.SetCustomShortcut(cpWithnewIdItem, Keys.Control | Keys.Alt | Keys.C); if (isDocument) { _contextMenu.MenuItems.Add("-"); var createWithnewIdItem = AddMenuItem( string.Format("Create {0} with new id based on this", _resourceType), (sender, e) => InvokeCreateNewDocumentBasedOnSelectedWithNewId() ); MenuItemHelper.SetCustomShortcut(createWithnewIdItem, Keys.Control | Keys.Alt | Keys.N); AddMenuItem(string.Format("Create {0}", _resourceType), myMenuItemCreateNewDocument_Click, Shortcut.CtrlN); AddMenuItem(string.Format("Create {0} with prefilled id", _resourceType), myMenuItemCreateNewDocumentWithId_Click, Shortcut.CtrlShiftN); AddMenuItem(string.Format("Create {0} from File...", _resourceType), myMenuItemCreateDocumentFromFile_Click); AddMenuItem(string.Format("Create Multiple {0}s from Folder...", _resourceType), myMenuItemCreateDocumentsFromFolder_Click); _contextMenu.MenuItems.Add("-"); AddMenuItem(string.Format("Paste {0} from clipboard", _resourceType), (sender, e) => InvokeCreateNewDocumentBasedOnClipboard(), Shortcut.CtrlV); } } if (isPermission) { ImageKey = "Permission"; SelectedImageKey = "Permission"; } else if (isAttachment) { ImageKey = "Attachment"; SelectedImageKey = "Attachment"; AddMenuItem("Download media", myMenuItemDownloadMedia_Click); AddMenuItem("Render media", myMenuItemRenderMedia_Click); } else if (isStoredProcedure || isTrigger || isUserDefinedFunction) { ImageKey = "Javascript"; SelectedImageKey = "Javascript"; if (isStoredProcedure) { AddMenuItem(string.Format("Execute {0}", _resourceType), myMenuItemExecuteStoredProcedure_Click); } } else if (isUser) { ImageKey = "User"; SelectedImageKey = "User"; Nodes.Add(new PermissionNode(_client)); } else if (isDocument) { Nodes.Add(new TreeNode("Fake")); _contextMenu.MenuItems.Add("-"); AddMenuItem("Create attachment", myMenuItemCreateAttachment_Click); AddMenuItem("Create attachment from file...", myMenuItemAttachmentFromFile_Click); } else if (isConflict) { ImageKey = "Conflict"; SelectedImageKey = "Conflict"; } else if (isOffer) { ImageKey = "Offer"; SelectedImageKey = "Offer"; } }
public Nodes getAllNodes() { Nodes nodes = new Nodes(); foreach (Node n in this.allNodes.Values) { nodes.Add(n); } return nodes; }
public ExpressionNode(string exp) { _expression = Utils.ShrinkExpression(exp); Nodes.Add(Utils.ExpressionStringToNode(_expression)); }
// all nodes contain nodes and all sublayer nodes, allLines contain all node lines and all sublayer lines public void getAllNodesAndLines(Nodes nodes, ref Nodes allNodes, ref Lines allLines) { foreach (Node node in nodes) { // add node itself to output allNodes.Add(node); if (node.haslayer) { Layer layer = this.getLayer(node.id); getAllNodesAndLines(layer.nodes, ref allNodes, ref allLines); } Lines lines = getAllLinesFromNode(node); foreach (Line line in lines) { bool found = false; foreach (Line subline in allLines) { if (line.start == subline.start && line.end == subline.end) { found = true; break; } } if (!found) { allLines.Add(line); } } } }
// 从文件读取 public void ReadFromFile(string filename) { using (FileStream fs = new FileStream(filename, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, Encoding.Default)) { // 读取文件头 if (sr.ReadLine() != RecordDataFileFlag) { throw new Exception("文件格式错误"); } // 读取创建时间 CreateTime = DateTime.Parse(sr.ReadLine()); // 读取记录名称 Name = sr.ReadLine(); // 读取车辆速度 CarSpeed = double.Parse(sr.ReadLine()); // 读取配送点停留时间 NodeStayTime = double.Parse(sr.ReadLine()); // 读取节点信息 int nodeCount = int.Parse(sr.ReadLine()); for (int i = 0; i < nodeCount; ++i) { double x = double.Parse(sr.ReadLine()); double y = double.Parse(sr.ReadLine()); double d = double.Parse(sr.ReadLine()); Nodes.Add(new Node { X = x, Y = y, Demand = d }); } // 读取车辆信息 int carCount = int.Parse(sr.ReadLine()); for (int i = 0; i < carCount; ++i) { double w = double.Parse(sr.ReadLine()); double d = double.Parse(sr.ReadLine()); Cars.Add(new Car { WeightLimit = w, DisLimit = d }); } // 读取路径信息 int pathCount = int.Parse(sr.ReadLine()); for (int i = 0; i < pathCount; ++i) { Paths.Add(new ObservableCollection <int>()); int pathLength = int.Parse(sr.ReadLine()); for (int j = 0; j < pathLength; ++j) { Paths[i].Add(int.Parse(sr.ReadLine())); } } } } }
protected void UpdateUIComponents() { if (_root == null) {// Clean and run. Nodes.Clear(); return; } TreeNode rootNode; if (Nodes.Count > 0 && Nodes[0].Tag == Root) {// Existing root. rootNode = Nodes[0]; rootNode.Text = Root.Name; } else {// New root. Nodes.Clear(); rootNode = new TreeNode(Root.Name, Root.ImageIndex, Root.ImageIndex); rootNode.Tag = Root; Nodes.Add(rootNode); } SynchronizeCollectionWithNode(rootNode, 0, _root.ChildrenArray); ExpandAll(); return; //lock (_simulation.Strategies) //{ // for (int i = 0; i < _simulation.Strategies.Count; i++) // { // TraderSimulationStrategy strategy = _simulation.Strategies[i]; // TreeNode strategyNode; // // Synchronize the simulation. // if (rootNode.Nodes.Count > i && rootNode.Nodes[i].Tag == strategy) // {// Node exists and is the proper one. // strategyNode = rootNode.Nodes[i]; // } // else // {// Node needs to be replaced/fixed. // strategyNode = new TreeNode(strategy.Name); // strategyNode.Tag = strategy; // strategyNode.ImageIndex = 1; // strategyNode.SelectedImageIndex = 1; // if (rootNode.Nodes.Count > i) // { // rootNode.Nodes[i] = strategyNode; // } // else // { // rootNode.Nodes.Add(strategyNode); // } // } // // Synchronize the simulation elements. // for (int j = 0; j < strategy.Entities.Count; j++) // { // TraderSimulationEntity entity = strategy.Entities[j]; // // Synchronize the simulation. // if (strategyNode.Nodes.Count > i && strategyNode.Nodes[i].Tag == entity) // {// Node exists and is the proper one. // } // else // {// Node needs to be replaced/fixed. // TreeNode entityNode = new TreeNode(entity.Name); // entityNode.Tag = entity; // entityNode.ImageIndex = 2; // entityNode.SelectedImageIndex = 2; // if (strategyNode.Nodes.Count > j) // { // strategyNode.Nodes[j] = entityNode; // } // else // { // strategyNode.Nodes.Add(strategyNode); // } // } // } // } // // Delete all the unneeded strategies. // for (int i = _simulation.Strategies.Count; i < rootNode.Nodes.Count; i++) // { // rootNode.Nodes.RemoveAt(i); // } //} }
internal void Read(EndianBinaryReader reader) { int osageNameCount = reader.ReadInt32(); int osageBoneCount = reader.ReadInt32(); reader.SeekCurrent(4); long osageBonesOffset = reader.ReadOffset(); long osageNamesOffset = reader.ReadOffset(); long nodesOffset = reader.ReadOffset(); int boneNameCount = reader.ReadInt32(); long boneNamesOffset = reader.ReadOffset(); long entriesOffset = reader.ReadOffset(); reader.ReadAtOffset(osageBonesOffset, () => { OsageBones.Capacity = osageBoneCount; for (int i = 0; i < osageBoneCount; i++) { var osageBone = new ExOsageBone(); osageBone.Read(reader); OsageBones.Add(osageBone); } }); reader.ReadAtOffset(osageNamesOffset, () => { OsageNames.Capacity = osageNameCount; for (int i = 0; i < osageNameCount; i++) { OsageNames.Add(reader.ReadStringOffset(StringBinaryFormat.NullTerminated)); } }); reader.ReadAtOffset(nodesOffset, () => { while (true) { string nodeSignature = reader.ReadStringOffset(StringBinaryFormat.NullTerminated); long nodeOffset = reader.ReadOffset(); if (nodeOffset == 0) { break; } reader.ReadAtOffset(nodeOffset, () => { if (!ExNode.NodeFactory.TryGetValue(nodeSignature, out var nodeConstructor)) { return; } var node = nodeConstructor(); node.Read(reader); Nodes.Add(node); }); } }); reader.ReadAtOffset(boneNamesOffset, () => { BoneNames.Capacity = boneNameCount; for (int i = 0; i < boneNameCount; i++) { BoneNames.Add(reader.ReadStringOffset(StringBinaryFormat.NullTerminated)); } }); reader.ReadAtOffset(entriesOffset, () => { while (true) { var entry = new ExEntry(); entry.Read(reader); if (entry.Field00 == 0) { break; } Entries.Add(entry); } }); }
public void Load(System.IO.Stream stream) { CanSave = false; modelFolder = new LM3_ModelFolder(this); DrawableContainer.Name = FileName; Renderer = new LM3_Renderer(); DrawableContainer.Drawables.Add(Renderer); Text = FileName; using (var reader = new FileReader(stream)) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian; uint Identifier = reader.ReadUInt32(); Unknown0x4 = reader.ReadUInt16(); //Could also be 2 bytes, not sure. Always 0x0401 IsCompressed = reader.ReadByte() == 1; reader.ReadByte(); //Padding uint SizeLargestFile = reader.ReadUInt32(); byte numFiles = reader.ReadByte(); byte numChunkInfos = reader.ReadByte(); byte numStrings = reader.ReadByte(); reader.ReadByte(); //padding //Start of the chunk info. A fixed list of chunk information for (int i = 0; i < numChunkInfos; i++) { ChunkInfo chunk = new ChunkInfo(); chunk.Read(reader); ChunkInfos.Add(chunk); } TreeNode tableNodes = new TreeNode("File Section Entries"); TreeNode chunkLookupNodes = new TreeNode("Chunk Lookup Files"); tableNodes.Nodes.Add(chunkLookupNodes); Nodes.Add(tableNodes); TreeNode stringFolder = new TreeNode("Strings"); TreeNode chunkTexFolder = new TreeNode("Texture"); TreeNode chunkModelFolder = new TreeNode("Model"); long FileTablePos = reader.Position; for (int i = 0; i < numFiles; i++) { var file = new FileEntry(this); file.Read(reader); fileEntries.Add(file); if (file.DecompressedSize > 0) { file.Text = $"entry {i}"; if (i < 52) { chunkLookupNodes.Nodes.Add(file); } else { tableNodes.Nodes.Add(file); } } //The first file stores a chunk layout //The second one seems to be a duplicate? if (i == 0) { using (var tableReader = new FileReader(file.GetData())) { ChunkTable = new LM3_ChunkTable(); ChunkTable.Read(tableReader); if (DebugMode) { TreeNode debugFolder = new TreeNode("DEBUG TABLE INFO"); Nodes.Add(debugFolder); TreeNode list1 = new TreeNode("Entry List 1"); TreeNode list2 = new TreeNode("Entry List 2 "); debugFolder.Nodes.Add(list1); debugFolder.Nodes.Add(list2); debugFolder.Nodes.Add(chunkFolder); foreach (var chunk in ChunkTable.ChunkEntries) { list1.Nodes.Add($"ChunkType {chunk.ChunkType.ToString("X")} ChunkOffset {chunk.ChunkOffset} ChunkSize {chunk.ChunkSize} ChunkSubCount {chunk.ChunkSubCount} Unknown3 {chunk.Unknown3}"); } foreach (var chunk in ChunkTable.ChunkSubEntries) { list2.Nodes.Add($"ChunkType 0x{chunk.ChunkType.ToString("X")} Size {chunk.ChunkSize} Offset {chunk.ChunkOffset}"); } } } } } for (int i = 0; i < numStrings; i++) { StringList.Add(reader.ReadZeroTerminatedString()); stringFolder.Nodes.Add(StringList[i]); } TreeNode havokFolder = new TreeNode("Havok Physics"); //Model data block //Contains texture hash refs and model headers var File052Data = fileEntries[52].GetData(); //Unsure, layout data?? var File053Data = fileEntries[53].GetData(); //Contains model data var File054Data = fileEntries[54].GetData(); //Image header block. Also contains shader data var File063Data = fileEntries[63].GetData(); //Image data block var File065Data = fileEntries[65].GetData(); //Get a list of chunk hashes List <uint> ModelHashes = new List <uint>(); for (int i = 0; i < ChunkTable.ChunkEntries.Count; i++) { if (ChunkTable.ChunkEntries[i].ChunkType == DataType.Model) { using (var chunkReader = new FileReader(File052Data, true)) { chunkReader.SeekBegin(ChunkTable.ChunkEntries[i].ChunkOffset); uint magic = chunkReader.ReadUInt32(); uint hash = chunkReader.ReadUInt32(); ModelHashes.Add(hash); } } } //Set an instance of our current data //Chunks are in order, so you build off of when an instance gets loaded LM3_Model currentModel = new LM3_Model(this); TreeNode currentModelChunk = null; TexturePOWE currentTexture = new TexturePOWE(); ChunkDataEntry currentVertexPointerList = null; List <uint> TextureHashes = new List <uint>(); int chunkId = 0; uint modelIndex = 0; uint ImageHeaderIndex = 0; uint havokFileIndex = 0; foreach (var chunk in ChunkTable.ChunkSubEntries) { var chunkEntry = new ChunkDataEntry(this, chunk); chunkEntry.Text = $"{chunkId} {chunk.ChunkType.ToString("X")} {chunk.ChunkType} {chunk.ChunkOffset} {chunk.ChunkSize}"; switch (chunk.ChunkType) { case SubDataType.HavokPhysics: chunkEntry.DataFile = File052Data; chunkEntry.Text = $"File_{havokFileIndex++}.hkx"; havokFolder.Nodes.Add(chunkEntry); break; case SubDataType.TextureHeader: chunkEntry.DataFile = File063Data; //Read the info using (var textureReader = new FileReader(chunkEntry.FileData, true)) { currentTexture = new TexturePOWE(); currentTexture.HeaderOffset = chunk.ChunkOffset; currentTexture.ImageKey = "texture"; currentTexture.SelectedImageKey = currentTexture.ImageKey; currentTexture.Index = ImageHeaderIndex; currentTexture.Read(textureReader); if (DebugMode) { currentTexture.Text = $"Texture {ImageHeaderIndex} {currentTexture.Unknown} {currentTexture.Unknown2} {currentTexture.Unknown3.ToString("X")}"; } else { currentTexture.Text = $"Texture {currentTexture.ID2.ToString("X")}"; } if (NLG_Common.HashNames.ContainsKey(currentTexture.ID2)) { currentTexture.Text = NLG_Common.HashNames[currentTexture.ID2]; } textureFolder.Nodes.Add(currentTexture); if (!Renderer.TextureList.ContainsKey(currentTexture.ID2.ToString("x"))) { Renderer.TextureList.Add(currentTexture.ID2.ToString("x"), currentTexture); } TextureHashes.Add(currentTexture.ID2); ImageHeaderIndex++; } break; case SubDataType.TextureData: chunkEntry.DataFile = File065Data; currentTexture.DataOffset = chunk.ChunkOffset; currentTexture.ImageData = chunkEntry.FileData.ToBytes(); break; case SubDataType.ModelInfo: chunkEntry.DataFile = File052Data; uint numModels = chunk.ChunkSize / 12; using (var dataReader = new FileReader(chunkEntry.FileData, true)) { for (int i = 0; i < numModels; i++) { uint hashID = dataReader.ReadUInt32(); uint numMeshes = dataReader.ReadUInt32(); dataReader.ReadUInt32(); //0 string text = hashID.ToString("X"); if (NLG_Common.HashNames.ContainsKey(hashID)) { text = NLG_Common.HashNames[hashID]; } currentModel.Text = $"Model {modelIndex - 1} [{text}]"; } } break; case SubDataType.MaterailData: currentModelChunk = new TreeNode($"Model {modelIndex}"); chunkFolder.Nodes.Add(currentModelChunk); chunkEntry.DataFile = File052Data; currentModel = new LM3_Model(this); currentModel.ModelInfo = new LM3_ModelInfo(); currentModel.Text = $"Model {modelIndex}"; currentModel.ModelInfo.Data = chunkEntry.FileData.ToBytes(); if (ModelHashes.Count > modelIndex) { currentModel.Text = $"Model {modelIndex} {ModelHashes[(int)modelIndex].ToString("x")}"; if (NLG_Common.HashNames.ContainsKey(ModelHashes[(int)modelIndex])) { currentModel.Text = NLG_Common.HashNames[ModelHashes[(int)modelIndex]]; } } modelIndex++; break; case SubDataType.MeshBuffers: chunkEntry.DataFile = File054Data; currentModel.BufferStart = chunkEntry.Entry.ChunkOffset; currentModel.BufferSize = chunkEntry.Entry.ChunkSize; break; case SubDataType.VertexStartPointers: chunkEntry.DataFile = File052Data; currentVertexPointerList = chunkEntry; break; case SubDataType.SubmeshInfo: chunkEntry.DataFile = File052Data; int MeshCount = (int)chunkEntry.FileData.Length / 0x40; using (var vtxPtrReader = new FileReader(currentVertexPointerList.FileData, true)) using (var meshReader = new FileReader(chunkEntry.FileData, true)) { for (uint i = 0; i < MeshCount; i++) { meshReader.SeekBegin(i * 0x40); LM3_Mesh mesh = new LM3_Mesh(); mesh.Read(meshReader); currentModel.Meshes.Add(mesh); var buffer = new LM3_Model.PointerInfo(); buffer.Read(vtxPtrReader, mesh.Unknown3 != 4294967295); currentModel.VertexBufferPointers.Add(buffer); } } modelFolder.Nodes.Add(currentModel); break; case SubDataType.ModelTransform: chunkEntry.DataFile = File052Data; using (var transformReader = new FileReader(chunkEntry.FileData, true)) { //This is possibly very wrong //The data isn't always per mesh, but sometimes is if (transformReader.BaseStream.Length / 0x40 == currentModel.Meshes.Count) { for (int i = 0; i < currentModel.Meshes.Count; i++) { currentModel.Meshes[i].Transform = transformReader.ReadMatrix4(); } } } break; case SubDataType.MaterialName: chunkEntry.DataFile = File053Data; /* using (var matReader = new FileReader(chunkEntry.FileData)) * { * materialNamesFolder.Nodes.Add(matReader.ReadZeroTerminatedString()); * }*/ break; case SubDataType.UILayoutMagic: chunkEntry.DataFile = File053Data; break; case SubDataType.UILayout: chunkEntry.DataFile = File053Data; break; case SubDataType.BoneData: if (chunk.ChunkSize > 0x40 && currentModel.Skeleton == null) { chunkEntry.DataFile = File052Data; using (var boneReader = new FileReader(chunkEntry.FileData, true)) { /* currentModel.Skeleton = new STSkeleton(); * DrawableContainer.Drawables.Add(currentModel.Skeleton); * * uint numBones = chunk.ChunkSize / 0x40; * for (int i = 0; i < numBones; i++) * { * boneReader.SeekBegin(i * 0x40); * uint HashID = boneReader.ReadUInt32(); * boneReader.ReadUInt32(); //unk * boneReader.ReadUInt32(); //unk * boneReader.ReadSingle(); //0 * var Scale = new OpenTK.Vector3( * boneReader.ReadSingle(), * boneReader.ReadSingle(), * boneReader.ReadSingle()); * boneReader.ReadSingle(); //0 * var Rotate = new OpenTK.Vector3( * boneReader.ReadSingle(), * boneReader.ReadSingle(), * boneReader.ReadSingle()); * boneReader.ReadSingle(); //0 * var Position = new OpenTK.Vector3( * boneReader.ReadSingle(), * boneReader.ReadSingle(), * boneReader.ReadSingle()); * float test = boneReader.ReadSingle(); //1 * STBone bone = new STBone(currentModel.Skeleton); * bone.Text = HashID.ToString("x"); * // if (HashNames.ContainsKey(HashID)) * // bone.Text = HashNames[HashID]; * // else * // Console.WriteLine($"bone hash {HashID}"); * * bone.position = new float[3] { Position.X, Position.Z, Position.Y }; * bone.rotation = new float[4] { Rotate.X, Rotate.Y, Rotate.Z, 1 }; * bone.scale = new float[3] { 0.2f, 0.2f, 0.2f }; * * bone.RotationType = STBone.BoneRotationType.Euler; * currentModel.Skeleton.bones.Add(bone); * } * * currentModel.Skeleton.reset(); * currentModel.Skeleton.update();*/ } } break; case (SubDataType)0x5012: case (SubDataType)0x5013: case (SubDataType)0x5014: chunkEntry.DataFile = File063Data; break; case (SubDataType)0x7101: case (SubDataType)0x7102: case (SubDataType)0x7103: case (SubDataType)0x7104: case (SubDataType)0x7106: case (SubDataType)0x6503: case (SubDataType)0x6501: chunkEntry.DataFile = File053Data; break; /* case (SubDataType)0x7105: * chunkEntry.DataFile = File053Data; * using (var chunkReader = new FileReader(chunkEntry.FileData)) * { * while (chunkReader.Position <= chunkReader.BaseStream.Length - 8) * { * uint hash = chunkReader.ReadUInt32(); * uint unk = chunkReader.ReadUInt32(); * * if (HashNames.ContainsKey(hash)) * Console.WriteLine("Hash Match! " + HashNames[hash]); * } * } * break;*/ case SubDataType.BoneHashList: chunkEntry.DataFile = File053Data; using (var chunkReader = new FileReader(chunkEntry.FileData, true)) { while (chunkReader.Position <= chunkReader.BaseStream.Length - 4) { uint hash = chunkReader.ReadUInt32(); // if (HashNames.ContainsKey(hash)) // Console.WriteLine("Hash Match! " + HashNames[hash]); } } break; default: chunkEntry.DataFile = File052Data; break; } if (chunk.ChunkType == SubDataType.MaterailData || chunk.ChunkType == SubDataType.ModelInfo || chunk.ChunkType == SubDataType.MeshBuffers || chunk.ChunkType == SubDataType.MeshIndexTable || chunk.ChunkType == SubDataType.SubmeshInfo || chunk.ChunkType == SubDataType.BoneHashList || chunk.ChunkType == SubDataType.BoneData) { currentModelChunk.Nodes.Add(chunkEntry); } else if (chunk.ChunkType != SubDataType.HavokPhysics) { chunkFolder.Nodes.Add(chunkEntry); } chunkId++; } foreach (var model in modelFolder.Nodes) { ((LM3_Model)model).ModelInfo.Read(new FileReader( ((LM3_Model)model).ModelInfo.Data), ((LM3_Model)model), TextureHashes); } if (havokFolder.Nodes.Count > 0) { Nodes.Add(havokFolder); } if (textureFolder.Nodes.Count > 0) { Nodes.Add(textureFolder); } if (modelFolder.Nodes.Count > 0) { Nodes.Add(modelFolder); } if (stringFolder.Nodes.Count > 0) { Nodes.Add(stringFolder); } } }
public ShellTree() { Sorted = true; TreeNode rootNode = Nodes.Add(Path.GetFileName(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))); rootNode.ImageIndex = 6; rootNode.SelectedImageIndex = 6; rootNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); TreeNode myFilesNode = rootNode.Nodes.Add(ResourceService.GetString("MainWindow.Windows.FileScout.MyDocuments")); myFilesNode.ImageIndex = 7; myFilesNode.SelectedImageIndex = 7; try { myFilesNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } catch (Exception) { myFilesNode.Tag = "C:\\"; } myFilesNode.Nodes.Add(""); TreeNode computerNode = rootNode.Nodes.Add(ResourceService.GetString("MainWindow.Windows.FileScout.MyComputer")); computerNode.ImageIndex = 8; computerNode.SelectedImageIndex = 8; try { computerNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } catch (Exception) { computerNode.Tag = "C:\\"; } //foreach (DriveInfo info in DriveInfo.GetDrives()) //{ // DriveObject drive = new DriveObject(info); // TreeNode node = new TreeNode(drive.ToString()); // node.Nodes.Add(new TreeNode("")); // node.Tag = drive.Drive.Substring(0, 2); // computerNode.Nodes.Add(node); // switch (info.DriveType) // { // case DriveType.Removable: // node.ImageIndex = node.SelectedImageIndex = 2; // break; // case DriveType.Fixed: // node.ImageIndex = node.SelectedImageIndex = 3; // break; // case DriveType.CDRom: // node.ImageIndex = node.SelectedImageIndex = 4; // break; // case DriveType.Network: // node.ImageIndex = node.SelectedImageIndex = 5; // break; // default: // node.ImageIndex = node.SelectedImageIndex = 3; // break; // } //} foreach (string directory in Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))) { TreeNode node = rootNode.Nodes.Add(Path.GetFileName(directory)); node.Tag = directory; node.ImageIndex = node.SelectedImageIndex = 0; node.Nodes.Add(new TreeNode("")); } rootNode.Expand(); computerNode.Expand(); InitializeComponent(); }
private void References_InsertedItem(object sender, CollectionChangedEventArgs e) { Nodes.Add(new FileReferenceNode(e.TargetObject as string, _iconProvider)); }
private void GenerateMeshNodes(int LElements, int HElements) { Nodes.Clear(); LeftNodes.Clear(); RightNodes.Clear(); int indexCur = 0; double xCur = 0; double yCur = _shape.H / 2; if (HElements % 2 == 1) { HElements++; } int HNodes = HElements + 1; int LNodes = LElements + 1; double xStep = _shape.L / Convert.ToDouble(LElements); double yStep = _shape.H / Convert.ToDouble(HElements); int HNodesdiv2 = HNodes / 2; for (int i = 0; i < HNodesdiv2; i++) { if (i == 0) { TopNodes.Clear(); } for (int j = 0; j < LNodes; j++) { Node node = new Node(); node.Index = indexCur; node.X = xCur; node.Y = yCur; Nodes.Add(node); if (j == 0) { LeftNodes.Add(node); } if (j == (LNodes - 1)) { RightNodes.Add(node); } indexCur++; xCur += xStep; if (i == 0) { TopNodes.Add(node); } } yCur -= yStep; xCur = 0; } xCur = 0; yCur = 0; MiddleNodes.Clear(); for (int j = 0; j < LNodes; j++) { Node node = new Node(); node.Index = indexCur; node.X = xCur; node.Y = yCur; Nodes.Add(node); MiddleNodes.Add(node); if (j == 0) { LeftNodes.Add(node); } if (j == (LNodes - 1)) { RightNodes.Add(node); } indexCur++; xCur += xStep; } xCur = 0; yCur -= yStep; for (int i = 0; i < HNodesdiv2; i++) { if (i == (HNodesdiv2 - 1)) { BottomNodes.Clear(); } for (int j = 0; j < LNodes; j++) { Node node = new Node(); node.Index = indexCur; node.X = xCur; node.Y = yCur; Nodes.Add(node); if (j == 0) { LeftNodes.Add(node); } if (j == (LNodes - 1)) { RightNodes.Add(node); } if (i == (HNodesdiv2 - 1)) { BottomNodes.Add(node); } indexCur++; xCur += xStep; } yCur -= yStep; xCur = 0; } }
public void AddNode(BFRESGroupNode node) { Nodes.Add(node); }
// copy part of diagram to text xml string public string GetDiagramPart(Nodes nodes) { Nodes copy = new Nodes(); foreach (Node node in nodes) { copy.Add(node); } string copyxml = ""; if (copy.Count() > 0) { XElement root = new XElement("diagram"); XElement rectangles = new XElement("rectangles"); XElement lines = new XElement("lines"); int minx = copy[0].position.x; int miny = copy[0].position.y; int minid = copy[0].id; foreach (Node node in copy) { if (node.position.x < minx) minx = node.position.x; if (node.position.y < miny) miny = node.position.y; if (node.id < minid) minid = node.id; } Nodes subnodes = new Nodes(); foreach (Node node in copy) { getLayerNodes(node, subnodes); } foreach (Node node in subnodes) { copy.Add(node); } foreach (Node rec in copy) { XElement rectangle = new XElement("rectangle"); rectangle.Add(new XElement("id", rec.id - minid + 1)); rectangle.Add(new XElement("x", rec.position.x - minx)); rectangle.Add(new XElement("y", rec.position.y - miny)); rectangle.Add(new XElement("text", rec.name)); rectangle.Add(new XElement("note", rec.note)); rectangle.Add(new XElement("color", rec.color)); rectangle.Add(Fonts.FontToXml(rec.font)); rectangle.Add(new XElement("fontcolor", rec.fontcolor)); if (rec.link != "") rectangle.Add(new XElement("link", rec.link)); if (rec.shortcut != 0 && rec.shortcut - minid + 1 > 0) rectangle.Add(new XElement("shortcut", rec.shortcut + 1)); if (rec.mark) rectangle.Add(new XElement("mark", rec.mark)); rectangle.Add(new XElement("transparent", rec.transparent)); if (rec.embeddedimage) rectangle.Add(new XElement("embeddedimage", rec.embeddedimage)); if (rec.embeddedimage && rec.image != null) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); rectangle.Add(new XElement("imagedata", Convert.ToBase64String((byte[])converter.ConvertTo(rec.image, typeof(byte[]))))); } else if (rec.imagepath != "") { rectangle.Add(new XElement("image", rec.imagepath)); } rectangle.Add(new XElement("timecreate", rec.timecreate)); rectangle.Add(new XElement("timemodify", rec.timemodify)); rectangle.Add(new XElement("attachment", rec.attachment)); if (rec.layer != 0 && rec.layer - minid + 1 > 0) rectangle.Add(new XElement("layer", rec.layer - minid + 1)); if (rec.protect) rectangle.Add(new XElement("protect", rec.protect)); rectangles.Add(rectangle); } foreach (Line li in this.getAllLines()) { foreach (Node recstart in copy) { if (li.start == recstart.id) { foreach (Node recend in copy) { if (li.end == recend.id) { XElement line = new XElement("line"); line.Add(new XElement("start", li.start - minid + 1)); line.Add(new XElement("end", li.end - minid + 1)); line.Add(new XElement("arrow", (li.arrow) ? "1" : "0")); line.Add(new XElement("color", li.color)); if (li.width != 1) line.Add(new XElement("width", li.width)); if (li.layer - minid +1 > 0) { line.Add(new XElement("layer", li.layer - minid + 1)); } lines.Add(line); } } } } } root.Add(rectangles); root.Add(lines); copyxml = root.ToString(); } return copyxml; }