/// <summary> /// Process the given <see cref="NavigationResponse"/> instance /// </summary> /// <param name="response"></param> void INavigationHandler.ProcessResponse(NavigationResponse response) { // basic check if (response == null) { throw new ArgumentNullException("response"); } // we check if the navigation was successfull or not if (response.Status != ResponseStatus.Success) { this.PublishNavigationFailedInfo(response.Request); IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>(); showMessageService.ButtonSetup = DialogButton.Ok; showMessageService.Caption = "Chronos - Error en la navegación"; showMessageService.Text = ((response.Error != null) ? response.Error.Message : String.Format("No ha sido posible resolver la navegación solicitada ({0})", response.Request.RequestUrl)); showMessageService.ShowMessage(); } else { Application.Current.Dispatcher.BeginInvoke ( DispatcherPriority.Background, new ThreadStart ( () => { WindowElement window = response.Content as WindowElement; if (response.ResponseParameters != null && response.ResponseParameters.Count > 0) { ISupportNavigationLifecycle supporter = nRoute.Navigation.NavigationService.GetSupporter <ISupportNavigationLifecycle>(response.Content); if (supporter != null) { supporter.Initialize(response.ResponseParameters); } } this.PublishNavigatedInfo(window.Title, response); if (response.Request.NavigationMode == NavigateMode.Modal) { ServiceLocator.GetService <IVirtualDesktopManager>().ShowDialog(window); } else { ServiceLocator.GetService <IVirtualDesktopManager>().Show(window); } } ) ); } }
/// <summary> /// Performs the navigation to the given target /// </summary> /// <param name="target"></param> public void Navigate(NavigateMode mode, string target, params object[] args) { if (String.IsNullOrEmpty(target)) { IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>(); showMessageService.ButtonSetup = DialogButton.Ok; showMessageService.Caption = "Warning"; showMessageService.Text = "Option not mapped to a view."; showMessageService.ShowMessage(); return; } Application.Current.Dispatcher.BeginInvoke ( DispatcherPriority.Background, new ThreadStart ( delegate { ParametersCollection navParams = null; string area = null; if (args != null && args.Length > 0) { navParams = new ParametersCollection(); navParams.Add(NavigationParams.NavigationParamsKey, args); } var smnode = SiteMapService.SiteMap.RootNode.ChildNodes .OfType <NavigationNode>() .Traverse <NavigationNode>(node => ((node.ChildNodes) != null ? node.ChildNodes.OfType <NavigationNode>() : null)) .Where(n => n.Url == target).SingleOrDefault(); if (smnode != null) { area = smnode.SiteArea; } NavigationRequest request = new NavigationRequest(target, navParams, area, mode); IDisposable navigationToken = nRoute.Navigation.NavigationService.Navigate(request); if (navigationToken != null) { navigationToken.Dispose(); navigationToken = null; } } ) ); }
private static void SaveFile(string filename, XElement xElement) { try { xElement.Save(filename); } catch (Exception) { IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>(); showMessageService.ButtonSetup = DialogButton.Ok; showMessageService.Caption = "Chronos - Error al guardar el estado del escritorio"; showMessageService.Text = "No ha sido posible al guardar el estado del escritorio."; showMessageService.ShowMessage(); } }
private static XElement LoadFromFile(string filename) { try { if (File.Exists(filename)) { return(XElement.Load(filename)); } } catch (Exception) { IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>(); showMessageService.ButtonSetup = DialogButton.Ok; showMessageService.Caption = "Chronos - Error en la carga del escritorio"; showMessageService.Text = "No ha sido posible realizar la carga del escritorio."; showMessageService.ShowMessage(); } return(null); }
/// <summary> /// Gets the requested view service. /// </summary> /// <typeparam name="TViewService">The type of the view service.</typeparam> /// <returns></returns> protected TViewService GetViewService <TViewService>() where TViewService : class { return(ViewServiceLocator.GetViewService <TViewService>()); }