Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a "Give Feedback" dialog box #192

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/HearThis/HearThis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HearThis</RootNamespace>
<AssemblyName>HearThis</AssemblyName>
<TargetFramework>NET472</TargetFramework>
<TargetFramework>net472</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<FileAlignment>512</FileAlignment>
<ApplicationIcon>UI\HearThis.ico</ApplicationIcon>
Expand Down Expand Up @@ -196,6 +196,9 @@
<Compile Update="UI\ScriptTextHasChangedControl.cs" />
<Compile Update="UI\ExclamationIcon.cs" />
<Compile Update="UI\DataMigrationReportNagDlg.cs" />
<Compile Update="UI\GiveFeedbackDlg.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
Expand All @@ -208,13 +211,6 @@
<_Parameter1>HearThisTests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
501 changes: 501 additions & 0 deletions src/HearThis/UI/GiveFeedbackDlg.Designer.cs

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions src/HearThis/UI/GiveFeedbackDlg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// --------------------------------------------------------------------------------------------
#region // Copyright (c) 2021, SIL International. All Rights Reserved.
// <copyright from='2021' to='2021' company='SIL International'>
// Copyright (c) 2021, SIL International. All Rights Reserved.
//
// Distributable under the terms of the MIT License (https://sil.mit-license.org/)
// </copyright>
#endregion
// --------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using L10NSharp;

namespace HearThis.UI
{
/// <summary>
/// This allows users a way to report a bug or give other feedback regarding HearThis.
/// </summary>
public partial class GiveFeedbackDlg : Form, ILocalizable
{
public enum TypeOfFeedback
{
Problem = 0,
Suggestion = 1,
Gratitude = 2,
Donate = 3,
}

public enum PriorityOrSeverity
{
LostData = 0,
NotAbleToCompleteTask = 1,
CompletedTaskWithDifficulty = 2,
Minor = 3,
NotApplicable,
}

public enum AffectedArea
{
NotApplicable, // Not available for some types of Feedback
Exporting,
Installation,
Localization,
MultipleAreas,
Navigation,
Other,
Playback,
ProjectAdministration,
ProjectSelection,
Recording,
Settings,
Website,
Unknown,
}

public GiveFeedbackDlg()
{
InitializeComponent();
_linkCommunityHelp.Links[0].LinkData = new Action(() => Process.Start($"https://{Program.kSupportUrlSansHttps}"));
_linkDonate.Links[0].LinkData = new Action(OpenDonationPage);

Program.RegisterLocalizable(this);
HandleStringsLocalized();
}

#region Properties
public string Title => _txtTitle.Text;

public TypeOfFeedback FeedbackType => (TypeOfFeedback)_cboTypeOfFeedback.SelectedIndex;

public PriorityOrSeverity Priority => PriorityIsRelevant ?
(PriorityOrSeverity)_cboPriority.SelectedIndex : PriorityOrSeverity.NotApplicable;

public string Description => _richTextBoxDescription.Text;

public AffectedArea AffectedPartOfProgram => (AffectedArea)
(_cboAffects.SelectedIndex + (FeedbackType == TypeOfFeedback.Gratitude ? 0 : 1));

private bool PriorityIsRelevant
{
get => _cboPriority.Visible;
set => _cboPriority.Visible = _lblPriorityOrSeverity.Visible = value;
}
#endregion

#region Evemnt handlers
public void HandleStringsLocalized()
{
_lblPriorityOrSeverity.Tag = _lblPriorityOrSeverity.Text;
_cboPriority.Tag = new List<string>(from object item in _cboPriority.Items select item.ToString());
_cboAffects.Tag = _cboAffects.Items[0].ToString();
_linkCommunityHelp.SetLinkRegions();
_linkDonate.SetLinkRegions();
}

private void LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
((Action)e.Link.LinkData).Invoke();
}

private void UpdateOkButtonState(object sender, EventArgs e)
{

}

private void _cboTypeOfFeedback_SelectedIndexChanged(object sender, EventArgs e)
{
_cboPriority.Items.Clear();
if (!(_cboPriority.Tag is List<string> severityList) || severityList.Count != 4)
throw new ApplicationException("_cboPriority.Tag not set properly in HandleStringsLocalized");
if (!(_cboAffects.Tag is string notApplicableItem))
throw new ApplicationException("_cboAffects.Tag not set properly in HandleStringsLocalized");

switch (FeedbackType)
{
case TypeOfFeedback.Problem:
_lblPriorityOrSeverity.Text = _lblPriorityOrSeverity.Tag as string;
PriorityIsRelevant = true;
RemoveNotApplicableItemFromAffectsCombo();
foreach (var item in severityList)
_cboPriority.Items.Add(item);
break;

case TypeOfFeedback.Suggestion:
_lblPriorityOrSeverity.Text = LocalizationManager.GetString("GiveFeedbackDlg._lblPriorityOrSeverity.SuggestionText",
"Priority");
PriorityIsRelevant = true;
RemoveNotApplicableItemFromAffectsCombo();
_cboPriority.Items.Add(severityList[(int)PriorityOrSeverity.NotAbleToCompleteTask]);
_cboPriority.Items.Add(severityList[(int)PriorityOrSeverity.CompletedTaskWithDifficulty]);
_cboPriority.Items.Add(LocalizationManager.GetString("GiveFeedbackDlg._cboPriority.MinorEnhancement",
"Idea for a minor enhancement"));
break;

case TypeOfFeedback.Gratitude:
if (_cboAffects.Items.Count == (int)AffectedArea.Unknown)
_cboAffects.Items.Insert(0, notApplicableItem);
PriorityIsRelevant = false;
break;

case TypeOfFeedback.Donate:
PriorityIsRelevant = false;
_lblDescription.Visible = false;
_richTextBoxDescription.Visible = false;
_lblAffects.Visible = false;
_cboAffects.Visible = false;
_lblProject.Visible = false;
_cboProjectOrWebsite.Visible = false;
_linkDonate.Visible = true;
return;
default:
throw new IndexOutOfRangeException("Unexpected type of feedback.");
}
}

private void _btnOk_Click(object sender, EventArgs e)
{
if (FeedbackType == TypeOfFeedback.Donate)
{
if (MessageBox.Show("Visit donation page now?", ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
OpenDonationPage();
}
}
#endregion

#region private helper methods
private void RemoveNotApplicableItemFromAffectsCombo()
{
if (_cboAffects.Items.Count > (int)AffectedArea.Unknown)
_cboAffects.Items.RemoveAt(0);
}

private void OpenDonationPage()
{
Process.Start("https://donate.givedirect.org/?cid=13536&n=289");
DialogResult = DialogResult.Cancel;
Close();
}
#endregion
}
}
126 changes: 126 additions & 0 deletions src/HearThis/UI/GiveFeedbackDlg.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="l10NSharpExtender1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="_lblInstructions.Text" xml:space="preserve">
<value>Use this form to give feedback to the {0} development team about the program. You can use it to report a problem you have encountered or to make a suggestion for an improvement. In addition to the description that you provide, the report will automatically include details about the version of {0}.</value>
</data>
</root>
Loading