public ModuleTracker(ILoggerFacade logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.logger = logger;

            // These states are defined specifically for the Silverlight version of the quickstart.
            this.moduleATrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleA,
                ExpectedDiscoveryMethod    = DiscoveryMethod.ApplicationReference,
                ExpectedInitializationMode = InitializationMode.WhenAvailable,
                ExpectedDownloadTiming     = DownloadTiming.WithApplication,
                ConfiguredDependencies     = WellKnownModuleNames.ModuleD,
            };

            this.moduleBTrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleB,
                ExpectedDiscoveryMethod    = DiscoveryMethod.XamlManifest,
                ExpectedInitializationMode = InitializationMode.WhenAvailable,
                ExpectedDownloadTiming     = DownloadTiming.InBackground,
            };
            this.moduleCTrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleC,
                ExpectedDiscoveryMethod    = DiscoveryMethod.ApplicationReference,
                ExpectedInitializationMode = InitializationMode.OnDemand,
                ExpectedDownloadTiming     = DownloadTiming.WithApplication,
            };
            this.moduleDTrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleD,
                ExpectedDiscoveryMethod    = DiscoveryMethod.XamlManifest,
                ExpectedInitializationMode = InitializationMode.WhenAvailable,
                ExpectedDownloadTiming     = DownloadTiming.InBackground,
            };
            this.moduleETrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleE,
                ExpectedDiscoveryMethod    = DiscoveryMethod.XamlManifest,
                ExpectedInitializationMode = InitializationMode.OnDemand,
                ExpectedDownloadTiming     = DownloadTiming.InBackground,
            };
            this.moduleFTrackingState = new ModuleTrackingState
            {
                ModuleName = WellKnownModuleNames.ModuleF,
                ExpectedDiscoveryMethod    = DiscoveryMethod.XamlManifest,
                ExpectedInitializationMode = InitializationMode.OnDemand,
                ExpectedDownloadTiming     = DownloadTiming.InBackground,
                ConfiguredDependencies     = WellKnownModuleNames.ModuleE,
            };
        }
Exemple #2
0
        public ModuleTracker(ILoggerFacade logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.logger = logger;

            // These states are defined specifically for the Silverlight version of the quickstart.
            this.moduleATrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleA,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.ApplicationReference,
                                         ExpectedInitializationMode = InitializationMode.WhenAvailable,
                                         ExpectedDownloadTiming = DownloadTiming.WithApplication,
                                         ConfiguredDependencies = WellKnownModuleNames.ModuleD,
                                     };

            this.moduleBTrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleB,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.XamlManifest,
                                         ExpectedInitializationMode = InitializationMode.WhenAvailable,
                                         ExpectedDownloadTiming = DownloadTiming.InBackground,
                                     };
            this.moduleCTrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleC,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.ApplicationReference,
                                         ExpectedInitializationMode = InitializationMode.OnDemand,
                                         ExpectedDownloadTiming = DownloadTiming.WithApplication,
                                     };
            this.moduleDTrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleD,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.XamlManifest,
                                         ExpectedInitializationMode = InitializationMode.WhenAvailable,
                                         ExpectedDownloadTiming = DownloadTiming.InBackground,
                                     };
            this.moduleETrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleE,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.XamlManifest,
                                         ExpectedInitializationMode = InitializationMode.OnDemand,
                                         ExpectedDownloadTiming = DownloadTiming.InBackground,
                                     };
            this.moduleFTrackingState = new ModuleTrackingState
                                     {
                                         ModuleName = WellKnownModuleNames.ModuleF,
                                         ExpectedDiscoveryMethod = DiscoveryMethod.XamlManifest,
                                         ExpectedInitializationMode = InitializationMode.OnDemand,
                                         ExpectedDownloadTiming = DownloadTiming.InBackground,
                                         ConfiguredDependencies = WellKnownModuleNames.ModuleE,
                                     };
        }
        /// <summary>
        /// Records the module has been constructed.
        /// </summary>
        /// <param name="moduleName">The <see cref="WellKnownModuleNames">well-known name</see> of the module.</param>
        public void RecordModuleConstructed(string moduleName)
        {
            ModuleTrackingState moduleTrackingState = this.GetModuleTrackingState(moduleName);

            if (moduleTrackingState != null)
            {
                moduleTrackingState.ModuleInitializationStatus = ModuleInitializationStatus.Constructed;
            }

            this.logger.Log(string.Format("'{0}' module constructed.", moduleName), Category.Debug, Priority.Low);
        }
Exemple #4
0
        private void ContentControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.UpdateClickToLoadTextBlockVisibility();
            this.UpdateLoadProgressTextBlockVisibility();

            ModuleTrackingState moduleTrackingState = this.DataContext as ModuleTrackingState;

            if (moduleTrackingState != null)
            {
                moduleTrackingState.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ModuleTrackingState_PropertyChanged);
            }
        }
Exemple #5
0
        /// <summary>
        /// Called before the <see cref="E:System.Windows.UIElement.MouseLeftButtonUp"/> event occurs.
        /// </summary>
        /// <param name="e">The data for the event.</param>
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);

            if (!e.Handled)
            {
                ModuleTrackingState moduleTrackingState = this.DataContext as ModuleTrackingState;
                if ((moduleTrackingState != null) && (moduleTrackingState.ExpectedInitializationMode == InitializationMode.OnDemand) && (moduleTrackingState.ModuleInitializationStatus == ModuleInitializationStatus.NotStarted))
                {
                    this.RaiseRequestModuleLoad();
                    e.Handled = true;
                }
            }
        }
Exemple #6
0
        private void UpdateLoadProgressTextBlockVisibility()
        {
            ModuleTrackingState moduleTrackingState = this.DataContext as ModuleTrackingState;

            if ((moduleTrackingState != null) &&
                (moduleTrackingState.ExpectedDownloadTiming == DownloadTiming.InBackground) &&
                (moduleTrackingState.ModuleInitializationStatus == ModuleInitializationStatus.Downloading))
            {
                this.LoadProgressPanel.Visibility = Visibility.Visible;
            }
            else
            {
                this.LoadProgressPanel.Visibility = Visibility.Collapsed;
            }
        }
Exemple #7
0
        private void UpdateClickToLoadTextBlockVisibility()
        {
            ModuleTrackingState moduleTrackingState = this.DataContext as ModuleTrackingState;

            if ((moduleTrackingState != null) &&
                (moduleTrackingState.ExpectedInitializationMode == InitializationMode.OnDemand) &&
                (moduleTrackingState.ModuleInitializationStatus == ModuleInitializationStatus.NotStarted))
            {
                this.ClickToLoadTextBlock.Visibility = Visibility.Visible;
            }
            else
            {
                this.ClickToLoadTextBlock.Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Records the module is loading.
        /// </summary>
        /// <param name="moduleName">The <see cref="WellKnownModuleNames">well-known name</see> of the module.</param>
        /// <param name="bytesReceived">The number of bytes downloaded.</param>
        public void RecordModuleDownloading(string moduleName, long bytesReceived, long totalBytesToReceive)
        {
            ModuleTrackingState moduleTrackingState = this.GetModuleTrackingState(moduleName);

            if (moduleTrackingState != null)
            {
                moduleTrackingState.BytesReceived       = bytesReceived;
                moduleTrackingState.TotalBytesToReceive = totalBytesToReceive;

                if (bytesReceived < totalBytesToReceive)
                {
                    moduleTrackingState.ModuleInitializationStatus = ModuleInitializationStatus.Downloading;
                }
                else
                {
                    moduleTrackingState.ModuleInitializationStatus = ModuleInitializationStatus.Downloaded;
                }
            }

            this.logger.Log(string.Format("'{0}' module is loading {1}/{2} bytes.", moduleName, bytesReceived, totalBytesToReceive), Category.Debug, Priority.Low);
        }