Copy File


Node Information
Copies the specified file to the specified location, you can attach a progress bar to see the copy 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
Source IN String ONE FALSE FALSE
Destination IN String ONE FALSE FALSE
ProgressBar IN ProgressBar ONE FALSE FALSE
ProgressChange OUT RUN MULTIPLE FALSE FALSE
Size OUT Int64 MULTIPLE FALSE FALSE
Transferred OUT Int64 MULTIPLE FALSE FALSE
Progress OUT Int32 MULTIPLE FALSE FALSE
Complete OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.File
{
    [IsNode("Copy File")]
    public class FileCopy : 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(Korduene.Designer.Standard.ProgressBar), AcceptsLinks.ONE,  "ProgressBar");
        Port chang = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "ProgressChange");
        Port size = new Port(PortType.OUT, typeof(long), AcceptsLinks.MULTIPLE, "Size");
        Port transf = new Port(PortType.OUT, typeof(long), AcceptsLinks.MULTIPLE, "Transferred");
        Port prog = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "Progress");
        Port complete = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE,  "Complete");
        Variable var1 = new Variable("KIO.CopyEx", null, "new KIO.CopyEx()");
        public FileCopy()
        {
            this.Dependency = DependencyLibraries.IOOPERATIONS;
            this.Name = "Copy File";
            this.NodeType = KGraph.NodeType.Method;
            AddPort(run);
            AddPort(sourcepath);
            AddPort(destpath);
            AddPort(prgbar);
            AddPort(chang);
            AddPort(size);
            AddPort(transf);
            AddPort(prog);
            AddPort(complete);
            Variables.Add(var1);
            Information = "Copies the specified file to the specified location, you can attach a progress bar to see the copy progress.";
        }
        public override string Code()
        {
            string spath = GetValue(sourcepath);
            string dpath = GetValue(destpath);
            var1.Name = run.ID;
            size.Instructions = var1.Name + ".TotalSize";
            transf.Instructions = var1.Name + ".Transferred";
            prog.Instructions = var1.Name + ".Progress";
            string code = string.Empty;
            if (prgbar.IsConnected)
            {
                code += var1.Name + ".ProgressBar = " + GetValue(prgbar) + ";\r\n";
            }
            code += var1.Name + ".ProgressChanged +=delegate (object sender, int e) {this.Invoke(new Action(()=> {" + GetValue(chang) + "}));};\r\n";
            code += var1.Name + ".Complete +=delegate (object sender, EventArgs e) {this.Invoke(new Action(()=> {" + GetValue(complete) + "}));};\r\n";
            code += var1.Name + ".Copy(" + GetValue(sourcepath) + ", " + GetValue(destpath) + ");";
            return code;
        }
    }
}