Esempio n. 1
0
        /// <summary>
        /// Invoked when the application is activated.
        /// This is the entry point for Device Autoplay when a device is attached to the PC.
        /// Other activation kinds (such as search and protocol activation) may also be handled here.
        /// </summary>
        /// <param name="args">Details about the activation request.</param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.Device)
            {
                Frame rootFrame = null;
                if (Window.Current.Content == null)
                {
                    rootFrame = new Frame();
                    rootFrame.Navigate(typeof(MainPage));
                    Window.Current.Content = rootFrame;
                }
                else
                {
                    rootFrame = Window.Current.Content as Frame;
                }
                Window.Current.Activate();
                MainPage mainPage = (MainPage)rootFrame.Content as MainPage;

                // Launched from Autoplay for device, receiving the device information identifier.
                DeviceActivatedEventArgs deviceArgs = args as DeviceActivatedEventArgs;
                mainPage.AutoplayNonFileSystemDeviceId = deviceArgs.DeviceInformationId;

                // Clear any saved drive or file so we always use the latest connected device
                mainPage.AutoplayFileSystemDeviceFolder = null;
                mainPage.FileActivationFiles            = null;

                // Select the Autoplay scenario
                mainPage.LoadAutoplayScenario();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked when the application is launched to open a specific file or to access
        /// specific content. This is the entry point for Content Autoplay when camera
        /// memory is attached to the PC.
        /// </summary>
        /// <param name="args">Details about the file activation request.</param>
        protected override void OnFileActivated(FileActivatedEventArgs args)
        {
            Frame rootFrame = null;

            if (Window.Current.Content == null)
            {
                rootFrame = new Frame();
                rootFrame.Navigate(typeof(MainPage));
                Window.Current.Content = rootFrame;
            }
            else
            {
                rootFrame = Window.Current.Content as Frame;
            }
            Window.Current.Activate();
            MainPage mainPage = (MainPage)rootFrame.Content as MainPage;

            // Clear any device id so we always use the latest connected device
            mainPage.AutoplayNonFileSystemDeviceId = null;

            if (args.Verb == "storageDevice")
            {
                // Launched from Autoplay for content. This will return a single storage folder
                // representing that file system device.
                mainPage.AutoplayFileSystemDeviceFolder = args.Files[0] as StorageFolder;
                mainPage.FileActivationFiles            = null;
            }
            else
            {
                // Launched to handle a file type.  This will return a list of image files that the user
                // requests for this application to handle.
                mainPage.FileActivationFiles            = args.Files;
                mainPage.AutoplayFileSystemDeviceFolder = null;
            }

            // Select the Autoplay scenario
            mainPage.LoadAutoplayScenario();
        }