Example #1
0
        public void NSSugInit()
        {
            string[] nimexes = { "nim.exe", "nimsuggest.exe" };
            for (int lexe = 0; lexe < 2; lexe++) {
                if (NSIni.Get("Main", nimexes[lexe]) == "") {
                    // nim exe not found in INI - try to find it in path, or c:\nim\bin
                    var patharr = new List<string>((Environment.GetEnvironmentVariable("PATH") ?? "").Split(';'));
                    patharr.Add(@"c:\nim\bin");
                    foreach (string spathi in patharr) {
                        string sfullpath = Path.Combine(spathi.Trim(), nimexes[lexe]);
                        if (File.Exists(sfullpath)) {
                            NSIni.Add("Main", nimexes[lexe], Path.GetFullPath(sfullpath));
                            NSIni.Write();
                            break;
                        }
                    }
                } else {
                    if (!File.Exists(NSIni.Get("Main", nimexes[lexe]))) {
                        System.Diagnostics.Debug.Print("NimStudio warning:" + nimexes[lexe] + " not found!");
                    }
                }
            }

            if (NSIni.Get("Main", nimexes[0]) == "" || NSIni.Get("Main", nimexes[1]) == "") {
                string msg = "";
                if (NSIni.Get("Main", nimexes[0]) == "" && NSIni.Get("Main", nimexes[1]) == "")
                    msg = "Path to nim.exe and nimsuggest.exe not found.";
                else
                    msg = String.Format("Path to {0} not found.", (NSIni.Get("Main", nimexes[0]) == "") ? nimexes[0] : nimexes[1]);

                msg += "\nEnter path(s) via:\n\n";
                msg += "Tools->NimStudio->Options Edit";
                msg += "\n   Then\n";
                msg += "Tools->NimStudio->Options Load";

                // write INI so user can edit
                NSIni.Add("Main", nimexes[0], "");
                NSIni.Add("Main", nimexes[1], "");
                NSIni.Write();

                System.Windows.Forms.MessageBox.Show(msg, "NimStudio configuration", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
            if (NSIni.Get("Main", nimexes[1]) != "") {
                if (nimsuggest==null)
                    nimsuggest = new NimSuggestProc();
                //nimsuggest.Init();
            }
        }
Example #2
0
        public void NSSugInit()
        {
            string[] nimexes = { "nim.exe", "nimsuggest.exe" };
            for (int lexe = 0; lexe < 2; lexe++)
            {
                if (NSIni.Get("Main", nimexes[lexe]) == "")
                {
                    // nim exe not found in INI - try to find it in path, or c:\nim\bin
                    var patharr = new List <string>((Environment.GetEnvironmentVariable("PATH") ?? "").Split(';'));
                    patharr.Add(@"c:\nim\bin");
                    foreach (string spathi in patharr)
                    {
                        string sfullpath = Path.Combine(spathi.Trim(), nimexes[lexe]);
                        if (File.Exists(sfullpath))
                        {
                            NSIni.Add("Main", nimexes[lexe], Path.GetFullPath(sfullpath));
                            NSIni.Write();
                            break;
                        }
                    }
                }
                else
                {
                    if (!File.Exists(NSIni.Get("Main", nimexes[lexe])))
                    {
                        System.Diagnostics.Debug.Print("NimStudio warning:" + nimexes[lexe] + " not found!");
                    }
                }
            }

            if (NSIni.Get("Main", nimexes[0]) == "" || NSIni.Get("Main", nimexes[1]) == "")
            {
                string msg = "";
                if (NSIni.Get("Main", nimexes[0]) == "" && NSIni.Get("Main", nimexes[1]) == "")
                {
                    msg = "Path to nim.exe and nimsuggest.exe not found.";
                }
                else
                {
                    msg = String.Format("Path to {0} not found.", (NSIni.Get("Main", nimexes[0]) == "") ? nimexes[0] : nimexes[1]);
                }

                msg += "\nEnter path(s) via:\n\n";
                msg += "Tools->NimStudio->Options Edit";
                msg += "\n   Then\n";
                msg += "Tools->NimStudio->Options Load";

                // write INI so user can edit
                NSIni.Add("Main", nimexes[0], "");
                NSIni.Add("Main", nimexes[1], "");
                NSIni.Write();

                System.Windows.Forms.MessageBox.Show(msg, "NimStudio configuration", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
            if (NSIni.Get("Main", nimexes[1]) != "")
            {
                if (nimsuggest == null)
                {
                    nimsuggest = new NimSuggestProc();
                }
                //nimsuggest.Init();
            }
        }