Esempio n. 1
0
        public void BeginLoading()
        {
            OMLApplication.DebugLine("Start loading new titles");
            plugin = GetPlugin();

            Application.DeferredInvokeOnWorkerThread(delegate
            {
                OMLApplication.DebugLine("[Setup UI] _BeginLoading called");
                LoadStarted = true;
                try
                {
                    for (int i = 0; i <= _treeView.CheckedNodes.Count - 1; i++)
                    {
                        OMLApplication.DebugLine("[Setup UI] Found a node");
                        TreeNode node = (TreeNode)_treeView.CheckedNodes[i];
                        if (node != null)
                        {
                            OMLApplication.DebugLine("[Setup UI] Scanning node: " + node.FullPath);
                            if (plugin.IsSingleFileImporter())
                            {
                                string fileNameToFind = plugin.DefaultFileToImport();
                                if (fileNameToFind != null)
                                {
                                    OMLApplication.DebugLine("[Setup UI] Looking for file: " + fileNameToFind);
                                    if (Directory.Exists(node.FullPath))
                                    {
                                        DirectoryInfo dirInfo = new DirectoryInfo(node.FullPath);
                                        if (dirInfo != null)
                                        {
                                            FileInfo[] fileInfos = dirInfo.GetFiles(fileNameToFind, SearchOption.TopDirectoryOnly);
                                            foreach (FileInfo fInfo in fileInfos)
                                            {
                                                OMLApplication.DebugLine("[Setup UI] File Found: " + fInfo.Name);
                                                plugin.DoWork(new string[] { fInfo.FullName });
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                OMLApplication.DebugLine("[Setup UI] Processing path: " + node.FullPath);
                                plugin.DoWork(new string[] { node.FullPath });
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    OMLApplication.DebugLine("[Setup UI] Error finding file: " + e.Message);
                }
            },
            delegate
            {
                OMLApplication.DebugLine("[Setup UI] _LoadingComplete called");
                LoadComplete = true;
                _titles = plugin.GetTitles();

                if (_titles.Count > 0)
                {
                    TotalTitlesFound = _titles.Count;
                    CurrentTitleIndex = 0;
                    CurrentTitle = _titles[CurrentTitleIndex];
                }
            }, null);
        }
        private void StartImport(int pluginID)
        {
            Cursor = Cursors.WaitCursor;
            this.Refresh();

            OMLPlugin plugin = new OMLPlugin();
            plugin = _importPlugins[pluginID];
            //plugin.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound);
            //if (plugin.CanCopyImages) AskIfShouldCopyImages();
            plugin.CopyImages = true;// Program._copyImages;

            string[] work = plugin.GetWork();
            if (work != null)
            {
                plugin.DoWork(work);
                LoadTitlesIntoDatabase(plugin);
            }

            Cursor = Cursors.Default;
            this.Refresh();
            string[] nonFatalErrors = plugin.GetErrors;
            if (nonFatalErrors.Length > 0)
                ShowNonFatalErrors(nonFatalErrors);
        }