From 1ad2f8025d81af92ff8db87afb700fdd5edbfb26 Mon Sep 17 00:00:00 2001 From: Fries Date: Sat, 6 May 2023 23:30:24 -0700 Subject: [PATCH] make the weed app yes, a calculator app, in an old .net framework, with the label weed on top of the form. --- .gitignore | 398 +++++++++++++++++++++++ WeedApp.sln | 20 ++ WeedApp/Form1.Designer.cs | 118 +++++++ WeedApp/Form1.cs | 105 ++++++ WeedApp/Form1.resx | 120 +++++++ WeedApp/MathOperators.cs | 10 + WeedApp/MathResult.cs | 22 ++ WeedApp/Program.cs | 20 ++ WeedApp/Properties/AssemblyInfo.cs | 33 ++ WeedApp/Properties/Resources.Designer.cs | 71 ++++ WeedApp/Properties/Resources.resx | 117 +++++++ WeedApp/Properties/Settings.Designer.cs | 30 ++ WeedApp/Properties/Settings.settings | 7 + WeedApp/Utilities.cs | 59 ++++ WeedApp/WeedApp.csproj | 81 +++++ 15 files changed, 1211 insertions(+) create mode 100644 .gitignore create mode 100644 WeedApp.sln create mode 100644 WeedApp/Form1.Designer.cs create mode 100644 WeedApp/Form1.cs create mode 100644 WeedApp/Form1.resx create mode 100644 WeedApp/MathOperators.cs create mode 100644 WeedApp/MathResult.cs create mode 100644 WeedApp/Program.cs create mode 100644 WeedApp/Properties/AssemblyInfo.cs create mode 100644 WeedApp/Properties/Resources.Designer.cs create mode 100644 WeedApp/Properties/Resources.resx create mode 100644 WeedApp/Properties/Settings.Designer.cs create mode 100644 WeedApp/Properties/Settings.settings create mode 100644 WeedApp/Utilities.cs create mode 100644 WeedApp/WeedApp.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a30d25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## 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/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# 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.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.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/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# 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 + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[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 + +# 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 +# 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. +!**/[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 + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.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 ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# 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/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/WeedApp.sln b/WeedApp.sln new file mode 100644 index 0000000..97f5e9b --- /dev/null +++ b/WeedApp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeedApp", "WeedApp\WeedApp.csproj", "{8C69CF03-3F67-47F0-8F27-DFB77AA389D0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8C69CF03-3F67-47F0-8F27-DFB77AA389D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C69CF03-3F67-47F0-8F27-DFB77AA389D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C69CF03-3F67-47F0-8F27-DFB77AA389D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C69CF03-3F67-47F0-8F27-DFB77AA389D0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WeedApp/Form1.Designer.cs b/WeedApp/Form1.Designer.cs new file mode 100644 index 0000000..a66a961 --- /dev/null +++ b/WeedApp/Form1.Designer.cs @@ -0,0 +1,118 @@ +namespace WeedApp +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.operators = new System.Windows.Forms.ComboBox(); + this.firstNumber = new System.Windows.Forms.TextBox(); + this.secondNumber = new System.Windows.Forms.TextBox(); + this.goButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(96, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 37); + this.label1.TabIndex = 0; + this.label1.Text = "Weed"; + this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // operators + // + this.operators.FormattingEnabled = true; + this.operators.Items.AddRange(new object[] { + "Add", + "Subtract", + "Multiply", + "Divide"}); + this.operators.Location = new System.Drawing.Point(85, 75); + this.operators.Name = "operators"; + this.operators.Size = new System.Drawing.Size(121, 21); + this.operators.TabIndex = 1; + this.operators.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // firstNumber + // + this.firstNumber.Location = new System.Drawing.Point(96, 49); + this.firstNumber.Name = "firstNumber"; + this.firstNumber.Size = new System.Drawing.Size(100, 20); + this.firstNumber.TabIndex = 2; + this.firstNumber.TextChanged += new System.EventHandler(this.firstNumber_TextChanged); + // + // secondNumber + // + this.secondNumber.Location = new System.Drawing.Point(96, 102); + this.secondNumber.Name = "secondNumber"; + this.secondNumber.Size = new System.Drawing.Size(100, 20); + this.secondNumber.TabIndex = 3; + this.secondNumber.TextChanged += new System.EventHandler(this.secondNumber_TextChanged); + // + // goButton + // + this.goButton.Enabled = false; + this.goButton.Location = new System.Drawing.Point(96, 128); + this.goButton.Name = "goButton"; + this.goButton.Size = new System.Drawing.Size(100, 23); + this.goButton.TabIndex = 4; + this.goButton.Text = "Go"; + this.goButton.UseVisualStyleBackColor = true; + this.goButton.Click += new System.EventHandler(this.goButton_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 266); + this.Controls.Add(this.goButton); + this.Controls.Add(this.secondNumber); + this.Controls.Add(this.firstNumber); + this.Controls.Add(this.operators); + this.Controls.Add(this.label1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox operators; + private System.Windows.Forms.TextBox firstNumber; + private System.Windows.Forms.TextBox secondNumber; + private System.Windows.Forms.Button goButton; + + } +} + diff --git a/WeedApp/Form1.cs b/WeedApp/Form1.cs new file mode 100644 index 0000000..029f024 --- /dev/null +++ b/WeedApp/Form1.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace WeedApp +{ + public partial class Form1 : Form + { + private MathOperators selectedMathOperator; + + private string firstNumberContents; + private string secondNumberContents; + + private bool firstNumberOnlyNumbers; + private bool secondNumberOnlyNumbers; + + public Form1() + { + InitializeComponent(); + this.operators.SelectedIndex = 0; + this.firstNumber.Select(); + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox box = (ComboBox)sender; + selectedMathOperator = (MathOperators)box.SelectedIndex; + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void firstNumber_TextChanged(object sender, EventArgs e) + { + firstNumberOnlyNumbers = Utilities.SetNumberContent((TextBox)sender, ref firstNumberContents); + CheckIfOnlyNumbers(); + } + + private void secondNumber_TextChanged(object sender, EventArgs e) + { + secondNumberOnlyNumbers = Utilities.SetNumberContent((TextBox)sender, ref secondNumberContents); + CheckIfOnlyNumbers(); + } + + private void goButton_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(firstNumberContents) || string.IsNullOrEmpty(secondNumberContents)) + { + throw new ArgumentException("Please enter a number into a field."); + } + int firstNumber = int.Parse(firstNumberContents); + int secondNumber = int.Parse(secondNumberContents); + MathResult sum = DoMath(firstNumber, secondNumber); + Utilities.SumMessage(this, sum); + } + catch (Exception exception) + { + string argumentType = exception.GetType().ToString(); + string message = exception.Message; + Utilities.ErrorMessage(this, argumentType + ": " + message); + } + } + + private MathResult DoMath(int num1, int num2) + { + switch (selectedMathOperator) + { + case MathOperators.Add: + int sumAdd = num1 + num2; + return new MathResult(selectedMathOperator, num1, num2, sumAdd); + case MathOperators.Subtract: + int sumSubtract = num1 - num2; + return new MathResult(selectedMathOperator, num1, num2, sumSubtract); + case MathOperators.Multiply: + int sumMultiply = num1 * num2; + return new MathResult(selectedMathOperator, num1, num2, sumMultiply); + case MathOperators.Divide: + int sumDivide = num1 / num2; + return new MathResult(selectedMathOperator, num1, num2, sumDivide); + default: + throw new ArgumentOutOfRangeException("Invaid MathOperator"); + } + } + + private void CheckIfOnlyNumbers() + { + if (firstNumberOnlyNumbers && secondNumberOnlyNumbers) + { + goButton.Enabled = true; + } + else + { + goButton.Enabled = false; + } + } + } +} diff --git a/WeedApp/Form1.resx b/WeedApp/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/WeedApp/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WeedApp/MathOperators.cs b/WeedApp/MathOperators.cs new file mode 100644 index 0000000..e8afc53 --- /dev/null +++ b/WeedApp/MathOperators.cs @@ -0,0 +1,10 @@ +namespace WeedApp +{ + public enum MathOperators + { + Add, + Subtract, + Multiply, + Divide + } +} diff --git a/WeedApp/MathResult.cs b/WeedApp/MathResult.cs new file mode 100644 index 0000000..0226e61 --- /dev/null +++ b/WeedApp/MathResult.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WeedApp +{ + internal struct MathResult + { + internal readonly MathOperators MathOperator; + internal readonly int Number1; + internal readonly int Number2; + internal readonly int Sum; + + internal MathResult(MathOperators mathOp, int num1, int num2, int sum) + { + this.MathOperator = mathOp; + this.Number1 = num1; + this.Number2 = num2; + this.Sum = sum; + } + } +} diff --git a/WeedApp/Program.cs b/WeedApp/Program.cs new file mode 100644 index 0000000..02351f8 --- /dev/null +++ b/WeedApp/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WeedApp +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/WeedApp/Properties/AssemblyInfo.cs b/WeedApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6186d49 --- /dev/null +++ b/WeedApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WeedApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WeedApp")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ef0e5172-51cc-4e75-97cd-bfb73d7a8939")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WeedApp/Properties/Resources.Designer.cs b/WeedApp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c47f482 --- /dev/null +++ b/WeedApp/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3053 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WeedApp.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeedApp.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/WeedApp/Properties/Resources.resx b/WeedApp/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/WeedApp/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WeedApp/Properties/Settings.Designer.cs b/WeedApp/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8ec9300 --- /dev/null +++ b/WeedApp/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3053 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WeedApp.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/WeedApp/Properties/Settings.settings b/WeedApp/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/WeedApp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WeedApp/Utilities.cs b/WeedApp/Utilities.cs new file mode 100644 index 0000000..29f7b95 --- /dev/null +++ b/WeedApp/Utilities.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace WeedApp +{ + public abstract class Utilities + { + internal static bool SetNumberContent(TextBox number, ref string content) + { + content = number.Text; + try + { + int.Parse(number.Text); + return true; + } + catch (Exception) + { + return false; + } + } + + internal static void ErrorMessage(IWin32Window owner, string message) + { + MessageBox.Show(owner, message, "An error has occured", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + internal static void SumMessage(IWin32Window owner, MathResult result) + { + string message; + + switch (result.MathOperator) + { + case MathOperators.Add: + message = GenerateSumMessage("+", result); + break; + case MathOperators.Subtract: + message = GenerateSumMessage("-", result); + break; + case MathOperators.Multiply: + message = GenerateSumMessage("*", result); + break; + case MathOperators.Divide: + message = GenerateSumMessage("/", result); + break; + default: + throw new ArgumentOutOfRangeException("Invalid Math Operator"); + } + + MessageBox.Show(owner, message, "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + private static string GenerateSumMessage(string mathOp, MathResult result) + { + return result.Number1 + " " + mathOp + " " + result.Number2 + " = " + result.Sum; + } + } +} diff --git a/WeedApp/WeedApp.csproj b/WeedApp/WeedApp.csproj new file mode 100644 index 0000000..b3740c7 --- /dev/null +++ b/WeedApp/WeedApp.csproj @@ -0,0 +1,81 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8C69CF03-3F67-47F0-8F27-DFB77AA389D0} + WinExe + Properties + WeedApp + WeedApp + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + \ No newline at end of file