Copy Directoy


Node Information
Copies the given directory recursively to the specified directory, you can attach a progress bar to it to see the progress.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Copy IN RUN MULTIPLE FALSE FALSE
Stop IN RUN MULTIPLE FALSE FALSE
Source IN String ONE FALSE FALSE
Destination IN String ONE FALSE FALSE
ProgressBar-File IN Object ONE FALSE FALSE
ProgressBar-Overall IN Object ONE FALSE FALSE
ProgressChange OUT RUN MULTIPLE FALSE FALSE
FileChanged OUT RUN MULTIPLE FALSE FALSE
FileProgressChanged OUT RUN MULTIPLE FALSE FALSE
CurrentFile OUT String MULTIPLE FALSE FALSE
FileProgress OUT Int32 MULTIPLE FALSE FALSE
TotalSize OUT Int64 MULTIPLE FALSE FALSE
FilesCopied OUT Int32 MULTIPLE FALSE FALSE
TotalFiles OUT Int32 MULTIPLE FALSE FALSE
Progress OUT Int32 MULTIPLE FALSE FALSE
Complete OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.Directory
{
    [IsNode("Copy Directory")]
    public class DirectoryCopy : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Copy");
        Port sourcepath = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Source");
        Port destpath = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Destination");
        Port prgbar = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "ProgressBar-File");
        Port prgbaroa = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "ProgressBar-Overall");
        Port stop = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Stop");
        Port filechanged = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "FileChanged");
        Port currentfileprog = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "FileProgressChanged");
        Port curfileprogress = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "FileProgress");
        Port progchanged = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "ProgressChange");
        Port complete = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "Complete");
        Port currentfile = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "CurrentFile");
        Port totalsize = new Port(PortType.OUT, typeof(long), AcceptsLinks.MULTIPLE, "TotalSize");
        Port totalfiles = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "TotalFiles");
        Port filescopied = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "FilesCopied");
        Port progress = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "Progress");
        Variable var1 = new Variable("KIO.KDirectory", "null", "new KIO.KDirectory()");
        public DirectoryCopy()
        {
            this.Dependency = DependencyLibraries.IOOPERATIONS;
            this.Name = "Copy Directoy";
            this.NodeType = KGraph.NodeType.Method;
            AddPort(run);
            AddPort(stop);
            AddPort(sourcepath);
            AddPort(destpath);
            AddPort(prgbar);
            AddPort(prgbaroa);
            AddPort(progchanged);
            AddPort(filechanged);
            AddPort(currentfileprog);
            AddPort(currentfile);
            AddPort(curfileprogress);
            AddPort(totalsize);
            AddPort(filescopied);
            AddPort(totalfiles);
            AddPort(progress);
            AddPort(complete);
            Variables.Add(var1);
            Information = "Copies the given directory recursively to the specified directory, you can attach a progress bar to it to see the progress.";
        }
        public override string Code()
        {
            var1.Name = run.ID;
            string code = string.Empty;
            currentfile.Instructions = var1.Name + ".CurrentFile";
            curfileprogress.Instructions = var1.Name + ".FileProgress";
            totalfiles.Instructions = var1.Name + ".TotalFiles";
            totalsize.Instructions = var1.Name + ".TotalSize";
            progress.Instructions = var1.Name + ".Progress";
            filescopied.Instructions = var1.Name + ".FilesCopied";
            stop.Instructions = var1.Name + ".Stop();";
            if (prgbar.IsConnected)
            {
                code += var1.Name + ".FileProgressBar = " + GetValue(prgbar) + ";\r\n";
            }
            if (prgbaroa.IsConnected)
            {
                code += var1.Name + ".OverAllProgressBar = " + GetValue(prgbaroa) + ";\r\n";
            }
            code += var1.Name + ".FileChanged +=delegate(object o, string p) \r\n{ \r\nthis.Invoke(new Action(()=> \r\n{\r\n " + GetValue(filechanged) + "\r\n}));};\r\n";
            code += var1.Name + ".ProgressChanged +=delegate(object o, int p) \r\n{ \r\nthis.Invoke(new Action(()=> \r\n{\r\n " + GetValue(progchanged) + "\r\n}));};\r\n";
            code += var1.Name + ".FileProgressChanged +=delegate(object o, int p) \r\n{ \r\nthis.Invoke(new Action(()=> \r\n{\r\n " + GetValue(currentfileprog) + "\r\n}));};\r\n";
            code += var1.Name + ".Complete +=delegate(object o, EventArgs ea) \r\n{ \r\nthis.Invoke(new Action(()=> \r\n{\r\n " + GetValue(complete) + "\r\n}));};\r\n";
            code += var1.Name + ".BackgroundCopy(" + GetValue(sourcepath) + ", " + GetValue(destpath) + ");";
            return code;
        }
    }
}