private void IndexFileSystemItem(IFileSystemItemModel fileSystemItem)
        {
            Index.TryAdd(fileSystemItem.Info.FullName.Trim(Path.DirectorySeparatorChar), fileSystemItem);

            if (fileSystemItem.IsHidden && !fileSystemItem.ParentFileSystemItem.IsHidden)
            {
                HiddenIndex.TryAdd(fileSystemItem.Info.FullName.Trim(Path.DirectorySeparatorChar), fileSystemItem);
            }

            if (fileSystemItem.IsSystem && !fileSystemItem.ParentFileSystemItem.IsSystem)
            {
                SystemIndex.TryAdd(fileSystemItem.Info.FullName.Trim(Path.DirectorySeparatorChar), fileSystemItem);
            }
        }
 private void RemoveFileSystemItemFromIndex(FileSystemInfo fileSystemInfo)
 {
     Index.Remove(fileSystemInfo.FullName);
     HiddenIndex.Remove(fileSystemInfo.FullName);
     SystemIndex.Remove(fileSystemInfo.FullName);
 }
 private void RemoveFileSystemItemFromIndex(IFileSystemItemModel fileSystemItem)
 {
     Index.Remove(fileSystemItem.Info.FullName);
     HiddenIndex.Remove(fileSystemItem.Info.FullName);
     SystemIndex.Remove(fileSystemItem.Info.FullName);
 }
示例#4
0
        public static void VA_Init1(ref Dictionary <string, object> state, ref Dictionary <string, Int16?> shortIntValues, ref Dictionary <string, string> textValues, ref Dictionary <string, int?> intValues, ref Dictionary <string, decimal?> decimalValues, ref Dictionary <string, bool?> booleanValues, ref Dictionary <string, object> extendedValues)
        {
            try
            {
                Debug.Write("---------------------- Ocellus Plugin " + pluginVersion + " Initializing ----------------------");
                string configPath = Config.Path();
                string drive      = configPath.Substring(0, 2);
                Debug.Write("Current culture set to: " + Thread.CurrentThread.CurrentCulture.ToString());

                // Cleanup
                string oldGrammar = Path.Combine(configPath, "systems_grammar.xml");
                if (File.Exists(oldGrammar))
                {
                    File.Delete(oldGrammar);
                }
                string oldEddb = Path.Combine(configPath, "eddb_index.txt");
                if (File.Exists(oldEddb))
                {
                    File.Delete(oldEddb);
                }
                string oldAtlas = Path.Combine(configPath, "atlas_index.txt");
                if (File.Exists(oldAtlas))
                {
                    File.Delete(oldAtlas);
                }

                Utilities.ReportFreeSpace(drive);
                Elite.MessageBus messageBus = new Elite.MessageBus();

                int registryCheck = PluginRegistry.checkRegistry();

                // Load System Index into memory
                SystemIndex.loadSystemIndex(ref messageBus);

                // Spin up Speech announcer thread
                Task.Run(() => Announcements.speak(messageBus));

                // Setup Speech engine
                try
                {
                    CultureInfo             currCulture       = Thread.CurrentThread.CurrentCulture;
                    SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(currCulture);
                    messageBus.recognitionEngine     = recognitionEngine;
                    messageBus.recognitionEngineLang = currCulture;
                }
                catch
                {
                    messageBus.recognitionEngineLang = new CultureInfo("en-US");
                    SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(messageBus.recognitionEngineLang);
                    messageBus.recognitionEngine = recognitionEngine;
                    Debug.Write("Warning:  Falling back to default language for recognition engine");
                }

                Task.Run(() => EliteGrammar.loadGrammar(messageBus));

                // Setup plugin storage directory - used for cookies and debug logs
                string appPath    = Config.Path();
                string cookieFile = Config.CookiePath();
                string debugFile  = Config.DebugPath();
                textValues["VAEDdebugPath"] = debugFile;

                // Determine Elite Dangerous directories
                string gameStartString = PluginRegistry.getStringValue("startPath");
                string gameStartParams = PluginRegistry.getStringValue("startParams");
                textValues["VAEDgameStartString"] = gameStartString;
                textValues["VAEDgameStartParams"] = gameStartParams;

                // Load Tracked Systems into memory
                TrackSystems.Load(ref state);

                CookieContainer cookieJar = new CookieContainer();
                if (File.Exists(cookieFile))
                {
                    // If we have cookies then we are likely already logged in
                    cookieJar = Web.ReadCookiesFromDisk(cookieFile);
                    Tuple <CookieContainer, string> tAuthentication = Companion.loginToAPI(cookieJar);
                    if (tAuthentication.Item2 == "ok")
                    {
                        cookieJar = tAuthentication.Item1;
                        state["VAEDcookieContainer"] = cookieJar;
                        state["VAEDloggedIn"]        = "ok";
                    }
                    else
                    {
                        state.Add("VAEDloggedIn", "no");
                    }
                }
                else
                {
                    state.Add("VAEDloggedIn", "no");
                }

                EliteBinds.getBinds(ref state, ref textValues, ref booleanValues, messageBus);

                messageBus.cookies       = cookieJar;
                messageBus.loggedinState = (string)state["VAEDloggedIn"];

                state["VAEDmessageBus"] = messageBus;

                Task.Run(() => Announcements.startupNotifications(messageBus, registryCheck));

                //Watch the netlog for docked and system change information
                Task.Run(() => Elite.tailNetLog(messageBus));
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
            }
        }