public bool ClickOnNodeAction(Diagram.Diagram diagram, DiagramView diagramview, Node node)
        {
            if (diagram.FileName != "" && this.IsUid(node.link))
            {
                string uid = this.GetUid(node.link);
                if (Os.FileExists(diagram.FileName))
                {
                    string diagramDirectory = Os.GetFileDirectory(diagram.FileName);

                    List <FileNameAndSizePair> files = new List <FileNameAndSizePair>();

                    foreach (string file in Directory.EnumerateFiles(diagramDirectory, "*.*", SearchOption.AllDirectories))
                    {
                        FileNameAndSizePair pair = new FileNameAndSizePair();
                        pair.name = file;
                        pair.size = new System.IO.FileInfo(file).Length;
                        files.Add(pair);
                    }

                    files.Sort(delegate(FileNameAndSizePair p1, FileNameAndSizePair p2) {
                        return(p1.size <p2.size ? -1 : p1.size> p2.size ? 1 : 0);
                    });

                    foreach (FileNameAndSizePair file in files)
                    {
                        try
                        {
                            // skip self
                            if (file.name == diagram.FileName)
                            {
                                continue;
                            }

                            long pos = 1;
                            foreach (string line in File.ReadAllLines(file.name))
                            {
                                if (line.Contains(uid))
                                {
                                    this.OpenFileOnPosition(file.name, pos);
                                    return(true);
                                }
                                pos++;
                            }
                        }
                        catch (Exception ex)
                        {
                            Program.log.Write("FindUidPlugin: " + ex.Message);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public void CreateDirectoryItem_Click(object sender, EventArgs e, Diagram.DiagramView diagramview)
        {
            string DiagramPath = diagramview.diagram.FileName.Trim();

            if (DiagramPath == "" && !Os.FileExists(DiagramPath))
            {
                return;
            }

            string NewDirectoryPath = Os.Combine(Os.GetFileDirectory(DiagramPath), "test");

            Os.CreateDirectory(NewDirectoryPath);

            Node newrec = diagramview.CreateNode(diagramview.actualMousePos.Clone());

            newrec.SetName("test");
            newrec.link = NewDirectoryPath;
            diagramview.diagram.Unsave("create", newrec, diagramview.shift, diagramview.currentLayer.id);
        }