|
1 | 1 | # XamarinForms.VisualDebugger
|
2 | 2 |
|
3 |
| -A library and client app to view the visual heirarchy of your Xamarin app pages as an interactive tree diagram |
| 3 | +A library and client app to view the visual heirarchy of your Xamarin app pages as an interactive tree diagram at runtime |
4 | 4 |
|
5 | 5 | 
|
| 6 | + |
| 7 | +# Getting Started |
| 8 | + |
| 9 | +Install the XamarinForms.VisualDebug Nuget packages into your Core AND platform specific projects |
| 10 | + |
| 11 | +```sh |
| 12 | +Install-Package XamarinForms.VisualDebug -Version 0.0.1 |
| 13 | +dotnet add package XamarinForms.VisualDebug --version 0.0.1 |
| 14 | +``` |
| 15 | + |
| 16 | +## Core project |
| 17 | + |
| 18 | +For the simplest use case in App.xaml.cs include the following |
| 19 | + |
| 20 | +```c# |
| 21 | + public App() |
| 22 | + { |
| 23 | + InitializeComponent(); |
| 24 | + |
| 25 | + MainPage = new NavigationPage(new MainPage()); |
| 26 | + |
| 27 | + //Add this line |
| 28 | + Current.PageAppearing += Current_PageAppearing; |
| 29 | + } |
| 30 | + |
| 31 | + private static XamarinForms.VisualDebug.Core.Sender Sender = new XamarinForms.VisualDebug.Core.Sender(); |
| 32 | + |
| 33 | + private void Current_PageAppearing(object sender, Page e) |
| 34 | + { |
| 35 | + var rep = XamarinForms.VisualDebug.Core.TreeRenderer.RenderVisualHeirarchyToJson(e); |
| 36 | + |
| 37 | + System.Threading.Tasks.Task.Run(async () => |
| 38 | + { |
| 39 | + var response = await Sender.SendToServer(rep).ConfigureAwait(false); |
| 40 | + if (response.IsSuccessStatusCode) |
| 41 | + { |
| 42 | + Console.WriteLine("Success!"); |
| 43 | + } |
| 44 | + else |
| 45 | + { |
| 46 | + Console.WriteLine(response.ReasonPhrase); |
| 47 | + } |
| 48 | + }); |
| 49 | + } |
| 50 | +``` |
| 51 | + |
| 52 | +## iOS |
| 53 | + |
| 54 | +Add the following line to FinishedLaunching in AppDelegate.cs somehwher after the Xamarin.Forms.Forms.Init call |
| 55 | + |
| 56 | +```c# |
| 57 | + XamarinForms.VisualDebug.iOS.VisualDebug.Init(); |
| 58 | +``` |
| 59 | + |
| 60 | +## Android |
| 61 | + |
| 62 | +Add the following line to FinishedLaunching in AppDelegate.cs somehwher after the Xamarin.Forms.Forms.Init call |
| 63 | + |
| 64 | +```c# |
| 65 | + XamarinForms.VisualDebug.Droid.VisualDebug.Init(); |
| 66 | +``` |
| 67 | + |
| 68 | +## Electron app |
| 69 | + |
| 70 | +Run the client before starting the simluator/emulator for your Xamarin app |
| 71 | + |
| 72 | +```sh |
| 73 | +$ cd XamarinForms.VisualDebug.App |
| 74 | +# Install dependencies |
| 75 | +$ npm install |
| 76 | +# Run the app |
| 77 | +$ npm start |
| 78 | +``` |
0 commit comments