public static async Task LoadDifference(bool updateMode = false) { FWindow.FMain.MI_LoadOnePAK.IsEnabled = false; FWindow.FMain.MI_LoadAllPAKs.IsEnabled = false; FWindow.FMain.MI_BackupPAKs.IsEnabled = false; FWindow.FMain.MI_DifferenceMode.IsEnabled = false; FWindow.FMain.MI_UpdateMode.IsEnabled = false; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.ViewModel = srt = new SortedTreeViewWindowViewModel(); FWindow.FMain.ImageBox_Main.Source = null; ListBoxUtility.FilesListWithoutPath = null; FWindow.FMain.ListBox_Main.Items.Clear(); umIsOk = false; FWindow.FMain.TreeView_Main.IsEnabled = false; await Task.Run(async() => { PAKEntries.PAKToDisplay = new Dictionary <string, FPakEntry[]>(); DebugHelper.WriteLine($".PAKs: User is loading difference at {PAK_PATH}\\"); LoadPAKFiles(true); await LoadBackupFile(updateMode); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); DebugHelper.WriteLine($".PAKs: Loaded difference at {PAK_PATH}\\"); }); }
public static async Task LoadAllPAKs() { FWindow.FMain.MI_LoadOnePAK.IsEnabled = false; FWindow.FMain.MI_LoadAllPAKs.IsEnabled = false; FWindow.FMain.MI_BackupPAKs.IsEnabled = false; FWindow.FMain.MI_DifferenceMode.IsEnabled = false; FWindow.FMain.MI_UpdateMode.IsEnabled = false; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.ViewModel = srt = new SortedTreeViewWindowViewModel(); FWindow.FMain.ImageBox_Main.Source = null; ListBoxUtility.FilesListWithoutPath = null; FWindow.FMain.ListBox_Main.Items.Clear(); await Task.Run(() => { PAKEntries.PAKToDisplay = new Dictionary <string, FPakEntry[]>(); LoadPAKFiles(true); FillTreeView(true); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); FWindow.FMain.MI_LoadOnePAK.IsEnabled = true; FWindow.FMain.MI_LoadAllPAKs.IsEnabled = true; FWindow.FMain.MI_BackupPAKs.IsEnabled = true; FWindow.FMain.MI_DifferenceMode.IsEnabled = true; }
public static async Task LoadOnePAK() { FWindow.FMain.MI_LoadOnePAK.IsEnabled = false; FWindow.FMain.MI_LoadAllPAKs.IsEnabled = false; FWindow.FMain.MI_BackupPAKs.IsEnabled = false; FWindow.FMain.MI_DifferenceMode.IsEnabled = false; FWindow.FMain.MI_UpdateMode.IsEnabled = false; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.ViewModel = srt = new SortedTreeViewWindowViewModel(); FWindow.FMain.ImageBox_Main.Source = null; ListBoxUtility.FilesListWithoutPath = null; FWindow.FMain.ListBox_Main.Items.Clear(); await Task.Run(() => { PAKEntries.PAKToDisplay = new Dictionary <string, FPakEntry[]>(); DebugHelper.WriteLine($".PAKs: User is loading {PAK_PATH}\\{FWindow.FCurrentPAK}"); new UpdateMyProcessEvents($"{PAK_PATH}\\{FWindow.FCurrentPAK}", "Loading").Update(); LoadPAKFiles(); FillTreeView(); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); DebugHelper.WriteLine($".PAKs: Loaded {PAK_PATH}\\{FWindow.FCurrentPAK}"); }); FWindow.FMain.MI_LoadOnePAK.IsEnabled = true; FWindow.FMain.MI_LoadAllPAKs.IsEnabled = true; FWindow.FMain.MI_BackupPAKs.IsEnabled = true; FWindow.FMain.MI_DifferenceMode.IsEnabled = true; }
private async void Window_Loaded(object sender, RoutedEventArgs e) { FModelVersionLabel.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5); AutoUpdater.CheckForUpdateEvent += UIHelper.AutoUpdaterOnCheckForUpdateEvent; AutoUpdater.Start("https://dl.dropbox.com/s/3kv2pukqu6tj1r0/FModel.xml?dl=0"); // Copy user settings from previous application version if necessary if (FProp.Default.FUpdateSettings) { FProp.Default.Upgrade(); FProp.Default.FUpdateSettings = false; FProp.Default.Save(); } await Task.Run(() => { FoldersUtility.LoadFolders(); FoldersUtility.CheckWatermark(); RegisterFromPath.FilterPAKs(); DynamicKeysChecker.SetDynamicKeys(); RegisterDownloadedBackups.LoadBackupFiles(); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); AvalonEdit.SetAEConfig(); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { FModelVersionLabel.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5); DebugHelper.WriteLine("AutoUpdater: Checking for updates"); AutoUpdater.CheckForUpdateEvent += UIHelper.AutoUpdaterOnCheckForUpdateEvent; AutoUpdater.Start("https://cdn.asval.tk/d/FModel/FModel.xml"); DebugHelper.WriteUserSettings(); await Task.Run(() => { FoldersUtility.CheckWatermark(); RegisterFromPath.CheckFortniteVersion(); RegisterFromPath.FilterPAKs(); DynamicKeysChecker.SetDynamicKeys(); RegisterDownloadedBackups.LoadBackupFiles(); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); Dispatcher.InvokeAsync(() => AvalonEdit.SetAEConfig()); Program.StartTimer.Stop(); DebugHelper.WriteLine("Startup time: {0} ms", Program.StartTimer.ElapsedMilliseconds); }); }
private async Task PopulateDataGrid() { Dictionary <string, string> IfExistChecker = new Dictionary <string, string>(); int i = 0; await Task.Run(() => { if (!string.IsNullOrEmpty(FWindow.FCurrentPAK)) { FPakEntry[] ohyeah = PAKEntries.PAKToDisplay[FWindow.FCurrentPAK]; FillList(ohyeah, IfExistChecker); i = ohyeah.Length; } else { foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values) { FillList(PAKsFileInfos, IfExistChecker); i += PAKsFileInfos.Length; } } }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); //max = million string number = i.ToString("# ### ###", new NumberFormatInfo { NumberGroupSeparator = " " }).Trim(); DebugHelper.WriteLine($"SearchFiles: Loaded {number} assets"); FoundNumber_Label.Content = $"Found {number} assets"; }
public static async Task CreateBackupFile() { await Task.Run(() => { GetPAKsFileInfos(); }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); }
private static async Task PopulateDataGrid() { Dictionary <string, string> IfExistChecker = new Dictionary <string, string>(); await Task.Run(() => { if (!string.IsNullOrEmpty(FWindow.FCurrentPAK)) { FillList(PAKEntries.PAKToDisplay[FWindow.FCurrentPAK], IfExistChecker); } else { foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values) { FillList(PAKsFileInfos, IfExistChecker); } } }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); }
public static async Task LoadSelectedAsset() { new UpdateMyProcessEvents("", "").Update(); FWindow.FMain.Button_Extract.IsEnabled = false; FWindow.FMain.Button_Stop.IsEnabled = true; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Json.xshd"); FWindow.FMain.ImageBox_Main.Source = null; string[] selectedItems = FWindow.FMain.ListBox_Main.SelectedItems.OfType <string>().ToArray(); //store selected items, doesn't crash if user select another item while extracting string treePath = TreeViewUtility.GetFullPath(FWindow.TVItem); //never change in the loop, in case user wanna see other folders while extracting TasksUtility.CancellableTaskTokenSource = new CancellationTokenSource(); CancellationToken cToken = TasksUtility.CancellableTaskTokenSource.Token; await Task.Run(() => { isRunning = true; foreach (string item in selectedItems) { DebugHelper.WriteLine("Assets: User selected " + item); cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item while (!string.Equals(FWindow.FCurrentAsset, item)) { FWindow.FCurrentAsset = item; } LoadAsset(treePath + "/" + item); } }, cToken).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); TasksUtility.CancellableTaskTokenSource.Dispose(); isRunning = false; }); FWindow.FMain.Button_Extract.IsEnabled = true; FWindow.FMain.Button_Stop.IsEnabled = false; }
private async Task UpdateImageWithWatermark() { bool watermarkEnabled = (bool)bWatermarkIcon.IsChecked; string rarityDesign = ((ComboBoxItem)ComboBox_Design.SelectedItem).Content.ToString(); bool isFeatured = (bool)bFeaturedIcon.IsChecked; int opacity = Convert.ToInt32(Opacity_Slider.Value); double scale = Scale_Slider.Value; double xPos = xPos_Slider.Value; double yPos = yPos_Slider.Value; await Task.Run(() => { DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { //INITIALIZATION drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 515))); BitmapImage source = null; switch (rarityDesign) { case "Default": source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_D_F.png" : "pack://application:,,,/Resources/Template_D_N.png")); break; case "Flat": source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_F_F.png" : "pack://application:,,,/Resources/Template_F_N.png")); break; case "Minimalist": source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png")); break; } drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515))); if (!string.IsNullOrEmpty(FProp.Default.FWatermarkFilePath) && watermarkEnabled) { using (StreamReader image = new StreamReader(FProp.Default.FWatermarkFilePath)) { if (image != null) { BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; bmp.StreamSource = image.BaseStream; bmp.EndInit(); drawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, opacity), new Rect(xPos, yPos, scale, scale)); } } } } if (drawingVisual != null) { RenderTargetBitmap RTB = new RenderTargetBitmap(515, 515, 96, 96, PixelFormats.Pbgra32); RTB.Render(drawingVisual); RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread FWindow.FMain.Dispatcher.InvokeAsync(() => { ImageBox_RarityPreview.Source = BitmapFrame.Create(RTB); //thread safe and fast af }); } }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); }
public static async Task ExtractFoldersAndSub(string path) { new UpdateMyProcessEvents("", "").Update(); FWindow.FMain.Button_Extract.IsEnabled = false; FWindow.FMain.Button_Stop.IsEnabled = true; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Json.xshd"); FWindow.FMain.ImageBox_Main.Source = null; List <IEnumerable <string> > assetList = new List <IEnumerable <string> >(); if (!string.IsNullOrEmpty(FWindow.FCurrentPAK)) { IEnumerable <string> files = PAKEntries.PAKToDisplay[FWindow.FCurrentPAK] .Where(x => x.Name.StartsWith(path + "/")) .Select(x => x.Name); if (files != null) { assetList.Add(files); } } else { foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values) { IEnumerable <string> files = PAKsFileInfos .Where(x => x.Name.StartsWith(path + "/")) .Select(x => x.Name); if (files != null) { assetList.Add(files); } } } TasksUtility.CancellableTaskTokenSource = new CancellationTokenSource(); CancellationToken cToken = TasksUtility.CancellableTaskTokenSource.Token; await Task.Run(() => { isRunning = true; DebugHelper.WriteLine("Assets: User is extracting everything in " + path); foreach (IEnumerable <string> filesFromOnePak in assetList) { foreach (string asset in filesFromOnePak.OrderBy(s => s)) { cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item string target; if (asset.EndsWith(".uexp") || asset.EndsWith(".ubulk")) { continue; } else if (!asset.EndsWith(".uasset")) { target = asset; //ini uproject locres etc } else { target = asset.Substring(0, asset.LastIndexOf(".")); //uassets } while (!string.Equals(FWindow.FCurrentAsset, Path.GetFileName(target))) { FWindow.FCurrentAsset = Path.GetFileName(target); } LoadAsset(target); } } }, cToken).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); TasksUtility.CancellableTaskTokenSource.Dispose(); isRunning = false; }); FWindow.FMain.Button_Extract.IsEnabled = true; FWindow.FMain.Button_Stop.IsEnabled = false; }
public static async Task ExtractUpdateMode() { new UpdateMyProcessEvents("", "").Update(); FWindow.FMain.Button_Extract.IsEnabled = false; FWindow.FMain.Button_Stop.IsEnabled = true; FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty; FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Json.xshd"); FWindow.FMain.ImageBox_Main.Source = null; bool sound = FProp.Default.FOpenSounds; FProp.Default.FOpenSounds = false; List <IEnumerable <string> > assetList = new List <IEnumerable <string> >(); foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values) { IEnumerable <string> files = PAKsFileInfos .Where(x => Forms.FModel_UpdateMode.AssetsEntriesDict.Any(c => bool.Parse(c.Value["isChecked"]) && x.Name.StartsWith(c.Value["Path"]))) .Select(x => x.Name); if (files != null) { assetList.Add(files); } } TasksUtility.CancellableTaskTokenSource = new CancellationTokenSource(); CancellationToken cToken = TasksUtility.CancellableTaskTokenSource.Token; await Task.Run(() => { isRunning = true; foreach (IEnumerable <string> filesFromOnePak in assetList) { foreach (string asset in filesFromOnePak.OrderBy(s => s)) { cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item string target; if (asset.EndsWith(".uexp") || asset.EndsWith(".ubulk")) { continue; } else if (!asset.EndsWith(".uasset")) { target = asset; //ini uproject locres etc } else { target = asset.Substring(0, asset.LastIndexOf(".")); //uassets } while (!string.Equals(FWindow.FCurrentAsset, Path.GetFileName(target))) { FWindow.FCurrentAsset = Path.GetFileName(target); } try { LoadAsset(target); } catch (System.Exception ex) { new UpdateMyConsole(ex.Message, CColors.Red, true).Append(); } } } }, cToken).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); TasksUtility.CancellableTaskTokenSource.Dispose(); isRunning = false; }); FWindow.FMain.MI_Auto_Save_Images.IsChecked = false; FWindow.FMain.Button_Extract.IsEnabled = true; FWindow.FMain.Button_Stop.IsEnabled = false; FWindow.FMain.MI_Auto_Save_Images.IsChecked = false; FProp.Default.FOpenSounds = sound; new UpdateMyProcessEvents("All assets have been extracted successfully", "Success").Update(); }
private async Task UpdateMergerPreview() { AddImages_Button.IsEnabled = false; RemoveImage_Button.IsEnabled = false; ClearImages_Button.IsEnabled = false; ImagesPerRow_Slider.IsEnabled = false; OpenImage_Button.IsEnabled = false; SaveImage_Button.IsEnabled = false; if ((_imagePath != null && _imagePath.Count > 0) || ImagesListBox.Items.Count > 0) { _imagePath = new List <string>(); for (int i = 0; i < ImagesListBox.Items.Count; ++i) { _imagePath.Add(((ListBoxItem)ImagesListBox.Items[i]).ContentStringFormat); } } int imageCount = _imagePath.Count; int numperrow = Convert.ToInt32(ImagesPerRow_Slider.Value); await Task.Run(() => { DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { //INITIALIZATION drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 515))); var w = 520 * numperrow; if (imageCount * 520 < 520 * numperrow) { w = imageCount * 520; } int h = int.Parse(Math.Ceiling(double.Parse(imageCount.ToString()) / numperrow).ToString(CultureInfo.InvariantCulture)) * 520; int num = 1; int curW = 0; int curH = 0; int maxHeight = 0; for (int i = 0; i < imageCount; i++) { int percentage = (i + 1) * 100 / imageCount; BitmapImage source = new BitmapImage(new Uri(_imagePath[i])); source.DecodePixelWidth = 515; double width = source.Width; double height = source.Height; if (height > maxHeight) { maxHeight = Convert.ToInt32(height); } drawingContext.DrawImage(source, new Rect(new Point(curW, curH), new Size(width, height))); if (num % numperrow == 0) { curW = 0; curH += maxHeight + 5; num += 1; maxHeight = 0; //reset max height for each new row } else { curW += Convert.ToInt32(width) + 5; num += 1; } } } if (drawingVisual != null) { RenderTargetBitmap RTB = new RenderTargetBitmap((int)Math.Floor(drawingVisual.DescendantBounds.Width), (int)Math.Floor(drawingVisual.DescendantBounds.Height), 96, 96, PixelFormats.Pbgra32); RTB.Render(drawingVisual); RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread this.Dispatcher.InvokeAsync(() => { MergerPreview_Image.Source = BitmapFrame.Create(RTB); //thread safe and fast af }); } }).ContinueWith(TheTask => { TasksUtility.TaskCompleted(TheTask.Exception); }); GC.Collect(); GC.WaitForPendingFinalizers(); AddImages_Button.IsEnabled = true; RemoveImage_Button.IsEnabled = true; ClearImages_Button.IsEnabled = true; ImagesPerRow_Slider.IsEnabled = true; OpenImage_Button.IsEnabled = true; SaveImage_Button.IsEnabled = true; }