private static void LoadLanguageResource() { if (TheApp == null) { throw new NullReferenceException("An instance of iApp is required to load language resources."); } Device.Resources.RemoveAllResources(); Device.Resources.AddResources("iFactr.UI.Resources.Strings", Device.Reflector.GetAssembly(typeof(TargetFactory))); Device.Resources.AddResources(Device.Reflector.GetAssembly(TheApp.GetType())); }
public void Middleware_can_wrap_the_response_of_an_application() { IApplication appWithoutMiddleware = new TheApp(); Assert.That(Application.GetResponse(appWithoutMiddleware, new Request()).BodyText, Is.EqualTo("Hello from the app")); IApplication appWithMiddleware = new MiddlewareThatWrapsBody(new TheApp()); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.Not.EqualTo("Hello from the app")); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.EqualTo("WRAPPED Hello from the app By Middleware!")); // another, passing args to constructor because we'll probably do something like this with Owin.Builder ... IMiddleware anotherApp = new MiddlewareThatWrapsBody("BEFORE:", ":AFTER"); anotherApp.InnerApplication = new TheApp(); Assert.That(Application.GetResponse(anotherApp, new Request()).BodyText, Is.EqualTo("BEFORE:Hello from the app:AFTER")); }
private void DesktopWindow_Load(object sender, EventArgs e) { // Add change notification handler and evaluate clean state to start change // notification flow. _theApp.Changed += TrackSelectionState; _theApp.GetAppLayout(); // Add single mashups of the two objects we want to add to the desktop. var visualizations = TheApp.GetSheets().First().Children.ToArray(); var barchart = visualizations.OfType <Barchart>().First(); var piechart = visualizations.OfType <Piechart>().First(); webBrowser1.Navigate(barchart.SingleUrl().Fix()); webBrowser2.Navigate(piechart.SingleUrl().Fix()); }
private void UpdateButtonState() { // Collect forward and back selection counts from the app, and update the // enable status of the buttons accordingly. var countTasks = new[] { TheApp.ForwardCountAsync(), TheApp.BackCountAsync() }; Task.WaitAll(countTasks); var forwardCnt = countTasks[0].Result; var backCnt = countTasks[1].Result; SetEnableStatus(buttonClear, forwardCnt != 0 || backCnt != 0); SetEnableStatus(buttonBack, backCnt != 0); SetEnableStatus(buttonForward, forwardCnt != 0); }
/// <summary> /// Handle opening gbXML file click /// </summary> private void Open_Click(object sender, RoutedEventArgs e) { TheApp.OpenFileCommand(); _viewportControl.ZoomAll(); }
/// <summary> /// Called when an <see cref="IMXController"/> instance has finished loading. /// </summary> /// <param name="fromView">The view that initiated the navigation to the controller.</param> /// <param name="controller">The controller that has finished loading.</param> /// <param name="perspective">The view perspective that was returned from the controller.</param> /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param> protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string perspective, string navigatedUri) { if (perspective == null) { TheApp.OnControllerLoadCanceled(fromView, controller, navigatedUri); return; } var layer = controller as iLayer; var parent = layer; while (layer != null) { var tabs = layer as NavigationTabs; if (tabs != null && tabs.TabItems != null && tabs.TabItems.Count == 0) { throw new NotSupportedException("NavigationTabs must have at least 1 Tab."); } if (layer is FormLayer) { layer.Items.AddRange(((FormLayer)layer).Fieldsets); } if (layer.CompositeParent != null) { layer.CompositeParent.Items.AddRange(layer.Items); } // for backwards compatibility if (layer.Items.FirstOrDefault() is iList || layer.Items.FirstOrDefault() is iPanel) { layer.Layout = LayerLayout.EdgetoEdge; } else if (layer.Items.FirstOrDefault() is iMenu || layer.Items.FirstOrDefault() is iBlock) { layer.Layout = LayerLayout.Rounded; } iLayer navLayer; var nextMapping = layer.CompositeLayerLink == null ? null : App.NavigationMap.MatchUrl(layer.CompositeLayerLink.Address); if (nextMapping == null || (navLayer = nextMapping.Controller as iLayer) == null || !LargeFormFactor) { break; } navLayer.CompositeParent = layer.CompositeParent ?? layer; navLayer.Clear(); var parameters = new Dictionary <string, string>(); nextMapping.ExtractParameters(layer.CompositeLayerLink.Address, parameters); navLayer.Load(navigatedUri, parameters); if (navLayer.ActionButtons.Any()) { navLayer.CompositeParent.ActionButtons = navLayer.ActionButtons; } layer = navLayer; } Thread.ExecuteOnMainThread(() => { if (parent == null) { OutputController(controller, perspective, navigatedUri); } else { parent.LoadComplete(); } }); }
/// <summary> /// Gets the abstracted object from an <see cref="IPairable"/>. /// </summary> /// <param name="pair">The object for which to return the abstract counterpart.</param> protected internal static object GetPair(object pair) { var pairable = pair as IPairable; if (pairable == null) { return(pair); } return((TheApp != null && Device.Reflector.GetAssembly(pair.GetType()) == Device.Reflector.GetAssembly(TheApp.GetType())) ? pair : pairable.Pair ?? pair); }
private void ButtonForward_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => TheApp.Forward()); }
private void ButtonBack_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => TheApp.Back()); }
private void ButtonClear_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => TheApp.ClearAll()); }