void closeDialog(NavigationContext context) { currentBackgroundTask = null; var screenMgr = ServiceRegistration.Get<IScreenManager>(); if (screenMgr.TopmostDialogInstanceId == context.DialogInstanceId) screenMgr.CloseTopmostDialog(); }
public bool CanEnterState(NavigationContext oldContext, NavigationContext newContext) { lock (syncObject) { return currentBackgroundTask == null; } }
protected static ItemsList UpdateNavigationItems(NavigationContext context) { try { ItemsList navigationItems = GetOrCreateNavigationItems(context); Stack<NavigationContext> contextStack = ServiceRegistration.Get<IWorkflowManager>().NavigationContextStack; List<NavigationContext> contexts = new List<NavigationContext>(contextStack); contexts.Reverse(); navigationItems.Clear(); bool first = true; foreach (NavigationContext ctx in contexts) { ListItem item = new ListItem(KEY_NAME, ctx.DisplayLabel); item.AdditionalProperties[KEY_ISFIRST] = first; NavigationContext contextCopy = ctx; item.Command = new MethodDelegateCommand(() => WorkflowPopToState(contextCopy.WorkflowState.StateId)); first = false; navigationItems.Add(item); } navigationItems.FireChange(); return navigationItems; } catch (Exception e) { ServiceRegistration.Get<ILogger>().Warn("WorkflowNavigationBar: Error updating properties", e); return null; } }
public void EnterModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { _messageQueue.Start(); // when entering OV model context and no siteutils have been loaded yet - run Automatic Update // todo : let the user configure if he wants to run the AutoUpdate or be asked, configure x hours before doing/asking again if (!OnlineVideoSettings.Instance.IsSiteUtilsListBuilt()) { if (_settingsWatcher.Settings.LastAutomaticUpdate.AddHours(4) < DateTime.Now && OnlineVideos.Sites.Updater.VersionCompatible) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePushAsync(Guids.DialogStateSiteUpdate); } else { // show the busy indicator, because loading site dlls takes some seconds ServiceRegistration.Get <ISuperLayerManager>().ShowBusyScreen(); try { OnlineVideoSettings.Instance.BuildSiteUtilsList(); RebuildSitesList(); } catch (Exception ex) { Log.Error(ex); } finally { ServiceRegistration.Get <ISuperLayerManager>().HideBusyScreen(); } } } }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { // reset the properties UpdateInfo = string.Empty; UpdateProgress = 0; // start the update in a background thread RunUpdate(newContext); }
public void EnterModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { // reset the properties UpdateInfo = string.Empty; UpdateProgress = 0; // start the update in a background thread RunUpdate(newContext); }
bool getParameters(NavigationContext context) { game = null; object gameObject; if (!context.ContextVariables.TryGetValue(KEY_GAME, out gameObject)) return false; game = gameObject as Game; return game != null; }
protected static ItemsList GetOrCreateNavigationItems(NavigationContext context) { lock (context.SyncRoot) { ItemsList result = GetNavigationItems(context); if (result == null) context.ContextVariables[NAVIGATION_ITEMS_KEY] = result = new ItemsList(); return result; } }
protected override void DoTask(NavigationContext context) { if (!getParameters(context)) return; SetProgress("Launching " + game.Title, 0); launcher = new GameLauncher(game); launcher.ExtractionProgress += (s, e) => SetProgress(string.Format("Extracting {0}%", e.Percent), e.Percent); launcher.Starting += (s, e) => SetProgress("Launching...", 50); launcher.Exited += launcher_Exited; launcher.Launch(); }
/// <summary> /// This constructor has to be called from the component managing the navigation context stack. /// </summary> public NavigationContext(WorkflowState workflowState, string displayLabel, NavigationContext predecessor, IWorkflowModel workflowModel) { _workflowState = workflowState; _displayLabel = displayLabel; _predecessor = predecessor; if (workflowModel != null) { _workflowModelId = workflowModel.ModelId; _models.Add(workflowModel.ModelId, workflowModel); } }
public void ExitModelContext(NavigationContext oldContext, NavigationContext newContext) { // set a flag to stop the update if the thread is still running lock (syncObject) { if (currentBackgroundTask != null) currentBackgroundTask.State = WorkState.CANCELED; } // wait until the update background thread has ended while (currentBackgroundTask != null) { System.Threading.Thread.Sleep(20); } }
public bool IsActionEnabled(NavigationContext context) { if (context.WorkflowModelId == Guids.WorkFlowModelOV) { if (!BackgroundTask.Instance.IsExecuting) { if (context.WorkflowState.Name == Guids.WorkflowStateCategoriesName || context.WorkflowState.StateId == Guids.WorkflowStateVideos) { return ((OnlineVideosWorkflowModel)context.Models[context.WorkflowModelId.Value]).SelectedSite.Site.CanSearch; } } } return false; }
public void ExitModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { // set a flag to stop the update if the thread is still running lock (syncObject) { if (currentBackgroundTask != null) { currentBackgroundTask.State = WorkState.CANCELED; } } // wait until the update background thread has ended while (currentBackgroundTask != null) { System.Threading.Thread.Sleep(20); } }
protected override void DoTask(NavigationContext context) { if (!getParameters(context)) return; SetProgress(string.Format("Looking up {0}", platformStr), 0); var platform = importer.GetPlatformByName(platformStr); if (platform != null) { SetProgress(string.Format("Retrieving info for {0}", platform.Name), 33); var platformInfo = importer.GetPlatformInfo(platform.Id); if (platformInfo != null) { System.Threading.Thread.Sleep(2000); SetProgress(string.Format("Updating {0}", emulator.Title), 67); emulator.Title = platformInfo.Title; emulator.Developer = platformInfo.Developer; emulator.Description = platformInfo.GetDescription(); using (ThumbGroup thumbGroup = new ThumbGroup(emulator)) { using (SafeImage image = ImageHandler.SafeImageFromWeb(platformInfo.LogoUrl)) { if (image != null) { thumbGroup.Logo.SetSafeImage(image.Image); thumbGroup.SaveThumb(ThumbType.Logo); } } using (SafeImage image = ImageHandler.SafeImageFromWeb(platformInfo.FanartUrl)) { if (image != null) { thumbGroup.Fanart.SetSafeImage(image.Image); thumbGroup.SaveThumb(ThumbType.Fanart); } } } emulator.Commit(); } } }
private static void OnStateSlotChanged(DependencyObject targetObject, NavigationContext context, string contextVariable) { if (string.IsNullOrEmpty(contextVariable)) { WorkflowSaveRestoreStateAction action = GetSaveRestoreAction(targetObject); if (action != null) { action.DetachFromObject(); RemoveSaveRestoreAction(targetObject); } } else { if (GetSaveRestoreAction(targetObject) != null) // Action already attached to object return; UIElement uiElement = targetObject as UIElement; WorkflowSaveRestoreStateAction action = new WorkflowSaveRestoreStateAction(context, contextVariable); SetSaveRestoreAction(targetObject, action); action.AttachToObject(uiElement); } }
public const string CONTEXT = "Context"; // Type: NavigationContext /// <summary> /// Sends a <see cref="MessageType.StatePushed"/> message. /// </summary> /// <param name="context">Navigation context of the workflow state which was pushed onto the navigation context stack.</param> public static void SendStatePushedMessage(NavigationContext context) { SystemMessage msg = new SystemMessage(MessageType.StatePushed); msg.MessageData[CONTEXT] = context; ServiceRegistration.Get<IMessageBroker>().Send(CHANNEL, msg); }
public void UpdateMenuActions(NavigationContext context, IDictionary<Guid, WorkflowAction> actions) { }
public void ExitModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { _messageQueue.Shutdown(); }
public ScreenUpdateMode UpdateScreen(NavigationContext context, ref string screen) { return ScreenUpdateMode.AutoWorkflowManager; }
public void Reactivate(NavigationContext oldContext, NavigationContext newContext) { PrepareState(newContext.WorkflowState.StateId); }
public void ChangeModelContext(NavigationContext oldContext, NavigationContext newContext, bool push) { PrepareState(newContext.WorkflowState.StateId); }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { SubscribeToMessages(); ClearData(); PrepareState(newContext.WorkflowState.StateId); }
public void Reactivate(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { }
public override bool IsVisible(NavigationContext context) { return(true); }
public bool CanEnterState(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { return(true); }
public override bool IsEnabled(NavigationContext context) { return(true); }
public bool CanEnterState(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext) { return(!BackgroundTask.Instance.IsExecuting); // only can enter a new state when not doing any background work }
public WorkflowSaveRestoreStateAction(NavigationContext context, string contextVariable) { _context = context; _contextVariable = contextVariable; }
/// <summary> /// Returns the information if this action is currently able to be executed in the given /// navigation <paramref name="context"/>. /// </summary> public abstract bool IsEnabled(NavigationContext context);
public bool CanEnterState(NavigationContext oldContext, NavigationContext newContext) { return true; }
public void ChangeModelContext(NavigationContext oldContext, NavigationContext newContext, bool push) { // We could initialize some data here when changing the media navigation state }
public void ExitModelContext(NavigationContext oldContext, NavigationContext newContext) { UnsubscribeFromMessages(); ClearData(); }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { Init(); }
public void Deactivate(NavigationContext oldContext, NavigationContext newContext) { // Nothing to do here }
public void ExitModelContext(NavigationContext oldContext, NavigationContext newContext) { }
public void UpdateMenuActions(NavigationContext context, IDictionary<Guid, WorkflowAction> actions) { actions.Add(Consts.ACTION_ID_REIMPORT_ALL_SHARES, new MethodCallAction(Consts.ACTION_ID_REIMPORT_ALL_SHARES, "ReImportAllShares", null, LocalizationHelper.CreateResourceString(Consts.RES_REIMPORT_ALL_SHARES), MODEL_ID_IMPORTS, "ReImportAllShares")); }
public void Reactivate(NavigationContext oldContext, NavigationContext newContext) { }
public ScreenUpdateMode UpdateScreen(MediaPortal.UI.Presentation.Workflow.NavigationContext context, ref string screen) { return(ScreenUpdateMode.AutoWorkflowManager); }
public void ChangeModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext, bool push) { // reload a site when going away from configuring it and settings were changed if (oldContext.WorkflowState.StateId == Guids.WorkflowStateSiteSettings && FocusedSite.UserSettingsChanged) { FocusedSite.RecreateSite(); // save Site Settings (OnlineVideoSettings.Instance.UserStore as Configuration.UserSiteSettingsStore).SaveAll(); } // going to sites view if (newContext.WorkflowState.StateId == Guids.WorkflowStateSites) { SelectedCategory = null; CategoriesList = null; } // going from categories to categories view else if (newContext.WorkflowState.Name == Guids.WorkflowStateCategoriesName && oldContext.WorkflowState.Name == Guids.WorkflowStateCategoriesName) { // going up in hierarchy if (oldContext.Predecessor == newContext) { CategoriesList = new ItemsList(); if (SelectedCategory.Category.ParentCategory != null) { SelectedCategory.Category.ParentCategory.SubCategories.ForEach(c => CategoriesList.Add(new CategoryViewModel(c))); ImageDownloader.GetImages <Category>(SelectedCategory.Category.ParentCategory.SubCategories); SelectedCategory = new CategoryViewModel(SelectedCategory.Category.ParentCategory); } else { foreach (Category c in SelectedSite.Site.Settings.Categories) { CategoriesList.Add(new CategoryViewModel(c)); } ImageDownloader.GetImages <Category>(SelectedSite.Site.Settings.Categories); SelectedCategory = null; } } } // going from videos to categories view else if (newContext.WorkflowState.Name == Guids.WorkflowStateCategoriesName && oldContext.WorkflowState.StateId == Guids.WorkflowStateVideos) { VideosList = null; CategoriesList = new ItemsList(); if (SelectedCategory != null && SelectedCategory.Category.ParentCategory != null) { SelectedCategory.Category.ParentCategory.SubCategories.ForEach(c => CategoriesList.Add(new CategoryViewModel(c))); ImageDownloader.GetImages <Category>(SelectedCategory.Category.ParentCategory.SubCategories); } else { foreach (Category c in SelectedSite.Site.Settings.Categories) { CategoriesList.Add(new CategoryViewModel(c)); } ImageDownloader.GetImages <Category>(SelectedSite.Site.Settings.Categories); } if (SelectedCategory != null && SelectedCategory.Category.ParentCategory != null) { SelectedCategory = new CategoryViewModel(SelectedCategory.Category.ParentCategory); } else { SelectedCategory = null; } } // going from details to videos view else if (newContext.WorkflowState.StateId == Guids.WorkflowStateVideos && oldContext.WorkflowState.StateId == Guids.WorkflowStateDetails) { DetailsVideosList = null; } }
public void ChangeModelContext(MediaPortal.UI.Presentation.Workflow.NavigationContext oldContext, MediaPortal.UI.Presentation.Workflow.NavigationContext newContext, bool push) { }
public bool IsActionEnabled(NavigationContext context) { return _scanningNICs.Count == 0; }
/// <summary> /// Returns the information if this action should be displayed to the user in the given /// navigation <paramref name="context"/>. /// </summary> public abstract bool IsVisible(NavigationContext context);
public void UpdateMenuActions(MediaPortal.UI.Presentation.Workflow.NavigationContext context, IDictionary <Guid, MediaPortal.UI.Presentation.Workflow.WorkflowAction> actions) { }