Skip to content

Commit

Permalink
Final v2.2.0 push with code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dahall committed Oct 25, 2019
1 parent 372619d commit 186cfd6
Show file tree
Hide file tree
Showing 13 changed files with 668 additions and 761 deletions.
31 changes: 9 additions & 22 deletions TestTimeSpan2/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Resources;
Expand Down Expand Up @@ -36,9 +35,7 @@ private static IEnumerable<CultureInfo> GetAsmCultures(Type type)
yield return culture;
}

/// <summary>
/// The main entry point for the application.
/// </summary>
/// <summary>The main entry point for the application.</summary>
[STAThread]
private static void Main()
{
Expand Down Expand Up @@ -68,8 +65,7 @@ private void button1_Click(object sender, EventArgs e)
{
try
{
TimeSpan2 ts;
if (TimeSpan2.TryParse(parseText.Text, out ts))
if (TimeSpan2.TryParse(parseText.Text, out var ts))
{
parseLabel.Text = ts.ToString(formatTextBox.Text, formatInfo);
timeSpanPicker.Value = ts;
Expand All @@ -83,8 +79,8 @@ private void button1_Click(object sender, EventArgs e)

private void dayUpDn_ValueChanged(object sender, EventArgs e)
{
var ts = new TimeSpan2((int) dayUpDn.Value, (int) hrUpDn.Value, (int) minUpDn.Value,
(int) secUpDn.Value, (int) msUpDn.Value);
var ts = new TimeSpan2((int)dayUpDn.Value, (int)hrUpDn.Value, (int)minUpDn.Value,
(int)secUpDn.Value, (int)msUpDn.Value);
try
{
outputLabel.Text = ts.ToString(formatTextBox.Text, formatInfo);
Expand All @@ -100,27 +96,18 @@ private void langCombo_SelectedIndexChanged(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = langCombo.SelectedItem as CultureInfo;
formatInfo = TimeSpan2FormatInfo.CurrentInfo;
((TimeSpan2FormatInfo) formatInfo).TimeSpanZeroDisplay = timeSpanPicker.FormattedZero;
((TimeSpan2FormatInfo)formatInfo).TimeSpanZeroDisplay = timeSpanPicker.FormattedZero;
dayUpDn_ValueChanged(dayUpDn, EventArgs.Empty);
timeSpanPicker_ValueChanged(timeSpanPicker, EventArgs.Empty);
//timeSpanPicker.FormatInfo = (System.Globalization.TimeSpan2FormatInfo)formatInfo;
parseText.Clear();
parseLabel.Text = string.Empty;
}

private void outputLabel_DoubleClick(object sender, EventArgs e)
{
Clipboard.SetText(outputLabel.Text, TextDataFormat.Text);
}
private void outputLabel_DoubleClick(object sender, EventArgs e) => Clipboard.SetText(outputLabel.Text, TextDataFormat.Text);

private void parseLabel_Click(object sender, EventArgs e)
{
Clipboard.SetText(parseLabel.Text, TextDataFormat.Text);
}
private void parseLabel_Click(object sender, EventArgs e) => Clipboard.SetText(parseLabel.Text, TextDataFormat.Text);

private void timeSpanPicker_ValueChanged(object sender, EventArgs e)
{
pickerValueLabel.Text = timeSpanPicker.Value.ToString(formatTextBox.Text, formatInfo);
}
private void timeSpanPicker_ValueChanged(object sender, EventArgs e) => pickerValueLabel.Text = timeSpanPicker.Value.ToString(formatTextBox.Text, formatInfo);
}
}
}
24 changes: 8 additions & 16 deletions TestTimeSpan2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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.
// 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("TestTimeSpan2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -14,23 +12,17 @@
[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.
// 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("403b34b0-7e66-4479-90a0-5019982b3ea7")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
// Major Version Minor Version Build Number Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// You can specify all the values or you can default the Build and Revision Numbers by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
2 changes: 1 addition & 1 deletion TestTimeSpan2/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration>
21 changes: 7 additions & 14 deletions TimeSpan2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using System.Resources;
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.
// 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("TimeSpan2")]
[assembly: AssemblyDescription("Library to extend the functionality of the TimeSpan structure to be comparable, serializable, and convertible.")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -14,24 +13,18 @@
[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.
// 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("ec238e85-542e-4557-b3d3-1d5cd659f9b9")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
// Major Version Minor Version Build Number Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
// You can specify all the values or you can default the Build and Revision Numbers by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: NeutralResourcesLanguage("en")]
49 changes: 24 additions & 25 deletions TimeSpan2/StringCollectionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ public ExposedStringCollectionEditor(Type type)
{
}

protected virtual string InstructionText => null;
protected virtual string FormTitle => null;
protected virtual string InstructionText => null;

protected override CollectionForm CreateCollectionForm() => new StringCollectionForm(this);

// Nested Types
private class StringCollectionForm : CollectionForm
{
private readonly ExposedStringCollectionEditor editor;

// Fields
private Button cancelButton;
private readonly ExposedStringCollectionEditor editor;

private Label instruction;
private Button okButton;
private TableLayoutPanel okCancelTableLayoutPanel;
Expand All @@ -36,6 +38,25 @@ public StringCollectionForm(CollectionEditor editor)
HookEvents();
}

protected override void OnEditValueChanged()
{
var items = Items;
var str = string.Empty;
for (var i = 0; i < items.Length; i++)
{
var s = items[i] as string;
if (s != null)
{
str = str + s;
if (i != items.Length - 1)
{
str = str + "\r\n";
}
}
}
textEntry.Text = str;
}

private void Edit1_keyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
Expand All @@ -45,10 +66,7 @@ private void Edit1_keyDown(object sender, KeyEventArgs e)
}
}

private void Form_HelpRequested(object sender, HelpEventArgs e)
{
editor.ShowHelp();
}
private void Form_HelpRequested(object sender, HelpEventArgs e) => editor.ShowHelp();

private void HookEvents()
{
Expand Down Expand Up @@ -158,25 +176,6 @@ private void OKButton_click(object sender, EventArgs e)
}
}

protected override void OnEditValueChanged()
{
var items = Items;
var str = string.Empty;
for (var i = 0; i < items.Length; i++)
{
var s = items[i] as string;
if (s != null)
{
str = str + s;
if (i != items.Length - 1)
{
str = str + "\r\n";
}
}
}
textEntry.Text = str;
}

private void StringCollectionEditor_HelpButtonClicked(object sender, CancelEventArgs e)
{
e.Cancel = true;
Expand Down
Loading

0 comments on commit 186cfd6

Please sign in to comment.