From 04f7a91416a23bd68bb23719c6b67f58c996ea80 Mon Sep 17 00:00:00 2001 From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Sun, 1 Dec 2019 19:41:55 +0100 Subject: [PATCH] Stuffs --- .gitignore | 212 +++++++++++++++++++++++++++++++-- GradeCalc.sln | 8 ++ GradeCalc/GradeCalc.csproj | 14 ++- GradeCalc/MainForm.Designer.cs | 4 +- GradeCalc/MainForm.cs | 19 ++- GradeCalc/app.manifest | 28 +++++ PostBuild.cs | 38 ++++++ README.md | 2 + 8 files changed, 309 insertions(+), 16 deletions(-) create mode 100644 GradeCalc/app.manifest create mode 100644 PostBuild.cs create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 4ce6fdd..490ca3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ + +# Created by https://www.gitignore.io/api/csharp,windows,visualstudio +# Edit at https://www.gitignore.io/?templates=csharp,windows,visualstudio + +### Csharp ### ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## @@ -13,6 +18,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -39,9 +47,10 @@ Generated\ Files/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUNIT +# NUnit *.VisualState.xml TestResult.xml +nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ @@ -182,6 +191,8 @@ PublishScripts/ # NuGet Packages *.nupkg +# NuGet Symbol Packages +*.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. @@ -206,6 +217,8 @@ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx +*.appxbundle +*.appxupload # Visual Studio cache files # files ending in .cache can be ignored @@ -255,7 +268,9 @@ ServiceFabricBackup/ *.bim.layout *.bim_*.settings *.rptproj.rsuser -*- Backup*.rdl +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -291,10 +306,6 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/ -*.sln.iml - # CodeRush personal settings .cr/personal @@ -337,4 +348,191 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### VisualStudio ### + +# User-specific files + +# User-specific files (MonoDevelop/Xamarin Studio) + +# Mono auto generated files + +# Build results + +# Visual Studio 2015/2017 cache/options directory +# Uncomment if you have tasks that create the project's static files in wwwroot + +# Visual Studio 2017 auto generated files + +# MSTest test Results + +# NUnit + +# Build Results of an ATL Project + +# Benchmark Results + +# .NET Core + +# StyleCop + +# Files built by Visual Studio + +# Chutzpah Test files + +# Visual C++ cache files + +# Visual Studio profiler + +# Visual Studio Trace Files + +# TFS 2012 Local Workspace + +# Guidance Automation Toolkit + +# ReSharper is a .NET coding add-in + +# JustCode is a .NET coding add-in + +# TeamCity is a build add-in + +# DotCover is a Code Coverage Tool + +# AxoCover is a Code Coverage Tool + +# Visual Studio code coverage results + +# NCrunch + +# MightyMoose + +# Web workbench (sass) + +# Installshield output folder + +# DocProject is a documentation generator add-in + +# Click-Once directory + +# Publish Web Output +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted + +# 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 + +# NuGet Packages +# NuGet Symbol Packages +# The packages folder can be ignored because of Package Restore +# except build/, which is used as an MSBuild target. +# Uncomment if necessary however generally it will be regenerated when needed +# NuGet v3's project.json files produces more ignorable files + +# Microsoft Azure Build Output + +# Microsoft Azure Emulator + +# Windows Store app package directories and files + +# Visual Studio cache files +# files ending in .cache can be ignored +# but keep track of directories ending in .cache + +# Others + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) + +# RIA/Silverlight projects + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) + +# SQL Server files + +# Business Intelligence projects + +# Microsoft Fakes + +# GhostDoc plugin setting file + +# Node.js Tools for Visual Studio + +# Visual Studio 6 build log + +# Visual Studio 6 workspace options file + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) + +# Visual Studio LightSwitch build output + +# Paket dependency manager + +# FAKE - F# Make + +# CodeRush personal settings + +# Python Tools for Visual Studio (PTVS) + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio + +# Telerik's JustMock configuration file + +# BizTalk build output + +# OpenCover UI analysis results + +# Azure Stream Analytics local run output + +# MSBuild Binary and Structured Log + +# NVidia Nsight GPU debugger configuration file + +# MFractors (Xamarin productivity tool) working folder + +# Local History for Visual Studio + +# BeatPulse healthcheck temp database + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 + +# End of https://www.gitignore.io/api/csharp,windows,visualstudio diff --git a/GradeCalc.sln b/GradeCalc.sln index 17406cd..53afbec 100644 --- a/GradeCalc.sln +++ b/GradeCalc.sln @@ -5,6 +5,14 @@ VisualStudioVersion = 16.0.29519.87 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GradeCalc", "GradeCalc\GradeCalc.csproj", "{D5948BBB-1F03-497A-A2BA-DD1E6F54A2A8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D467D391-1707-4626-A85A-A4D195DF72AA}" + ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes + .gitignore = .gitignore + PostBuild.cs = PostBuild.cs + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/GradeCalc/GradeCalc.csproj b/GradeCalc/GradeCalc.csproj index e4ff1f2..a1d7e52 100644 --- a/GradeCalc/GradeCalc.csproj +++ b/GradeCalc/GradeCalc.csproj @@ -29,13 +29,16 @@ AnyCPU - pdbonly + none true bin\Release\ TRACE prompt 4 + + app.manifest + ..\packages\Antlr4.Runtime.4.6.4\lib\net45\Antlr4.Runtime.dll @@ -83,6 +86,7 @@ Resources.resx True + SettingsSingleFileGenerator @@ -106,4 +110,12 @@ + + cd "$(SolutionDir)" +if $(ConfigurationName)==Release ( +C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe PostBuild.cs /r:System.IO.Compression.FileSystem.dll +PostBuild "$(TargetDir)\" "$(TargetFileName)" +del PostBuild.exe +) + \ No newline at end of file diff --git a/GradeCalc/MainForm.Designer.cs b/GradeCalc/MainForm.Designer.cs index 1dd79ef..08a31a8 100644 --- a/GradeCalc/MainForm.Designer.cs +++ b/GradeCalc/MainForm.Designer.cs @@ -79,12 +79,12 @@ | System.Windows.Forms.AnchorStyles.Right))); this.algorithmBox.FormattingEnabled = true; this.algorithmBox.Items.AddRange(new object[] { - "totalScore / maxScore"}); + "score / maxScore"}); this.algorithmBox.Location = new System.Drawing.Point(357, 8); this.algorithmBox.Name = "algorithmBox"; this.algorithmBox.Size = new System.Drawing.Size(180, 21); this.algorithmBox.TabIndex = 3; - this.algorithmBox.Text = "totalScore / maxScore"; + this.algorithmBox.Text = "score / maxScore"; // // tasksNum // diff --git a/GradeCalc/MainForm.cs b/GradeCalc/MainForm.cs index 3c2b19b..b1f5e90 100644 --- a/GradeCalc/MainForm.cs +++ b/GradeCalc/MainForm.cs @@ -43,12 +43,19 @@ namespace GradeCalc totalScore += decimal.Parse((string)cell.FormattedValue); } }); - Expression ex = new Expression(algorithmBox.Text); - ex.Parameters["score"] = (double)totalScore; - ex.Parameters["maxScore"] = (double)maxScore; - //double gradeVal = (double)totalScore / (double)maxScore; - double grade = 6 - (NCalcDoubleParser.Parse(ex.Evaluate()) * 5); - ((DataGridViewTextBoxCell)row.Cells[gradeColumn.Name]).Value = (grade.ToString().Length > 13 ? grade.ToString().Remove(13) : grade.ToString()) + " " + texGrade(grade); + try + { + Expression ex = new Expression(algorithmBox.Text); + ex.Parameters["score"] = (double)totalScore; + ex.Parameters["maxScore"] = (double)maxScore; + //double gradeVal = (double)totalScore / (double)maxScore; + double grade = 6 - (NCalcDoubleParser.Parse(ex.Evaluate()) * 5); + ((DataGridViewTextBoxCell)row.Cells[gradeColumn.Name]).Value = (grade.ToString().Length > 13 ? grade.ToString().Remove(13) : grade.ToString()) + " " + texGrade(grade); + } + catch (Exception e1) + { + ((DataGridViewTextBoxCell)row.Cells[gradeColumn.Name]).Value = e1.Message; + } } dataGridView.Sort(nameColumn, ListSortDirection.Ascending); } diff --git a/GradeCalc/app.manifest b/GradeCalc/app.manifest new file mode 100644 index 0000000..ab36f16 --- /dev/null +++ b/GradeCalc/app.manifest @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/PostBuild.cs b/PostBuild.cs new file mode 100644 index 0000000..35d4d6f --- /dev/null +++ b/PostBuild.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; + +public class Program +{ + public static void Main(string[] args) + { + //Variables + string TargetDir = args[0].Trim('"').TrimEnd('\\'); + string TargetFileName = args[1].Trim('"'); + //Copy Data dir + if (File.Exists(TargetDir + ".zip")) + File.Delete(TargetDir + ".zip"); + if (File.Exists(TargetDir + @"\package.zip")) + File.Delete(TargetDir + @"\package.zip"); + if (Directory.Exists(TargetDir + @"\package")) + Directory.Delete(TargetDir + @"\package", true); + ZipFile.CreateFromDirectory(TargetDir, TargetDir + ".zip"); + Directory.CreateDirectory(TargetDir + @"\package\Data"); + ZipFile.ExtractToDirectory(TargetDir + ".zip", TargetDir + @"\package\Data"); + File.Delete(TargetDir + ".zip"); + //Remove useless Files + Directory.GetFiles(TargetDir + @"\package\Data") + .Where(s => new string[] { ".xml", ".pdb" }.Contains(Path.GetExtension(s))) + .ToList().ForEach(s => File.Delete(s)); + //Add package scripts + string programName = Path.GetFileNameWithoutExtension(TargetFileName); + File.WriteAllText(TargetDir + @"\package\Install.bat", + "@echo off\r\necho INSTALL\r\npowershell \"$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\" + programName + ".lnk');$s.TargetPath='%cd%\\" + programName + ".exe';$s.Save()\"\r\ntimeout /t 1"); + File.WriteAllText(TargetDir + @"\package\Remove.bat", + "@echo off\r\necho REMOVE\r\ndel \"%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\" + programName + ".lnk\"\r\ntaskkill /f /im \"" + programName + ".exe\"\r\ntimeout /t 1"); + //Package up result + ZipFile.CreateFromDirectory(TargetDir + @"\package", TargetDir + @"\package.zip"); + Directory.Delete(TargetDir + @"\package", true); + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..46f6fe6 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# UpTool2-Forms-Template +Windows Forms template with extras