Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF Amazon Explorer Using 3D

, 27 Feb 2008
WPF Amazon Explorer Using 3D
explorer3d.zip
Explorer3D
Explorer3D
3dTools
3DTools.dll
bin
Debug
3DTools.dll
Explorer3D.application
Explorer3D.exe
Explorer3D.exe.manifest
Explorer3D.vshost.application
Explorer3D.vshost.exe
Controls
Explorer3d.csproj.user
Misc Classes
obj
Debug
Controls
TempPE
Properties
app.manifest
Settings.settings
Resources
Amazon.png
arrows.png
banner.png
Favourites.png
Service References
AmazonService
AmazonSearch.wsdl
configuration.svcinfo
Explorer3D.AmazonService.GetTransactionDetailsResponse.datasource
Explorer3D.AmazonService.ListingProductDetails.datasource
Explorer3D.AmazonService.MarketplaceSearch.datasource
Explorer3D.AmazonService.ProductInfo.datasource
Explorer3D.AmazonService.ProductLine.datasource
Explorer3D.AmazonService.SellerProfile.datasource
Explorer3D.AmazonService.SellerSearch.datasource
Explorer3D.AmazonService.ShoppingCart.datasource
Reference.svcmap
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using AmazonService;

namespace Explorer3D
{
    /// <summary>
    /// The event args for the AmazonItem.ItemClickedEvent. These 
    /// RoutedEventArgs expose a single Details (Amazon Item)
    /// which is used by the subscriber of this event to to launch 
    /// an instance of <see cref="FlowDocumentWindow">FlowDocumentWindow
    /// </see> which will show all the contained AmazonItem fields in
    /// a nice FlowDocument.
    /// </summary>
    public class AmazonItemRoutedEventArgs : RoutedEventArgs
    {
        #region properties
        public Details AmazonDetail { get; private set; }
        #endregion

        #region Ctor
        public AmazonItemRoutedEventArgs(RoutedEvent routedEvent, Details amazonDetail) : base(routedEvent)
        {
            this.AmazonDetail = amazonDetail;
        }
        #endregion
    }

    /// <summary>
    /// This UserConrtrol respresents a single item that matched the current query to
    /// Amazon. The user may click on this control, to launch an instance of <see 
    /// cref="FlowDocumentWindow">FlowDocumentWindow</see> which will show all the
    /// contained AmazonItem fields in a nice FlowDocument. This control is also
    /// used as the Material of <see cref="_3dTools.InteractiveVisual3D">
    /// 3d Tools, 3d element that support 2d Visuals</see>
    /// </summary>
    public partial class AmazonItem : UserControl
    {
        #region Instance fields
        public Details AmazonDetail { get; private set; }
        #endregion

        #region Routed Events

        ////the event handler delegate
        public delegate void AmazonItemClickedEventHandler
            (object sender, AmazonItemRoutedEventArgs e);

        /// <summary>
        /// FriendAddedEvent event, occurs when the user clicks the add button
        /// </summary>
        public static readonly RoutedEvent ItemClickedEvent = EventManager.RegisterRoutedEvent(
            "ItemClickedEvent", RoutingStrategy.Bubble, typeof(AmazonItemClickedEventHandler),
            typeof(AmazonItem));

        /// <summary>
        /// Expose the ItemClickedEvent to external sources
        /// </summary>
        public event AmazonItemClickedEventHandler ItemClicked
        {
            add { AddHandler(ItemClickedEvent, value); }
            remove { RemoveHandler(ItemClickedEvent, value); }
        }
        #endregion

        #region Ctors

        public AmazonItem()
        {
            InitializeComponent();

        }

        public AmazonItem(Details amazonDetail)
        {
            InitializeComponent();
            try
            {
                if (amazonDetail != null)
                {
                    AmazonDetail = amazonDetail;

                    if (AmazonDetail.Authors != null)
                        lblAuthor.Content = "Author : " + getShortenedString(AmazonDetail.Authors[0]);
                    lblProductName.Content = "Product Name : " + getShortenedString(AmazonDetail.ProductName);
                    lblReleaseDate.Content = "Release Date : " + getShortenedString(AmazonDetail.ReleaseDate);
                    storedImg.OriginalFileUrl = AmazonDetail.ImageUrlLarge;
                }
            }
            catch 
            {
            }
        }
        #endregion

        #region Private helpers
        private string getShortenedString(string input)
        {
            if (input.Length > 30)
                return input.Substring(0, 30) + "...";
            else
                return input;
        }

        private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (AmazonDetail != null)
            {
                RaiseEvent(new AmazonItemRoutedEventArgs(ItemClickedEvent, AmazonDetail));
            }
        }
        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

| Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 27 Feb 2008
Article Copyright 2008 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid