private async void ExcuteTransfer(IEnumerable items) { Console.WriteLine("Excute"); var sels = ProtoFiles.ToList().FindAll(item => item.IsSelected); List <Task> tlist = new List <Task>(); foreach (var s in sels) { var orginPath = s.ProtoFile.FilePath; var dirPath = ".\\SrcProto"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } Task t = new Task(() => { var src = Path.Combine(dirPath, Path.GetFileName(orginPath)); File.Copy(orginPath, src, true); var state = ProtoGenerator.DoGen((output) => { s.ProtoFile.OutputMessage = output; }, $"{src}", $"--csharp_out={OutputDir}"); if (!state) { s.ProtoFile.ErrMsg = s.ProtoFile.OutputMessage; } else { s.ProtoFile.ErrMsg = "Generated Succeed"; s.ProtoFile.InputMessage = File.ReadAllText(src); } }); tlist.Add(t); } tlist.ForEach(t => t.Start()); Task.WaitAll(tlist.ToArray()); }
private void AddFilePath(params string[] files) { ProtoFiles.Clear(); if (files == null || files.Length <= 0) { return; } for (int i = 0; i < files.Length; i++) { var f = files[i]; ProtoFiles.Add(new ProtoFileModel() { ProtoFile = new ProtoFile() { FilePath = f, ID = i } }); } }
public void Select(int id) { ProtoFileModel md = ProtoFiles.Where(p => p.ProtoFile.ID == id).FirstOrDefault(); if (md != null) { if (!md.IsSelected && IsSelectAll) { IsSelectAll = false; } else if (md.IsSelected && !IsSelectAll) { foreach (var item in ProtoFiles) { if (!item.IsSelected) { return; } } IsSelectAll = true; } } }