示例#1
0
        private async void UpdateManager_XamlUpdated(object sender, PageNotificationEventArgs e)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(this.DisposalToken);

            _outputPane.OutputString($"The page '{e.PageId}' received a new xaml.");
            _outputPane.OutputString(Environment.NewLine);

            System.Diagnostics.Debug.WriteLine($"The page '{e.PageId}' received a new xaml.");
        }
示例#2
0
        private async void UpdateManager_PageAppeared(object sender, PageNotificationEventArgs e)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(this.DisposalToken);

            _outputPane.OutputString($"The page '{e.PageId}' is now visible.");
            _outputPane.OutputString(Environment.NewLine);

            System.Diagnostics.Debug.WriteLine($"The page '{e.PageId}' is now visible.");

            try
            {
                EnvDTE.ProjectItem appPi = _dte.Solution.FindProjectItem("App.xaml");
                if (appPi != null)
                {
                    foreach (ProjectItem pi in appPi.ContainingProject.ProjectItems)
                    {
                        if (!pi.Name.Contains(".xaml"))
                        {
                            continue;
                        }

                        string     fileName = pi.FileNames[0];
                        XDocument  xdoc     = XDocument.Load(fileName);
                        XNamespace xnsp     = "http://schemas.microsoft.com/winfx/2009/xaml";
                        string     pageId   = xdoc.Root.Attribute(xnsp + "Class").Value;
                        if (pageId != e.PageId)
                        {
                            continue;
                        }

                        var    document  = pi.Document;
                        string localPath = pi.Properties.Item("LocalPath").Value?.ToString();
                        string xaml      = System.IO.File.ReadAllText(localPath);

                        await UpdateManager.Current.SendXamlAsync(pageId, xaml, false);
                    }
                }
            }
            catch (Exception ex)
            {
                _outputPane.OutputString($"Something went wrong! RealXaml was unable to send the xaml.");
                _outputPane.OutputString(Environment.NewLine);
                _outputPane.OutputString(ex.ToString());
                _outputPane.OutputString(Environment.NewLine);

                System.Diagnostics.Debug.WriteLine("Something went wrong! RealXaml was unable to send the xaml.");
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }