Ejemplo n.º 1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            AddService(typeof(NanoDeviceCommService), CreateNanoDeviceCommService);

            // Need to add the View model Locator to the application resource dictionary programatically
            // because at the extension level we don't have 'XAML' access to it
            // try to find if the view model locator is already in the app resources dictionary
            if (System.Windows.Application.Current.TryFindResource("Locator") == null)
            {
                // instantiate the view model locator...
                ViewModelLocator = new ViewModelLocator();

                // ... and add it there
                System.Windows.Application.Current.Resources.Add("Locator", ViewModelLocator);
            }

            ServiceLocator.Current.GetInstance <DeviceExplorerViewModel>().Package = this;

            // need to switch to the main thread to initialize the command handlers
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            DeviceExplorerCommand.Initialize(this, ViewModelLocator, await this.GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService);
            DeployProvider.Initialize(this, ViewModelLocator);

            // Enable debugger UI context
            UIContext.FromUIContextGuid(CorDebug.EngineGuid).IsActive = true;

            await TaskScheduler.Default;

            ServiceLocator.Current.GetInstance <DeviceExplorerViewModel>().NanoDeviceCommService = await this.GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService;

            await base.InitializeAsync(cancellationToken, progress);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static void Initialize(Package package, ViewModelLocator vmLocator, INanoDeviceCommService nanoDeviceCommService)
        {
            Instance = new DeviceExplorerCommand(package);

            Instance.ViewModelLocator      = vmLocator;
            Instance.NanoDeviceCommService = nanoDeviceCommService;

            //windowApp = ();

            Instance.CreateToolbarHandlers();

            // setup message listeners to be notified of events occurring in the View Model
            Messenger.Default.Register <NotificationMessage>(Instance, DeviceExplorerViewModel.MessagingTokens.SelectedNanoDeviceHasChanged, (message) => Instance.SelectedNanoDeviceHasChangedHandler());
            Messenger.Default.Register <NotificationMessage>(Instance, DeviceExplorerViewModel.MessagingTokens.NanoDevicesCollectionHasChanged, (message) => Instance.NanoDevicesCollectionChangedHandler());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static async Task InitializeAsync(AsyncPackage package, ViewModelLocator vmLocator, INanoDeviceCommService nanoDeviceCommService)
        {
            s_instance = new DeviceExplorerCommand(package);

            s_instance.ViewModelLocator      = vmLocator;
            s_instance.NanoDeviceCommService = nanoDeviceCommService;

            //windowApp = ();

            // need to switch to the main thread to initialize the command handlers
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            s_instance.CreateToolbarHandlers();

            // setup message listeners to be notified of events occurring in the View Model
            Messenger.Default.Register <NotificationMessage>(s_instance, DeviceExplorerViewModel.MessagingTokens.SelectedNanoDeviceHasChanged, (message) => s_instance.SelectedNanoDeviceHasChangedHandler());
            Messenger.Default.Register <NotificationMessage>(s_instance, DeviceExplorerViewModel.MessagingTokens.NanoDevicesCollectionHasChanged, (message) => s_instance.NanoDevicesCollectionChangedHandler());
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // make sure "our" key exists and it's writeable
            s_instance.UserRegistryRoot.CreateSubKey(EXTENSION_SUBKEY, true);

            AddService(typeof(NanoDeviceCommService), CreateNanoDeviceCommServiceAsync);

            // Need to add the View model Locator to the application resource dictionary programmatically
            // because at the extension level we don't have 'XAML' access to it
            // try to find if the view model locator is already in the app resources dictionary
            if (System.Windows.Application.Current.TryFindResource("Locator") == null)
            {
                // instantiate the view model locator...
                ViewModelLocator = new ViewModelLocator();

                // ... and add it there
                System.Windows.Application.Current.Resources.Add("Locator", ViewModelLocator);
            }

            SimpleIoc.Default.GetInstance <DeviceExplorerViewModel>().Package = this;

            await MessageCentre.InitializeAsync(this, "nanoFramework Extension");

            await DeviceExplorerCommand.InitializeAsync(this, ViewModelLocator, await GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService);

            DeployProvider.Initialize(this, ViewModelLocator);

            // Enable debugger UI context
            UIContext.FromUIContextGuid(CorDebug.EngineGuid).IsActive = true;

            await TaskScheduler.Default;

            SimpleIoc.Default.GetInstance <DeviceExplorerViewModel>().NanoDeviceCommService = await GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService;

            OutputWelcomeMessage();

            await base.InitializeAsync(cancellationToken, progress);
        }
Ejemplo n.º 5
0
 private void DeviceExplorerControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
 {
     // update the status of the control button
     DeviceExplorerCommand.UpdateShowInternalErrorsButton(NanoFrameworkPackage.OptionShowInternalErrors);
 }