public void StateTransfersOnlyChangedValues() { ResetComet(); const string textValue = "Hello"; var orgView = new MyOrgView(); var orgText = orgView.GetView() as Text; Assert.NotEqual(orgView.bindingObject.Title, textValue); orgView.bindingObject.Title = textValue; Assert.Equal(textValue, orgText.Value); //IsEnabled is defaulted to true. Assert.True(orgView.bindingObject.IsEnabled); HotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView)); HotReloadHelper.TriggerReload(); var newText = orgView.GetView() as Text; Assert.NotNull(newText); var v = orgView.GetReplacedView(); var newView = v as MyNewView; Assert.IsType <MyNewView>(v); Assert.NotNull(newView); Assert.False(newView.bindingObject.IsEnabled); Assert.Equal(textValue, newView.bindingObject.Title); }
public static void ResetHotUI() { var v = new View(); v.ResetGlobalEnvironment(); v.DisposeAllViews(); HotReloadHelper.Reset(); v?.Dispose(); }
public static void ResetComet() { var v = new View(); v.ResetGlobalEnvironment(); v.DisposeAllViews(); UI.Init(true); HotReloadHelper.Reset(); v?.Dispose(); }
public void HotReloadRegisterReplacedViewReplacesView() { var orgView = new MyOrgView(); var orgText = orgView.GetView() as Text; Assert.Equal(MyOrgView.TextValue, orgText.Value.CurrentValue); HotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView)); var newText = orgView.GetView() as Text; Assert.Equal(MyNewView.TextValue, newText.Value.CurrentValue); }
public MainPage(List <MenuItem> additionalPage = null) { //This is only required since there is a parameter for the view HotReloadHelper.Register(this, additionalPage); if (additionalPage != null) { pages.AddRange(additionalPage); } Body = () => new NavigationView { new ListView <MenuItem> (pages) { Cell = (page) => new NavigationButton(page.Title, page.Page), } }; }
public void StateIsTransferedToReloadedView() { ResetComet(); const string textValue = "Hello"; var orgView = new MyOrgView(); var orgText = orgView.GetView() as Text; Assert.NotEqual(orgView.bindingObject.Title, textValue); orgView.bindingObject.Title = textValue; Assert.Equal(textValue, orgText.Value); HotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView)); var newText = orgView.GetView() as Text; Assert.Equal(textValue, newText.Value); }
public MainPage(List <MenuItem> additionalPage = null) { this.Title("Main Page"); //This is only required since there is a parameter for the view HotReloadHelper.Register(this, additionalPage); if (additionalPage != null) { pages.AddRange(additionalPage); } Body = () => new NavigationView { new ListView <MenuItem> (pages) { Cell = (page) => new HStack() { new Text(page.Title), new Spacer() }.Frame(height: 44).Padding(left: 10), }.OnSelected(page => Navigation.PerformNavigate(page.Page?.Invoke()?.Title(page.Title))) }; }
public MainPage(IGame game, IPixelMapper pixelMapper, ITrackParameters trackParameters, OrderedList <ITool> tools, OrderedList <ILayerRenderer> layers, OrderedList <ICommand> commands) { HotReloadHelper.Register(this, game, pixelMapper, trackParameters, tools, layers); this.Title("Trains.NET"); var controlDelegate = new TrainsDelegate(game, pixelMapper); this.Body = () => { return(new HStack() { new VStack() { new ToggleButton("Configuration", _configurationShown, () => _configurationShown.Value = !_configurationShown.Value), new Spacer(), _configurationShown ? CreateConfigurationControls(trackParameters, layers) : CreateToolsControls(tools, controlDelegate), new Spacer(), _configurationShown ? null : CreateCommandControls(commands), new Spacer() }.Frame(100, alignment: Alignment.Top), new DrawableControl(controlDelegate).FillVertical() }.FillHorizontal()); }; _timer = new Timer((state) => { ThreadHelper.Run(async() => { await ThreadHelper.SwitchToMainThreadAsync(); controlDelegate.Invalidate(); }); }, null, 0, 16); }
public MainPage(List <MenuItem> additionalPage = null) { //This is only required since there is a parameter for the view HotReloadHelper.Register(this, additionalPage); if (additionalPage != null) { pages.AddRange(additionalPage); } this.Title("UI Samples"); Body = () => new NavigationView { new ListView <MenuItem> (pages) { ViewFor = (page) => new HStack() { new Text(page.Title), new Spacer() }.Frame(height: 44).Padding(left: 10), }.OnSelectedNavigate(page => page.Page().Title(page.Title)) }; }
public MainPage(IGame game, IPixelMapper pixelMapper, IEnumerable <ITool> tools) { HotReloadHelper.Register(this, game); this.Title("Trains.NET"); this.Body = () => { var controlsPanel = new VStack(); var controlDelegate = new TrainsDelegate(game, pixelMapper); foreach (ITool tool in tools) { controlsPanel.Add(new Button(tool.Name, () => controlDelegate.CurrentTool = tool)); } return(new HStack() { controlsPanel.Frame(100), new DrawableControl(controlDelegate).FillVertical() }.FillHorizontal()); }; }
public MyOrgView(string text) { HotReloadHelper.Register(this, text); this.Body = () => new Text(text); }
public MyNewView1(string text = TextValue) { HotReloadHelper.Register(this, text); this.Body = () => new Text(text); }