Mercurial > silverbladetech
changeset 45:274fd2386d55
Merge with Test
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Wed, 04 Apr 2012 19:41:51 +0100 |
parents | 0d4aff4f699d (current diff) 382813d76dde (diff) |
children | 8e6458270599 |
files | Library/LibrarySystem.Tests/LibrarySystemTests.cs Library/LibrarySystem/Core/Rental.cs Library/LibrarySystem/Interfaces/IRental.cs PdfViewAndPrint/Libs/AxInterop.AcroPDFLib.dll PdfViewAndPrint/PdfViewAndPrint.sln PdfViewAndPrint/PdfViewAndPrint/App.xaml PdfViewAndPrint/PdfViewAndPrint/App.xaml.cs PdfViewAndPrint/PdfViewAndPrint/FTSE_INDEX_LINKED_ETFs.pdf PdfViewAndPrint/PdfViewAndPrint/MainWindow.xaml PdfViewAndPrint/PdfViewAndPrint/MainWindow.xaml.cs PdfViewAndPrint/PdfViewAndPrint/Pdf.ico PdfViewAndPrint/PdfViewAndPrint/PdfViewAndPrint.csproj PdfViewAndPrint/PdfViewAndPrint/Properties/AssemblyInfo.cs PdfViewAndPrint/PdfViewAndPrint/Properties/Resources.Designer.cs PdfViewAndPrint/PdfViewAndPrint/Properties/Resources.resx PdfViewAndPrint/PdfViewAndPrint/Properties/Settings.Designer.cs PdfViewAndPrint/PdfViewAndPrint/Properties/Settings.settings PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.Designer.cs PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.cs PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.resx PdfViewAndPrint/clean.bat |
diffstat | 46 files changed, 824 insertions(+), 1181 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Tue Apr 03 23:32:40 2012 +0100 +++ b/.hgignore Wed Apr 04 19:41:51 2012 +0100 @@ -5,4 +5,6 @@ *.csproj.user */obj/* */_ReSharper* -Stocks/packages/* +*.DotSettings.user +*/packages/* +*.stats
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/.nuget/NuGet.Config Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <solution> + <add key="disableSourceControlIntegration" value="true" /> + </solution> +</configuration> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/.nuget/NuGet.targets Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> + + <!-- Windows specific commands --> + <NuGetToolsPath Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> + <PackagesConfig Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> + <PackagesDir Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> + + <!-- We need to launch nuget.exe with the mono command if we're not on windows --> + <NuGetToolsPath Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir).nuget</NuGetToolsPath> + <PackagesConfig Condition=" '$(OS)' != 'Windows_NT' ">packages.config</PackagesConfig> + <PackagesDir Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)packages</PackagesDir> + + <!-- NuGet command --> + <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath> + <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> + <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand> + + <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> + + <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> + <PackageSources>""</PackageSources> + + <!-- Enable the restore command to run before builds --> + <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages> + + <!-- Property that enables building a package from a project --> + <BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage> + + <!-- Commands --> + <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand> + <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand> + + <!-- Make the build depend on restore packages --> + <BuildDependsOn Condition="$(RestorePackages) == 'true'"> + RestorePackages; + $(BuildDependsOn); + </BuildDependsOn> + + <!-- Make the build depend on restore packages --> + <BuildDependsOn Condition="$(BuildPackage) == 'true'"> + $(BuildDependsOn); + BuildPackage; + </BuildDependsOn> + </PropertyGroup> + + <Target Name="CheckPrerequisites"> + <!-- Raise an error if we're unable to locate nuget.exe --> + <Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> + </Target> + + <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> + <Exec Command="$(RestoreCommand)" + Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> + + <Exec Command="$(RestoreCommand)" + LogStandardErrorAsError="true" + Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> + </Target> + + <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites" Condition=" '$(OS)' != 'Windows_NT' "> + <Exec Command="$(BuildCommand)" + Condition=" '$(OS)' != 'Windows_NT' " /> + + <Exec Command="$(BuildCommand)" + LogStandardErrorAsError="true" + Condition=" '$(OS)' == 'Windows_NT' " /> + </Target> +</Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/BookTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,42 @@ +using System; +using LibrarySystem.Core; +using LibrarySystem.Interfaces; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + class BookTests + { + [Test] + public void Create_WithNullIdAndNullPublication_ShouldThrowArgumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Book.Create(null, null)); + } + + [Test] + public void Create_WithNullIdAndValidPublication_ShouldThrowArgumentNullException() + { + var publisher = Publisher.Create("dummy"); + var publication = Publication.Create("dummy", "dummy", publisher, "dummy"); + Assert.Throws<ArgumentNullException>(() => Book.Create(null, publication)); + } + + [Test] + public void Create_WithNullPublication_ShouldThrowArgumentNullException() + { + var validId = "1"; + Assert.Throws<ArgumentNullException>(() => Book.Create(validId, null)); + } + + [Test] + public void Create_WithValidParametersPublication_ShouldReturnBook() + { + var publisher = Publisher.Create("dummy"); + var publication = Publication.Create("dummy","dummy", publisher, "dummy"); + var validId = "1"; + IBook book = Book.Create(validId, publication); + Assert.NotNull(book); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/LibraryTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,374 @@ +using System; +using System.Collections.Generic; +using LibrarySystem.Core; +using LibrarySystem.Interfaces; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + public class LibraryTests + { + #region Factory methods to setup fixed scenario for testing + + // Factory that creates: + // A library object with 10 books (2 x Lord of the Flies, 3 x 1984, 5 x Brave New World) + private ILibrary CreateLibraryScenario() + { + #region Publisher + + IPublisher penguin = Publisher.Create("Penguin"); + + #endregion + + #region Publications + + IPublication lordOfTheFlies = Publication.Create("William Golding", "0140283331", penguin, "Lord of the Flies"); + + IPublication nineteenEightyFour = Publication.Create("George Orwell", "0452284236", penguin, "Nineteen Eighty-Four"); + + IPublication braveNewWorld = Publication.Create("Aldous Huxley", "0060850523", penguin, "Brave New World"); + + #endregion + + #region Books + + // Lord of the flies + IBook book1 = Book.Create("0000001", lordOfTheFlies); + IBook book2 = Book.Create("0000002", lordOfTheFlies); + IBook book3 = Book.Create("0000003", lordOfTheFlies); + + // 1984 + IBook book4 = Book.Create("0000004", nineteenEightyFour); + IBook book5 = Book.Create("0000005", nineteenEightyFour); + + // Brave new world + IBook book6 = Book.Create("0000006", braveNewWorld); + IBook book7 = Book.Create("0000007", braveNewWorld); + IBook book8 = Book.Create("0000008", braveNewWorld); + IBook book9 = Book.Create("0000009", braveNewWorld); + IBook book10 = Book.Create("0000010", braveNewWorld); + + #endregion + + #region Library + + ILibrary library = Library.Create("Leicester Square"); + library.AddStock(book1, book2, book3, book4, book5, book6, book7, book8, book9, book10); + + #endregion + + return library; + } + + public IBook CreateBook(string bookId = "dummy") + { + IPublisher publisher = Publisher.Create("dummy"); + IPublication publication = Publication.Create("dummy", "dummy", publisher, "dummy"); + IBook book = Book.Create(bookId, publication); + return book; + } + + #endregion + + #region Create + + [Test] + public void Create_WithNullLocation_ThrowsArgumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Library.Create(null)); + } + + #endregion + + #region AddStock + + [Test] + public void AddStock_WithNullBook_ShouldThrowArgumentNullException() + { + var library = CreateLibraryScenario(); + Assert.Throws<ArgumentNullException>(() => library.AddStock(null)); + } + + [Test] + public void AddStock_WithOneValidBookAndOneNullBook_ShouldThrowArgumentNullException() + { + var library = CreateLibraryScenario(); + var validBook = CreateBook(); + Assert.Throws<ArgumentNullException>(() => library.AddStock(validBook, null)); + } + + [Test] + public void AddStock_WithValidBook_ShouldIncreaseStockListCountByOne() + { + //arrange + var library = CreateLibraryScenario(); + var expected = library.StockList.Count + 1; + var dummyBook = CreateBook(); + + //act + library.AddStock(dummyBook); + var actual = library.StockList.Count; + + //assert + Assert.AreEqual(expected, actual); + } + + [Test] + public void AddStock_WithBookIdAlreadyInStock_ShouldThrowException() + { + //arrange + var library = CreateLibraryScenario(); + var idThatIsAlreadyInStock = "0000001"; + var dummyBook = CreateBook(idThatIsAlreadyInStock); + + //act + Assert.Throws<Exception>( + () => library.AddStock(dummyBook), + string.Format("Book with {0} is already in stock", idThatIsAlreadyInStock)); + } + + [Test] + public void AddStock_WithValidBook_ShouldMakeBookAvailable() + { + //arrange + var library = CreateLibraryScenario(); + var id = "0000001"; + var dummyBook = CreateBook(); + + //act + library.AddStock(dummyBook); + var lookupBook = ((List<IStock>) library.StockList).Find(s => s.Book.Id == id); + var actual = lookupBook.IsAvailable; + + //assert + Assert.IsTrue(actual); + } + + #endregion + + #region IsBookAvailableByISBN + + [Test] + public void IsBookAvailableByISBN_WithNullISBN_ShouldThrowArgumentNullExpection() + { + var library = CreateLibraryScenario(); + Assert.Throws<ArgumentNullException>(() => library.IsBookAvailableByISBN(null)); + } + + [Test] + public void IsBookAvailableByISBN_WithValidISBN_ShouldReturnTrue() + { + var library = CreateLibraryScenario(); + + // Lord of the flies + var validISBN = "0140283331"; + + var actual = library.IsBookAvailableByISBN(validISBN); + + Assert.IsTrue(actual); + } + + [Test] + public void IsBookAvailableByISBN_WithUnknownISBN_ShouldReturnFalse() + { + var library = CreateLibraryScenario(); + + // rubbish data + var unknownISBN = "X"; + + var actual = library.IsBookAvailableByISBN(unknownISBN); + + Assert.IsFalse(actual); + } + + #endregion + + #region FindBooks + + [Test] + public void FindBooks_WhenNullSearchString_ShouldThrowArgumentNullExpection() + { + var library = CreateLibraryScenario(); + Assert.Throws<ArgumentNullException>(() => library.FindBooks(null)); + } + + + [Test] + public void FindBooks_WithValidSearchTitleString_ShouldReturnCorrectNumberOfBooks() + { + var library = CreateLibraryScenario(); + + // good search string + var searchString = "Flies"; + + // number of Lord of the Flies books expected + var expected = 3; + var actual = library.FindBooks(searchString).Count; + + Assert.AreEqual(expected, actual); + } + + [Test] + public void FindBooks_WithValidSearchTitleStringLowerCase_ShouldReturnCorrectNumberOfBooks() + { + var library = CreateLibraryScenario(); + + // good search string + var searchString = "flies"; + + // number of Lord of the Flies books expected + var expected = 3; + var actual = library.FindBooks(searchString).Count; + + Assert.AreEqual(expected, actual); + } + + [Test] + public void FindBooks_WithValidSearchStringMultiplePublications_ShouldReturnCorrectNumberOfBooks() + { + var library = CreateLibraryScenario(); + + // good search string + var searchString = "e"; + + // number of Lord of the Flies books expected + var expected = 10; + var actual = library.FindBooks(searchString).Count; + + Assert.AreEqual(expected, actual); + } + + [Test] + public void FindBooks_WithValidSearchAuthorString_ShouldReturnCorrectNumberOfBooks() + { + var library = CreateLibraryScenario(); + + // number of Brave New World books expected + var expected = 5; + var searchString = "ldous"; + + var actual = library.FindBooks(searchString).Count; + + Assert.AreEqual(expected, actual); + } + + [Test] + public void FindBooks_WithInvalidSearchString_ShouldBeEmpty() + { + var library = CreateLibraryScenario(); + + // rubbish data + var searchString = "XYZ"; + + var actual = library.FindBooks(searchString); + + Assert.IsEmpty(actual); + } + + #endregion + + #region GetBookById + + [Test] + public void GetBookById_WhenNullId_ShouldThrowArgumentNullExpection() + { + var library = CreateLibraryScenario(); + Assert.Throws<ArgumentNullException>(() => library.GetBookById(null)); + } + + [Test] + public void GetBookById_WhenValidId_ShouldReturnBook() + { + var library = CreateLibraryScenario(); + var validBookId = "0000001"; + var book = library.GetBookById(validBookId); + Assert.IsNotNull(book); + } + + [Test] + public void GetBookById_WhenValidId_ShouldReturnNull() + { + var library = CreateLibraryScenario(); + var invalidBookId = "X"; + var book = library.GetBookById(invalidBookId); + Assert.IsNull(book); + } + + #endregion + + #region LendBook + + [Test] + public void LendBook_ShouldMakeBookInLibraryStockListUnavailable() + { + //arrange + var library = CreateLibraryScenario(); + var person = CreatePerson(); + var bookId = "0000001"; + + // act + library.LendBook(person, bookId); + var lookupBook = ((List<IStock>) library.StockList).Find(s => s.Book.Id == bookId); + var actual = lookupBook.IsAvailable; + + // assert + Assert.IsFalse(actual); + } + + private IPerson CreatePerson() + { + var person = Person.Create("dummy", "dummy"); + return person; + } + + [Test] + public void LendBook_WithNullPerson_ShouldThrowArgumentNullException() + { + //arrange + var library = CreateLibraryScenario(); + var id = "dummy"; + + // act & assert + Assert.Throws<ArgumentNullException>(() => library.LendBook(null, id)); + } + + [Test] + public void LendBook_WithNullBook_ShouldThrowArgumentNullException() + { + //arrange + var library = CreateLibraryScenario(); + var person = CreatePerson(); + + // act & assert + Assert.Throws<ArgumentNullException>(() => library.LendBook(person, null)); + } + + [Test] + public void LendBook_WithNullBookAndNullPerson_ShouldThrowArgumentNullException() + { + //arrange + var library = CreateLibraryScenario(); + + // act & assert + Assert.Throws<ArgumentNullException>(() => library.LendBook(null, null)); + } + + [Test] + public void LendBook_WithUnknownBook_ShouldThrowArgumentException() + { + //arrange + var library = CreateLibraryScenario(); + var person = CreatePerson(); + var id = "dummy"; + + // act & assert + Assert.Throws<Exception>( + () => library.LendBook(person, id), + string.Format("Book id {0} is not in stock", id)); + } + + #endregion + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/PersonTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,35 @@ +using System; +using LibrarySystem.Core; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + class PersonTests + { + [Test] + public void Create_WithValidParams_ShouldReturnPerson() + { + var person = Person.Create("dummy", "dummy"); + Assert.IsNotNull(person); + } + + [Test] + public void Create_WithNullAddress_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Person.Create(null, "dummy")); + } + + [Test] + public void Create_WithNullName_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Person.Create("dummy", null)); + } + + [Test] + public void Create_WithNullAddressAndName_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Person.Create(null, null)); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/PublicationTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,45 @@ +using System; +using LibrarySystem.Core; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + class PublicationTests + { + [Test] + public void Create_WithValidParams_ShouldReturnPublication() + { + var publisher = Publisher.Create("dummy"); + var publication = Publication.Create("dummy","dummy", publisher, "dummy"); + Assert.IsNotNull(publication); + } + + [Test] + public void Create_WithNullAuthor_ShouldThrowAgrumentNullException() + { + var publisher = Publisher.Create("dummy"); + Assert.Throws<ArgumentNullException>(() => Publication.Create(null, "dummy", publisher, "dummy")); + } + + [Test] + public void Create_WithNullISBN_ShouldThrowAgrumentNullException() + { + var publisher = Publisher.Create("dummy"); + Assert.Throws<ArgumentNullException>(() => Publication.Create("dummy", null, publisher, "dummy")); + } + + [Test] + public void Create_WithNullPublisher_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Publication.Create("dummy","dummy", null, "dummy")); + } + + [Test] + public void Create_WithNullTitle_ShouldThrowAgrumentNullException() + { + var publisher = Publisher.Create("dummy"); + Assert.Throws<ArgumentNullException>(() => Publication.Create("dummy", "dummy", publisher, null)); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/PublisherTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,23 @@ +using System; +using LibrarySystem.Core; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + class PublisherTests + { + [Test] + public void Create_WithValidName_ShouldReturnPublisher() + { + var publisher = Publisher.Create("dummy"); + Assert.IsNotNull(publisher); + } + + [Test] + public void Create_WithNullName_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Publisher.Create(null)); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem.Tests/Core/StockTests.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,26 @@ +using System; +using LibrarySystem.Core; +using NUnit.Framework; + +namespace LibrarySystem.Tests.Core +{ + [TestFixture] + class StockTests + { + [Test] + public void Create_WithValidName_ShouldReturnPublisher() + { + var publisher = Publisher.Create("dummy"); + var publication = Publication.Create("dummy","dummy", publisher, "dummy"); + var book = Book.Create("dummy", publication); + var stock = Stock.Create(book, true); + Assert.IsNotNull(stock); + } + + [Test] + public void Create_WithNullBook_ShouldThrowAgrumentNullException() + { + Assert.Throws<ArgumentNullException>(() => Stock.Create(null, true)); + } + } +}
--- a/Library/LibrarySystem.Tests/LibrarySystem.Tests.csproj Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem.Tests/LibrarySystem.Tests.csproj Wed Apr 04 19:41:51 2012 +0100 @@ -12,6 +12,8 @@ <AssemblyName>LibrarySystem.Tests</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\Library\</SolutionDir> + <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -38,8 +40,13 @@ <Reference Include="System.Core" /> </ItemGroup> <ItemGroup> - <Compile Include="LibrarySystemTests.cs" /> + <Compile Include="Core\BookTests.cs" /> + <Compile Include="Core\LibraryTests.cs" /> + <Compile Include="Core\PersonTests.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Core\PublicationTests.cs" /> + <Compile Include="Core\PublisherTests.cs" /> + <Compile Include="Core\StockTests.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\LibrarySystem\LibrarySystem.csproj"> @@ -51,6 +58,7 @@ <None Include="packages.config" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(SolutionDir)\.nuget\nuget.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">
--- a/Library/LibrarySystem.Tests/LibrarySystemTests.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,204 +0,0 @@ -using LibrarySystem.Core; -using LibrarySystem.Interfaces; -using NUnit.Framework; - -namespace LibrarySystem.Tests -{ - [TestFixture] - public class LibraryTests - { - /* - * Factory that creates: - * Library with 10 books (2 x Lord of the Flies, 3 x 1984, 5 x Brave New World) - */ - private ILibrary CreateScenario() - { - #region Publisher - - IPublisher penguin = new Publisher() {Name = "Penguin"}; - - #endregion - - #region Publications - - IPublication lordOfTheFlies = new Publication() - { - Author = "William Golding", - ISBN = "0140283331", - Publisher = penguin, - Title = "Lord of the Flies" - }; - - IPublication nineteenEightyFour = new Publication() - { - Author = "George Orwell", - ISBN = "0452284236", - Title = "Nineteen Eighty-Four" - }; - - IPublication braveNewWorld = new Publication() - { - Author = "Aldous Huxley", - ISBN = "0060850523", - Title = "Brave New World" - }; - - #endregion - - #region Books - - // Lord of the flies - IBook book1 = new Book(lordOfTheFlies) - {Id = "0000001", CurrentFee = 1.25m}; - IBook book2 = new Book(lordOfTheFlies) - {Id = "0000002", CurrentFee = 1.25m}; - IBook book3 = new Book(lordOfTheFlies) - {Id = "0000003", CurrentFee = 1.25m}; - - // 1984 - IBook book4 = new Book(nineteenEightyFour) - {Id = "0000004", CurrentFee = 1.5m}; - IBook book5 = new Book(nineteenEightyFour) - {Id = "0000005", CurrentFee = 1.5m}; - - // Brave new world - IBook book6 = new Book(braveNewWorld) - {Id = "0000006", CurrentFee = 1.8m}; - IBook book7 = new Book(braveNewWorld) - {Id = "0000007", CurrentFee = 1.8m}; - IBook book8 = new Book(braveNewWorld) - {Id = "0000008", CurrentFee = 1.8m}; - IBook book9 = new Book(braveNewWorld) - {Id = "0000009", CurrentFee = 1.8m}; - IBook book10 = new Book(braveNewWorld) - {Id = "0000010", CurrentFee = 1.8m}; - - #endregion - - #region Library - - ILibrary library = new Library(); - library.Location = "Leicester Square"; - library.AddStock(book1, book2, book3, book4, book5, book6, book7, book8, book9, book10); - - #endregion - - return library; - } - - [Test] - public void AddStockShouldIncreaseStockListCountByOne() - { - //arrange - var library = new Library(); - var expected = library.StockList.Count + 1; - var dummyBook = new Book(new Publication()); - - //act - library.AddStock(dummyBook); - var actual = library.StockList.Count; - - //assert - Assert.AreEqual(expected, actual); - } - - [Test] - public void SearchForAvailableBookByIBSNShouldReturnTrue() - { - var library = CreateScenario(); - - // Lord of the flies - var validISBN = "0140283331"; - - var actual = library.IsBookAvailableByISBN(validISBN); - - Assert.IsTrue(actual); - } - - [Test] - public void SearchForUnavailableBookByIBSNShouldReturnFalse() - { - var library = CreateScenario(); - - // rubbish data - var invalidISBN = "X"; - - var actual = library.IsBookAvailableByISBN(invalidISBN); - - Assert.IsFalse(actual); - } - - [Test] - public void FindBooksByValidSearchTitleString() - { - var library = CreateScenario(); - - // good search string - var searchString = "Flies"; - - // number of Lord of the Flies books expected - var expected = 3; - var actual = library.FindBooks(searchString).Count; - - Assert.AreEqual(expected, actual); - } - - - [Test] - public void FindBooksByValidSearchTitleStringLowerCase() - { - var library = CreateScenario(); - - // good search string - var searchString = "flies"; - - // number of Lord of the Flies books expected - var expected = 3; - var actual = library.FindBooks(searchString).Count; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void FindBooksByValidSearchStringMultiplePublications() - { - var library = CreateScenario(); - - // good search string - var searchString = "e"; - - // number of Lord of the Flies books expected - var expected = 10; - var actual = library.FindBooks(searchString).Count; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void FindBooksByValidSearchAuthorString() - { - var library = CreateScenario(); - - // number of Brave New World books expected - var expected = 5; - var searchString = "ldous"; - - var actual = library.FindBooks(searchString).Count; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void FindBooksByInvalidSearchString() - { - var library = CreateScenario(); - - // rubbish data - var searchString = "XYZ"; - - var actual = library.FindBooks(searchString); - - Assert.IsEmpty(actual); - } - } -}
--- a/Library/LibrarySystem/Core/Book.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Core/Book.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System; using LibrarySystem.Interfaces; namespace LibrarySystem.Core @@ -10,16 +10,25 @@ public IPublisher Publisher { get; set; } public string Title { get; set; } public string Id { get; set; } - public decimal CurrentFee { get; set; } - public IList<IRental> RentalHistory { get; set; } - public Book(IPublication publication) + private Book() + { + + } + + public static IBook Create(string id, IPublication publication) { - Author = publication.Author; - ISBN = publication.ISBN; - Title = publication.Title; - Publisher = publication.Publisher; - RentalHistory = new List<IRental>(0); + if (id == null || publication == null) + throw new ArgumentNullException(); + + return new Book() + { + Author = publication.Author, + Id = id, + ISBN = publication.ISBN, + Title = publication.Title, + Publisher = publication.Publisher + }; } } }
--- a/Library/LibrarySystem/Core/Library.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Core/Library.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using LibrarySystem.Interfaces; @@ -6,30 +7,55 @@ { public class Library : ILibrary { - public string Location { get; set; } - public IList<IStock> StockList { get; set; } + public string Location { get; private set; } + public IList<IStock> StockList { get; private set; } + + private Library() + { + } - public Library() + public static ILibrary Create(string location) { - StockList = new List<IStock>(0); + if (location == null) + throw new ArgumentNullException(); + + return new Library() {Location = location, StockList = new List<IStock>(0)}; } public void AddStock(params IBook[] books) { + if (books == null) + throw new ArgumentNullException(); + var stock = new List<IStock>(StockList.Count + books.Length); stock.AddRange(StockList); foreach (var book in books) { - stock.Add(new Stock() { Book = book, IsAvailable = true }); + if (book == null) + throw new ArgumentNullException(); + + ThrowExceptionIfBookIsAlreadyInStock(book); + + stock.Add(Stock.Create(book, true)); } StockList = stock; } + private void ThrowExceptionIfBookIsAlreadyInStock(IBook book) + { + var lookup = ((List<IStock>) StockList).Find(s => s.Book.Id == book.Id); + if (lookup != null) + throw new Exception(string.Format("Book id {0} is already in stock", book.Id)); + } + public bool IsBookAvailableByISBN(string isbn) { + if (isbn == null) + throw new ArgumentNullException(); + var qry = from books in StockList where books.Book.ISBN == isbn & books.IsAvailable @@ -40,6 +66,9 @@ public IList<IStock> FindBooks(string searchString) { + if (searchString == null) + throw new ArgumentNullException(); + searchString = searchString.ToLower(); var qry = from books in StockList @@ -50,9 +79,38 @@ return qry.ToList(); } - public void LendBook(IPerson person, IBook book) + public IBook GetBookById(string id) { - throw new System.NotImplementedException(); + if (id == null) + throw new ArgumentNullException(); + + id = id.ToLower(); + + var qry = from books in StockList + where books.Book.Id.ToLower() == id + select books.Book; + + return qry.FirstOrDefault(); + } + + + public void LendBook(IPerson person, string id) + { + if (person == null || id == null) + throw new ArgumentNullException(); + + var stock = ThrowExceptionIfBookIsNotInStock(id); + stock.IsAvailable = false; + + // FUTURE: register with person that they have borrowed the book + } + + private IStock ThrowExceptionIfBookIsNotInStock(string id) + { + var lookup = ((List<IStock>) StockList).Find(s => s.Book.Id == id); + if (lookup == null) + throw new Exception(string.Format("Book with id {0} is not in stock", id)); + return lookup; } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Library/LibrarySystem/Core/Person.cs Wed Apr 04 19:41:51 2012 +0100 @@ -0,0 +1,24 @@ +using System; +using LibrarySystem.Interfaces; + +namespace LibrarySystem.Core +{ + public class Person : IPerson + { + public string Address { get; private set; } + public string Name { get; private set; } + + private Person() + { + + } + + public static IPerson Create(string address, string name) + { + if (address == null || name == null) + throw new ArgumentNullException(); + + return new Person() { Address = address, Name = name}; + } + } +}
--- a/Library/LibrarySystem/Core/Publication.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Core/Publication.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,13 +1,33 @@ -using LibrarySystem.Interfaces; +using System; +using LibrarySystem.Interfaces; namespace LibrarySystem.Core { public class Publication : IPublication { - public string Author { get; set; } - public string ISBN { get; set; } - public IPublisher Publisher { get; set; } - public string Title { get; set; } + public string Author { get; private set; } + public string ISBN { get; private set; } + public IPublisher Publisher { get; private set; } + public string Title { get; private set; } + + private Publication() + { + + } + + public static IPublication Create(string author, string isbn, IPublisher publisher, string title) + { + if (author == null || isbn == null || publisher == null || title == null) + throw new ArgumentNullException(); + + return new Publication() + { + Author = author, + ISBN = isbn, + Publisher = publisher, + Title = title + }; + } } }
--- a/Library/LibrarySystem/Core/Publisher.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Core/Publisher.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,9 +1,23 @@ -using LibrarySystem.Interfaces; +using System; +using LibrarySystem.Interfaces; namespace LibrarySystem.Core { public class Publisher : IPublisher { - public string Name { get; set; } + public string Name { get; private set; } + + private Publisher() + { + + } + + public static IPublisher Create(string name) + { + if (name == null) + throw new ArgumentNullException(); + + return new Publisher() { Name = name }; + } } }
--- a/Library/LibrarySystem/Core/Rental.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -using System; -using LibrarySystem.Interfaces; - -namespace LibrarySystem.Core -{ - public class Rental : IRental - { - public DateTime ActualCheckIn { get; set; } - public IBook Book { get; set; } - public DateTime CheckOut { get; set; } - public DateTime ExpectedCheckIn { get; set; } - public decimal Fee { get; set; } - public IPerson Person { get; set; } - } -}
--- a/Library/LibrarySystem/Core/Stock.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Core/Stock.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,10 +1,24 @@ -using LibrarySystem.Interfaces; +using System; +using LibrarySystem.Interfaces; namespace LibrarySystem.Core { public class Stock : IStock { + public IBook Book { get; private set; } public bool IsAvailable { get; set; } - public IBook Book { get; set; } + + private Stock() + { + + } + + public static IStock Create(IBook book, bool isAvailable) + { + if (book == null) + throw new ArgumentNullException(); + + return new Stock() {Book = book, IsAvailable = isAvailable}; + } } }
--- a/Library/LibrarySystem/Diagrams/Overview.cd Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Diagrams/Overview.cd Wed Apr 04 19:41:51 2012 +0100 @@ -1,12 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <ClassDiagram MajorVersion="1" MinorVersion="1"> - <Interface Name="LibrarySystem.Interfaces.IRental"> - <Position X="5.25" Y="3" Width="1.5" /> - <TypeIdentifier> - <HashCode>AIAAAAAAAAAABABgACAAAAAAAgAAAAAAAAAAAAAAAAA=</HashCode> - <FileName>Interfaces\IRental.cs</FileName> - </TypeIdentifier> - </Interface> <Interface Name="LibrarySystem.Interfaces.IPublication"> <Position X="3.5" Y="1" Width="1.5" /> <TypeIdentifier> @@ -17,28 +10,28 @@ <Interface Name="LibrarySystem.Interfaces.IBook"> <Position X="5.25" Y="1" Width="1.5" /> <TypeIdentifier> - <HashCode>AAACAAAAABAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAA=</HashCode> + <HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>Interfaces\IBook.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="LibrarySystem.Interfaces.IStock"> - <Position X="7" Y="1" Width="2.25" /> + <Position X="5.25" Y="2.5" Width="1.5" /> <TypeIdentifier> <HashCode>AAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode> <FileName>Interfaces\IStock.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="LibrarySystem.Interfaces.ILibrary"> - <Position X="9.5" Y="1" Width="1.5" /> + <Position X="7" Y="1" Width="1.5" /> <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAIAgAAEAAAAAAAAAAIAABAAAgA=</HashCode> + <HashCode>AAAAAAAAAAAAAAAAAAIAgAAEAAAAgAAAAAIAABAAAgA=</HashCode> <FileName>Interfaces\ILibrary.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="LibrarySystem.Interfaces.IPerson"> - <Position X="7.25" Y="3" Width="1.5" /> + <Position X="8.75" Y="1" Width="1.5" /> <TypeIdentifier> - <HashCode>AAAAAAAABAAAAAAAAAAAAAQAAAAAAIACAAAAAAAAAAA=</HashCode> + <HashCode>AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAACAAAAAAAAAAA=</HashCode> <FileName>Interfaces\IPerson.cs</FileName> </TypeIdentifier> </Interface>
--- a/Library/LibrarySystem/Interfaces/IBook.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/IBook.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,11 +1,7 @@ -using System.Collections.Generic; - -namespace LibrarySystem.Interfaces +namespace LibrarySystem.Interfaces { public interface IBook : IPublication { - string Id { get; set; } - decimal CurrentFee { get; set; } - IList<IRental> RentalHistory { get; set; } + string Id { get; } } } \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/ILibrary.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/ILibrary.cs Wed Apr 04 19:41:51 2012 +0100 @@ -4,12 +4,13 @@ { public interface ILibrary { - string Location { get; set; } - IList<IStock> StockList { get; set; } + string Location { get; } + IList<IStock> StockList { get; } void AddStock(params IBook[] books); bool IsBookAvailableByISBN(string isbn); IList<IStock> FindBooks(string searchString); - void LendBook(IPerson person, IBook book); + IBook GetBookById(string id); + void LendBook(IPerson person, string id); } } \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/IPerson.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/IPerson.cs Wed Apr 04 19:41:51 2012 +0100 @@ -1,13 +1,9 @@ -using System.Collections.Generic; -using LibrarySystem.Core; - + namespace LibrarySystem.Interfaces { public interface IPerson { - string Address { get; set; } - decimal CurrentBalance { get; set; } - IList<Rental> RentalHistory { get; set; } - string Name { get; set; } + string Address { get; } + string Name { get; } } } \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/IPublication.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/IPublication.cs Wed Apr 04 19:41:51 2012 +0100 @@ -2,9 +2,9 @@ { public interface IPublication { - string Author { get; set; } - string ISBN { get; set; } - IPublisher Publisher { get; set; } - string Title { get; set; } + string Author { get; } + string ISBN { get; } + IPublisher Publisher { get; } + string Title { get; } } } \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/IPublisher.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/IPublisher.cs Wed Apr 04 19:41:51 2012 +0100 @@ -2,6 +2,6 @@ { public interface IPublisher { - string Name { get; set; } + string Name { get; } } } \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/IRental.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -using System; - -namespace LibrarySystem.Interfaces -{ - public interface IRental - { - DateTime ActualCheckIn { get; set; } - IBook Book { get; set; } - DateTime CheckOut { get; set; } - DateTime ExpectedCheckIn { get; set; } - Decimal Fee { get; set; } - IPerson Person { get; set; } - } -} \ No newline at end of file
--- a/Library/LibrarySystem/Interfaces/IStock.cs Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/Interfaces/IStock.cs Wed Apr 04 19:41:51 2012 +0100 @@ -3,6 +3,6 @@ public interface IStock { bool IsAvailable { get; set; } - IBook Book { get; set; } + IBook Book { get; } } } \ No newline at end of file
--- a/Library/LibrarySystem/LibrarySystem.csproj Tue Apr 03 23:32:40 2012 +0100 +++ b/Library/LibrarySystem/LibrarySystem.csproj Wed Apr 04 19:41:51 2012 +0100 @@ -12,6 +12,8 @@ <AssemblyName>LibrarySystem</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\Library\</SolutionDir> + <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -36,7 +38,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Core\Book.cs" /> - <Compile Include="Interfaces\IRental.cs" /> + <Compile Include="Core\Person.cs" /> <Compile Include="Interfaces\IBook.cs" /> <Compile Include="Interfaces\ILibrary.cs" /> <Compile Include="Interfaces\IPerson.cs" /> @@ -47,13 +49,13 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Core\Publication.cs" /> <Compile Include="Core\Publisher.cs" /> - <Compile Include="Core\Rental.cs" /> <Compile Include="Core\Stock.cs" /> </ItemGroup> <ItemGroup> <None Include="Diagrams\Overview.cd" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(SolutionDir)\.nuget\nuget.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">
--- a/PdfViewAndPrint/PdfViewAndPrint.sln Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfViewAndPrint", "PdfViewAndPrint\PdfViewAndPrint.csproj", "{1339C473-6A53-443A-9B7C-E805F639A367}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1339C473-6A53-443A-9B7C-E805F639A367}.Debug|x86.ActiveCfg = Debug|x86 - {1339C473-6A53-443A-9B7C-E805F639A367}.Debug|x86.Build.0 = Debug|x86 - {1339C473-6A53-443A-9B7C-E805F639A367}.Release|x86.ActiveCfg = Release|x86 - {1339C473-6A53-443A-9B7C-E805F639A367}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal
--- a/PdfViewAndPrint/PdfViewAndPrint/App.xaml Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<Application x:Class="PdfViewAndPrint.App" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - StartupUri="MainWindow.xaml"> - <Application.Resources> - - </Application.Resources> -</Application>
--- a/PdfViewAndPrint/PdfViewAndPrint/App.xaml.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Windows; - -namespace PdfViewAndPrint -{ - /// <summary> - /// Interaction logic for App.xaml - /// </summary> - public partial class App : Application - { - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/MainWindow.xaml Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -<Window x:Class="PdfViewAndPrint.MainWindow" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Title="PDF View and Print" - MinWidth="725" - MinHeight="550" - Icon="pdf.ico"> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="*" /> - <ColumnDefinition Width="100" /> - </Grid.ColumnDefinitions> - - <Grid.RowDefinitions> - <RowDefinition /> - <RowDefinition Height="20" /> - </Grid.RowDefinitions> - - <WindowsFormsHost Name="windowsFormsHost" /> - - <DockPanel Grid.Column="1"> - - <DockPanel.Resources> - <Style TargetType="Button"> - <Setter Property="Margin" Value="10,5,10,5" /> - <Setter Property="DockPanel.Dock" Value="Top" /> - <Setter Property="Height" Value="50" /> - <Setter Property="Width" Value="80" /> - </Style> - </DockPanel.Resources> - - <Button Name="btnLoad" - Click="btnLoad_Click" - Content="Load" - IsDefault="True" - IsEnabled="True" /> - - <Button Name="btnPrint" - Click="btnPrint_Click" - Content="Print" - IsEnabled="True" /> - - <Button Name="btnOpen" - Click="btnOpen_Click" - IsEnabled="True"> - <TextBlock TextWrapping="Wrap">Open in Acrobat</TextBlock> - </Button> - - <Button Name="btnClose" - Height="25" - VerticalAlignment="Bottom" - Click="btnClose_Click" - Content="Close" - IsCancel="True" /> - </DockPanel> - - <StatusBar Name="StatusBar" - Grid.Row="1" - Grid.ColumnSpan="2"> - <TextBlock Name="StatusBarText">You need Adobe Acrobat Reader installed on the client machine to view PDFs in WPF (via a WinFormsHost)</TextBlock> - </StatusBar> - </Grid> -</Window>
--- a/PdfViewAndPrint/PdfViewAndPrint/MainWindow.xaml.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -using System; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Threading; -using Acrobat; - -namespace PdfViewAndPrint -{ - /// <summary> - /// Interaction logic for MainWindow.xaml - /// </summary> - public partial class MainWindow - { - private string pdfFilePath; - - public MainWindow() - { - InitializeComponent(); - - // create win forms control and hook up event handling for notification - var winFormsUserControl = new WinFormsUserControl(); - winFormsUserControl.Notification += winFormsUserControl_Notification; - windowsFormsHost.Child = winFormsUserControl; - - if (string.IsNullOrEmpty(pdfFilePath)) - SetButtons(false); - } - - public delegate void ActionDelegate(); - - private void winFormsUserControl_Notification(object sender, NotifyEventArgs e) - { - Dispatcher.BeginInvoke(new Action(() => this.StatusBarText.Text = e.Message), DispatcherPriority.Background); - } - - private void btnClose_Click(object sender, RoutedEventArgs e) - { - Application.Current.Shutdown(); - } - - private void btnLoad_Click(object sender, RoutedEventArgs e) - { - var dialog = new Microsoft.Win32.OpenFileDialog - { - DefaultExt = ".pdf", - Filter = "PDF documents (.pdf)|*.pdf" - }; - - - var result = dialog.ShowDialog(); - - if (result != true) - { - SetButtons(false); - return; - } - - pdfFilePath = dialog.FileName; - - //Task.Factory.StartNew(() => - ((WinFormsUserControl)this.windowsFormsHost.Child).LoadPdf(pdfFilePath); - //); - - SetButtons(true); - } - - private void SetButtons(bool isEnabled) - { - btnPrint.IsEnabled = isEnabled; - btnOpen.IsEnabled = isEnabled; - } - - private void btnPrint_Click(object sender, RoutedEventArgs e) - { - - } - - private void btnOpen_Click(object sender, RoutedEventArgs e) - { - Task.Factory.StartNew(OpenInAcrobat); - } - - private void OpenInAcrobat() - { - var acrobat = new AcroApp(); - acrobat.Show(); - - var avDoc = new AcroAVDoc(); - - if (avDoc.Open(pdfFilePath, "")) - StatusBarText.Text = pdfFilePath + " loaded"; - else - StatusBarText.Text = pdfFilePath + " cannot be opened in Acrobat Reader"; - } - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/PdfViewAndPrint.csproj Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -<?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)' == '' ">x86</Platform> - <ProductVersion>8.0.30703</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{1339C473-6A53-443A-9B7C-E805F639A367}</ProjectGuid> - <OutputType>WinExe</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>PdfViewAndPrint</RootNamespace> - <AssemblyName>PdfViewAndPrint</AssemblyName> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - <TargetFrameworkProfile>Client</TargetFrameworkProfile> - <FileAlignment>512</FileAlignment> - <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <PlatformTarget>x86</PlatformTarget> - <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|x86' "> - <PlatformTarget>x86</PlatformTarget> - <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.Drawing" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - <Reference Include="System.Core" /> - <Reference Include="System.Xaml"> - <RequiredTargetFramework>4.0</RequiredTargetFramework> - </Reference> - <Reference Include="WindowsBase" /> - <Reference Include="PresentationCore" /> - <Reference Include="PresentationFramework" /> - <Reference Include="WindowsFormsIntegration" /> - </ItemGroup> - <ItemGroup> - <ApplicationDefinition Include="App.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </ApplicationDefinition> - <Compile Include="WinFormsUserControl.cs"> - <SubType>UserControl</SubType> - </Compile> - <Compile Include="WinFormsUserControl.Designer.cs"> - <DependentUpon>WinFormsUserControl.cs</DependentUpon> - </Compile> - <Page Include="MainWindow.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </Page> - <Compile Include="App.xaml.cs"> - <DependentUpon>App.xaml</DependentUpon> - <SubType>Code</SubType> - </Compile> - <Compile Include="MainWindow.xaml.cs"> - <DependentUpon>MainWindow.xaml</DependentUpon> - <SubType>Code</SubType> - </Compile> - </ItemGroup> - <ItemGroup> - <Compile Include="Properties\AssemblyInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Properties\Resources.Designer.cs"> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - <DependentUpon>Resources.resx</DependentUpon> - </Compile> - <Compile Include="Properties\Settings.Designer.cs"> - <AutoGen>True</AutoGen> - <DependentUpon>Settings.settings</DependentUpon> - <DesignTimeSharedInput>True</DesignTimeSharedInput> - </Compile> - <Content Include="Pdf.ico"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <EmbeddedResource Include="Properties\Resources.resx"> - <Generator>ResXFileCodeGenerator</Generator> - <LastGenOutput>Resources.Designer.cs</LastGenOutput> - </EmbeddedResource> - <EmbeddedResource Include="WinFormsUserControl.resx"> - <DependentUpon>WinFormsUserControl.cs</DependentUpon> - </EmbeddedResource> - <Content Include="FTSE_INDEX_LINKED_ETFs.pdf"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <None Include="Properties\Settings.settings"> - <Generator>SettingsSingleFileGenerator</Generator> - <LastGenOutput>Settings.Designer.cs</LastGenOutput> - </None> - <AppDesigner Include="Properties\" /> - </ItemGroup> - <ItemGroup> - <COMReference Include="Acrobat"> - <Guid>{E64169B3-3592-47D2-816E-602C5C13F328}</Guid> - <VersionMajor>1</VersionMajor> - <VersionMinor>1</VersionMinor> - <Lcid>0</Lcid> - <WrapperTool>tlbimp</WrapperTool> - <Isolated>False</Isolated> - <EmbedInteropTypes>True</EmbedInteropTypes> - </COMReference> - <COMReference Include="AcroPDFLib"> - <Guid>{05BFD3F1-6319-4F30-B752-C7A22889BCC4}</Guid> - <VersionMajor>1</VersionMajor> - <VersionMinor>0</VersionMinor> - <Lcid>0</Lcid> - <WrapperTool>tlbimp</WrapperTool> - <Isolated>False</Isolated> - <EmbedInteropTypes>True</EmbedInteropTypes> - </COMReference> - <COMReference Include="AxAcroPDFLib"> - <Guid>{05BFD3F1-6319-4F30-B752-C7A22889BCC4}</Guid> - <VersionMajor>1</VersionMajor> - <VersionMinor>0</VersionMinor> - <Lcid>0</Lcid> - <WrapperTool>aximp</WrapperTool> - <Isolated>False</Isolated> - </COMReference> - </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> \ No newline at end of file
--- a/PdfViewAndPrint/PdfViewAndPrint/Properties/AssemblyInfo.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 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("PdfViewAndPrint")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PdfViewAndPrint")] -[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)] - -//In order to begin building localizable applications, set -//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file -//inside a <PropertyGroup>. For example, if you are using US english -//in your source files, set the <UICulture> to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// 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")]
--- a/PdfViewAndPrint/PdfViewAndPrint/Properties/Resources.Designer.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.17379 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace PdfViewAndPrint.Properties -{ - - - /// <summary> - /// A strongly-typed resource class, for looking up localized strings, etc. - /// </summary> - // 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", "4.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() - { - } - - /// <summary> - /// Returns the cached ResourceManager instance used by this class. - /// </summary> - [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("PdfViewAndPrint.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// <summary> - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// </summary> - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/Properties/Resources.resx Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -<?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.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: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" type="xsd:string" /> - <xsd:attribute name="type" type="xsd:string" /> - <xsd:attribute name="mimetype" type="xsd:string" /> - </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" msdata:Ordinal="1" /> - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> - </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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> - <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> -</root> \ No newline at end of file
--- a/PdfViewAndPrint/PdfViewAndPrint/Properties/Settings.Designer.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.17379 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace PdfViewAndPrint.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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; - } - } - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/Properties/Settings.settings Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> - <Profiles> - <Profile Name="(Default)" /> - </Profiles> - <Settings /> -</SettingsFile> \ No newline at end of file
--- a/PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.Designer.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -namespace PdfViewAndPrint -{ - partial class WinFormsUserControl - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WinFormsUserControl)); - this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF(); - ((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).BeginInit(); - this.SuspendLayout(); - // - // axAcroPDF1 - // - this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill; - this.axAcroPDF1.Enabled = true; - this.axAcroPDF1.Location = new System.Drawing.Point(0, 0); - this.axAcroPDF1.Name = "axAcroPDF1"; - this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState"))); - this.axAcroPDF1.Size = new System.Drawing.Size(150, 150); - this.axAcroPDF1.TabIndex = 0; - // - // WinFormsUserControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.axAcroPDF1); - this.Name = "WinFormsUserControl"; - this.Load += new System.EventHandler(this.WinFormsUserControl_Load); - ((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private AxAcroPDFLib.AxAcroPDF axAcroPDF1; - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.cs Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace PdfViewAndPrint -{ - public partial class WinFormsUserControl : UserControl - { - public WinFormsUserControl() - { - InitializeComponent(); - } - - private void WinFormsUserControl_Load(object sender, EventArgs e) - { - - } - - public void LoadPdf(string pdfFilePath) - { - try - { - this.axAcroPDF1.LoadFile(pdfFilePath); - } - catch (Exception e) - { - OnNotify(e.Message); - } - } - - - #region Event code to pass messages back to WPF - - public delegate void NotifyEventHandler(object sender, NotifyEventArgs e); - public event NotifyEventHandler Notification; - protected void OnNotify(string message) - { - if (Notification != null) - Notification(this, new NotifyEventArgs() {Message = message}); - } - - #endregion - - } - - public class NotifyEventArgs : EventArgs - { - public string Message { get; set; } - } -}
--- a/PdfViewAndPrint/PdfViewAndPrint/WinFormsUserControl.resx Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -<?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> - <data name="axAcroPDF1.OcxState" mimetype="application/x-microsoft.net.object.binary.base64"> - <value> - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAIQAAAAIB - AAAAAQAAAAAAAAAAAAAAAAwAAAAACQAA2BMAANgTAAAL -</value> - </data> -</root> \ No newline at end of file
--- a/PdfViewAndPrint/clean.bat Tue Apr 03 23:32:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -del /s /ah /f *.suo -del /s /f *.user -del /s /f *.cache -del /s /f *.keep -del /s /ah StyleCop.Cache - -rd /s /q bin obj ClientBin _Resharper.* _Upgrade* TestResults - -del dirs.txt -dir /s /b /ad bin > dirs.txt -dir /s /b /ad obj >> dirs.txt -dir /s /b /ad ClientBin >> dirs.txt -dir /s /b /ad _Resharper.* >> dirs.txt -dir /s /b /ad _Upgrade* >> dirs.txt -dir /s /b /ad TestResults >> dirs.txt - -for /f "delims=;" %%i in (dirs.txt) DO rd /s /q "%%i" -del dirs.txt