Beispiel #1
0
        protected override void Invoke(object parameter)
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            var viewmodel = this.AssociatedObject.DataContext as DemoBrowserViewModel;

            if (viewmodel == null)
            {
                return;
            }

            if ((viewmodel.SelectedProduct != null && viewmodel.SelectedProduct.DemoLauchMode == DemoLauchMode.Window) ||
                (viewmodel.SelectedSample != null && viewmodel.SelectedSample.DemoLauchMode == DemoLauchMode.Window))
            {
                try
                {
                    if (viewmodel.SelectedSample.ShowBusyIndicator)
                    {
                        viewmodel.IsProductDemoBusy = true;
                    }
                    var window = DemoLaucherExtension.LauchDemo <Window>(viewmodel, viewmodel.SelectedSample);
                    DemosNavigationService.MainWindow.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        viewmodel.IsProductDemoBusy = false;
                    }),
                                                                             System.Windows.Threading.DispatcherPriority.ApplicationIdle);

                    if (window != null)
                    {
                        window.Title = viewmodel.SelectedSample.Title;
                        window.Owner = DemosNavigationService.MainWindow;
                        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        window.Closed += Window_Closed;
                        window.ShowDialog();
                    }
                }
                catch (Exception exception)
                {
                    viewmodel.IsProductDemoBusy = false;
                    ErrorWindow.Show(exception.Message + "\n" + exception.StackTrace);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs when the selection of show case demos
        /// </summary>
        private void ShowcaseList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListView listView = sender as ListView;

            if (listView != null && listView.SelectedItem is DemoInfo && sampleBrowserViewModel != null)
            {
                try
                {
                    DemoInfo demo = listView.SelectedItem as DemoInfo;
                    if (demo.ShowBusyIndicator)
                    {
                        sampleBrowserViewModel.IsShowCaseDemoBusy = true;
                    }
                    var window = Activator.CreateInstance(demo.DemoViewType) as Window;
                    AssociatedObject.ShowcaseList.SelectedItem = null;

                    DemosNavigationService.MainWindow.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sampleBrowserViewModel.IsShowCaseDemoBusy = false;
                    }),
                                                                             System.Windows.Threading.DispatcherPriority.ApplicationIdle);

                    if (window != null)
                    {
                        window.Owner = DemosNavigationService.MainWindow;
                        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        window.Closed += Window_Closed;
                        window.ShowDialog();
                    }
                }
                catch (Exception exception)
                {
                    sampleBrowserViewModel.IsShowCaseDemoBusy = false;
                    ErrorWindow.Show(exception.Message + "\n" + exception.StackTrace);
                }
            }
        }