示例#1
0
        public override void Invoke(object inArg, IntPtr outArg, OLECMDEXECOPT options)
        {
            // getting the current value
            if (outArg != IntPtr.Zero)
            {
                var text = _envSwitchMgr.CurrentFactory?.Configuration.Description ?? string.Empty;
                Marshal.GetNativeVariantForObject(text, outArg);
            }

            // setting the current value
            if (inArg != null)
            {
                var text    = inArg as string;
                var factory = _envSwitchMgr.AllFactories.SingleOrDefault(f => f.Configuration.Description == text);
                if (factory != null)
                {
                    SwitchToFactoryAsync(factory).HandleAllExceptions(_serviceProvider, GetType()).DoNotWait();
                }
                else
                {
                    // The special "Add Environment..." entry, or any entry that no longer exists brings up the add dialog
                    AddEnvironmentCommand
                    .AddEnvironmentAsync(_envSwitchMgr, _serviceProvider, AddEnvironmentDialog.PageKind.VirtualEnvironment)
                    .HandleAllExceptions(_serviceProvider, GetType())
                    .DoNotWait();
                }
            }
        }
示例#2
0
        public override void Invoke(object inArg, IntPtr outArg, OLECMDEXECOPT options)
        {
            var logger = _serviceProvider.GetService(typeof(IPythonToolsLogger)) as IPythonToolsLogger;

            // getting the current value
            if (outArg != IntPtr.Zero)
            {
                var text = EnvSwitchManager.CurrentFactory?.Configuration.Description ?? string.Empty;
                Marshal.GetNativeVariantForObject(text, outArg);
            }

            // setting the current value
            if (inArg != null)
            {
                var text    = inArg as string;
                var factory = EnvSwitchManager.AllFactories.SingleOrDefault(f => f.Configuration.Description == text);
                if (factory != null)
                {
                    logger?.LogEvent(PythonLogEvent.SelectEnvFromToolbar, new SelectEnvFromToolbarInfo()
                    {
                        InterpreterId = factory.Configuration.Id,
                        Architecture  = factory.Configuration.Architecture.ToString(),
                        Version       = factory.Configuration.Version.ToString(),
                        IsIronPython  = factory.Configuration.IsIronPython(),
                    });

                    SwitchToFactoryAsync(factory).HandleAllExceptions(_serviceProvider, GetType()).DoNotWait();
                }
                else
                {
                    // The special "Add Environment..." entry, or any entry that no longer exists brings up the add dialog
                    logger?.LogEvent(PythonLogEvent.AddEnvFromToolbar, null);
                    AddEnvironmentCommand
                    .AddEnvironmentAsync(_serviceProvider, AddEnvironmentDialog.PageKind.VirtualEnvironment)
                    .HandleAllExceptions(_serviceProvider, GetType())
                    .DoNotWait();
                }
            }
        }