internal static void OnDragDrop(object sender, DragEventArgs e) { Array a = e.Data.GetData(DataFormats.FileDrop) as Array; if (a != null && a.Length > 0) { IDragDropHandlerService handlerSvc = ServiceManager.Instance.GetService <IDragDropHandlerService>(); for (int i = 0; i < a.Length; i++) { string file = a.GetValue(i).ToString(); IList <IDragDropHandler> handlers = handlerSvc.GetHandlersForFile(file); if (handlers.Count == 0) { continue; } if (handlers.Count == 1) { using (TempCursor cur = new TempCursor(Cursors.WaitCursor)) { handlers[0].HandleDrop(file); } } if (handlers.Count > 1) { //Resolve which handler to use } } } }
/// <summary> /// Invokes the command. /// </summary> public override void Run() { EventWatcher.Initialize(); ServiceManager svcMgr = ServiceManager.Instance; Res.RegisterNeutralStrings(FdoToolbox.Base.Strings.ResourceManager); Res.RegisterNeutralImages(FdoToolbox.Base.Images.ResourceManager); Res.RegisterNeutralStrings(ResourceUtil.StringResourceManager); Workbench.WorkbenchInitialized += delegate { Workbench wb = Workbench.Instance; List <IObjectExplorerExtender> extenders = AddInTree.BuildItems <IObjectExplorerExtender>("/ObjectExplorer/Extenders", this); if (extenders != null) { foreach (IObjectExplorerExtender dec in extenders) { dec.Decorate(wb.ObjectExplorer); } } svcMgr.RestoreSession(); Msg.MainForm = wb; //Find and register drag and drop handlers List <IDragDropHandler> handlers = AddInTree.BuildItems <IDragDropHandler>("/FdoToolbox/DragDropHandlers", this); if (handlers != null) { IDragDropHandlerService handlerSvc = ServiceManager.Instance.GetService <IDragDropHandlerService>(); foreach (IDragDropHandler h in handlers) { handlerSvc.RegisterHandler(h); } } //Init the scripting engine ScriptingEngine engine = ScriptingEngine.Instance; ScriptManager mgr = new ScriptManager(); wb.ShowContent(mgr, ViewRegion.Right); string startup = Path.Combine(Application.StartupPath, "Scripts\\" + ScriptingEngine.STARTUP_SCRIPT); engine.ScriptLoaded += new ScriptEventHandler(EventWatcher.OnScriptLoaded); //Run startup script engine.RunScript(startup); wb.FormClosing += delegate { svcMgr.UnloadAllServices(); }; }; }