Пример #1
0
        private static void LookSelectedModel()
        {
            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"));
                    }
                }
                UEViewer.QuickLookModel(Application.StartupPath, str1);
            }
        }
Пример #2
0
        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();
                }
            }
        }
Пример #3
0
 private static void TryCancelAnalysis()
 {
     if (AnalysisClass.analysisWorker.IsBusy)
     {
         AnalysisClass.timer.Stop();
         AnalysisClass.analysisWorker.CancelAsync();
         AnalysisClass.userCancelAnalysis = true;
         IntPtr intPtr = new IntPtr(UEViewer.FindWindow(null, "UE Viewer"));
         if ((intPtr == new IntPtr(0) ? false : !AnalysisClass.lostHandles.Contains(intPtr)))
         {
             UEViewer.SendMessageA(intPtr, 16, 0, 0);
         }
     }
 }
Пример #4
0
        private static void singleAnalysisWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string argument  = (string)((object[])e.Argument)[0];
            string str       = (string)((object[])e.Argument)[1];
            string argument1 = (string)((object[])e.Argument)[2];

            bool[]   flagArray = (bool[])((object[])e.Argument)[3];
            DateTime now       = DateTime.Now;

            LogClass.AppendLine(string.Concat("Start single parse ", now.ToString()), true);
            AnalysisClass.ue = new UEViewer(argument, str, argument1);
            AnalysisClass.singleAnalysisWorker.ReportProgress(0, new Report((object x) => AnalysisClass.timer.Start(), null));
            string imageReturnLog = AnalysisClass.ue.AnalysisToImageReturnLog();

            object[] hasImage = new object[] { imageReturnLog, AnalysisClass.ue.HasImage, AnalysisClass.ue.TempFileName, argument, flagArray };
            e.Result = hasImage;
        }
Пример #5
0
 private static void timer_Tick(object sender, EventArgs e)
 {
     if (AnalysisClass.ue != null)
     {
         if ((!AnalysisClass.isSingleAnalysis ? true : !AnalysisClass.ue.HasImage))
         {
             IntPtr intPtr = new IntPtr(UEViewer.FindWindow(null, "UE Viewer"));
             if ((intPtr == new IntPtr(0) ? false : !AnalysisClass.lostHandles.Contains(intPtr)))
             {
                 AnalysisClass.lostHandles.Add(intPtr);
                 Thread.Sleep(AnalysisClass.interval);
                 Graphics      graphic = Graphics.FromHwnd(intPtr);
                 UEViewer.RECT rECT    = new UEViewer.RECT();
                 UEViewer.GetWindowRect(intPtr, ref rECT);
                 int      right    = rECT.Right - rECT.Left;
                 int      bottom   = rECT.Bottom - rECT.Top;
                 Bitmap   bitmap   = new Bitmap(right - 16, bottom - 38, graphic);
                 Graphics graphic1 = Graphics.FromImage(bitmap);
                 IntPtr   hdc      = graphic.GetHdc();
                 IntPtr   hdc1     = graphic1.GetHdc();
                 UEViewer.BitBlt(hdc1, 0, 0, right - 16, bottom - 38, hdc, 0, 0, 13369376);
                 graphic.ReleaseHdc(hdc);
                 graphic1.ReleaseHdc(hdc1);
                 Bitmap   bitmap1  = new Bitmap(bitmap, right - 16, bottom - 38);
                 UEViewer uEViewer = AnalysisClass.ue;
                 string   str      = AnalysisClass.outputModelFolderName;
                 Guid     guid     = Guid.NewGuid();
                 uEViewer.TempFileName = Path.Combine(str, string.Concat(guid.ToString(), ".jpg"));
                 bitmap1.Save(AnalysisClass.ue.TempFileName, ImageFormat.Jpeg);
                 AnalysisClass.ue.HasImage = true;
                 if (!AnalysisClass.isSingleAnalysis)
                 {
                     UEViewer.SendMessageA(intPtr, 16, 0, 0);
                 }
             }
         }
         else
         {
             AnalysisClass.timer.Stop();
         }
     }
 }
Пример #6
0
        private static void ExportFile(string outputFolderName, string exportFileFullName, bool isSource)
        {
            string str;

            ManualClass.exportWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine(string.Concat("Start manual Unpack", DateTime.Now.ToString()), true), null));
            if (!Directory.Exists(outputFolderName))
            {
                throw new Exception(string.Concat("Export folder\"", outputFolderName, "\"does not exist, Please fix"));
            }
            string str1 = Path.Combine(outputFolderName, (isSource ? "Source" : "Target"));

            if (!Directory.Exists(str1))
            {
                Directory.CreateDirectory(str1);
            }
            UEViewer uEViewer = new UEViewer(exportFileFullName, str1, Application.StartupPath);

            uEViewer.Unpack(out str);
            ManualClass.exportWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), str));
        }
Пример #7
0
        private static void replaceWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string           str;
            string           str1;
            string           str2;
            string           str3;
            string           str4;
            string           str5;
            string           argument         = (string)((object[])e.Argument)[0];
            string           argument1        = (string)((object[])e.Argument)[1];
            string           argument2        = (string)((object[])e.Argument)[2];
            string           argument3        = (string)((object[])e.Argument)[3];
            string           argument4        = (string)((object[])e.Argument)[4];
            bool             flag             = (bool)((object[])e.Argument)[5];
            BackgroundWorker backgroundWorker = ReplaceClass.replaceWorker;
            InvokeAction     invokeAction     = (object x) => {
                LogClass.AppendLine(string.Concat("Start to model transformation", DateTime.Now.ToString()), true);
                LogClass.AppendLine((string)x, false);
            };

            string[] fileNameWithoutExtension = new string[] { "Start", Path.GetFileNameWithoutExtension(argument), "to", Path.GetFileNameWithoutExtension(argument1), "Model Transformation" };
            backgroundWorker.ReportProgress(0, new Report(invokeAction, string.Concat(fileNameWithoutExtension)));
            if (!ReplaceClass.userCancelReplace)
            {
                string str6 = Path.Combine(argument3, "ModsOutput");
                string str7 = Path.Combine(str6, string.Concat(Path.GetFileNameWithoutExtension(argument), " to ", Path.GetFileNameWithoutExtension(argument1)));
                str6 = str7;
                ReplaceClass.exportCompletedReportDir = str7;
                string str8 = Path.Combine(str6, "Backup source model");
                if (!ReplaceClass.userCancelReplace)
                {
                    if (Directory.Exists(str6))
                    {
                        try
                        {
                            Directory.Delete(str6, true);
                        }
                        catch
                        {
                        }
                    }
                    if (!Directory.Exists(str6))
                    {
                        Directory.CreateDirectory(str6);
                    }
                    if (!Directory.Exists(str8))
                    {
                        Directory.CreateDirectory(str8);
                    }
                    string str9 = Path.Combine(str6, "Source");
                    if (!Directory.Exists(str9))
                    {
                        Directory.CreateDirectory(str9);
                    }
                    string str10 = Path.Combine(str6, "Target");
                    if (!Directory.Exists(str10))
                    {
                        Directory.CreateDirectory(str10);
                    }
                    if (!ReplaceClass.userCancelReplace)
                    {
                        string modelFileName  = ReplaceClass.GetModelFileName(argument, argument4, flag, out str, out str1);
                        string modelFileName1 = ReplaceClass.GetModelFileName(argument1, argument4, flag, out str2, out str3);
                        if (!ReplaceClass.userCancelReplace)
                        {
                            UEViewer uEViewer = new UEViewer(modelFileName, str9, Path.GetDirectoryName(argument2));
                            if (!ReplaceClass.userCancelReplace)
                            {
                                UEViewer uEViewer1 = new UEViewer(modelFileName1, str10, Path.GetDirectoryName(argument2));
                                if (!ReplaceClass.userCancelReplace && !ReplaceClass.userCancelReplace)
                                {
                                    bool flag1 = uEViewer.Unpack(out str4, argument4, flag);
                                    ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), str4));
                                    if (!ReplaceClass.userCancelReplace)
                                    {
                                        bool flag2 = uEViewer1.Unpack(out str5, argument4, flag);
                                        ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), str5));
                                        if (!ReplaceClass.userCancelReplace)
                                        {
                                            if (!flag1)
                                            {
                                                throw new Exception(string.Concat("error_source\\", str6));
                                            }
                                            if (!flag2)
                                            {
                                                throw new Exception(string.Concat("error_target\\", str6));
                                            }
                                            if (!ReplaceClass.userCancelReplace)
                                            {
                                                ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), "Official convert Start"));
                                                ReplaceClass.DoReplace(str9, str10, str, str2, str1, str3, argument4, flag, str6);
                                                ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), "Concluded an official convert"));
                                                e.Result = str6;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        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;
                }
            }
        }