Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Created CommonExtensions project. Moved files around

  • Loading branch information...
commit 0109e71a56ed3ac596bd5ce528067a9f4e4c7996 1 parent ae886bd
@benrhughes authored
View
30 Client/Client.csproj
@@ -74,26 +74,27 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
- <ApplicationDefinition Include="App.xaml">
+ <ApplicationDefinition Include="Controls\App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Compile Include="ExceptionExtensions.cs" />
<Compile Include="SortType.cs" />
<Compile Include="UpdateChecker.cs" />
<Compile Include="MainWindowViewModel.cs" />
- <Compile Include="PostponeDialog.xaml.cs">
+ <Compile Include="Controls\PostponeDialog.xaml.cs">
<DependentUpon>PostponeDialog.xaml</DependentUpon>
</Compile>
- <Compile Include="FilterDialog.xaml.cs">
+ <Compile Include="Controls\FilterDialog.xaml.cs">
<DependentUpon>FilterDialog.xaml</DependentUpon>
</Compile>
- <Compile Include="Help.xaml.cs">
+ <Compile Include="Controls\Help.xaml.cs">
<DependentUpon>Help.xaml</DependentUpon>
</Compile>
<Compile Include="HotKey.cs" />
<Compile Include="HotKeyMainWindows.cs" />
<Compile Include="ObserverChangeFile.cs" />
- <Compile Include="Options.xaml.cs">
+ <Compile Include="Controls\Options.xaml.cs">
<DependentUpon>Options.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\SharedAssemblyInfo.cs" />
@@ -110,33 +111,32 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>User.settings</DependentUpon>
</Compile>
- <Compile Include="Utilities.cs" />
<Compile Include="WindowLocation.cs" />
- <Page Include="PostponeDialog.xaml">
+ <Page Include="Controls\PostponeDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="FilterDialog.xaml">
+ <Page Include="Controls\FilterDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="Help.xaml">
+ <Page Include="Controls\Help.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="MainWindow.xaml">
+ <Page Include="Controls\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Compile Include="App.xaml.cs">
+ <Compile Include="Controls\App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
- <Compile Include="MainWindow.xaml.cs">
+ <Compile Include="Controls\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
- <Page Include="Options.xaml">
+ <Page Include="Controls\Options.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -157,6 +157,10 @@
<Project>{C51DEEDA-B581-401B-870B-DBB7D10119BF}</Project>
<Name>ColorFont</Name>
</ProjectReference>
+ <ProjectReference Include="..\CommonExtensions\CommonExtensions.csproj">
+ <Project>{5CE19CC1-833A-4950-B86E-CBF59FA00D6F}</Project>
+ <Name>CommonExtensions</Name>
+ </ProjectReference>
<ProjectReference Include="..\ToDoLib\ToDoLib.csproj">
<Project>{07AA9CEA-4EF0-4B47-AFBD-6F74AD9C4653}</Project>
<Name>ToDoLib</Name>
View
0  Client/App.xaml → Client/Controls/App.xaml
File renamed without changes
View
0  Client/App.xaml.cs → Client/Controls/App.xaml.cs
File renamed without changes
View
0  Client/FilterDialog.xaml → Client/Controls/FilterDialog.xaml
File renamed without changes
View
0  Client/FilterDialog.xaml.cs → Client/Controls/FilterDialog.xaml.cs
File renamed without changes
View
0  Client/Help.xaml → Client/Controls/Help.xaml
File renamed without changes
View
0  Client/Help.xaml.cs → Client/Controls/Help.xaml.cs
File renamed without changes
View
0  Client/MainWindow.xaml → Client/Controls/MainWindow.xaml
File renamed without changes
View
6 Client/MainWindow.xaml.cs → Client/Controls/MainWindow.xaml.cs
@@ -41,7 +41,7 @@ public MainWindow()
{
Application.Current.DispatcherUnhandledException += (o, e) =>
{
- HandleException("An unexpected error occurred", e.Exception);
+ Helper.HandleException("An unexpected error occurred", e.Exception);
e.Handled = true;
};
@@ -450,7 +450,7 @@ private void lbTasks_PreviewKeyUp(object sender, KeyEventArgs e)
ViewModel.KeyboardShortcut(e.Key, e.KeyboardDevice.Modifiers);
}
- //this is just for j and k - the nav keys. Using KeyDown allows for holding the key to navigate
+ // Using KeyDown allows for holding the key to navigate
private void lbTasks_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt) && lbTasks.HasItems)
@@ -513,7 +513,7 @@ private void lbTasks_PreviewKeyDown(object sender, KeyEventArgs e)
private void lbTasks_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
- KeyboardShortcut(Key.U);
+ ViewModel.KeyboardShortcut(Key.U);
}
#endregion
View
0  Client/Options.xaml → Client/Controls/Options.xaml
File renamed without changes
View
0  Client/Options.xaml.cs → Client/Controls/Options.xaml.cs
File renamed without changes
View
0  Client/postponedialog.xaml → Client/Controls/postponedialog.xaml
File renamed without changes
View
0  Client/postponedialog.xaml.cs → Client/Controls/postponedialog.xaml.cs
File renamed without changes
View
16 Client/Utilities.cs → Client/ExceptionExtensions.cs
@@ -7,21 +7,9 @@
namespace Client
{
- public class Utilities
+ public static class ExceptionExtensions
{
- public void Try(Action action, string errorMessage)
- {
- try
- {
- action();
- }
- catch (Exception ex)
- {
- HandleException(errorMessage, ex);
- }
- }
-
- public void HandleException(string errorMessage, Exception ex)
+ public static void Handle(this Exception ex, string errorMessage)
{
Log.Error(errorMessage, ex);
MessageBox.Show(errorMessage + Environment.NewLine + ex.Message + Environment.NewLine + "Please see Help -> Show Error Log for more details",
View
34 Client/MainWindowViewModel.cs
@@ -8,6 +8,7 @@
using System.Windows.Input;
using System.IO;
using ColorFont;
+using CommonExtensions;
namespace Client
{
@@ -31,7 +32,7 @@ public MainWindowViewModel(MainWindow window)
UpdateDisplayedTasks();
}
- public SortType SortType
+ public SortType SortType
{
get { return _sortType; }
set
@@ -60,7 +61,7 @@ public void LoadTasks(string filePath)
}
catch (Exception ex)
{
- HandleException("An error occurred while opening " + filePath, ex);
+ ex.Handle("An error occurred while opening " + filePath);
}
}
@@ -172,7 +173,15 @@ public void KeyboardShortcut(Key key, ModifierKeys modifierKeys = ModifierKeys.N
if (res == MessageBoxResult.Yes)
{
- Try(() => _taskList.Delete((Task)_window.lbTasks.SelectedItem), "Error deleting task");
+ try
+ {
+ _taskList.Delete((Task)_window.lbTasks.SelectedItem);
+ }
+ catch (Exception ex)
+ {
+ ex.Handle("Error deleting task");
+ }
+
UpdateDisplayedTasks();
}
}
@@ -245,7 +254,7 @@ public void UpdateDisplayedTasks()
}
catch (Exception ex)
{
- HandleException("Error while sorting tasks", ex);
+ ex.Handle("Error while sorting tasks");
}
if (selected == null)
@@ -288,7 +297,14 @@ private void Refresh()
private void Reload()
{
- Try(() => _taskList.ReloadTasks(), "Error loading tasks");
+ try
+ {
+ _taskList.ReloadTasks();
+ }
+ catch (Exception ex)
+ {
+ ex.Handle("Error loading tasks");
+ }
}
public void ShowFilterDialog()
@@ -300,7 +316,7 @@ public void ShowFilterDialog()
f.FilterTextPreset1 = User.Default.FilterTextPreset1;
f.FilterTextPreset2 = User.Default.FilterTextPreset2;
f.FilterTextPreset3 = User.Default.FilterTextPreset3;
-
+
if (f.ShowDialog().Value)
{
User.Default.FilterText = f.FilterText.Trim();
@@ -317,7 +333,7 @@ public static IEnumerable<Task> FilterList(IEnumerable<Task> tasks)
{
var filters = User.Default.FilterText;
var comparer = User.Default.FilterCaseSensitive ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase;
-
+
if (String.IsNullOrEmpty(filters))
return tasks;
@@ -334,7 +350,7 @@ public static IEnumerable<Task> FilterList(IEnumerable<Task> tasks)
else if (filter.Equals("due:future", StringComparison.OrdinalIgnoreCase)
&& task.DueDate.IsDateGreaterThan(DateTime.Now))
continue;
- else if (filter.Equals("due:past", StringComparison.OrdinalIgnoreCase)
+ else if (filter.Equals("due:past", StringComparison.OrdinalIgnoreCase)
&& task.DueDate.IsDateLessThan(DateTime.Now))
continue;
else if (filter.Equals("due:active", StringComparison.OrdinalIgnoreCase)
@@ -452,7 +468,7 @@ private void ToggleComplete(Task task)
}
catch (Exception ex)
{
- HandleException("An error occurred while updating the task's completed status", ex);
+ ex.Handle("An error occurred while updating the task's completed status");
}
}
View
55 CommonExtensions/CommonExtensions.csproj
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5CE19CC1-833A-4950-B86E-CBF59FA00D6F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>CommonExtensions</RootNamespace>
+ <AssemblyName>CommonExtensions</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="IEnumerableExtensions.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="StringExtensions.cs" />
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
25 CommonExtensions/IEnumerableExtensions.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace CommonExtensions
+{
+ public static class IEnumerableExtensions
+ {
+ public static void Each<T>(this IEnumerable<T> items, Action<T> action)
+ {
+ if (!items.IsNullOrEmpty())
+ {
+ foreach (var item in items)
+ if (item != null)
+ action(item);
+ }
+ }
+
+ public static bool IsNullOrEmpty<T>(this IEnumerable<T> items)
+ {
+ return items == null || items.Count() == 0;
+ }
+ }
+}
View
36 CommonExtensions/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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("CommonExtensions")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CommonExtensions")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[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("c667f573-1652-4a43-9b87-c6f3a662af4f")]
+
+// Version information for an assembly consists of the following four values:
+//
+// 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")]
View
34 CommonExtensions/StringExtensions.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace CommonExtensions
+{
+ public static class StringExtensions
+ {
+ public static bool IsDateGreaterThan(this string dateString, DateTime date)
+ {
+ if (dateString.IsNullOrEmpty())
+ return false;
+
+ DateTime comparisonDate;
+ if (!DateTime.TryParse(dateString, out comparisonDate))
+ return false;
+
+ return comparisonDate.Date > date.Date;
+ }
+
+ public static bool IsDateLessThan(this string dateString, DateTime date)
+ {
+ if (dateString.IsNullOrEmpty())
+ return false;
+
+ DateTime comparisonDate;
+ if (!DateTime.TryParse(dateString, out comparisonDate))
+ return false;
+
+ return comparisonDate.Date < date.Date;
+ }
+ }
+}
View
12 ToDo.Net.sln
@@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildController", "BuildCon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorFont", "ColorFont\ColorFont.csproj", "{C51DEEDA-B581-401B-870B-DBB7D10119BF}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonExtensions", "CommonExtensions\CommonExtensions.csproj", "{5CE19CC1-833A-4950-B86E-CBF59FA00D6F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -85,6 +87,16 @@ Global
{C51DEEDA-B581-401B-870B-DBB7D10119BF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C51DEEDA-B581-401B-870B-DBB7D10119BF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C51DEEDA-B581-401B-870B-DBB7D10119BF}.Release|x86.ActiveCfg = Release|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {5CE19CC1-833A-4950-B86E-CBF59FA00D6F}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
53 ToDoLib/ExtensionMethods.cs
@@ -1,53 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace ToDoLib
-{
- public static class ExtensionMethods
- {
- public static void Each<T>(this IEnumerable<T> items, Action<T> action)
- {
- if (!items.IsNullOrEmpty())
- {
- foreach (var item in items)
- if (item != null)
- action(item);
- }
- }
-
- public static bool IsNullOrEmpty<T>(this IEnumerable<T> items)
- {
- return items == null || items.Count() == 0;
- }
-
- public static bool Contains(this string source, string toCheck, StringComparison comp)
- {
- return source.IndexOf(toCheck, comp) >= 0;
- }
-
- public static bool IsDateGreaterThan(this string dateString, DateTime date)
- {
- if (dateString.IsNullOrEmpty())
- return false;
-
- DateTime comparisonDate;
- if (!DateTime.TryParse(dateString, out comparisonDate))
- return false;
-
- return comparisonDate.Date > date.Date;
- }
-
- public static bool IsDateLessThan(this string dateString, DateTime date)
- {
- if (dateString.IsNullOrEmpty())
- return false;
-
- DateTime comparisonDate;
- if (!DateTime.TryParse(dateString, out comparisonDate))
- return false;
-
- return comparisonDate.Date < date.Date;
- }
- }
-}
View
1  ToDoLib/Log.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Threading;
+using CommonExtensions;
namespace ToDoLib
{
View
1  ToDoLib/Task.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Globalization;
+using CommonExtensions;
namespace ToDoLib
{
View
7 ToDoLib/ToDoLib.csproj
@@ -43,13 +43,18 @@
<Compile Include="..\Client\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="ExtensionMethods.cs" />
<Compile Include="Log.cs" />
<Compile Include="TaskException.cs" />
<Compile Include="TaskList.cs" />
<Compile Include="Task.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CommonExtensions\CommonExtensions.csproj">
+ <Project>{5CE19CC1-833A-4950-B86E-CBF59FA00D6F}</Project>
+ <Name>CommonExtensions</Name>
+ </ProjectReference>
+ </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.
Please sign in to comment.
Something went wrong with that request. Please try again.