private static string MoveImageFile(string outputFolderName, string log, string tempFileName, string modelFileName, bool[] filter) { string str; string str1; string str2; if (!AnalysisClass.AnalysisLog(modelFileName, log, out str, out str1, filter)) { File.Delete(tempFileName); str2 = null; } else { string str3 = Path.Combine(outputFolderName, "ImgModelLib"); string str4 = Path.Combine(str3, str); string str5 = string.Format("{0}+{1}.jpg", Path.GetFileNameWithoutExtension(modelFileName), str1); string str6 = Path.Combine(str4, Path.GetFileName(str5)); if (File.Exists(str6)) { File.Delete(str6); } File.Move(tempFileName, str6); str2 = str6; } return(str2); }
private static void singleAnalysisWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { AnalysisClass.timer.Stop(); AnalysisClass.isSingleAnalysis = false; AnalysisClass.ue.Dispose(); AnalysisClass.ue = null; AnalysisClass.SetControlState(AnalysisStates.None); AnalysisClass.mainForm.OnDoOperation(Operations.None); string result = (string)((object[])e.Result)[0]; bool flag = (bool)((object[])e.Result)[1]; string str = (string)((object[])e.Result)[2]; string result1 = (string)((object[])e.Result)[3]; bool[] flagArray = (bool[])((object[])e.Result)[4]; LogClass.AppendLine(result, false); DateTime now = DateTime.Now; LogClass.AppendLine(string.Concat("Single parse ending", now.ToString()), false); if (e.Error != null) { MessageBox.Show(e.Error.Message); LogClass.AppendLine(string.Concat("Tracking error:", e.Error.ToString()), false); } else if (!flag) { MessageBox.Show("Failed to parse model image, The file should not be a valid model file."); } else if (MessageBox.Show("Want to save the model image?", string.Empty, MessageBoxButtons.OKCancel) != DialogResult.OK) { File.Delete(str); } else { string str1 = AnalysisClass.MoveImageFile(AnalysisClass.mainForm.txtOutputFolder.Text, result, str, result1, flagArray); DialogResult dialogResult = MessageBox.Show("Click 'Yes' to open the folder where the image, click 'No' to open the image.", string.Empty, MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) { Process process = new Process(); process.StartInfo.FileName = "explorer.exe"; process.StartInfo.Arguments = Path.GetDirectoryName(str1); process.Start(); } else if (dialogResult == DialogResult.No) { Process process1 = new Process(); process1.StartInfo.FileName = str1; process1.Start(); } } }
private static void refreshWorker_DoWork(object sender, DoWorkEventArgs e) { AnalysisClass.refreshWorker.ReportProgress(0, new Report((object x) => { AnalysisClass.mainForm.lstAnalysisFileName.Items.Clear(); AnalysisClass.mainForm.panelLoadingAnalysisFileName.Visible = true; }, null)); if (!(bool)((object[])e.Argument)[1]) { e.Result = AnalysisClass.ReadItemListFromCustom((string)((object[])e.Argument)[0]); } else { e.Result = AnalysisClass.ReadItemListFromGame((string)((object[])e.Argument)[0]); } }
private static void CurrentSelectedItemAnalysis() { string str; if (AnalysisClass.mainForm.lstAnalysisFileName.SelectedIndex >= 0) { string str1 = null; if (!AnalysisClass.mainForm.rbSetup.Checked) { str = AnalysisClass.mainForm.lstAnalysisFileName.SelectedItem.ToString(); str1 = Path.Combine(AnalysisClass.mainForm.txtModelFolder.Text, string.Concat(str, ".upk")); } else { str = AnalysisClass.mainForm.lstAnalysisFileName.SelectedItem.ToString(); if (!str.StartsWith(".\\bns\\")) { str1 = Path.Combine(AnalysisClass.mainForm.txtModelFolder.Text, //"contents\\Local\\TENCENT\\CHINESES\\CookedPC"); "contents\\local\\NCWEST\\ENGLISH\\CookedPC"); str1 = Path.Combine(str1, string.Concat(str.Substring(".\\local\\".Length), ".upk")); } else { str1 = Path.Combine(AnalysisClass.mainForm.txtModelFolder.Text, "contents\\bns\\CookedPC"); str1 = Path.Combine(str1, string.Concat(str.Substring(".\\bns\\".Length), ".upk")); } } if (!File.Exists(str1)) { MessageBox.Show(string.Concat("文件\"", str1, "\"does not exist。")); } else { AnalysisClass.SingleAnalysis(str1); } } else { MessageBox.Show("没有在列表中选择项。"); } }
private static void SingleAnalysis(string fileFullName) { if (Directory.Exists(AnalysisClass.mainForm.txtOutputFolder.Text)) { AnalysisClass.TryCreateOutputAnalysisFolder(AnalysisClass.mainForm.txtOutputFolder.Text); AnalysisClass.interval = Convert.ToInt32(AnalysisClass.mainForm.txtAnalysisInterval.Text); AnalysisClass.outputModelFolderName = AnalysisClass.mainForm.txtOutputFolder.Text; AnalysisClass.isSingleAnalysis = true; BackgroundWorker backgroundWorker = AnalysisClass.singleAnalysisWorker; object[] objArray = new object[] { fileFullName, AnalysisClass.mainForm.txtOutputFolder.Text, Application.StartupPath, null }; bool[] @checked = new bool[] { AnalysisClass.mainForm.chkAnalysisJinM.Checked, AnalysisClass.mainForm.chkAnalysisJinF.Checked, AnalysisClass.mainForm.chkAnalysisGonM.Checked, AnalysisClass.mainForm.chkAnalysisGonF.Checked, AnalysisClass.mainForm.chkAnalysisLynM.Checked, AnalysisClass.mainForm.chkAnalysisLynF.Checked, AnalysisClass.mainForm.chkAnalysisKunN.Checked, AnalysisClass.mainForm.chkAnalysisOther.Checked }; objArray[3] = @checked; backgroundWorker.RunWorkerAsync(objArray); } else { MessageBox.Show(string.Concat("Export folder\"", AnalysisClass.mainForm.txtOutputFolder.Text, "\"does not exist,Please re-set the correct folder.")); AnalysisClass.mainForm.OnDoOperation(Operations.None); } }
private static void mainForm_DoOperation(object sender, OperationEventArgs e) { if ((e.Operation != Operations.LeaveSettings ? true : Directory.Exists(AnalysisClass.mainForm.txtModelFolder.Text))) { switch (e.Operation) { case Operations.LeaveSettings: { if (AnalysisClass.analysisWorker.IsBusy) { break; } AnalysisClass.SetControlState(AnalysisStates.Refresh); AnalysisClass.TryCancelAnalysis(); AnalysisClass.TryCancelRefresh(); AnalysisClass.BeginRefresh(); break; } case Operations.RefreshAnalysisList: { AnalysisClass.SetControlState(AnalysisStates.Refresh); AnalysisClass.TryCancelAnalysis(); AnalysisClass.TryCancelRefresh(); AnalysisClass.BeginRefresh(); break; } case Operations.CancelRefreshanalysisList: { AnalysisClass.TryCancelRefresh(); break; } case Operations.LookModel: { AnalysisClass.LookSelectedModel(); break; } case Operations.BeginAnalysis: { AnalysisClass.SetControlState(AnalysisStates.Analysis); AnalysisClass.TryCancelAnalysis(); AnalysisClass.TryCancelRefresh(); AnalysisClass.BeginAnalysis(); break; } case Operations.CancelAnalysis: { AnalysisClass.TryCancelAnalysis(); break; } case Operations.DragAnalysis: { AnalysisClass.SetControlState(AnalysisStates.OtherWork); AnalysisClass.DragDropAnalysis(); break; } case Operations.CurrentAnalysis: { AnalysisClass.SetControlState(AnalysisStates.OtherWork); AnalysisClass.CurrentSelectedItemAnalysis(); break; } case Operations.BeginReplace: { AnalysisClass.SetControlState(AnalysisStates.OtherWork); break; } case Operations.ManualAction: { AnalysisClass.SetControlState(AnalysisStates.OtherWork); break; } case Operations.None: { AnalysisClass.SetControlState(AnalysisStates.None); break; } } } }
private static void DragDropAnalysis() { string str = ((Array)AnalysisClass.DropItem.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); AnalysisClass.SingleAnalysis(str); }
private static void analysisWorker_DoWork(object sender, DoWorkEventArgs e) { string argument = (string)((object[])e.Argument)[0]; bool flag = (bool)((object[])e.Argument)[1]; string argument1 = (string)((object[])e.Argument)[2]; string str1 = (string)((object[])e.Argument)[3]; string argument2 = (string)((object[])e.Argument)[4]; ListBox.ObjectCollection objectCollections = (ListBox.ObjectCollection)((object[])e.Argument)[5]; bool[] flagArray = (bool[])((object[])e.Argument)[6]; AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => { AnalysisClass.mainForm.pbAnalysis.Value = 0; AnalysisClass.mainForm.lblCurrentAnalysisFileName.Text = string.Empty; AnalysisClass.mainForm.lblAnalysisProgress.Text = "0/0"; LogClass.AppendLine(string.Concat("批量解析Start于", DateTime.Now.ToString()), true); }, null)); if (!Directory.Exists(argument1)) { throw new Exception(string.Concat("Export folder\"", argument1, "\"does not exist,Please re-set the correct folder.")); } string str2 = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "umodel.exe"); if (!File.Exists(str2)) { throw new Exception(string.Concat("\"", str2, "\"does not exist,请自行从\"http://www.gildor.org/en/projects/umodel\"网站下载UEViewer程序并将所有文件到本程序所在文件夹。")); } AnalysisClass.TryCreateOutputAnalysisFolder(argument1); List <string> strs = new List <string>(); if (!objectCollections.Contains(str1)) { throw new Exception("解析Start项does not exist,不能进行解析。"); } if (!objectCollections.Contains(argument2)) { throw new Exception("解析结束项does not exist,不能进行解析。"); } int num1 = objectCollections.IndexOf(str1); int num2 = objectCollections.IndexOf(argument2); if (num1 > num2) { throw new Exception("解析Start项在结束项之后,请重新设置解析范围。"); } for (int i = num1; i < num2 + 1; i++) { string fileFullNameFromItemList = AnalysisClass.GetFileFullNameFromItemList(objectCollections[i].ToString(), argument, flag); strs.Add(fileFullNameFromItemList); } AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => { if (x != null) { AnalysisClass.mainForm.pbAnalysis.Maximum = (int)x; AnalysisClass.mainForm.lblAnalysisProgress.Text = string.Concat("0/", x.ToString()); } }, (object)strs.Count)); int num3 = 0; while (true) { if (num3 < strs.Count) { AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => { if (x != null) { int num = (int)x; AnalysisClass.mainForm.lblCurrentAnalysisFileName.Text = strs[num]; AnalysisClass.mainForm.pbAnalysis.Value = num + 1; Label label = AnalysisClass.mainForm.lblAnalysisProgress; int value = AnalysisClass.mainForm.pbAnalysis.Value; string str = value.ToString(); value = AnalysisClass.mainForm.pbAnalysis.Maximum; label.Text = string.Concat(str, "/", value.ToString()); LogClass.AppendLine(string.Concat("正在解析文件:", strs[num3]), false); } }, (object)num3)); DateTime now = DateTime.Now; AnalysisClass.ue = new UEViewer(strs[num3], argument1, Application.StartupPath); string imageReturnLog = null; string tempFileName = null; bool hasImage = false; try { imageReturnLog = AnalysisClass.ue.AnalysisToImageReturnLog(); tempFileName = AnalysisClass.ue.TempFileName; hasImage = AnalysisClass.ue.HasImage; } finally { AnalysisClass.ue.Dispose(); } if (hasImage) { AnalysisClass.MoveImageFile(argument1, imageReturnLog, tempFileName, strs[num3], flagArray); } if (AnalysisClass.userCancelAnalysis) { AnalysisClass.ue = null; AnalysisClass.lostHandles.Clear(); break; } else { num3++; } } else { break; } } }