From 880586f21a3db9bfb27e12d9283dccaff60c401b Mon Sep 17 00:00:00 2001 From: GoneUp Date: Sat, 13 Oct 2018 14:11:35 +0200 Subject: [PATCH] Fixed search crash, code cleanup, added status info from search --- .gitignore | 299 ++++++++++++++------- GPK_RePack/Forms/GUI.cs | 27 +- GPK_RePack/Forms/Helper/TextBoxTempShow.cs | 48 ++++ GPK_RePack/GPK_RePack.csproj | 1 + 4 files changed, 272 insertions(+), 103 deletions(-) create mode 100644 GPK_RePack/Forms/Helper/TextBoxTempShow.cs diff --git a/.gitignore b/.gitignore index ecf2875..c15fa47 100644 --- a/.gitignore +++ b/.gitignore @@ -5,69 +5,76 @@ GPK_RePack/bin/ GPK_RePack/obj/ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.suo *.user +*.userosscache *.sln.docstates -# Build results +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs +# Build results [Dd]ebug/ +[Dd]ebugPublic/ [Rr]elease/ +[Rr]eleases/ x64/ +x86/ +bld/ [Bb]in/ [Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -*.log +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -82,22 +89,34 @@ x64/ *.vssscc .builds *.pidb -*.log +*.svclog *.scc -*.Cache + +# Chutzpah Test files +_Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb +*.opendb *.opensdf *.sdf *.cachefile +*.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ # Guidance Automation Toolkit *.gpState @@ -105,6 +124,10 @@ ipch/ # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode # TeamCity is a build add-in _TeamCity* @@ -112,9 +135,25 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + # NCrunch -*.ncrunch* +_NCrunch_* .*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ # Installshield output folder [Ee]xpress/ @@ -133,93 +172,169 @@ DocProject/Help/html publish/ # Publish Web Output -*.Publish.xml +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -packages/ - -# Windows Azure Build Output -csx +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ *.build.csdef -# Windows Store app package directory +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ # Others -sql/ -*.Cache ClientBin/ -[Ss]tyle[Cc]op.* ~$* *~ *.dbmdl -*.[Pp]ublish.xml +*.dbproj.schemaview +*.jfm *.pfx *.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ # RIA/Silverlight projects Generated_Code/ -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files -App_Data/*.mdf -App_Data/*.ldf +*.mdf +*.ldf +*.ndf -############# -## Windows detritus -############# +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser -# Windows image file caches -Thumbs.db -ehthumbs.db +# Microsoft Fakes +FakesAssemblies/ -# Folder config file -Desktop.ini +# GhostDoc plugin setting file +*.GhostDoc.xml -# Recycle Bin used on file shares -$RECYCLE.BIN/ +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ -# Mac crap -.DS_Store +# Visual Studio 6 build log +*.plg -############# -## Python -############# +# Visual Studio 6 workspace options file +*.opt -*.py[cod] +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions -# Installer logs -pip-log.txt +# Paket dependency manager +.paket/paket.exe +paket-files/ -# Unit test / coverage reports -.coverage -.tox +# FAKE - F# Make +.fake/ -#Translations -*.mo +# JetBrains Rider +.idea/ +*.sln.iml -#Mr Developer -.mr.developer.cfg -*.log +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +# Local History for Visual Studio +.localhistory/ diff --git a/GPK_RePack/Forms/GUI.cs b/GPK_RePack/Forms/GUI.cs index 4beb69e..bc6655e 100644 --- a/GPK_RePack/Forms/GUI.cs +++ b/GPK_RePack/Forms/GUI.cs @@ -14,6 +14,7 @@ using System.Windows.Media.Imaging; using System.Xml; using GPK_RePack.Editors; +using GPK_RePack.Forms.Helper; using GPK_RePack.IO; using GPK_RePack.Model; using GPK_RePack.Model.Interfaces; @@ -57,6 +58,7 @@ public GUI() private List searchResultNodes = new List(); private int searchResultIndex = 0; + private TextBoxTempShow tempStatusLabel; private TabPage texturePage; #endregion @@ -65,7 +67,6 @@ public GUI() protected override void OnLoad(EventArgs e) { - base.OnLoad(e); } @@ -103,6 +104,7 @@ private void GUI_Load(object sender, EventArgs e) //Our stuff logger.Info("Startup"); loadedGpkPackages = new List(); + tempStatusLabel = new TextBoxTempShow(lblStatus, this); //audio waveOut = new WaveOut(); @@ -1239,7 +1241,7 @@ private void searchForObjectToolStripMenuItem_Click(object sender, EventArgs e) { string input = Microsoft.VisualBasic.Interaction.InputBox("String to search?", "Search"); - if (input == "") + if (String.IsNullOrEmpty(input)) return; searchResultNodes.Clear(); @@ -1253,7 +1255,7 @@ private void searchForObjectToolStripMenuItem_Click(object sender, EventArgs e) } } - selectSearchResult(); + tryToSelectNextSearchResult(); } IEnumerable Collect(TreeNodeCollection nodes) @@ -1269,22 +1271,25 @@ IEnumerable Collect(TreeNodeCollection nodes) private void nextToolStripMenuItem_Click(object sender, EventArgs e) { - searchResultIndex++; - if (searchResultNodes.Count == 0 || searchResultNodes.Count <= searchResultIndex) + tryToSelectNextSearchResult(); + } + + private void tryToSelectNextSearchResult() + { + if (searchResultNodes.Count == 0 || searchResultIndex >= searchResultNodes.Count) { SystemSounds.Asterisk.Play(); + searchResultIndex = 0; + tempStatusLabel.StartTimer("Ready", String.Format("End reached, searching from start.", searchResultIndex, searchResultNodes.Count), 2000); return; } - - selectSearchResult(); - } - - private void selectSearchResult() - { treeMain.SelectedNode = searchResultNodes[searchResultIndex]; treeMain_AfterSelect(this, new TreeViewEventArgs(searchResultNodes[searchResultIndex])); + tempStatusLabel.StartTimer("Ready", String.Format("Result {0}/{1}", searchResultIndex + 1, searchResultNodes.Count), 2000); + + searchResultIndex++; } #endregion //search diff --git a/GPK_RePack/Forms/Helper/TextBoxTempShow.cs b/GPK_RePack/Forms/Helper/TextBoxTempShow.cs new file mode 100644 index 0000000..4358af9 --- /dev/null +++ b/GPK_RePack/Forms/Helper/TextBoxTempShow.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + + +namespace GPK_RePack.Forms.Helper +{ + class TextBoxTempShow + { + private readonly ToolStripItem box; + private readonly Form mainForm; + private readonly Timer changeTimer; + private string defaultString; + + public TextBoxTempShow(ToolStripItem box, Form mainForm) + { + this.box = box; + this.mainForm = mainForm; + + changeTimer = new Timer(); + changeTimer.Tick += Timer_Tick; + } + + public void StartTimer(String defaultString, String changeString, int timeToShowInMs) + { + changeTimer.Stop(); + + this.defaultString = defaultString; + mainForm.Invoke(new Action(() => + box.Text = changeString + )); + + changeTimer.Interval = timeToShowInMs; + changeTimer.Start(); + } + + + private void Timer_Tick(object sender, EventArgs e) + { + changeTimer.Stop(); + mainForm.Invoke(new Action(() => + box.Text = defaultString + )); + } + } +} diff --git a/GPK_RePack/GPK_RePack.csproj b/GPK_RePack/GPK_RePack.csproj index 3f217ba..9429046 100644 --- a/GPK_RePack/GPK_RePack.csproj +++ b/GPK_RePack/GPK_RePack.csproj @@ -118,6 +118,7 @@ +