Ejemplo n.º 1
0
        public static void NimExeFind(NSPackage pkg)
        {
            string[] nimexes = { "nim.exe", "nimsuggest.exe" };

            var patharr = new List <string>((Environment.GetEnvironmentVariable("PATH") ?? "").Split(';'));

            patharr.Add(@"c:\myprogs\nim\bin");
            foreach (string nimexe in nimexes)
            {
                foreach (string spathi in patharr)
                {
                    if (NSIni.Get("Main", nimexe) == "")
                    {
                        string sfullpath = Path.Combine(spathi.Trim(), nimexe);
                        if (File.Exists(sfullpath))
                        {
                            NSIni.Add("Main", nimexe, Path.GetFullPath(sfullpath));
                            NSIni.Write();
                            pkg.GetType().GetProperty(nimexe.Replace(".", "")).SetValue(nimexe.Replace(".", ""), sfullpath);
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();
            nspackage = this;

            #if ivslang
            LangInfo = new VSNLanguageInfo();
            ((IServiceContainer)this).AddService(typeof(VSNLanguageInfo), LangInfo, true);
            #endif

            menucmds = new Dictionary <int, string>()
            {
                { 0x0100, "NSMenuCmdOptionsEdit" },
                { 0x0101, "NSMenuCmdOptionsLoad" }
            };

            // menu commands - .vsct file
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs != null)
            {
                foreach (int dkey in menucmds.Keys)
                {
                    CommandID   cmdid   = new CommandID(GuidList.NSMenuCmdTopGUID, dkey);
                    MenuCommand menucmd = new MenuCommand(MenuItemCallback, cmdid);
                    mcs.AddCommand(menucmd);
                }
            }

            IServiceContainer ServiceCnt = this as IServiceContainer;
            NSLangServ        ServiceLng = new NSLangServ();
            ServiceLng.SetSite(this);
            ServiceCnt.AddService(typeof(NSLangServ), ServiceLng, true);

            IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
            if (m_ComponentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_ComponentID);
            }

            nimsettingsini = System.IO.Path.Combine(UserDataPath, "nimstudio.ini");
            NSIni.Init(nimsettingsini);
            NSSugInit();

            if (NSIni.Get("Main", "exttoolsadded") != "true")
            {
                NSIni.Add("Main", "exttoolsadded", "true");
                NSIni.Write();
                string reg_keyname = "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\12.0\\External Tools";
                object reg_ret;
                bool   regstateok = false;
                reg_ret = Registry.GetValue(reg_keyname, "ToolNumKeys", -1);
                while (true)
                {
                    if (reg_ret == null)
                    {
                        break;
                    }
                    if (reg_ret.GetType() != typeof(int))
                    {
                        break;
                    }
                    int totkeys = (int)reg_ret;
                    if (totkeys == -1)
                    {
                        break;
                    }
                    for (int rloop = 0; rloop < totkeys; rloop++)
                    {
                        reg_ret = Registry.GetValue(reg_keyname, "ToolTitle" + rloop.ToString(), null);
                        if (reg_ret == null)
                        {
                            break;
                        }
                        if (reg_ret.GetType() != typeof(string))
                        {
                            break;
                        }
                        if (reg_ret == "NimStudio Compile+Run")
                        {
                            break;
                        }
                        if (rloop == totkeys - 1)
                        {
                            regstateok = true;
                        }
                    }
                    if (regstateok)
                    {
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile+Run", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath) & echo ****Running**** & $(ItemDir)$(ItemFileName).exe""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath)""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolNumKeys", totkeys, RegistryValueKind.DWord);
                    }
                }
            }
        }