internal static Plugin GetDefaultHandler(OpenFileArgs args) { if (App.Settings.DefaultHandlers.ContainsKey(args.FileTypeKey)) { var handlerKey = App.Settings.DefaultHandlers[args.FileTypeKey]; if (plugins.ContainsKey(handlerKey)) //in case the plugin is no longer installed { return(plugins[handlerKey]); } } var handler = AllPlugins .Where(p => p.CanOpenFile(args)) .OrderByDescending(p => p.FilePriority ?? int.MaxValue) .ThenBy(p => p.Name) .FirstOrDefault(); if (handler == null) { return(handler); } if (App.Settings.DefaultHandlers.ContainsKey(args.FileTypeKey)) { App.Settings.DefaultHandlers.Remove(args.FileTypeKey); } App.Settings.DefaultHandlers.Add(args.FileTypeKey, handler.Key); return(handler); }
public override IEnumerable <PluginContextItem> GetContextItems(OpenFileArgs context) { if (context.File.OfType <IRenderGeometry>().Any()) { yield return(ExtractBitmapsContextItem); } }
private void OnContextItemClick(string key, OpenFileArgs context) { if (!isBusy) { if (!GetDataFolder(out lastDataFolder)) { return; } } var node = context.File.OfType <TreeItemModel>().FirstOrDefault(); if (node != null) { BatchQueue(node, lastDataFolder); } else { var item = context.File.Select(f => GetExtractable(f, lastDataFolder)).FirstOrDefault(e => e != null); if (item != null) { extractionQueue.Enqueue(item); } } if (isBusy) { return; } tokenSource = new CancellationTokenSource(); Task.Run(ProcessQueueAsync, tokenSource.Token); }
public override bool CanOpenFile(OpenFileArgs args) { #if DEBUG return(args.File.OfType <IIndexItem>().Any(i => Controls.DXEditor.CanOpenTag(i)) || args.File.OfType <IIndexItem>().Any(i => Controls.BspEditor.CanOpenTag(i))); #else return(args.File.OfType <IIndexItem>().Any(i => Controls.DXEditor.CanOpenTag(i))); #endif }
/// <summary> /// Opens a file object with the associated default handler. /// </summary> /// <param name="args">The file arguments.</param> public static bool OpenWithDefault(OpenFileArgs args) { var defaultHandler = GetDefaultHandler(args); if (defaultHandler == null || !defaultHandler.CanOpenFile(args)) { return(false); } defaultHandler.OpenFile(args); return(true); }
public override void OpenFile(OpenFileArgs args) { var model = args.File.OfType <IRenderGeometry>().FirstOrDefault(); if (model != null) { DisplayModel(args.TargetWindow, model, args.FileName); return; } var modelTag = args.File.OfType <IIndexItem>().FirstOrDefault(); DisplayModel(args.TargetWindow, modelTag, args.FileName); }
/// <summary> /// Prompts the user to select which handler to open a file object with. /// </summary> /// <param name="args">The file arguments.</param> public static bool OpenWithPrompt(OpenFileArgs args) { var defaultHandler = GetDefaultHandler(args); if (defaultHandler == null) { return(false); } var allHandlers = AllPlugins .Where(p => p.CanOpenFile(args)); OpenWithDialog.HandleFile(allHandlers, args); return(true); }
public override IEnumerable <PluginContextItem> GetContextItems(OpenFileArgs context) { Match match; if ((match = Regex.Match(context.FileTypeKey, BlamFileRegex)).Success) { if (!ValidateCacheType(match.Groups[1].Value)) { yield break; } if (match.Groups[2].Value == FileKeyWildcard && context.File.Any(i => i is TreeItemModel)) { yield return(ExtractMultipleContextItem); } else { if (context.File.Any(f => IsExtractable(f))) { yield return(ExtractSingleContextItem); } } } else if ((match = Regex.Match(context.FileTypeKey, SaberFileRegex)).Success) { if (match.Groups[1].Value != "Halo1X") { yield break; } if (match.Groups[2].Value == FileKeyWildcard && context.File.Any(i => i is TreeItemModel)) { yield return(ExtractMultipleContextItem); } else { if (context.File.Any(f => IsExtractable(f))) { yield return(ExtractSingleContextItem); } } } }
public override void OpenFile(OpenFileArgs args) { var bitm = args.File.OfType <IBitmap>().FirstOrDefault(); DisplayBitmap(args.TargetWindow, bitm, args.FileName); }
public override bool CanOpenFile(OpenFileArgs args) { return(args.File.Any(i => i is IBitmap)); }
private void OnContextItemClick(string key, OpenFileArgs context) { var geometry = context.File.OfType <IRenderGeometry>().FirstOrDefault(); ExportBitmaps(geometry); }
public override void OpenFile(OpenFileArgs args) { var model = args.File.OfType <IRenderGeometry>().FirstOrDefault(); DisplayModel(args.TargetWindow, model, args.FileName); }
public override bool CanOpenFile(OpenFileArgs args) { return(args.File.Any(i => i is IRenderGeometry)); }
/// <summary> /// When overidden in a derived class, gets a value indicating if the current /// plugin accepts a particular type of file object. If this method returns true, /// the <see cref="Substrate"/> may proceed to call <see cref="OpenFile(OpenFileArgs)"/>. /// </summary> /// <param name="args">The file arguments.</param> public virtual bool CanOpenFile(OpenFileArgs args) => false;
/// <summary> /// Fetches context items from across all plugins for a particular file object. /// </summary> /// <param name="context">The file arguments.</param> public static IEnumerable <PluginContextItem> GetContextItems(OpenFileArgs context) { return(AllPlugins.SelectMany(p => p.GetContextItems(context))); }
/// <summary> /// When overidden in a derived class, processes the request to handle a particular file object. /// This method is called by the <see cref="Substrate"/> when the user requests for a file to be handled. /// </summary> /// <param name="args">The file arguments.</param> public virtual void OpenFile(OpenFileArgs args) { }
/// <summary> /// When overidden in a derived class, gets a list of context menu items provided by the current plugin /// for a particular file object. This method is called by the <see cref="Substrate"/> when another plugin /// requests context items for a particular file object. /// </summary> /// <param name="context">The file arguments.</param> public virtual IEnumerable <PluginContextItem> GetContextItems(OpenFileArgs context) { yield break; }
/// <summary> /// Executes the handler associated with the context menu item. /// </summary> /// <param name="context">The file object that the context menu is attached to.</param> public void ExecuteHandler(OpenFileArgs context) => handler(key, context);
public override void OpenFile(OpenFileArgs args) { var modelTag = args.File.OfType <IIndexItem>().FirstOrDefault(); DisplayModel(args.TargetWindow, modelTag, args.FileName); }
public override bool CanOpenFile(OpenFileArgs args) { return(args.File.Any(i => i is IRenderGeometry) || args.File.OfType <IIndexItem>().Any(i => Controls.DXViewer.CanOpenTag(i))); }