From d4c8f5b51fcfb5782a5993f5b55df5cdd72207b9 Mon Sep 17 00:00:00 2001 From: Riley McGee <mcgeer@mcmaster.ca> Date: Sun, 20 Nov 2016 21:06:05 -0500 Subject: [PATCH] Comments added to Form1 --- src/Gifitti/Gifitti/Gifitti.csproj | 28 ++++ .../Gifitti/View_Models/Form1.Designer.cs | 55 +++---- src/Gifitti/Gifitti/View_Models/Form1.cs | 145 +++++++++++------- 3 files changed, 146 insertions(+), 82 deletions(-) diff --git a/src/Gifitti/Gifitti/Gifitti.csproj b/src/Gifitti/Gifitti/Gifitti.csproj index 4a25a11..2d6a12e 100644 --- a/src/Gifitti/Gifitti/Gifitti.csproj +++ b/src/Gifitti/Gifitti/Gifitti.csproj @@ -12,6 +12,21 @@ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> @@ -22,6 +37,7 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Debug\Documentation\Gifitti.XML</DocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> @@ -98,6 +114,18 @@ <ItemGroup> <Folder Include="Transformation\" /> </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> + <Visible>False</Visible> + <ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/src/Gifitti/Gifitti/View_Models/Form1.Designer.cs b/src/Gifitti/Gifitti/View_Models/Form1.Designer.cs index 10ec398..d600768 100644 --- a/src/Gifitti/Gifitti/View_Models/Form1.Designer.cs +++ b/src/Gifitti/Gifitti/View_Models/Form1.Designer.cs @@ -64,10 +64,10 @@ // // gifView // - this.gifView.Location = new System.Drawing.Point(12, 12); + this.gifView.Location = new System.Drawing.Point(14, 15); this.gifView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.gifView.Name = "gifView"; - this.gifView.Size = new System.Drawing.Size(608, 470); + this.gifView.Size = new System.Drawing.Size(684, 588); this.gifView.TabIndex = 2; this.gifView.TabStop = false; // @@ -142,44 +142,44 @@ // this.textBox1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.textBox1.Enabled = false; - this.textBox1.Location = new System.Drawing.Point(285, 567); + this.textBox1.Location = new System.Drawing.Point(321, 709); this.textBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(29, 22); + this.textBox1.Size = new System.Drawing.Size(32, 26); this.textBox1.TabIndex = 3; - this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + this.textBox1.TextChanged += new System.EventHandler(this.StartFrameTextChanged); // // textBox2 // this.textBox2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.textBox2.Enabled = false; - this.textBox2.Location = new System.Drawing.Point(320, 567); + this.textBox2.Location = new System.Drawing.Point(360, 709); this.textBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(29, 22); + this.textBox2.Size = new System.Drawing.Size(32, 26); this.textBox2.TabIndex = 4; - this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); + this.textBox2.TextChanged += new System.EventHandler(this.StopFrameTextChanged); // // button3 // this.button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.button3.Enabled = false; - this.button3.Location = new System.Drawing.Point(355, 564); + this.button3.Location = new System.Drawing.Point(399, 705); this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(67, 30); + this.button3.Size = new System.Drawing.Size(75, 38); this.button3.TabIndex = 5; this.button3.Text = "Stop"; this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.button3_Click); + this.button3.Click += new System.EventHandler(this.StartStopClickEvent); // // label1 // this.label1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(282, 548); + this.label1.Location = new System.Drawing.Point(317, 685); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 17); + this.label1.Size = new System.Drawing.Size(44, 20); this.label1.TabIndex = 6; this.label1.Text = "Start"; // @@ -187,9 +187,9 @@ // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(319, 548); + this.label2.Location = new System.Drawing.Point(359, 685); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(33, 17); + this.label2.Size = new System.Drawing.Size(38, 20); this.label2.TabIndex = 7; this.label2.Text = "End"; // @@ -197,34 +197,35 @@ // this.label3.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(213, 561); + this.label3.Location = new System.Drawing.Point(240, 701); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(66, 34); + this.label3.Size = new System.Drawing.Size(75, 40); this.label3.TabIndex = 8; this.label3.Text = "Frame \r\nSelection"; // // timer1 // this.timer1.Interval = 20; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + this.timer1.Tick += new System.EventHandler(this.AdvanceFrameTimer); // // trackBar1 // this.trackBar1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.trackBar1.Location = new System.Drawing.Point(437, 561); + this.trackBar1.Location = new System.Drawing.Point(492, 701); + this.trackBar1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.trackBar1.Name = "trackBar1"; - this.trackBar1.Size = new System.Drawing.Size(183, 56); + this.trackBar1.Size = new System.Drawing.Size(206, 69); this.trackBar1.TabIndex = 9; this.trackBar1.Value = 10; - this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged); + this.trackBar1.ValueChanged += new System.EventHandler(this.GifFPSSliderUpdate); // // label4 // this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(478, 551); + this.label4.Location = new System.Drawing.Point(538, 689); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(110, 17); + this.label4.Size = new System.Drawing.Size(123, 20); this.label4.TabIndex = 10; this.label4.Text = "Playback Speed"; // @@ -234,17 +235,17 @@ this.label6.AutoSize = true; this.label6.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F); - this.label6.Location = new System.Drawing.Point(87, 560); + this.label6.Location = new System.Drawing.Point(98, 700); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(96, 29); + this.label6.Size = new System.Drawing.Size(109, 32); this.label6.TabIndex = 12; this.label6.Text = "GIFITTI"; // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(632, 577); + this.ClientSize = new System.Drawing.Size(711, 721); this.Controls.Add(this.label6); this.Controls.Add(this.label4); this.Controls.Add(this.trackBar1); diff --git a/src/Gifitti/Gifitti/View_Models/Form1.cs b/src/Gifitti/Gifitti/View_Models/Form1.cs index 1f370ac..feb41d4 100644 --- a/src/Gifitti/Gifitti/View_Models/Form1.cs +++ b/src/Gifitti/Gifitti/View_Models/Form1.cs @@ -14,6 +14,11 @@ using System.Threading; namespace Gifitti.View_Models { + /// <summary> + /// System Controller, binded to Form1 View + /// This File abstracts all control elements away from the view + /// elements stored in the remainder of the partial class + /// </summary> public partial class Form1 : Form { #region Fields @@ -26,6 +31,9 @@ namespace Gifitti.View_Models Image globalGif; #endregion #region Constructors + /// <summary> + /// Returns a new Form1 instance, and initializes the view. + /// </summary> public Form1() { InitializeComponent(); @@ -37,71 +45,35 @@ namespace Gifitti.View_Models } #endregion #region Buttons - private void button1_Click(object sender, EventArgs e) - { - openGifFileDialog.Filter = "GIF Files|*.gif"; - DialogResult result = openGifFileDialog.ShowDialog(); // Show the dialog. - if (result == DialogResult.OK) // Test result. - { - string file = openGifFileDialog.FileName; - try - { - gm = new GifModel(file); - gm.ReverseAtEnd = false; - Image loadedGif = gm.gifImage; - globalGif = loadedGif; - //gifView.Image = loadedGif; - - gifView.Width = loadedGif.Width; - gifView.Height = loadedGif.Height; - ClientSize = new Size(loadedGif.Width + widthBuffer, loadedGif.Height + heightBuffer); - } - - catch (IOException) - { - } - - CenterToScreen(); - - //Focus the gif: - gifView.Select(); - gifView.Focus(); - ActiveControl = gifView; - - //Start Animating - timer1.Enabled = true; - - //Enable frame selection - textBox1.Enabled = true; - textBox2.Enabled = true; - button3.Enabled = true; - - //set the initial frames in textbox - textBox1.Text = "0"; - textBox2.Text = gm.numberOfFrames.ToString(); - } - } - + #endregion #region SystemChecks + /// <summary> + /// Validates that a GIF is loaded and in the model instance. + /// If not instance is loaded a prompt is displayed to the user. + /// </summary> + /// <returns> True iff a gif file is loaded and stored in the model. False else. /returns> private Boolean chkImage() { - Boolean check = true; try { int Length = globalGif.GetFrameCount(FrameDimension.Time); + return true; } catch (Exception e) { - check = false; - MessageBox.Show("Must load a gif before getting output"); + MessageBox.Show("Must load a gif before this option is availiable!"); } - - return (check); + return false; } #endregion #region MenuItems + /// <summary> + /// On event invocation the loaded gif is decomposed into its frames and saved to a specified folder as JPEG images. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuItemExportJPEG(object sender, EventArgs e) { if(chkImage()) @@ -130,6 +102,11 @@ namespace Gifitti.View_Models } + /// <summary> + /// On event invocation the loaded gif is decomposed into its frames and saved to a specified folder as PNG images. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuItemExportPNG(object sender, EventArgs e) { if (chkImage()) @@ -157,6 +134,11 @@ namespace Gifitti.View_Models } } + /// <summary> + /// On event invocation the loaded gif is decomposed into its frames and saved to a specified folder as BMP (Bitmap) images. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuItemExportBMP(object sender, EventArgs e) { if (chkImage()) @@ -184,6 +166,11 @@ namespace Gifitti.View_Models } } + /// <summary> + /// On event invocation the loaded gif is decomposed into its frames and saved to a specified folder as TIFF images. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuItemExportTIFF(object sender, EventArgs e) { if (chkImage()) @@ -210,7 +197,14 @@ namespace Gifitti.View_Models } } } - private void button3_Click(object sender, EventArgs e) + + /// <summary> + /// Controls the start stop behaviour. Execution of this command + /// toggles if the GIF is playing or paused. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> + private void StartStopClickEvent(object sender, EventArgs e) { if (timer1.Enabled == true) { @@ -226,14 +220,24 @@ namespace Gifitti.View_Models } } - private void timer1_Tick(object sender, EventArgs e) + /// <summary> + /// GIF playback controller + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> + private void AdvanceFrameTimer(object sender, EventArgs e) { //get next frame Thread.Sleep(delay); gifView.Image = gm.GetNextFrame(); } - private void textBox1_TextChanged(object sender, EventArgs e) + /// <summary> + /// Static link between the start frame text box and model start frame. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> + private void StartFrameTextChanged(object sender, EventArgs e) { int start = 0; bool pass = int.TryParse(textBox1.Text, out start); @@ -243,7 +247,12 @@ namespace Gifitti.View_Models } } - private void textBox2_TextChanged(object sender, EventArgs e) + /// <summary> + /// Static link between the stop frame text box and model stop frame. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> + private void StopFrameTextChanged(object sender, EventArgs e) { int end = 0; bool pass = int.TryParse(textBox2.Text, out end); @@ -254,6 +263,11 @@ namespace Gifitti.View_Models } + /// <summary> + /// Event controlling the Save File Dialog. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuItemFileSaveAs(object sender, EventArgs e) { if (!chkImage()) @@ -278,12 +292,22 @@ namespace Gifitti.View_Models #endregion #region File Dialogs + /// <summary> + /// Statically binded function executed when openGifDialog has its button "Ok" clicked. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void openGifDialog_FileOk(object sender, CancelEventArgs e) { } #endregion + /// <summary> + /// Launches a file dialog to load a GIF. Users can only select valid files. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void MenuOpenFile(object sender, EventArgs e) { openGifFileDialog.Filter = "GIF Files|*.gif"; @@ -329,13 +353,24 @@ namespace Gifitti.View_Models } } + /// <summary> + /// Loads the Help Menu Form. + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> private void menuOpenHelp(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); } - private void trackBar1_ValueChanged(object sender, EventArgs e) + /// <summary> + /// Static Binding to the GIF Frame rate slider, slecting current frame rate. + /// Delay ranges from 0-100ms + /// </summary> + /// <param name="sender"> Caller of the event. </param> + /// <param name="e"> Event arguments associated with this event. </param> + private void GifFPSSliderUpdate(object sender, EventArgs e) { delay = (10-trackBar1.Value)*10; } -- GitLab