예제 #1
0
 public static object Load(this IXamlLoader loader, string xml, object instance)
 {
     using (var stream = xml.FromUTF8ToStream())
     {
         return(loader.Load(stream, instance));
     }
 }
예제 #2
0
        public ConnectionPage(DesignServer server, IXamlLoader xamlLoader, ITypeFinder typeFinder, IGetDesignerVersion version)
        {
            _server     = server;
            _xamlLoader = xamlLoader;
            _typeFinder = typeFinder;
            _version    = version;

            _mainLayout = new StackLayout
            {
                Padding     = new Thickness(10),
                Spacing     = 5,
                Orientation = StackOrientation.Vertical
            };

            _disconnectBtn = new Button
            {
                Text              = "Disconnect",
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
            };

            _continueBtn = new Button
            {
                Text              = "Design Surface",
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
            };

            _acceptingConnections = new Label
            {
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor = Color.White,
                Text      = $"Ready!\nNow accepting connections to:\n{_server.ListeningOn}",
                FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
            };

            _status = new Label
            {
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = "Listening..."
            };

            _toolboxConnected = new Label
            {
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                Text     = "A toolbox is connected.\nYou can close the connection or continue to the design surface.",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
            };

            _continueBtn.Clicked += async(s, e) => await ShowDesignSurfaceAsync();

            _disconnectBtn.Clicked += (s, e) => OnDisconnect();

            RegisterServerEventHandlers();

            Content = _mainLayout;

            if (Device.OS == TargetPlatform.Android)
            {
                BackgroundImage = "background.png";
            }
            else
            {
                BackgroundColor = Color.White;
                _acceptingConnections.TextColor = Color.Black;
                _status.TextColor           = Color.Black;
                _toolboxConnected.TextColor = Color.Black;
            }

            StartAcceptingConnections();
        }