Represents an Amazon product Used to populate the data grid.
Пример #1
0
        /// <summary>
        /// Double clicking a result item will attempt to open the item's URL
        /// in whatever program they have associated with URLs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            // If the user is clicking the scrollbar (the arrow
            // or the "thumb"), don't attempt to open an item in the browser
            IInputElement element = e.MouseDevice.DirectlyOver;

            if (element != null && element is FrameworkElement)
            {
                var elementType = element.GetType();

                if (elementType == typeof(System.Windows.Controls.Primitives.RepeatButton) ||
                    elementType == typeof(System.Windows.Controls.Primitives.Thumb))
                {
                    return;
                }
            }

            if (ResultGrid.SelectedItem == null)
            {
                return;
            }
            AmazonItem item = ResultGrid.SelectedItem as AmazonItem;

            if (item.URL == null)
            {
                MessageBox.Show("The item's URL cannot be parsed.");
                return;
            }
            OpenWebpage(item.URL.ToString());
        }
Пример #2
0
        /// <summary>
        /// Obtains the selected result item's URL and attempts to open
        /// the user's default web browser to that page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenInBrowser_Click(object sender, RoutedEventArgs e)
        {
            AmazonItem item = ((FrameworkElement)sender).DataContext as AmazonItem;

            if (item.URL == null)
            {
                MessageBox.Show("The item's URL cannot be parsed.");
                return;
            }
            OpenWebpage(item.URL.ToString());
        }
Пример #3
0
 /// <summary>
 /// Takes a validated result and adds it to the datagrid
 /// </summary>
 /// <param name="result"></param>
 void AddResultToGrid(AmazonItem result)
 {
     if (result == null) return;
     // Add results to the data grid as soon as they are available
         try
         { ResultGrid.Items.Add(result); }
         catch
         {
             string msg = "Error adding item to the result grid: " +
                 result.ToString();
             Debug.WriteLine(msg);
         }
 }
Пример #4
0
 /// <summary>
 /// Takes a validated result and adds it to the datagrid
 /// </summary>
 /// <param name="result"></param>
 void AddResultToGrid(AmazonItem result)
 {
     if (result == null)
     {
         return;
     }
     // Add results to the data grid as soon as they are available
     try
     { ResultGrid.Items.Add(result); }
     catch
     {
         string msg = "Error adding item to the result grid: " +
                      result.ToString();
         Debug.WriteLine(msg);
     }
 }