Guest User

Untitled

a guest
May 26th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using Microsoft.Phone.Controls;
  13.  
  14. namespace samples_imap
  15. {
  16.     public partial class samples2 : PhoneApplicationPage
  17.     {
  18.         private bool isShowing = false;
  19.         private MovieList lista;
  20.        
  21.           // Constructor
  22.         public samples2()
  23.         {
  24.             InitializeComponent();
  25.             fillListBox();
  26.         }
  27.         // Constructor
  28.         public void fillListBox()
  29.         {
  30.             lista = new MovieList();
  31.             this.listBoxEmail.ItemsSource = lista;
  32.          
  33.         }
  34.  
  35.         private void btnEcho_Click(object sender, RoutedEventArgs e)
  36.         {
  37.  
  38.         }
  39.        
  40.         private void CheckBox_Checked(object sender, RoutedEventArgs e) {
  41.            
  42.             ListBoxItem checedItem = this.listBoxEmail.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
  43.             if (checedItem != null) {
  44.                 checedItem.IsSelected = true;
  45.              
  46.             }
  47.         } private void CheckBox_Unchecked(object sender, RoutedEventArgs e) {
  48.             ListBoxItem checedItem = this.listBoxEmail.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
  49.             if (checedItem != null) {
  50.                 checedItem.IsSelected = false;
  51.             }
  52.         }
  53.  
  54.         private void listBoxEmail_SelectionChanged(object sender, SelectionChangedEventArgs e)
  55.         {
  56.            
  57.         }
  58.  
  59.         private void stackPanel3_Hold(object sender, GestureEventArgs e)
  60.         {
  61.             for (int i = 0; i < lista.Count; i++)
  62.             {
  63.                
  64.                 ListBoxItem item = this.listBoxEmail.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
  65.                 StackPanel stack = findStackPanelCollapsed<StackPanel>(item);
  66.                
  67.                 var collapsed = ((StackPanel) stack.Children.FirstOrDefault()).Children.FirstOrDefault();
  68.                 if (!this.isShowing)
  69.                 {
  70.                     collapsed.Visibility = System.Windows.Visibility.Visible;
  71.                 }
  72.                 else
  73.                 {
  74.                     collapsed.Visibility = System.Windows.Visibility.Collapsed;
  75.                 }
  76.             }
  77.  
  78.             if (this.isShowing)
  79.             {
  80.                 listBoxEmail.Margin = new Thickness(35, 155, 0, 0);
  81.                 this.isShowing = false;
  82.             }
  83.             else
  84.             {
  85.                 listBoxEmail.Margin = new Thickness(-1, 155, 0, 0);
  86.                 this.isShowing = true;
  87.             }
  88.         }
  89.  
  90.         private T findStackPanelCollapsed<T>(DependencyObject parent) where T : DependencyObject
  91.         {
  92.             var count = VisualTreeHelper.GetChildrenCount(parent);
  93.             if (count == 0)
  94.             {
  95.                 return null;
  96.             }
  97.             else
  98.             {
  99.                 var child = VisualTreeHelper.GetChild(parent, 0);
  100.                
  101.                 if (child != null && child is T)
  102.                 {
  103.                     return (T)child;
  104.                 }
  105.                 else
  106.                 {
  107.                     var result = findStackPanelCollapsed<T>(child);
  108.                     if (result != null)
  109.                     {
  110.                         return result;
  111.                     }
  112.                 }
  113.             }
  114.  
  115.             return null;
  116.         }
  117.  
  118.  
  119.         //private void stackpanel_tap(object sender, gestureeventargs e)
  120.         //{
  121.         //    navigationservice.navigate(new uri(string.format("/mainpage.xaml"), urikind.relativeorabsolute));
  122.         //}
  123.  
  124.     }
  125.  
  126.     public class MovieList : List<Email>
  127.     {
  128.         public MovieList(){
  129.  
  130.             Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
  131.             Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
  132.             Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
  133.             Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
  134.  
  135.         }
  136.     }
  137.  
  138.      public class Email{
  139.         public string Subject { get; set; }
  140.         public string Favoritar { get; set; }
  141.         public string From { get; set; }
  142.         public string pubDate { get; set; }
  143.      }
  144. }
Add Comment
Please, Sign In to add comment