Ejemplo n.º 1
0
        public EventStatsGrid()
        {
            InitializeComponent();
            this.DataContextChanged += StatsWindow_DataContextChanged;
            this.loadingAdorner      = new LoadingAdorner(this.statsGrid, "Loading Stats");
            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.statsGrid);

            adornerLayer.Add(loadingAdorner);
        }
Ejemplo n.º 2
0
 private static LoadingAdorner ChangeOverlayInternal(Window window, bool newShowFlag, OverlayType overlayType)
 {
     if (newShowFlag)
     {
         if (overlayType == OverlayType.Loading)
         {
             AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer((Visual)window.Content);
             if (adornerLayer != null)
             {
                 var loadingAdorner = new LoadingAdorner(adornerLayer);
                 adornerLayer.Add(loadingAdorner);
                 return(loadingAdorner);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        private void AttachLoadingAdorner(UIElement view, ExplorerViewModel viewModel)
        {
            LoadingAdorner loading = new LoadingAdorner(view);

            //We can set font information and text.
            loading.FontSize      = 14;
            loading.OverlayedText = "Please Wait! Extracting folders/files information from Selected Drive.";
            loading.Typeface      = new Typeface(new FontFamily("Arial"), FontStyles.Italic, FontWeights.Bold, FontStretches.Normal);

            Binding bind = new Binding();

            bind.Source    = viewModel;
            bind.Path      = new PropertyPath("Isbusy");
            bind.Converter = new VisibilityConverter();
            loading.SetBinding(LoadingAdorner.VisibilityProperty, bind);
            System.Windows.Documents.AdornerLayer.GetAdornerLayer(view).Add(loading);
        }
Ejemplo n.º 4
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Setup adorner for the grid.
            this.loadingAdorner = new LoadingAdorner(this.eventsGrid,
                                                     "Press F5 or Enter in the Source Filter box to refresh grid");
            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.eventsGrid);

            adornerLayer.Add(loadingAdorner);
            this.loadingAdorner.Visibility = System.Windows.Visibility.Visible;

            // Setup help for the main window.
            HelpProvider.OnHelp += this.CommandBinding_Help;

            this.EventTimeline.DataContext    = this.TimelineModel;
            this.Spinny.DataContext           = this.Model;
            this.eventsGrid.DataContext       = this.EventsModel;
            this.eventsGrid.OnCellCopy       += new Action <string, EventRecordProxy>(eventsGrid_OnCellCopy);
            this.eventsGrid.OnRangeSelected  += new Action <TimeSpan, TimeSpan>(eventsGrid_OnRangeSelected);
            this.eventsGrid.OnSelectInterval += new Action <TimeSpan, TimeSpan>(eventsGrid_OnSelectInterval);
            this.Model.PropertyChanged       += Model_PropertyChanged;

            // FindCommand Setup
            this.Model.FindNextCommand.CanExecuteTargets += () => this.EventsModel.HasEvents;
            this.Model.FindNextCommand.ExecuteTargets    += (o) =>
            {
                this.FilterModel.Mode = FilterMode.Search;
                this.SearchText(this.FilterModel.FilterText.Trim());
            };

            this.filterbox.DataContext                     = this.FilterModel;
            this.KeywordFilterListBox.DataContext          = this.FilterModel;
            this.ProviderFilterListBox.DataContext         = this.FilterModel;
            this.FilterModel.FilterCommand.ExecuteTargets += FilterCommand_ExecuteTargets;
            this.FilterModel.PropertyChanged              += FilterModel_PropertyChanged;
            this.SetupEventStats();
            this.SetupQueryCommand();
            this.SetupPlugins();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _adorner = new LoadingAdorner(this);

            Binding isLoadingBinding = new Binding("IsLoading");

            isLoadingBinding.Source = RootModel;
            _adorner.SetBinding(LoadingAdorner.IsLoadingProperty, isLoadingBinding);

            Loaded += delegate
            {
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);
                if (layer != null)
                {
                    layer.Add(_adorner);
                }

                RaiseEvent(new ProgressRoutedEventArgs(ProgressEvent, new ProgressEventArgs(0, "DirectoryTree Loaded",
                                                                                            WorkType.Unknown, WorkStatusType.wsCompleted, WorkResultType.wrSuccess)));
            };
        }
Ejemplo n.º 6
0
        //public static void ShowLoading(this UIElement element, bool isAutoClose=false)
        //{
        //    ShowLoading(element, string.Empty, string.Empty, 60, HorizontalAlignment.Center, VerticalAlignment.Center, null, null, false, Brushes.Gray, null);
        //    Task.Factory.StartNew(() =>
        //    {
        //        Task.Delay(10 * 1000);
        //        if (element == null || element.Dispatcher == null) return;
        //        element.Dispatcher.BeginInvoke(new Action(() => { element.HideLoading(); }));
        //    });
        //}

        //public static void UpdateLoading(this UIElement element, string Percent = "", string LoadingName = "")
        //{
        //    ShowLoading(element, Percent, LoadingName, 60, HorizontalAlignment.Center, VerticalAlignment.Center, null, null, false, Brushes.Gray, null);
        //}

        public static void HideLoading(this UIElement element, bool disableElement = false)
        {
            if (element == null || element.Dispatcher == null)
            {
                return;
            }
            if (element.Dispatcher.CheckAccess())
            {
                element.IsEnabled        = !disableElement;
                element.IsHitTestVisible = true;
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(element);
                if (layer == null)
                {
                    var win = element as Window;
                    if (win != null && win.Content != null && win.Content is UIElement)
                    {
                        element = win.Content as UIElement;
                        layer   = AdornerLayer.GetAdornerLayer(element);
                    }
                    else if (element is FrameworkElement)
                    {
                        FrameworkElement fe = element as FrameworkElement;
                        if (!fe.IsLoaded)
                        {
                            lock (list)
                            {
                                ShowLoadingContext target = null;
                                foreach (var p in list)
                                {
                                    if (p.Target == fe)
                                    {
                                        target = p;
                                        break;
                                    }
                                }

                                if (target != null)
                                {
                                    list.Remove(target);
                                }
                            }

                            fe.Loaded -= OnFrameworkElementLoaded;
                            return;
                        }
                    }
                }

                if (layer != null)
                {
                    LoadingAdorner target = null;
                    var            items  = layer.GetAdorners(element);
                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            if (item is LoadingAdorner)
                            {
                                target = item as LoadingAdorner;
                                if (target != null)
                                {
                                    layer.Remove(target);
                                    target.Dispose();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Action <UIElement, Boolean> action = HideLoading;
                element.Dispatcher.BeginInvoke(action, element, disableElement);
            }
        }
Ejemplo n.º 7
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Setup adorner for the grid.
            this.loadingAdorner = new LoadingAdorner(this.eventsGrid,
                "Press F5 or Enter in the Source Filter box to refresh grid");
            AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.eventsGrid);
            adornerLayer.Add(loadingAdorner);
            this.loadingAdorner.Visibility = System.Windows.Visibility.Visible;

            // Setup help for the main window.
            HelpProvider.OnHelp += this.CommandBinding_Help;

            this.EventTimeline.DataContext = this.TimelineModel;
            this.Spinny.DataContext = this.Model;
            this.eventsGrid.DataContext = this.EventsModel;
            this.eventsGrid.OnCellCopy += new Action<string, EventRecordProxy>(eventsGrid_OnCellCopy);
            this.eventsGrid.OnRangeSelected += new Action<TimeSpan, TimeSpan>(eventsGrid_OnRangeSelected);
            this.eventsGrid.OnSelectInterval += new Action<TimeSpan, TimeSpan>(eventsGrid_OnSelectInterval);
            this.Model.PropertyChanged += Model_PropertyChanged;

            // FindCommand Setup
            this.Model.FindNextCommand.CanExecuteTargets += () => this.EventsModel.HasEvents;
            this.Model.FindNextCommand.ExecuteTargets += (o) =>
                {
                    this.FilterModel.Mode = FilterMode.Search;
                    this.SearchText(this.FilterModel.FilterText.Trim());
                };

            this.filterbox.DataContext = this.FilterModel;
            this.KeywordFilterListBox.DataContext = this.FilterModel;
            this.ProviderFilterListBox.DataContext = this.FilterModel;
            this.FilterModel.FilterCommand.ExecuteTargets += FilterCommand_ExecuteTargets;
            this.FilterModel.PropertyChanged += FilterModel_PropertyChanged;
            this.SetupEventStats();
            this.SetupQueryCommand();
            this.SetupPlugins();
        }
Ejemplo n.º 8
0
 private void RemoveLoadingAdorner()
 {
     if (_loadingAdorner != null)
     {
         _loadingAdorner.Visibility = Visibility.Hidden;
         AdornerLayer layer = AdornerLayer.GetAdornerLayer(PrimaryGrid);
         layer.Remove(_loadingAdorner);
         _loadingAdorner = null;
     }
 }
Ejemplo n.º 9
0
 private LoadingAdorner GetLoadingAdorner()
 {
     if (_loadingAdorner == null)
     {
         _loadingAdorner = new LoadingAdorner(PrimaryGrid);
         AdornerLayer layer = AdornerLayer.GetAdornerLayer(PrimaryGrid);
         layer.Add(_loadingAdorner);
     }
     return _loadingAdorner;
 }