file360

Log | Files | Refs

Dialog.cs (2126B)


      1 using System;
      2 using System.Collections.Generic;
      3 using System.Linq;
      4 using System.Text;
      5 using System.Threading.Tasks;
      6 using Windows.UI;
      7 using Windows.UI.Xaml;
      8 using Windows.UI.Xaml.Controls;
      9 using Windows.UI.Xaml.Controls.Primitives;
     10 using Windows.UI.Xaml.Media;
     11 using Windows.UI.Xaml.Media.Animation;
     12 
     13 namespace File360
     14 {
     15     public class Dialog : Grid
     16     {
     17         Storyboard OpenDialog = new Storyboard();
     18         Storyboard CloseDialog = new Storyboard();
     19         public Dialog()
     20         {
     21             Height = Window.Current.Bounds.Height;
     22             Width = Window.Current.Bounds.Width;
     23             Window.Current.SizeChanged += CurrentSizeChanged;
     24             Background = new SolidColorBrush((Color)Application.Current.Resources["ContentDialogDimmingColor"]);
     25             FadeInThemeAnimation fadeInAnimation = new FadeInThemeAnimation();
     26 
     27             Storyboard.SetTarget(fadeInAnimation, this);
     28             OpenDialog.Children.Add(fadeInAnimation);
     29 
     30 
     31             FadeOutThemeAnimation fadeOutAnimation = new FadeOutThemeAnimation();
     32 
     33             Storyboard.SetTarget(fadeOutAnimation, this);
     34             CloseDialog.Children.Add(fadeOutAnimation);
     35 
     36         }
     37         
     38         public bool IsOpen
     39         {
     40             get 
     41             {
     42                 if (Visibility == Visibility.Collapsed)
     43                     return false;
     44                 else return true;
     45             }
     46             set
     47             {
     48                 if (value == true)
     49                 {
     50                     Visibility = Visibility.Visible;
     51                     OpenDialog.Begin();
     52                 }
     53                 else
     54                 {
     55 
     56                     CloseDialog.Begin();
     57                     CloseDialog.Completed += (s, f) =>
     58                     {
     59                         Visibility = Visibility.Collapsed;
     60                     };
     61                 }
     62             }
     63         }
     64 
     65         private void CurrentSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
     66         {
     67             Height = Window.Current.Bounds.Height;
     68             Width = Window.Current.Bounds.Width;
     69             this.UpdateLayout();
     70         }
     71     }
     72 }