ContinuationManager is used to detect if the most recent activation was due to a continuation such as the FileOpenPicker or WebAuthenticationBroker
示例#1
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            Debug.WriteLine("First line");
            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();

            await RestoreStatusAsync(e.PreviousExecutionState);

            Debug.WriteLine("Second line");

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                Frame appFrame = Window.Current.Content as Frame;
                if (appFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, appFrame);
                }
            }
            Debug.WriteLine("Third line");

            Window.Current.Activate();
        }
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();

            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = MainPage.Current.FindName("ScenarioFrame") as Frame;
                if (scenarioFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            Window.Current.Activate();
        }
示例#3
0
 /// <summary>
 /// Initializes the singleton instance of the <see cref="App"/> class. This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     // Hook up suspention manager
     this.Suspending    += this.OnSuspending;
     ContinuationManager = new ContinuationManager();
 }
示例#4
0
    public void ReportBug(string body)
    {
        JSONNode node = new JSONClass();

        Debug.Log("Sending issue...");

        node["body"] = body;
        node["name"] = LocalUserInfo.Me.ClientCharacter.Name;

        byte[] rawdata = Encoding.UTF8.GetBytes(node.ToString());

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("Content-Type", "application/json");
        headers.Add("Cookie", CookiesManager.Instance.GetCookiesString());

        WWW req = new WWW(Config.BASE_URL + "/issues/create", rawdata, headers);

        // show the logs only in the editor
        #if UNITY_EDITOR
        ContinuationManager.Add(() => req.isDone, () =>
        {
            if (!string.IsNullOrEmpty(req.error))
            {
                Debug.Log("WWW failed: " + req.error);
            }
            Debug.Log("WWW result : " + req.text);
        });
        #endif
    }
示例#5
0
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = Window.Current.Content as Frame;
                if (scenarioFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            Window.Current.Activate();
        }
示例#6
0
    static void UpdateFromSpreadsheet()
    {
        UnityDataConnector conn = GameObject.Find("ConnectionExample").GetComponent <UnityDataConnector>();

        string connectionString = conn.webServiceUrl + "?ssid=" + conn.spreadsheetId + "&sheet=" + conn.worksheetName + "&pass="******"&action=GetData";

        Debug.Log("Connecting to webservice on " + connectionString);

        WWW www = new WWW(connectionString);

        ContinuationManager.Add(() => www.isDone, () =>
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.Log("WWW failed: " + www.error);
            }

            try
            {
                JsonData[] ssObjects = JsonMapper.ToObject <JsonData[]>(www.text);
                Debug.Log("Data Successfully Retrieved!");
                GameObject dataUseExample = Selection.activeObject as GameObject;
                dataUseExample.GetComponent <AdjustBalls>().DoSomethingWithTheData(ssObjects);
            }
            catch
            {
                Debug.LogError("Data error: could not parse retrieved data as json.");
            }
        }
                                );
    }
示例#7
0
    public static void SubmitBug(string url, string username, string project, string area, string description, string extra, string email, bool forceNewBug = false, int retryCount = 0)
    {
        string bugUrl =
            $"{url}?Description={UnityWebRequest.EscapeURL(description)}&Extra={UnityWebRequest.EscapeURL(extra)}&Email={UnityWebRequest.EscapeURL(email)}&ScoutUserName={UnityWebRequest.EscapeURL(username)}&ScoutProject={UnityWebRequest.EscapeURL(project)}&ScoutArea={UnityWebRequest.EscapeURL(area)}&ForceNewBug={(forceNewBug ? "1" : "0")}";

        var form           = new WWWForm();
        var request        = UnityWebRequest.Post(url, form);
        var asyncOperation = request.SendWebRequest();

        ContinuationManager.Add(() => asyncOperation.isDone, () =>
        {
            bool success = string.IsNullOrEmpty(request.error);
            if (success)
            {
                DebugLog.Log("Bug successfully reported to the 'Unity Version Control' FogBugz database.");
            }
            else
            {
                if (retryCount <= maxRetryCount)
                {
                    SubmitBug(url, username, project, area, description, extra, email, forceNewBug, ++retryCount);
                }
                else
                {
                    DebugLog.LogError("Bug report failed:\n" + request.error);
                }
            }
        });
    }
示例#8
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();

            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            if (e.Kind == ActivationKind.VoiceCommand)
            {
                //if (!((Frame)Window.Current.Content).Navigate(typeof(NordicUART), "Nordic Uart"))
                //{
                //}
                VoiceControlHandler.HandleCommand(e, rootFrame);
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                continuationManager.Continue(continuationEventArgs, rootFrame);
            }
            Window.Current.Activate();
        }
示例#9
0
    public WWW GET(string url, Dictionary <string, string> headers, IRequestListener requestListener)
    {
        WWW www = new WWW(url, null, headers);

        ContinuationManager.Add(() => www.isDone, () => WaitForRequest(www, requestListener));
        return(www);
    }
示例#10
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(weibo_loginPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs, rootFrame);
            }

            Window.Current.Activate();
        }
    public static void SubmitBug(string url, string username, string project, string area, string description, string extra, string email, bool forceNewBug = false, int retryCount = 0)
    {
        string bugUrl = string.Format("{0}?Description={1}&Extra={2}&Email={3}&ScoutUserName={4}&ScoutProject={5}&ScoutArea={6}&ForceNewBug={7}",
                                      url,
                                      WWW.EscapeURL(description),
                                      WWW.EscapeURL(extra),
                                      WWW.EscapeURL(email),
                                      WWW.EscapeURL(username),
                                      WWW.EscapeURL(project),
                                      WWW.EscapeURL(area),
                                      (forceNewBug ? "1" : "0")
                                      );

        var www = new WWW(bugUrl);

        ContinuationManager.Add(() => www.isDone, () =>
        {
            bool success = string.IsNullOrEmpty(www.error) && www.text.Contains("<Success>");
            if (success)
            {
                DebugLog.Log("Bug successfully reported to the 'Unity Version Control' FogBugz database.");
            }
            else
            {
                if (retryCount <= maxRetryCount)
                {
                    SubmitBug(url, username, project, area, description, extra, email, forceNewBug, ++retryCount);
                }
                else
                {
                    DebugLog.LogError("Bug report failed:\n" + www.error);
                }
            }
        });
    }
示例#12
0
    public static void Get(string url, string type, CsvParseRegime regime, string postfix)
    {
        EditorUtility.DisplayProgressBar("Loading", "Requesting csv file. Please wait...", 0f);
        Debug.Log("Loading csv from: " + url);
        var www = new WWW(url);

        ContinuationManager.Add(() => {
            EditorUtility.DisplayProgressBar("Loading", "Requesting csv file. Please wait...", www.progress);
            return(www.isDone);
        },
                                () => {
            EditorUtility.ClearProgressBar();

            // Let's parse this CSV!
            TextReader sr = new StringReader(www.text);
            try {
                if (regime == CsvParseRegime.ObjectPerRow)
                {
                    ParseCsv2(sr, type, postfix);
                }
                else
                {
                    ParseCsv_Sopog(sr, type, postfix);
                }
            }
            catch (Exception ex) {
                Debug.LogException(ex);
            }
        });
    }
示例#13
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            ContinuationManager = new ContinuationManager();
            ContinuationManager.Continue(args as IContinuationActivatedEventArgs);
        }
    public static void Init()
    {
        UpdateManager manager = (UpdateManager)EditorWindow.GetWindow(typeof(UpdateManager));

        manager.invoice         = PlayerPrefs.GetString("AIInvoice", string.Empty);
        manager.checkForUpdates = PlayerPrefs.GetInt("checkForUpdates", 1) > 0 ? true : false;
        if (!string.IsNullOrEmpty(manager.invoice))
        {
            manager.loading = true;
            WWWForm form = new WWWForm();
            form.AddField("invoice", manager.invoice);
            var www = new WWW("http://zerano-unity3d.com/checkUpdates.php", form);

            ContinuationManager.Add(() => www.isDone, () =>
            {
                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.Log("WWW failed: " + www.error);
                }

                if (!www.text.Trim().Equals("false"))
                {
                    string[] all     = www.text.Split(',');
                    manager.examples = new List <string> (all);
                    PlayerPrefs.SetString("AIInvoice", manager.invoice);
                    manager.hasIncoice = true;
                    PlayerPrefs.SetString("AIUpdate", System.DateTime.Today.ToString());
                }
                manager.loading = false;
            });
        }
    }
示例#15
0
        /// <summary>
        /// Initializes the singleton application object. This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += this.OnSuspending;

            #if WINDOWS_PHONE_APP
            ContinuationManager = new ContinuationManager();
            #endif
        }
示例#16
0
        /// <summary>
        /// On activated callback. It is used in order to continue the application
        /// after the user authenticated.
        /// </summary>
        protected override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            var continuationManager   = new ContinuationManager();
            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                continuationManager.Continue(continuationEventArgs);
            }
            Window.Current.Activate();
        }
示例#17
0
    public WWW POST(string url, byte[] data, Dictionary <string, string> headers, IRequestListener requestListener)
    {
        // Force post
        if (data == null)
        {
            data = Encoding.UTF8.GetBytes(" ");
        }
        WWW www = new WWW(url, data, headers);

        ContinuationManager.Add(() => www.isDone, () => WaitForRequest(www, requestListener));

        return(www);
    }
示例#18
0
        public void TestEditorWWW()
        {
#if UNITY_EDITOR
            var www = new WWW("https://tile.mapzen.com/mapzen/vector/v1//buildings,landuse,water,roads/17/70076/48701.json");

            ContinuationManager.Add(() => www.isDone, () => {
                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.Log("WWW failed: " + www.error);
                }
                Debug.Log("[GOMap Editor] Request success: " + www.text);
            });
#endif
        }
示例#19
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            continuationManager = new ContinuationManager();

            // Activated again due to continuation?
            var contEventArgs = args as IContinuationActivatedEventArgs;

            if (contEventArgs != null)
            {
                continuationManager.Continue(contEventArgs);
            }

            base.OnActivated(args);
        }
示例#20
0
    public static void ShowWindow(string startProduct)
    {
        RDExtensionWindow window;

        window = GetWindow <RDExtensionWindow>();
        Texture2D icon = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Shared/RogoDigital_Icon.png");

        window.titleContent = new GUIContent("Extensions", icon);

        ContinuationManager.Add(() => window.gotListing, () => {
            if (window.headerLinks.Contains(startProduct))
            {
                window.currentFilter = window.headerLinks.IndexOf(startProduct);
            }
        });
    }
示例#21
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            continuationManager = new ContinuationManager();
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                // Restore the saved session state only when appropriate
                try
                {
                    await SuspensionManager.RestoreAsync();
                }
                catch (SuspensionManagerException)
                {
                    //Something went wrong restoring state.
                    //Assume there is no state and continue
                }
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
示例#22
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            var rootFrame           = _frame;
            var continuationManager = new ContinuationManager();

            var continuationEventArgs = args as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                if (rootFrame != null)
                {
                    continuationManager.Continue(continuationEventArgs, rootFrame);
                }
            }
        }
    private void DownloadItem(ItemListing listing, bool silentInstall = false)
    {
        downloading = true;
#if UNITY_2018_3_OR_NEWER
        downloadConnection = UnityWebRequest.Get(baseAddress + listing.url);
        downloadConnection.SendWebRequest();
#else
        downloadConnection = new WWW(baseAddress + listing.url);
#endif
        currentExtension = listing.name;

        ContinuationManager.Add(() => downloadConnection.isDone, () =>
        {
            if (downloading)
            {
                downloading = false;
                if (!string.IsNullOrEmpty(downloadConnection.error))
                {
                    Debug.LogError(downloadConnection.error);
                    ShowNotification(new GUIContent(currentExtension + " - Download Failed"));
                }
                else if (downloadConnection.isDone)
                {
#if UNITY_2018_3_OR_NEWER
                    File.WriteAllBytes(Application.dataPath + "/" + currentExtension + ".unitypackage", downloadConnection.downloadHandler.data);
#else
                    File.WriteAllBytes(Application.dataPath + "/" + currentExtension + ".unitypackage", downloadConnection.bytes);
#endif
                    if (!silentInstall)
                    {
                        ShowNotification(new GUIContent(currentExtension + " Downloaded"));
                    }
                    AssetDatabase.ImportPackage(Application.dataPath + "/" + currentExtension + ".unitypackage", !silentInstall);
                    File.Delete(Application.dataPath + "/" + currentExtension + ".unitypackage");
                    if (silentInstall)
                    {
                        Close();
                    }
                }
                else
                {
                    ShowNotification(new GUIContent(currentExtension + " Download Cancelled"));
                }
            }
        });
    }
示例#24
0
        public IEnumerator TestEditorUnityWebRequest()
        {
#if UNITY_EDITOR
            var www = UnityWebRequest.Get("https://tile.nextzen.org/tilezen/vector/v1/all/17/70076/48701.json");
            yield return(www.SendWebRequest());

            ContinuationManager.Add(() => www.isDone, () =>
            {
                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.Log("UnityWebRequest failed: " + www.error);
                }
                Debug.Log("[GOMap Editor] Request success: " + www.downloadHandler.text);
            });
#endif
            yield return(null);
        }
示例#25
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            var rootFrame = await this.CreateRootFrameAsync(args.PreviousExecutionState);

            var continuationEventArgs = args as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                // Call ContinuationManager to handle continuation activation.
                continuationManager = new ContinuationManager();
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
        private void StartClientPipeline(object obj, string methodName, ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(obj, "obj");
            Assert.ArgumentNotNullOrEmpty(methodName, "methodName");
            Assert.ArgumentNotNull((object)args, "args");
            ContinuationManager   current = ContinuationManager.Current;
            ISupportsContinuation @object = obj as ISupportsContinuation;

            if (current != null && @object != null)
            {
                current.Start(@object, methodName, args);
            }
            else
            {
                Context.ClientPage.Start(obj, methodName, args);
            }
        }
示例#27
0
        /// <summary>
        // Handle protocol activations and continuation activations.
        /// </summary>
        protected override void OnActivated(IActivatedEventArgs e)
        {
            if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs protocolArgs = e as ProtocolActivatedEventArgs;
                Frame rootFrame = CreateRootFrame();
                RestoreStatus(e.PreviousExecutionState);

                if (rootFrame.Content == null)
                {
                    if (!rootFrame.Navigate(typeof(MainPage)))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }

                var p = rootFrame.Content as MainPage;
                p.FileEvent     = null;
                p.ProtocolEvent = protocolArgs;
                p.NavigateToProtocolPage();

                // Ensure the current window is active
                Window.Current.Activate();
            }
#if WINDOWS_PHONE_APP
            else if (e.Kind == ActivationKind.PickFileContinuation)
            {
                base.OnActivated(e);

                var continuationEventArgs = e as IContinuationActivatedEventArgs;
                if (continuationEventArgs != null)
                {
                    CreateRootFrame();
                    RestoreStatus(e.PreviousExecutionState);

                    Frame scenarioFrame = MainPage.Current.FindName("ScenarioFrame") as Frame;
                    if (scenarioFrame != null)
                    {
                        continuationManager = new ContinuationManager();
                        continuationManager.Continue(continuationEventArgs, scenarioFrame);
                    }
                }
            }
#endif
        }
示例#28
0
        /// <summary>
        /// Download and import asset store package.
        /// </summary>
        public void DownloadAndImportPackage(string downloadURL, bool runningInBatchMode)
        {
            tempPackagePath = FileUtil.GetUniqueTempPathInProject();

            StartPackageDownload(downloadURL);

            m_DownloadTimeout = DateTime.UtcNow.AddSeconds(k_DownloadTimeoutInSeconds);

            ContinuationManager.Add(
                () => File.Exists(tempPackagePath) || DownloadTimeExpired(),
                () => {
                if (File.Exists(tempPackagePath))
                {
                    AssetDatabase.ImportPackage(tempPackagePath, !runningInBatchMode);
                }
            }
                );
        }
示例#29
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            // ContinuationManager tells app how to respond from Web Authentication.
            ContinuationManager = new ContinuationManager();

            var continuationEventArgs = args as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = Window.Current.Content as Frame;
                if (scenarioFrame != null)
                {
                    ContinuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            base.OnActivated(args);
        }
    public static void RequestInstall(string name)
    {
        var       window = GetWindow <RDExtensionWindow>();
        Texture2D icon   = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Shared/RogoDigital_Icon.png");

        window.titleContent = new GUIContent("Extensions", icon);

        ContinuationManager.Add(() => window.connectionsInProgress == 0, () =>
        {
            for (int i = 0; i < window.itemsAlpha.Count; i++)
            {
                if (window.itemsAlpha[i].name == name)
                {
                    window.DownloadItem(window.itemsAlpha[i], true);
                }
            }
        });
    }
示例#31
0
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            ClientPipelineArgs args = new ClientPipelineArgs();

            args.Parameters["entryids"] = context.Parameters["entryids"];

            ContinuationManager current = ContinuationManager.Current;

            if (current != null)
            {
                current.Start(this, "Run", args);
            }
            else
            {
                Context.ClientPage.Start(this, "Run", args);
            }
        }
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            ContinuationManager = new ContinuationManager();
            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(args.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = args as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                // Call ContinuationManager to handle continuation activation
                ContinuationManager.Continue(continuationEventArgs, rootFrame);
            }

            Window.Current.Activate();
        }
示例#33
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {            
            base.OnActivated(args);
#if WINDOWS_PHONE_APP            
            Frame rootFrame = Window.Current.Content as Frame;
            if (rootFrame == null)
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //await SuspensionManager.RestoreAsync(); //disabling this until we can find a way to not trap users on the SettingsPage.
            }

            var continuationEventArgs = args as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {                
                if(rootFrame.CurrentSourcePageType != typeof(MainPage))
                {
                    rootFrame.Navigate(typeof(MainPage));
                }
                ContinuationManager manager = new ContinuationManager();
                manager.Continue(continuationEventArgs, rootFrame);
            }
#endif            
        }
示例#34
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            // ContinuationManager tells app how to respond from Web Authentication.
            ContinuationManager = new ContinuationManager();

            var continuationEventArgs = args as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = Window.Current.Content as Frame;
                if (scenarioFrame != null)
                {
                    ContinuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            base.OnActivated(args);
        }
示例#35
0
文件: App.xaml.cs 项目: ckc/WinApp
        /// <summary>
        // Handle protocol activations and continuation activations.
        /// </summary>
        protected override void OnActivated(IActivatedEventArgs e)
        {
            if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs protocolArgs = e as ProtocolActivatedEventArgs;
                Frame rootFrame = CreateRootFrame();
                RestoreStatus(e.PreviousExecutionState);

                if (rootFrame.Content == null)
                {
                    if (!rootFrame.Navigate(typeof(MainPage)))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }

                var p = rootFrame.Content as MainPage;
                p.FileEvent = null;
                p.ProtocolEvent = protocolArgs;
                p.NavigateToProtocolPage();

                // Ensure the current window is active
                Window.Current.Activate();
            }
#if WINDOWS_PHONE_APP
            else if (e.Kind == ActivationKind.PickFileContinuation)
            {
                base.OnActivated(e);

                var continuationEventArgs = e as IContinuationActivatedEventArgs;
                if (continuationEventArgs != null)
                {
                    CreateRootFrame();
                    RestoreStatus(e.PreviousExecutionState);

                    Frame scenarioFrame = MainPage.Current.FindName("ScenarioFrame") as Frame;
                    if (scenarioFrame != null)
                    {
                        continuationManager = new ContinuationManager();
                        continuationManager.Continue(continuationEventArgs, scenarioFrame);
                    }
                }
            }
#endif
        }
示例#36
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                if (!rootFrame.Navigate(typeof(UrlToolkit.View.MainView)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                // TODO: Normalde burada register edilmiş frame'i alıp onu continue fonksiyonuna gönderiyor.
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
示例#37
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += this.OnSuspending;
     ContinuationManager = new ContinuationManager();
 }
示例#38
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {            
            if (e.Kind.Equals(ActivationKind.PickFileContinuation))
            {
               
                base.OnActivated(e);

                ContinuationManager = new ContinuationManager();

                Frame rootFrame = CreateRootFrame();
                await RestoreStatusAsync(e.PreviousExecutionState);

                if (rootFrame.Content == null)
                {

                    rootFrame.Navigate(typeof(OptionsPage));
                }

                var continuationEventArgs = e as IContinuationActivatedEventArgs;

                if (continuationEventArgs != null)
                {
                    Frame scenarioFrame = OptionsPage.Current.FindName("ScenarioFrame") as Frame;

                    if (scenarioFrame != null)
                    {
                        // Call ContinuationManager to handle continuation activation
                        // pass the frame that it is the options page
                        ContinuationManager.Continue(continuationEventArgs, scenarioFrame);
                    }

                }
                
                Window.Current.Activate();

            }
            else {
                
            }
           
        }
示例#39
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = Window.Current.Content as Frame;
                if (scenarioFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            Window.Current.Activate();
        }
示例#40
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = await CreateRootFrameAndRestore(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(PivotPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                continuationManager.Continue(continuationEventArgs, PivotPage.Current.Frame);
            }
        }
示例#41
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            Debug.WriteLine("First line");
            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(e.PreviousExecutionState);
            Debug.WriteLine("Second line");

            if(rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                Frame appFrame = Window.Current.Content as Frame;
                if (appFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, appFrame);
                }
            }
            Debug.WriteLine("Third line");

            Window.Current.Activate();
        }
示例#42
0
        /// <summary>
        /// Handle OnActivated event to deal with File Open/Save continuation activation kinds
        /// </summary>
        /// <param name="e">Application activated event arguments, it can be casted to proper sub-type based on ActivationKind</param>
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(LoginPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
示例#43
0
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(IndexPivotPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            FileOpenPickerContinuationEventArgs arguments = continuationEventArgs as FileOpenPickerContinuationEventArgs;

            if (continuationEventArgs != null)
            {
                switch (continuationEventArgs.Kind)
                {
                    case ActivationKind.PickFileContinuation:

                        //string passedData = (string)arguments.ContinuationData["keyParameter"];
                        StorageFile pickedFile = arguments.Files.FirstOrDefault();

                        CardSet pickedCardSet = await new DataLoader().LoadFrom_StorageFile(pickedFile);

                        userSetManager.AddNewCardSet(pickedCardSet);

                        appWideUserSet = userSetManager.UserSet as UserSet;

                        break;
                }
            }
                        //var continuationEventArgs = e as IContinuationActivatedEventArgs;
             

            if (continuationEventArgs != null)
            {
                
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            if (continuationEventArgs != null)
            {
                Frame scenarioFrame = MainPage.Current.FindName("ContentFrame") as Frame;
                if (scenarioFrame != null)
                {
                    // Call ContinuationManager to handle continuation activation
                    continuationManager.Continue(continuationEventArgs, scenarioFrame);
                }
            }

            Window.Current.Activate();
        }
示例#45
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            continuationManager = new ContinuationManager();

            var continuationEventArgs = args as IContinuationActivatedEventArgs;
            if (continuationEventArgs == null)
                return;

            var frame = Window.Current.Content as Frame;
            if (frame != null)
            {
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs, frame);
            }
        }